I'm running kernel 2.4.17 with a Keyspan USA-19QW usb serial adapter.
I know that the source/firmware for the 19QW isn't included in the
2.4.17 kernel. I downloaded it from their web-site. As such, this
may not be the appropriate channel to ask for help. I'm not really
sure the status of this driver since it is GPL.
Anyway, I have a fairly smart device that I'm talking to with a
proprietary protocol over the serial port. The technique is pretty
simple: I send commands and it sends me results. The code I inherited
for this task in user-land looked like this:
static int SendCommand (int sPort, char *command)
{
tcflush (sPort, TCIOFLUSH);
return (write (sPort, command, strlen (command)) == strlen (command));
}
Using the standard serial port, this seemed to work fine. Using the
usb-serial adapter some commands just failed. I know this code isn't
very good so I re-wrote it like this:
static int SendCommand (int sPort, char *command)
{
int rc = 0; /* return code from write command */
int total = 0; /* total bytes written */
int size = strlen (command); /* size of command to write */
/* clear serial port buffers */
tcflush (sPort, TCIOFLUSH);
/* keep writing the command until the total written is equal to
* the size of the command */
while (total != size || rc == -1) {
rc = write (sPort, command + total, size - total);
total += rc;
}
/* return false on write error */
return ((rc == -1) ? 0 : 1);
}
Using gdb with this function I can see clearly now what's happening.
With the standard serial port all of the commands I write out always
go in one write. The usb-serial adapter seems to have a limit of 126
bytes for each write. The command I'm testing right now is 143 bytes
long. Using usb-serial it takes two writes: one of 126 another of
17. Both writes succeed. My device reports an error of "Command too
long" when I do these two writes rather than just the one with the
standard serial port.
My question is where do you thing the corruption is? Is there
something wrong with my code I wrote, they keyspan protocol driver,
the usbserial driver, or the keyspan device itself?
--
(__) Doug Alcorn - Unix/Linux/Web Developing
oo / PGP 02B3 1E26 BCF2 9AAF 93F1 61D7 450C B264 3E63 D543
|_/ mailto:[EMAIL PROTECTED] http://www.lathi.net
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users