tsao.terence <> [2010-03-04 08:44:03]:
> I had success reading from ttyUSB0 with 9600 and 38400 baudrate, but when I
> jump to 57600 baud, the program just hangs. I think there might be
> something wrong as I open the USB port, or my receive function has too much
> software overhead. Anyone here had success reading from the ttyUSB0 port?
Hi, take a look at my librs232 here http://github.com/ynezz/librs232.
Using it is easy:
#define BUF_SIZE 20
usigned char buf[BUF_SIZE] = {0};
struct rs232_port_t *p = rs232_init();
rs232_set_device(p, "/dev/ttyUSB0");
rs232_open(p);
rs232_set_baud(p, RS232_BAUD_57600);
rs232_read(p, buf, BUF_SIZE, &len_read);
if (len_read > 0)
fprintf(stdout, "read: '%s' len: %d\n", (char *) buf, len_read);
else
fprintf(stdout, "read nothing...\n");
rs232_close(p);
-- ynezz
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|