SUCCESS!!
I found my error. Apparently I need to claim the device by this program
that I'm running. The new code is as follows (with some new declarations);

import sys
import usb.core
import usb.util


dev = usb.core.find(idVendor=0x130c, idProduct=0x0001)
interface = 5
endpoint = dev[0][(0,0)][0]

if dev.is_kernel_driver_active(interface) is True:
  # tell the kernel to detach
  dev.detach_kernel_driver(interface)
  # claim the device
  usb.util.claim_interface(dev, interface)

#if dev is None:
# raise ValueError('Device not found')

dev.set_configuration()
print "Connected to " + str(dev)

QS="\x51\x53\x0D"   #Call for Serial number
BLON="\x42\x4C\x4F\x4E\x0D"     #Backlight ON
BLOFF="\x42\x4C\x4F\x46\x46\x0D"      #Backlight OFF


dev.write(0x02,QS,0,0)

ret = dev.read(0x82,endpoint.wMaxPacketSize)
sret=''.join([chr(x) for x in ret])
print "Return Raw: ",ret
print "Return : ", sret

# release the device
#usb.util.release_interface(dev, interface)
# reattach the device to the OS kernel
#dev.attach_kernel_driver(interface)

I did get an error the first time when I did not have the last line
commented out. I need to work on that one, but it does work now! I can call
the serial number and turn the back light on and off so the train is
rolling.

Thanks!



On Mon, Jun 1, 2015 at 8:44 AM, Caleb Mayfield <caleb.mayfi...@gmail.com>
wrote:

> Attached is the manual that was sent to me. One thing to note from the
> person who sent it to me, this was in development and was never completed.
> There is no Appendix C with an example code in it. I'm still learning about
> this level of programming. My experience thus far has been a moderate level
> of Arduino work and some beginner level shell scripting and java. I feel
> like I'm missing something that's right in front of my face, so any help is
> appreciated.
>
> Below is the lsusb -v output for this device. I'm currently working on a
> Pi2 running the 2015-05-05 Raspbian release using Python 2.7.3 for coding.
>
> Bus 001 Device 004: ID 130c:0001
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               1.01
>   bDeviceClass          255 Vendor Specific Class
>   bDeviceSubClass       255 Vendor Specific Subclass
>   bDeviceProtocol       255 Vendor Specific Protocol
>   bMaxPacketSize0        64
>   idVendor           0x130c
>   idProduct          0x0001
>   bcdDevice            1.00
>   iManufacturer           1 Quest Technologies, Inc.
>   iProduct                2 Quest Technologies SoundPro SLM
>   iSerial                 6 BJL060022
>   bNumConfigurations      1
>   Configuration Descriptor:
>     bLength                 9
>     bDescriptorType         2
>     wTotalLength           32
>     bNumInterfaces          1
>     bConfigurationValue     1
>     iConfiguration          3 Quest Technologies Device
>     bmAttributes         0xc0
>       Self Powered
>     MaxPower                0mA
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       0
>       bNumEndpoints           2
>       bInterfaceClass       255 Vendor Specific Class
>       bInterfaceSubClass    255 Vendor Specific Subclass
>       bInterfaceProtocol    255 Vendor Specific Protocol
>       iInterface              5 Virtual COM
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x02  EP 2 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x82  EP 2 IN
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
> Device Status:     0x0001
>   Self Powered
>
>
> On Sat, May 30, 2015 at 5:05 AM, Karl Palsson <ka...@tweak.net.au> wrote:
>
>>
>> I'm pretty sure you're not actually sending the request that the manual
>> says.
>>
>> Caleb Mayfield <caleb.mayfi...@gmail.com> wrote:
>> >  I am new to using Python and PyUSB. I am trying to write a program to
>> > communicate with a 3M Quest SoundPro sound meter. Because I'm new, I'm
>> > starting simple. The vendor was gracious enough to send me the manual
>> > they
>> > have on the commands for the unit. Right now all I'm trying to do is
>> > request the serial number and read the response. I just need to get
>> > communication between a Raspberry Pi and the device working. I have used
>> > the software on a Windows 7 machine along with a USB sniffer to verify
>> > the
>> > commands and endpoint address were correct.
>> >
>> > This is the program;
>> >
>> > import usb.core
>> >
>> > import usb.util
>> >
>> > import sys
>> >
>> > dev = usb.core.find(idVendor=0x130c, idProduct=0x0001)
>> >
>> > if dev is None:
>> >
>> > raise ValueError('Device not found')
>> >
>> > dev.set_configuration()
>> >
>> > print "Connected to " + str(dev)
>> >
>> > QS = '0x51,0x53,0x0D'   #Call for Serial number
>> >
>> > dev.write(0x02,QS,0,0)
>>
>> I don't believe this is really right, you're probably meant to send the
>> three bytes, 0x51, 0x53, 0xd, not the 14 bytes, 0, x,5,1,,,0,x,5,3.....
>>
>> You probably just want to do something like...
>>
>> dev.write(0x02, "QS\r", 0, 0)
>>
>>
>> If you can share the manual, You can probably get more correct help than
>> my asumptions. :)
>>
>> Cheers,
>> Karl P
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> pyusb-users mailing list
>> pyusb-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>>
>>
>
>
> --
> Caleb Mayfield
>
> James 1:19-20
>



-- 
Caleb Mayfield

James 1:19-20
------------------------------------------------------------------------------
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to