while your "solution" definitely closes serial port connections, it closes all of them. So if you have multiple connections, executing the command task will kill all of them.
For instructions on how to gracefully shut down serial port connections in Royal TSX (and screen in general) please see this KB article.
Thank you Felix, for your swift response. That's exactly what I was looking for.
I still prefer my "lazy" solution using Disconnect Task. It removes the additional steps and I only use a single Serial (screen) connection at a time, so it is no big deal killing all screen processes;-)
sure, use whatever works for you!
FYI: You could also create a key sequence task which sends control+a+k and, after a little delay, the y key to confirm.
After disconnecting a serial port connection in TSX, screen still keeps the usbserial device busy and doesn't allow new connections. When you try to reconnect to it, you will simply get:
"Cannot open line /dev/cu.usbserial for R/W: Resource busy"
To fix this:
1. Create a Command Task: "killall SCREEN"
2. Assign it to your Serial Terminal Connection as a Disconnect Task.
Now, when you disconnect a Serial Terminal Connection, it will automatically free up the usbserial device and you can happily connect without having to unplug/insert the usb-to-serial adapter ;)