-->

USB USPS Postage Scale API

2019-08-06 14:08发布

问题:

I'm trying to integrate a USPS postage scale with a C# application and I'm having no luck. I actually have 2 scales, one is a Mettler Toledo PS60 and the other is the USPS PS-100 (http://www.measurement-ltd.com/ps-100-det.html). The MT scale works beautifully with Mike O'Brien's HidLibrary (https://github.com/mikeobrien/HidLibrary). However, the USPS scale does not (Please note that this is NOT the Stamps.com scale, which DOES appear to work with the HidLibrary). I know the scale is working because I downloaded the Postage Metering software from USPS and that reads the scale just fine.

I also downloaded a USB analyzer and it shows nothing coming back from the scale when no other applications are talking to it, so that suggests it isn't constantly sending out data and needs to be polled. I further confirmed this by launching the USPS Postal Meter software and the analyzer started showing data to/from the device. However, this data doesn't make any sense to me, nor have I had any luck trying to duplicate it in my own application.

As an example, with an exactly 1lb package on the scale, the analyzer shows it receives an 8 byte hex response as follows: 07 54 04 00 FF FF 00 00. With nothing on the scale, it shows this: 07 00 00 00 FF FF 00 00. That suggests that the 2nd and 3rd bytes somehow indicate 1 lb, but I have not been able to crack the code. It also looks like the polling command to get the scale data is 90 DE 80 00 00 00 00 00 (as seen from the analyzer), however this didn't seem to work for me from my application.

So I guess I have 2 issues. First, I can't get the scale to talk back to me. The only way is if the metering application is running. So I need to figure that out. Second, even when I do get data, it doesn't make any sense.

Does anyone have any experience with this or could point me in the right direction?

Thanks!

回答1:

I went through the same thing and finally got those scales to work. Here is what I found about the message.

SM WW WW 00 FF 00 00

  • S => sign (+ or -). 0 is +, 8 is -
  • M => mode. 1: gram, 7: lb oz /, 3 lb oz., 2: oz
  • WWWW => Weight in gram (Kg for 75lb scale) and little-endian base 16.

(Please note that only first 3 bytes are used)

With your example: 07 54 04 00 FF FF 00 00

+0454 grams = 1 lb 0/0 oz


It is a HID device, to get this interrupt message you need to set a Feature (weight) 90 de 80 00 00 00 00 00

To init the device you need to set this feature a0 de a0 00 00 00 00 00

Here is the DLL I used http://msdn.microsoft.com/en-us/library/windows/hardware/ff539684%28v=vs.85%29.aspx


Protocol sequence example

App to Scale (init mode)
--> a0 de a0 00 00 00 00 00

(wait 1s for scale initialization and tare)

App to Scale (get weight)
--> 90 de 80 00 00 00 00 00

Scale to App (interrupt)
<-- 07 54 04 00 ff ff 00 00

App to Scale (get weight)
--> 90 de 80 00 00 00 00 00

Scale to App (interrupt)
<-- 07 54 04 00 ff ff 00 00

etc



标签: c# usb hid usps