Re: Accessing USB thermometer sensor
Glynn Clements <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming,org.kernel.vger.linux-serial |
|---|---|
| Message-ID | <[email protected]> |
Josh Hammond wrote:
> >> usb 1-2.2: pl2303 converter now attached to ttyUSB0
> >
> > Does "cat /dev/ttyUSB0" work?
>
> Nope. I get only blank
Thinking about it some more, if the device is outputting binary, the
line buffering performed by the TTY driver and stdio will get in the
way. How about:
stty raw < /dev/ttyUSB0
dd if=/dev/ttyUSB0 bs=1 | od -t x1 -w1
Or, in C:
int fd;
struct termios t;
fd = open("/dev/ttyUSB0", O_RDONLY|O_NOCTTY);
tcgetattr(fd, &t);
cfmakeraw(&t);
tcsetattr(fd, TCSANOW, &t);
for (;;) {
unsigned char buf[1];
if (read(fd, buf, 1) <= 0)
break;
printf("%02x\n", *buf);
}
close(fd);
--
Glynn Clements <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html