erjiang / usbscale

Reads weight data from USB scales.
GNU General Public License v3.0
91 stars 22 forks source link

Unable to read from Accupost PP-10USB #14

Closed librarianmage closed 8 years ago

librarianmage commented 8 years ago

I received an Accupost PP-10USB - 10 lbs USB postal scale for a project that I am working on. I would like to read data from it using this code. After plugging it in and running lsusb, I deduced that it was Bus 001 Device 004: ID 04d9:8010 Holtek Semiconductor, Inc.. I put it into the file specified in the repo and it compiled without an error. However, running it causes it to hang before spitting out Error in USB transfer. Is there anything I am doing wrong? The output from lsusb -v is:

Bus 001 Device 004: ID 04d9:8010 Holtek Semiconductor, Inc. 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x04d9 Holtek Semiconductor, Inc.
  idProduct          0x8010 
  bcdDevice            1.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      53
         Report Descriptors: 
           ** UNAVAILABLE **
      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               8
erjiang commented 8 years ago

Assuming you added the vendor and product IDs correctly to the scales.h file, can you try compiling with debugging turned on, and then paste the output here?

You can do it by changing this line in the Makefile:

CFLAGS=-Wall -DDEBUG

and then running make clean; make usbscale

The new build should print out more information.

juanguinho commented 8 years ago

The same problem but with another scale. With the changes in the Makefile , no messages , no errors.

The result of execute "usbscale" is:

`./usbscale Found scale 067b:2303 (bus 3, device 6) It has descriptors: manufc: 1 prodct: 2 serial: 0 class: 0 subclass: 0 Manufacturer: Prolific Technology Inc. bEndpointAddress 0x81 -7 Error in USB transfer

-7 is the value of var r = libusb_interrupt_transfer

Any idea?

sanmai commented 8 years ago

067b:2303 is a USB to Serial Bridge Controller from Prolific. I doubt that it could work as a scale.

juanguinho commented 8 years ago

Yes, i have a usb to serial bridge controller but connected a scale to it. If i do in terminal cat /dev/port i can see the de data of scale.

sanmai commented 8 years ago

usbscale is for USB HID scales that work over specialized protocol, not your regular serial port. You can't do that trick with cat /dev/port with these scales, hence this program.

Really, if you could simply read data from a plain old serial port, you should do just that.

sanmai commented 8 years ago

@MathWhiz if you haven't sorted it out, please post your scales.h

juanguinho commented 8 years ago

OK, Thanks for your help. Regards Juan

librarianmage commented 8 years ago

@erjiang @sanmai Sorry, still haven't figured it out. Will post scales.h and debug info ASAP.

librarianmage commented 8 years ago

@erjiang

Found scale 04d9:8010 (bus 1, device 7)
It has descriptors:
        manufc: 1
        prodct: 2
        serial: 0
        class: 0
        subclass: 0
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/007: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.

This is after I move the udev rules

sanmai commented 8 years ago

What if you run that with sudo?

sanmai commented 8 years ago

I see that at least someone managed to read data from this model.

librarianmage commented 8 years ago

@sanmai I get

Found scale 04d9:8010 (bus 1, device 7)
It has descriptors:
        manufc: 1
        prodct: 2
        serial: 0
        class: 0
        subclass: 0
Manufacturer: Holtek
bEndpointAddress 0x81
Error in USB transfer
sanmai commented 8 years ago

What if you read directly from /dev/hidrawX?

Try this script.

sanmai commented 8 years ago

Are you using the latest version of usbscale?

librarianmage commented 8 years ago

I am using the latest version of usbscale On Mon, Aug 1, 2016 at 12:05 AM Alexey Kopytko notifications@github.com wrote:

Are you using the latest version of usbscale?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/erjiang/usbscale/issues/14#issuecomment-236490352, or mute the thread https://github.com/notifications/unsubscribe-auth/ALz_8y_pgkj6z4jxFRtG9qa0km1-ZcdBks5qbX6dgaJpZM4IgRQB .

librarianmage commented 8 years ago

None of the /dev/hiddraw* things output anything On Mon, Aug 1, 2016 at 12:07 AM Ray Arndorfer raymond.arndorfer@gmail.com wrote:

I am using the latest version of usbscale On Mon, Aug 1, 2016 at 12:05 AM Alexey Kopytko notifications@github.com wrote:

Are you using the latest version of usbscale?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/erjiang/usbscale/issues/14#issuecomment-236490352, or mute the thread https://github.com/notifications/unsubscribe-auth/ALz_8y_pgkj6z4jxFRtG9qa0km1-ZcdBks5qbX6dgaJpZM4IgRQB .

sanmai commented 8 years ago

If you will move things off and on the scale, will there be any output from any of the /dev/hiddraw*?

librarianmage commented 8 years ago

No On Mon, Aug 1, 2016 at 12:18 AM Alexey Kopytko notifications@github.com wrote:

If you will move things off and on the scale, will there be any output from any of the /dev/hiddraw*?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/erjiang/usbscale/issues/14#issuecomment-236491597, or mute the thread https://github.com/notifications/unsubscribe-auth/ALz_8x97t1kKrDVLR4eLCzpjCuwy-Uybks5qbYGjgaJpZM4IgRQB .

sanmai commented 8 years ago

Well, apparently you need a different approach because if you can't read a thing from /dev/hiddrawX neither usbscale can. Unfortunately.

librarianmage commented 8 years ago

Maybe I was just doing it incorrectly… On Mon, Aug 1, 2016 at 1:32 AM Alexey Kopytko notifications@github.com wrote:

Well, apparently you need a different approach because if you can't read a thing from /dev/hiddrawX neither usbscale can. Unfortunately.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/erjiang/usbscale/issues/14#issuecomment-236499878, or mute the thread https://github.com/notifications/unsubscribe-auth/ALz_8yjHRKhwuNWoM0_yH6EbokiyYXgBks5qbZMGgaJpZM4IgRQB .

erjiang commented 8 years ago

The forum that @sanmai linked that purportedly contains working code for this scale indicates that the Holtek scale does not follow the USB HID scale spec. It uses report ID=9 (setReport(9, array('B',(0x10,0,0,0,0,0,0,0)))) which isn't even one of the six reports listed in the USB HID scale spec.

Closing this for now - unlikely that usbscale will support non-standard scales when support for standard scales is still so barebones.

seacuello commented 7 years ago

Hi, I'm having a similar problem with my satorius scale. I've added the debugging line to the make file and then did a make clean and make usbscale. it does find the scale and can id the manufacturer, etc. below is the output:

pi@raspberrypi:~/Downloads/usbscale $ sudo ./usbscale Found scale 24bc:0010 (bus 1, device 15) It has descriptors: manufc: 1 prodct: 2 serial: 3 class: 239 subclass: 2 Manufacturer: Sartorius libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=22 bEndpointAddress 0x85 Error in USB transfer

Any advice would be so greatly appreicated! Thanks! -Stephen

erjiang commented 7 years ago

@seacuello for new scales, please open a separate issue. It's possible the scale does not follow the USB standard, but every scale is different and some investigation needs to be done. The test of reading from hiddraw would help, for example.