扩展VB应用程序的接口

时间:2010-07-30 14:30:44

标签: vb.net serial-port

我有一些不同的尺度,我正在构建一个VB应用程序。是否有一种通用的串口语言在体重秤中很常见,我可以用它将实时权重导入VB?

2 个答案:

答案 0 :(得分:1)

是的,有一个标准协议,由Scale制造商协会制定。规范下载is here。您的实际秤是否符合该标准是一个悬而未决的问题,请查看数据表中的小字或编程手册。这很少是一个真正的问题,这些协议很容易使用简单的命令/响应字符串。

答案 1 :(得分:0)

这是我在阅读Zebra的ZBI 2 / ZPL手册时所发现的。非常有用!!!!

1 rem ********************************************************
05 for i = 1 to 9 step 1
10 close #i
20 next i
30 open # 2 : name "SER"
40 open # 1 : name "ZPL"
1 rem ********************************************************
1 rem main program; send serial port a 'W' in order to get a weight
1 rem ********************************************************
50 do
60 do
70 sleep 1 ! sleep so scale is not bombarded with incoming
1 rem data
80 print # 2 : "W" ; ! semicolon ends sent W without a CRLF
1 rem ********************************************************
1 rem get response from scale; note that input requires a CRLF to be
1 rem entered
1 rem ********************************************************
90 input # 2 : a$
100 if a$ = "EXIT" then! back door exit - if EXIT is received, ZBI ends
110 close # 2
120 print #1: "^XZ"
130 close #1
140 end
150 end if
1 rem ********************************************************
1 rem loop until valid weight is received, then print on label
1 rem ********************************************************
160 loop while pos ( a$ , "000.00" ) = 1 or pos ( a$ , "?" ) = 1
170 print # 1 : "~SD25^XA^FS";
180 print # 1 : "^LH0,0^FS";
190 print # 1 : "^FO56,47^A0N,69,58^FDThis weighs^FS";
1 rem ********************************************************
1 rem print weight on label; & character concatenates strings
1 rem ********************************************************
200 print # 1 : "^FO56,150^A0N,69,58^FD" & A$ & " lbs^FS";
210 print # 1 : "^PQ1,0,0,N";
220 print # 1 : "^XZ"
1 rem ********************************************************
1 rem loop until weight is off scale, then repeat for next item
1 rem weighed
1 rem ********************************************************
230 do
240 print # 2 : "W" ;
250 input # 2 : A$
260 loop until pos(A$ , "000.00") = 1 or pos(A$ , "?") = 1
270 loop