通过串口以编程方式打印余额
如何? 我正在使用 SerialPort.Write 函数,看起来它在大多数情况下都可以工作,但突然它停止工作了。
我还注意到,每次我发送打印命令(即使我遵循手册,P 带有回车符),我都会收到包含“ES”的字符串 - 根据手册,即使捕获了重量,这也意味着错误。 然后突然间,电子秤完全停止对打印命令做出反应。
这是我的代码:
//send the print command to the balance:
Byte[] bytes = {80, 13}; //50 0D
_sp.Write(bytes,0,bytes.Length);
_sp 是 SerialPort 类的实例。 我使用的是奥豪斯 CD-11 天平; 应用程序是在紧凑框架 2.0、hp 瘦客户端、WinCE 5.0 上用 C# 编写的
任何想法都值得赞赏。 应该很简单,但显然不是。
How to? I am using SerialPort.Write function and it looks like it works most of the time, but out of the blue it just stops working.
I also noticed that every time I send the command to print (even though I follow the manual, P with carriage return), I get string containing "ES" back - which according to the manual means error even though the weight is captured. Then suddenly, the scale stops reacting to the print command at all.
here is my code:
//send the print command to the balance:
Byte[] bytes = {80, 13}; //50 0D
_sp.Write(bytes,0,bytes.Length);
_sp is an instance of SerialPort class.
I am using OHAUS CD-11 balance; app is written with c# on compact framework 2.0, hp thin client, WinCE 5.0
Any ideas are appreciated. SHould be simple to do but apparently not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您确定您的波特率/停止位等正确吗(请参阅手册中的第 12 页和第 13 页)?
Are you sure your baud rate / stop bits etc. are right (see page 12 & 13 in the manual)?
也许只是 CR 不起作用,尽管手册建议它可以? 即你尝试过吗
Maybe just CR doesn't work even though the manual suggests it does? i.e. Have you tried
我在 OHAUS Valor 7000 上遇到了同样的问题,ES 字符串返回给我。
我正在使用 putty 进行测试,使用 ctrl-j 发送 CRLF 并不断返回 es。 我最终按下大写锁,它开始工作。
在我的代码中,发送 0x50 不起作用,但发送十进制 80 最终会像上面的建议一样工作,这很奇怪,因为 0x50 = 80。
I was having the same problem with the ES string coming back to me on an OHAUS Valor 7000.
I was testing with putty using ctrl-j to send the CRLF and kept getting es back. I ended up hitting caps locks and it start working.
In my code, sending 0x50 wouldn't work, but sending a decimal 80 ended up working like the suggestion above, which is odd because 0x50 = 80.