Re: Accessing USB thermometer sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <glynn@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux