WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug  (Read 3955 times)

Offline jeffcraighead

  • Newbie
  • *
  • Posts: 9
UPDATE: Problem: USB Serial devices assigned ttyUSB0 and ttyUSB1, but unable to read until unplug/replug. there are no errors, the read just blocks.

---

I've got two USB serial devices that after some wrangling with udev rules and modprobe, I was able to get assigned to ttyUSB0 and ttyUSB1 with aliases at /dev/wavetrend and /dev/canbus.

The udev rules are:

KERNEL=="ttyUSB?", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="wavetrend"

KERNEL=="ttyUSB?", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="fac6", SYMLINK+="canbus"

To get the CAN adapter to attach I have a script run on boot that copies the above rules (in a file 99-spt.rules) to /etc/udev/rules.d/ then runs the following commands.

'modprobe -r ftdi_sio'
'modprobe ftdi_sio vendor=0x0403 product=0xfac6'

This is followed by the execution of a Python script that reads and writes to both of these devices.  This is being executed on an eBox 3350MX. Other machines running Ubuntu and my desktop machine are able to read from the devices just fine without a problem after a clean boot.

Any suggestions?

Thanks!
« Last Edit: December 14, 2012, 09:53:27 AM by jeffcraighead »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug
« Reply #1 on: December 14, 2012, 09:38:46 AM »
Not sure what your problem is? (yes, it's in the title, but not in the text ;))

Anyway, guessing you need to notify udev to reload its rules after copying them, see the udevadm command. Also check the devices' permissions, before and after replug.
The only barriers that can stop you are the ones you create yourself.

Offline jeffcraighead

  • Newbie
  • *
  • Posts: 9
Re: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug
« Reply #2 on: December 14, 2012, 02:02:27 PM »
Permissions for ttyUSB0 and ttyUSB1 are 660 owned by root:staff, before and after unplugging/replugging. The symlinks exist with permissions 777 so I believe udev is loading the rules properly, but I'll check out udevadm in a bit. Any other suggestions in the mean time?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug
« Reply #3 on: December 14, 2012, 02:08:39 PM »
Well, what is the exact error you get trying to read from them?
The only barriers that can stop you are the ones you create yourself.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug
« Reply #4 on: December 14, 2012, 02:19:00 PM »
Permissions on symlinks are meaningless.  Only the actual nodes matter.

Offline jeffcraighead

  • Newbie
  • *
  • Posts: 9
Re: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug
« Reply #5 on: December 14, 2012, 03:04:15 PM »
There is no error, it just blocks. The devices just stream data so there is always data available. After unplugging and replugging the devices, everything works as expected. the issue only happens after a reboot.

Offline jeffcraighead

  • Newbie
  • *
  • Posts: 9
Re: USB Serial device assigned ttyUSB0, but unable to read until unplug/replug
« Reply #6 on: December 14, 2012, 05:09:52 PM »
I was able to reproduce the issue on a Ubuntu machine, on that one it happens only on a cold boot. So, if I cold boot the machine the read blocks. I then unplug the serial device and replug it in and reads work fine. If I reboot the machine with 'sudo reboot', the serial device works fine after the reboot without having to unplug and replug it. Still no idea what the cause is, so any other suggestions would be appreciated.

Thanks.
« Last Edit: December 14, 2012, 05:16:07 PM by jeffcraighead »