Vernier Go Temp USB device in Linux: Difference between revisions

From finninday
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 31: Line 31:


Perhaps I need a USB sniffer.  Does such a thing exist?
Perhaps I need a USB sniffer.  Does such a thing exist?
Also, udev says that it has created a device for the ldusb driver called /dev/ldusb0 here:
crw-rw---- 1 root root 180, 176 2008-01-05 11:17 /dev/ldusb0
That's hopeful, but how do I poke at that device, exactly?
Googling for ldusb0 I found someone who has the same device ( http://www.thok.org/intranet/python/vernier/README.html) and says that this code works to read it:
<pre>
#!/usr/bin/python
import time
import struct
ldusb = file("/dev/ldusb0")
time.sleep(0.5)
# for n in range(10):
while True:
    # time.sleep(0.5)
    pkt = ldusb.read(8)
    parsed_pkt = list(struct.unpack("<BBHHH", pkt))
    num_samples = parsed_pkt.pop(0)
    seqno = parsed_pkt.pop(0)
    for sample in range(num_samples):
        print seqno+sample, parsed_pkt[sample]/100.0
    # time.sleep(0.5)
</pre>
But it doesn't work for me.  I picked a bad day to not learn python.  Perhaps I can grok it enough to write a perl script to do the same thing.

Revision as of 00:27, 12 January 2008

I've got a USB thermometer that is recognized by Linux when I plug it in, but I have no idea how to read it. Here is what I know so far.

/proc/bus/usb/devices says this about it:

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=1.5 MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=08f7 ProdID=0002 Rev= 1.53
S:  Manufacturer=Vernier Software & Technology
S:  Product=Go! Temp ver 1.53
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=ldusb
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=10ms

So I assume that /proc/bus/usb/002/002 is the file that corresponds to this device since it is bus 2, device 2.

Looking at that file through octaldump, I see this:

root@weasel:/proc/bus/usb/002# od -c 002
0000000 022 001 020 001  \0  \0  \0  \b 367  \b 002  \0   S 001 001 002
0000020  \0 001  \t 002   "  \0 001 001  \0 200   2  \t 004  \0  \0 001
0000040 003  \0  \0  \0  \t   ! 020 001  \0 001   "   2  \0  \a 005 201
0000060 003  \b  \0  \n
0000064

I'd like it if one of those numbers were a temperature, but I doubt it is that easy.

I'd also like it if setting one of those bits were to control the LEDs on the thermometer...

Perhaps I need a USB sniffer. Does such a thing exist?

Also, udev says that it has created a device for the ldusb driver called /dev/ldusb0 here:

crw-rw---- 1 root root 180, 176 2008-01-05 11:17 /dev/ldusb0

That's hopeful, but how do I poke at that device, exactly?

Googling for ldusb0 I found someone who has the same device ( http://www.thok.org/intranet/python/vernier/README.html) and says that this code works to read it:

#!/usr/bin/python
import time
import struct

ldusb = file("/dev/ldusb0")

time.sleep(0.5)

# for n in range(10):
while True:
    # time.sleep(0.5)
    pkt = ldusb.read(8)
    parsed_pkt = list(struct.unpack("<BBHHH", pkt))
    num_samples = parsed_pkt.pop(0)
    seqno = parsed_pkt.pop(0)
    for sample in range(num_samples):
        print seqno+sample, parsed_pkt[sample]/100.0
    # time.sleep(0.5)

But it doesn't work for me. I picked a bad day to not learn python. Perhaps I can grok it enough to write a perl script to do the same thing.