Close a serial port with Serial IO

monobrau's picture

Hi all,

I'm developing a composition for an installation that controls a PTZ cam trough serial commands with a UC-232A cable connected. All works fine, but I would like to make it more usable for my setup.

It seems, when stopping the composition the serial port isn't closed by the plugin. When restarting the composition it can't send any commands because the serial port is still in use. The only solution I came up with now is quitting QC, disconnect and reconnect the serial cable and start QC+the composition again.

Does anyone know a way to close the port somehow without having to restart&replug the cable, or is it maybe possible with an update of the serialIO plugin?

Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

jean_pierre's picture
Re: Close a serial port with Serial IO

you might try matti's MonsteriSerialOut patch and see if it has the same issue or not, there is some discussion of it in this thread: http://kineme.net/release/SerialIO/20080326#comment-20634

harrisonpault's picture
Re: Close a serial port with Serial IO

the Apple example CommandLineTool or the old Kineme Shell patch or somebody's AppleScript patch might be useful for OS cleanup tasks like this?

monobrau's picture
Re: Close a serial port with Serial IO

The applescript/commandlinescript patch gave me bad results earlier when doing system tasks, check:

http://kineme.net/forum/Discussion/General/CreateNewFolder#comment-14552

I'm hoping for a more reliable solution.

monobrau's picture
Re: Close a serial port with Serial IO

I'll give the mansterii patch another try, I forgot about the single character output.

jean_pierre's picture
Re: Close a serial port with Serial IO

harrisonpault wrote:
the Apple example CommandLineTool or the old Kineme Shell patch or somebody's AppleScript patch might be useful for OS cleanup tasks like this?
this is not just an OS cleanup task though, the serial writer patch itself is holding a reference to the port through -disableExecution: which neither the command line tool nor some applescript would likely be able to resolve.

monobrau's picture
Re: Close a serial port with Serial IO

No luck with the mansteri serial patch, it seems to be sending, but i presume as a string or ASCII, and not as binary (what the VISCA protocol needs). Also the single character output would probably decrease the responsiveness I'd like to have.

Just wondering, could it be possible to update the kineme Serial IO patch with a trigger that opens/closes the serial port from the patch settings?

jean_pierre's picture
Re: Close a serial port with Serial IO

hmm, does the kineme serial writer have a data input port that is a numerical value, not a string? it appears as though the serial patch is now missing from the downloads section or i'd just give it a try.

monobrau's picture
Re: Close a serial port with Serial IO

It has both, a data and binary input field. I'm using the binary for this one, to send hex messages.

I'm using this version: http://kineme.net/release/SerialIO/20091206 (It's under the beta releases)

I've attached sample patch, so you can see how I use it.

PreviewAttachmentSize
visca_sample.qtz16.33 KB

jean_pierre's picture
Re: Close a serial port with Serial IO

my error, somehow i disabled the beta access flag in my account -- thanks for the sample composition, that nicely explains the issue though your binary data '8101046300FF' is actually hex no? maybe the kineme patch scans the input string and divines the format before converting and sending.

monobrau's picture
Re: Close a serial port with Serial IO

Yes, it's hex. The binary data input seems to be handling it fine. The sending and receiving part works well with this setup, the only thing is, is that it doesn't work anymore when running the composition for a second time. It only works when I un- and replug the usb-serial cable and quit/restart QC.

Now when I start inspecting the serialIO log from the console it says that it closes the connection the first time, but it doesn't say it opens the device the second time I try to run the composition (openDevice: using alread-opened device for /dev/tty.UC-232AC)

This is my console log:

open QC, start composition

Console:

06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialInput: Opening /dev/tty.UC-232AC
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialO: openDevice: opening /dev/tty.UC-232AC
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: openDevice: Configuring device
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO:  9600 baud rate configured
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: Current Configuration:
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: configDevice: Disabling Parity
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: configDevice: Enabling 8 Data Bits
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: openDevice: Configured.  Adding to dictionary.
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: openDevice:  all finished up!
06-08-11 21:31:40   Quartz Composer[310]   KinemeSerialIO: openDevice:  using alread-opened device for /dev/tty.UC-232AC

result: serial in/output works

stop composition

Console:

06-08-11 21:33:12   Quartz Composer[310]   KinemeSerialIO: closeDevice: 1 user closed, dropping use count from 2
06-08-11 21:33:13   Quartz Composer[310]   KinemeSerialIO: closeDevice: Last user of 13 closed.  Cleaning up
06-08-11 21:33:13   Quartz Composer[310]   KinemeSerialIO: closeDevice: All devices closed.  Cleaning up.

start composition (2nd time)

Console:

06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialInput: Opening /dev/tty.UC-232AC
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialO: openDevice: opening /dev/tty.UC-232AC
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO: openDevice: Configuring device
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO:  9600 baud rate configured
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO: Current Configuration:
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO: configDevice: Disabling Parity
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO: configDevice: Enabling 8 Data Bits
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO: openDevice: Configured.  Adding to dictionary.
06-08-11 21:34:22   Quartz Composer[310]   KinemeSerialIO: openDevice:  all finished up!

Now the serialIO doesn't seem to work anymore.

stop composition

Console:

06-08-11 21:35:58   Quartz Composer[310]   KinemeSerialIO: closeDevice: Last user of 13 closed.  Cleaning up
06-08-11 21:35:58   Quartz Composer[310]   KinemeSerialIO: closeDevice: All devices closed.  Cleaning up.

Now I'm wondering, is this a serialIO bug?

jean_pierre's picture
Re: Close a serial port with Serial IO

yeah, it might just be a defect in the Serial IO patch, though it is interesting that the device was already open when first opened (and confined on first close), but on the second open the device is not said to be open already. could something else on your system be opening the serial port? i can't say how the Serial IO patch is constructed, but generally speaking serial ports can have exclusive access holders, i wonder if that is at play here.

monobrau's picture
Re: Close a serial port with Serial IO

No other programs seem to be using the serial port. From the console log when I open the connection the first time I read that the KinemeSerialInput patch opens it first, and then the KinemeSerialIO seems to access the address '/dev/tty.UC-232AC' that openDevice passes.

Now when I stop/start the composition the same log events show up, except that 'KinemeSerialIO: openDevice: using alread-opened device for /dev/tty.UC-232AC' isn't included.

My technical knowledge is limited to know what's actually happening here, but it might be a clue?

jean_pierre's picture
Re: Close a serial port with Serial IO

i think you are doing everything right and this is just a defect in the SerialIO patch, it might not be fully releasing the port after opening it. if you quit the application and restart that works though?

monobrau's picture
Re: Close a serial port with Serial IO

Yeah, restarting&replugging works, but It would be nice if I didn't have to during a performance.

jean_pierre's picture
Re: Close a serial port with Serial IO

did you find a solution to this? do you need to send binary data or are you using hex?

monobrau's picture
Re: Close a serial port with Serial IO

The solution I'm using now is sending hex data trough the binary data port. That works like a charm but I still have to reconnect the serial cable and restart QC to be able to use my composition again if I stopped it.