linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Accessing USB thermometer sensor
@ 2008-06-20 13:28 Josh Hammond
  2008-06-20 16:44 ` Glynn Clements
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Josh Hammond @ 2008-06-20 13:28 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-c-programming-u79uwXL29TY76Z2rM5mHXA

Hello to everybody.
I have recently purchased a USB thermometer from a chinese ebay store.
The sensor has no brand whatsoever and just carries the "TEMPer" label.

I plugged it to my debian unstable box (with a vanilla 2.6.24.4 kernel)
and it was detected as

4348:5523 WinChipHead USB->RS 232 adapter with Prolifec PL 2303 chipset

I believe this means that it is, at least partly, accessible by a linux
system (although it seems to do some weird USB-serial emulation).
I am now trying to access the thermometer, and more specifically be able
to read the data it provides.

I realize this is a very broad question, but could somebody point me in
the right direction to be able to read the temperature from command
line?
The only serial experience I have is connecting to a switch's console and
configuring it with putty/minicom.

I pasted the outputs from syslog and lsusb but I dont' really see how
the latter relates to my problem.
Thanks to everyone that will respond, since now I feel quite lost.

Josh




dmesg:

usb 1-2.2: new full speed USB device using ehci_hcd and address 9
usb 1-2.2: configuration #1 chosen from 1 choice
pl2303 1-2.2:1.0: pl2303 converter detected
usb 1-2.2: pl2303 converter now attached to ttyUSB0


lsusb -v:

Bus 001 Device 009: ID 4348:5523 WinChipHead USB->RS 232 adapter with
Prolifec PL 2303 chipset
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x4348 WinChipHead
  idProduct          0x5523 USB->RS 232 adapter with Prolifec PL 2303
chipset
  bcdDevice            2.50
  iManufacturer           0
  iProduct                2 USB-SER!
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               78mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      1
      bInterfaceProtocol      2
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)




--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing USB thermometer sensor
  2008-06-20 13:28 Accessing USB thermometer sensor Josh Hammond
@ 2008-06-20 16:44 ` Glynn Clements
       [not found]   ` <18523.56941.116797.23150-o3XtBhA/DwwNEGAfyhIZ+pATpRlcFRyyAL8bYrjMMd8@public.gmane.org>
  2008-06-20 21:32 ` Chris Doré
  2008-06-23  7:20 ` Tosoni
  2 siblings, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2008-06-20 16:44 UTC (permalink / raw)
  To: jhammond; +Cc: linux-usb, linux-serial, linux-c-programming


Josh Hammond wrote:

> Hello to everybody.
> I have recently purchased a USB thermometer from a chinese ebay store.
> The sensor has no brand whatsoever and just carries the "TEMPer" label.
> 
> I plugged it to my debian unstable box (with a vanilla 2.6.24.4 kernel)
> and it was detected as
> 
> 4348:5523 WinChipHead USB->RS 232 adapter with Prolifec PL 2303 chipset
> 
> I believe this means that it is, at least partly, accessible by a linux
> system (although it seems to do some weird USB-serial emulation).
> I am now trying to access the thermometer, and more specifically be able
> to read the data it provides.
> 
> I realize this is a very broad question, but could somebody point me in
> the right direction to be able to read the temperature from command
> line?
> The only serial experience I have is connecting to a switch's console and
> configuring it with putty/minicom.
> 
> I pasted the outputs from syslog and lsusb but I dont' really see how
> the latter relates to my problem.
> Thanks to everyone that will respond, since now I feel quite lost.

> usb 1-2.2: pl2303 converter now attached to ttyUSB0

Does "cat /dev/ttyUSB0" work?

-- 
Glynn Clements <glynn@gclements.plus.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing USB thermometer sensor
       [not found]   ` <18523.56941.116797.23150-o3XtBhA/DwwNEGAfyhIZ+pATpRlcFRyyAL8bYrjMMd8@public.gmane.org>
@ 2008-06-20 16:50     ` Josh Hammond
       [not found]       ` <1f60185ec2ee200f67d7a12ee6cbf2fb.squirrel-2RFepEojUI3piBo0p4lDPw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Josh Hammond @ 2008-06-20 16:50 UTC (permalink / raw)
  To: Glynn Clements
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-c-programming-u79uwXL29TY76Z2rM5mHXA

On Fri, June 20, 2008 6:44 pm, Glynn Clements wrote:
>
> Josh Hammond wrote:
>
>> usb 1-2.2: pl2303 converter now attached to ttyUSB0
>
> Does "cat /dev/ttyUSB0" work?
>

Nope. I get only blank

Josh

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Accessing USB thermometer sensor
  2008-06-20 13:28 Accessing USB thermometer sensor Josh Hammond
  2008-06-20 16:44 ` Glynn Clements
@ 2008-06-20 21:32 ` Chris Doré
  2008-06-23  7:20 ` Tosoni
  2 siblings, 0 replies; 6+ messages in thread
From: Chris Doré @ 2008-06-20 21:32 UTC (permalink / raw)
  To: jhammond, linux-usb, linux-serial, linux-c-programming

> From: Josh Hammond
> Sent: June 20, 2008 9:28 AM
> 
> I have recently purchased a USB thermometer from a chinese ebay store.
> The sensor has no brand whatsoever and just carries the "TEMPer" label.

Is one of these what you have:
http://www.usbfever.com/index_eproduct_view.php?products_id=257
http://www.usbfever.com/index_eproduct_view.php?products_id=446

Perhaps you can use some of the code here (C#, but you can probably work out
what it does):
http://nofeature.blogspot.com/2008/01/taking-advantage-of-your-temper-device
html
It looks like you have to do some sort of polling to get the data.


Best of luck, Chris



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing USB thermometer sensor
       [not found]       ` <1f60185ec2ee200f67d7a12ee6cbf2fb.squirrel-2RFepEojUI3piBo0p4lDPw@public.gmane.org>
@ 2008-06-21  9:02         ` Glynn Clements
  0 siblings, 0 replies; 6+ messages in thread
From: Glynn Clements @ 2008-06-21  9:02 UTC (permalink / raw)
  To: jhammond-qGaTmy9+pjn8wb0/L2CcF0B+6BGkLq7r
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-c-programming-u79uwXL29TY76Z2rM5mHXA


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Accessing USB thermometer sensor
  2008-06-20 13:28 Accessing USB thermometer sensor Josh Hammond
  2008-06-20 16:44 ` Glynn Clements
  2008-06-20 21:32 ` Chris Doré
@ 2008-06-23  7:20 ` Tosoni
  2 siblings, 0 replies; 6+ messages in thread
From: Tosoni @ 2008-06-23  7:20 UTC (permalink / raw)
  To: jhammond, linux-usb, linux-serial, linux-c-programming

> the right direction to be able to read the temperature from command
> line?
> Josh
>
Reading a serial device from the commannd line is not easy.
First because each command you type closes the port after running and so it
flushes buffers.

I would suggest using shell parenthesis to group the commands
Use stty to set the port to raw mode etc.
Use 'echo' and 'dd' which is like 'cat' but much more configurable for
buffer sizes
something like:
( stty 9600 raw; echo 'request'; dd bs=1 count=10 >response.out)
</dev/serialusb >&0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-23  7:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-20 13:28 Accessing USB thermometer sensor Josh Hammond
2008-06-20 16:44 ` Glynn Clements
     [not found]   ` <18523.56941.116797.23150-o3XtBhA/DwwNEGAfyhIZ+pATpRlcFRyyAL8bYrjMMd8@public.gmane.org>
2008-06-20 16:50     ` Josh Hammond
     [not found]       ` <1f60185ec2ee200f67d7a12ee6cbf2fb.squirrel-2RFepEojUI3piBo0p4lDPw@public.gmane.org>
2008-06-21  9:02         ` Glynn Clements
2008-06-20 21:32 ` Chris Doré
2008-06-23  7:20 ` Tosoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).