Fixing digitemp with LinkUSB on kernels after 2.6.32-24
Posted by Admin • Tuesday, January 11. 2011 • Category: Linux
As many people have discovered, kernels after 2.6.32-24 changed the USB-RS232 serial driver to not set hardware flow control (RTS/DTS) flags. No doubt there was a good reason. Unfortunately, digitemp and owfs don't enable it either, also probably for a good reason - at least when applied to older devices. What this means is that now when you try to use a LinkUSB (and probably other DS9097U type hardware behind USB to Serial converters), digitemp and owfs no longer work.
Let's apply a time-tested hackish approach.
After some reading I found a reference to the offending commit to the ftdi_sio.c driver
This is great and all, but to me this is basically gibberish. "use TIOCMSET/TIOCMBI[SC] after port open" ? What this means to us is that if you run minicom -s /dev/ttyUSB0 with normal settings (hardware flow control enabled), you can talk to the LinkUSB just fine.
Good news is, someone has already solved this issue in owfs code. Fortunately, patching digitemp is exactly the same:
<pre><blockquote>digitemp-3.6.0/userial/ds9097u/linuxlnk.c
@@ -161,8 +161,8 @@
t.c_iflag &= ~(BRKINT|ICRNL|IGNCR|INLCR|INPCK|ISTRIP|IXON|IXOFF|PARMRK);
t.c_iflag |= IGNBRK|IGNPAR;
t.c_oflag &= ~(OPOST);
- t.c_cflag &= ~(CRTSCTS|CSIZE|HUPCL|PARENB);
- t.c_cflag |= (CLOCAL|CS8|CREAD);
+ t.c_cflag &= ~(CSIZE|HUPCL|PARENB);
+ t.c_cflag |= (CRTSCTS|CLOCAL|CS8|CREAD);
t.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|IEXTEN|ISIG);
t.c_cc[VMIN] = 0;
t.c_cc[VTIME] = 3;</blockquote></pre>
(Of course you will need a normal build env on your system)
I'm thinking that the proper way to fix this would either be to add a runtime flag to digitemp, or to introduce yet another diigtemp variant (digitemp_linkusb?)
Let's apply a time-tested hackish approach.
The error looks like this:
$ ./digitemp_DS9097U -s /dev/ttyUSB0 -w DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Error 5: DS2480B Adapter Not Detected Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed Error 10: Read COM Failed
After some reading I found a reference to the offending commit to the ftdi_sio.c driver
This is great and all, but to me this is basically gibberish. "use TIOCMSET/TIOCMBI[SC] after port open" ? What this means to us is that if you run minicom -s /dev/ttyUSB0 with normal settings (hardware flow control enabled), you can talk to the LinkUSB just fine.
Good news is, someone has already solved this issue in owfs code. Fortunately, patching digitemp is exactly the same:
Hack
- Download the latest digitemp (3.6.0 at this time, though when compiled it reports 3.5.0).
- Edit userial/ds9097u/linuxlnk.c
- Make the change as per diff below
- run make ds9097u
- You should have a hacked up version that enables flow control now
<pre><blockquote>digitemp-3.6.0/userial/ds9097u/linuxlnk.c
@@ -161,8 +161,8 @@
t.c_iflag &= ~(BRKINT|ICRNL|IGNCR|INLCR|INPCK|ISTRIP|IXON|IXOFF|PARMRK);
t.c_iflag |= IGNBRK|IGNPAR;
t.c_oflag &= ~(OPOST);
- t.c_cflag &= ~(CRTSCTS|CSIZE|HUPCL|PARENB);
- t.c_cflag |= (CLOCAL|CS8|CREAD);
+ t.c_cflag &= ~(CSIZE|HUPCL|PARENB);
+ t.c_cflag |= (CRTSCTS|CLOCAL|CS8|CREAD);
t.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|IEXTEN|ISIG);
t.c_cc[VMIN] = 0;
t.c_cc[VTIME] = 3;</blockquote></pre>
(Of course you will need a normal build env on your system)
I'm thinking that the proper way to fix this would either be to add a runtime flag to digitemp, or to introduce yet another diigtemp variant (digitemp_linkusb?)
0 Comments
Add Comment