大家好:现在我把我的程序写在下面,请大家帮我看看毛病出在哪?
我的硬件为:PC----->FX-485PC-IF----->FX2N-485ADP
我向plc的D123读取4字节的数据:
private sub command1_click()
mscomm1.commport=1
mscomm1.setting="9600,n,7,1"
msomm1.handshaking=comRTS
mscomm1.RTSenable=true
if mscomm1.portopen=false then
mscomm1.portopen=true
end if
mscomm1.inbuffercount=0
if mscomm1.CTSholding=true then '硬件握手
msg"硬件连接正常"
else
msg"硬件连接不正常"
end if
end sub
private sub command2_click()
mscomm1.output=stx+chr$(5)+etx '发出ENQ字符
if mscomm1.input=chr$(6) then
msg"软件握手成功”
elseif mscomm1.input=chr$(21) then
msg"软件握手不成功"
end if
end sub
private sub command3_click()
mscomm1.output=stx+chr(48)+chr(49)+chr(48)+chr(70)+chr(54)+chr(48)+chr(52)+etx+chr(55)+chr(52)
text1.text=mscomm1.input
end sub
可能有些打字上的错误,请大家不要见怪,帮我看看上面的程序到底哪有毛病?谢了各位
02-01-30 12:59