USB to Serial Adaptor works once for every reboot

consoleusb

Update#2, After testing with different console applications, I think the conclusion is GNU screen coming with Mac OS X 10.11.4 has a defect causing this issue. Hope some dev can see this and help diagnose for a fix…

Update#1, Now I upgraded to the 10.11.4 and also upgraded cable driver… Issue still happens…help!!!

I have a USB to Serial Adaptor for connecting to CONSOLE port of switch/router and I use "screen" inside Terminal to connect. Recently I found the "screen /dev/cu.usbserial 9600" works only once for every system reboot. Here are the steps to replicate:

  1. The output of "ls /dev/usb" shows the correct device.
  2. Login to console of the device with "screen /dev/cu.usbserial 9600"
  3. Press "Ctrl+A, Ctrl+K" to exit screen
  4. (optional), disconnect/reconnect the usb to serial adaptor from laptop OR disconnect/reconnect the console cable from target device.
  5. The output of "ls /dev/usb" still shows the correct device.
  6. Try to connect to console again with "screen /dev/cu.usbserial 9600", the screen process will hang. Once that is happening, the screen process can not be killed via "sudo kill -9" and only be solved by complete power cycle. BTW, the laptop will also hang during reboot/shutdown, until I keep pressing on power button…
  7. Once screen hang, The output of "ls /dev/usb" would show nothing.

Once laptop boots up again, I can connect with the same screen command and same scenario for step 2-3 above…

I have Mac OS 10.11.3 and adaptor is Micro Innovations branded (Prolific chip). I downloaded and installed/re-installed driver from Prolific site and no difference…

Any idea?

Best Answer

Firstly, does cu -l /dev/cu.usbserial -s 9600 work more than once? If not, how does it fail?

Because the second open blocks and does not die even with kill -9 it probably it is a driver issue with the call to open(2) getting the initial device handle blocking. The device open might block if the device is not in local mode and the CD input is low.

Some versions of those devices have hardware flow control bugs. You could try a hardware fix of looping RTS to CTS and connecting DTR, DSR and CD on the connector and just let the RX, TX and ground pins connect to the console port.

Another possibility is running stty clocal < /dev/cu.usbserial. This should make the device ignore control signals. This is worth trying from a different terminal while the second open is blocking.

Update:

You need to run cu with sudo so that it can write a lock file to /var/spool/uucp. If you have no contention for ports (unlikely on a single user Mac), you can change the lock directory path using a config file. Create an empty directory, then create a config file setting lockdir to that directory path. Something like:

lockdir /User/yourname/lockdir

Then run using a command line like this:

cu -I /path/to/conf/file -l /dev/cu.usbserial -s 9600