USB USPS邮费秤API [英] USB USPS Postage Scale API

查看:119
本文介绍了USB USPS邮费秤API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将USPS邮资秤与C#应用程序集成在一起,但我没有运气.我实际上有2个秤,一个是Mettler Toledo PS60,另一个是USPS PS-100( https://github.com/mikeobrien/HidLibrary ).但是,USPS比例尺不适用(请注意,这不是Stamps.com比例尺,它似乎可以与HidLibrary一起使用).我知道秤正在工作,因为我从USPS下载了邮资计费软件,并且可以很好地读取秤.

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.

我还下载了一个USB分析仪,当没有其他应用程序与之对话时,它没有显示出从磅秤返回的任何东西,因此这表明它不是一直在发送数据并且需要轮询.我通过启动USPS邮政计量仪软件进一步确认了这一点,分析仪开始向/从设备显示数据.但是,这些数据对我来说没有任何意义,也没有运气尝试在自己的应用程序中进行复制.

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.

作为示例,在秤上正好有1磅包装的情况下,分析仪显示它收到一个8字节的十六进制响应,如下所示:07 54 04 00 FF FF 0000.在秤上什么都没有时,它显示:07 00 00 00 FF FF 0000.这表明第二个和第三个字节以某种方式表示1 lb,但是我无法破解该代码.看起来,用于获取比例数据的轮询命令是90 DE 80 00 00 00 00 00 00(从分析仪中看到),但是对于我的应用程序来说,这似乎不起作用.

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.

所以我想我有2个问题.首先,我无法应付自己.唯一的方法是计量应用程序正在运行.所以我需要弄清楚.其次,即使我确实获得了数据,也没有任何意义.

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?

谢谢!

推荐答案

我经历了同样的事情,并最终使这些天平得以工作.这是我从邮件中找到的内容.

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

SM WW WW 00 FF 00 00

  • S =>符号(+或-). 0是+,8是-
  • M =>模式. 1:克,7:磅盎司/,3磅盎司,2:盎司
  • WWWW =>重量(克)(75磅秤为Kg)和小端基数为16.

(请注意,仅使用前3个字节)

(Please note that only first 3 bytes are used)

以您的示例为例: 07 54 04 00 FF FF 00 00

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

+0454克= 1磅0/0盎司

+0454 grams = 1 lb 0/0 oz

这是一个HID设备,要获取此中断消息,您需要设置功能(权重) 90 de 80 00 00 00 00 00

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

要初始化设备,您需要设置此功能 a0 de a0 00 00 00 00 00

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

这是我使用的DLL http://msdn.microsoft .com/en-us/library/windows/hardware/ff539684%28v = vs.85%29.aspx

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

协议序列示例

按比例缩放(初始模式)
-> a0 de a0 00 00 00 00 00

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

(等待1秒钟进行秤的初始化和去皮)

(wait 1s for scale initialization and tare)

按比例缩放(获取重量)
-> 90 de 80 00 00 00 00 00

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

扩展到App(中断)
<-07 54 04 00 ff ff 00 00

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

按比例缩放(获取重量)
-> 90 de 80 00 00 00 00 00

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

扩展到App(中断)
<-07 54 04 00 ff ff 00 00

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

这篇关于USB USPS邮费秤API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆