pc机要连两个下位机,我是在程序中建立了一个WINSOCK的数组控件,在一个timer中每5分钟轮巡给这两个下位机发送查询数据的命令,接到的数据由dataarrive触发,而无论我先发给那个下位机总是第二个下位机传上的数据在固定的几个位置数据都不对,代码如下(由于网络限制,代码不能靠出,大体就是这个样子,还请见谅!)多谢了pravite sub Sendcmd() for i=0 to 1 winsock(i).senddata "05" next end subpravite sub timer_timer() Sendcmd end subprivait sub Data_Arrival(index as integer,bytestotal as integer) if bytestotal=1024 then winsock(index).peekdata bytR() elseif bytestotal=1025 then winsock(index).getdata bytR() endif end sub 上位机发送"05",下位机就会给上位机发送1025个字节,1024为数据,最后一位为校验位
我的通讯速率是19200,每次发送都延时1秒了也不行,接受的数据总是在固定的几个位置上出错,帮帮忙在帮忙分析一下吧
for i=0 to 1
winsock(i).senddata "05"
next
end subpravite sub timer_timer()
Sendcmd
end subprivait sub Data_Arrival(index as integer,bytestotal as integer)
if bytestotal=1024 then
winsock(index).peekdata bytR()
elseif bytestotal=1025 then
winsock(index).getdata bytR()
endif
end sub
上位机发送"05",下位机就会给上位机发送1025个字节,1024为数据,最后一位为校验位