PB编程实时读取电子称(RS232 COM串口)

biaosun biaosun 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
PB编程实时读取电子称(RS232 COM串口)?

下面是通过BUTTON的CLICKED事件,可以读出来。如何实时读取数据?

string ls_text,ls_flag
dec ldec_wt

ls_text = serial_port1.read(2000)
if isnull(ls_text) or ls_text='' or len(trim(ls_text))=0 then
return
end if
ls_text = trim(ls_text)
if pos(ls_text,'GGU')>0 then
ls_text =trim(mid(ls_text,1,pos(ls_text,'GGU')-1))
end if
if pos(ls_text,'GGS')>0 then
ls_text =trim(mid(ls_text,1,pos(ls_text,'GGS')-1))
end if
if pos(ls_text,'+')>0 then
ls_text =trim(mid(ls_text,pos(ls_text,'+')+1))
end if
if pos(ls_text,'+')>0 then
ls_text =trim(mid(ls_text,2))
end if
if isnumber(mid(ls_text,1,7)) then
ldec_wt = dec(mid(ls_text,1,7))
//清空
serial_port1.write('')
sle_1.text = string(ldec_wt)
if ls_flag='N' then
st_2.text = 'g'
else
st_2.text = 'g'
end if
else
setnull(ldec_wt)
end if
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
biaosun
API 调用 681 成员 4,761 内容