hi,
i did again some testing with several pl2303 based adapters
under linux-2.6.0-test4.
the serial apps still have severe problems.
i've done some more testing and it seems that the first
byte coming to the pl2303 _never_ arrives in a read() from
/dev/ttyUSB0 - except in the _first_ read after reinsertion
of the pl2303 based device!
the problem is very easy to reproduce:
just connect a serial cross link cable to /dev/ttyS0 and the
other end to /dev/ttyUSB0 (the pl2303) and run the
attached debug.c file.
this program expects 2 params: read device and write device
eg: ./debug /dev/ttyUSB /dev/ttyS0
a test string ("Hello World") is written to argv[2] and
the data read from argv[1] is written to stderr.
i can reproduce the following on several uhci based boxes:
*** disconnect pl2303 from usb port
*** modprobe pl2303
*** insert pl2303 device into usb port
*** first run:
command line: ./debug /dev/ttyUSB0 /dev/ttyS0
writing "Hello World" to /dev/ttyS0 ...
wrote 11 bytes.
reading from /dev/ttyUSB0 ...
result: Hello World
*** second run:
command line: ./debug /dev/ttyUSB0 /dev/ttyS0
writing "Hello World" to /dev/ttyS0 ...
wrote 11 bytes.
reading from /dev/ttyUSB0 ...
result: ello World
^ first byte is missing
*** third run
command line: ./debug /dev/ttyUSB0 /dev/ttyS0
writing "Hello World" to /dev/ttyS0 ...
wrote 11 bytes.
reading from /dev/ttyUSB0 ...
result: ello World
^ first byte is missing
*** same error for all following runs
debug.c source code:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define TESTSTRING "Hello World"
int main(int argc, char **argv) {
int fd_rd, fd_wr;
struct termios tio_save_rd, tio_save_wr, tio;
char buf[255];
char *dev_rd;
char *dev_wr;
int rv;
int err=0;
int len;
char *p;
if(argc!=3) {
fprintf(stderr, "usage: %s read_device write_device\n", argv[0]);
exit(1);
}
fprintf(stderr, "command line: %s %s %s\n\n", argv[0], argv[1], argv[2]);
dev_rd = argv[1];
dev_wr = argv[2];
fd_rd = open(dev_rd, O_RDWR, O_NOCTTY);
if(fd_rd < 0) {
perror(dev_rd);
exit(1);
}
fd_wr = open(dev_wr, O_RDWR, O_NOCTTY);
if(fd_wr < 0) {
perror(dev_wr);
exit(1);
}
memset(&tio, 0, sizeof(tio));
/* save initial port attributes */
tcgetattr(fd_rd, &tio_save_rd);
tcgetattr(fd_wr, &tio_save_wr);
tio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
tio.c_cc[VTIME] = 10;
tcflush(fd_rd, TCIOFLUSH);
tcflush(fd_wr, TCIOFLUSH);
tcsetattr(fd_rd, TCSANOW, &tio);
tcsetattr(fd_wr, TCSANOW, &tio);
fprintf(stderr, "writing \"%s\" to %s ...\n", TESTSTRING, dev_wr);
rv = write(fd_wr, TESTSTRING, strlen(TESTSTRING));
if(rv<0) {
perror(dev_wr);
err=1;
goto exit;
}
fprintf(stderr, "wrote %d bytes.\n", rv);
fprintf(stderr, "reading from %s ...\n", dev_rd);
len = sizeof(buf);
p = buf;
do {
rv = read(fd_rd, p, len);
if(rv<0) {
perror(dev_rd);
err=1;
goto exit;
}
len -= rv;
p += rv;
} while (rv && len);
*p='\0';
fprintf(stderr, "result: %s\n", buf);
exit:
/* restore initial port attributes */
tcsetattr(fd_rd, TCSANOW, &tio_save_rd);
tcsetattr(fd_wr, TCSANOW, &tio_save_wr);
close(fd_rd);
close(fd_wr);
exit(err);
}
cheers,
Norbert
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel