主题:汽车衡串口数据采集的问题
这是一段采集汽车衡过磅数据的小程序,但采集得来的数据,不管哪个位遇到9,数据就不能采集,哪位高手指点一下。
******开始读取数据
flagxxx=.f.
DO WHILE !FLAGXXX
zhongliang=0
thisform.olecontrol1.rthreshold=10
*****如果缓冲区没有足够的数据,延时等待后再来!
IF thisform.olecontrol1.inbuffercount<10
FOR I=1 TO 100
NEXT
LOOP
ENDIF
for i=1 to 100
xx=thisform.olecontrol1.input
flagxx=asc(xx)
if flagxx=255
xxx=thisform.olecontrol1.input
flagxxx=asc(xxx)
w1=asc(thisform.olecontrol1.input)
IF W1=255
FLAGXXX=.F.
EXIT
ENDIF
w2=asc(thisform.olecontrol1.input)
IF W2=255
FLAGXXX=.F.
EXIT
ENDIF
w3=asc(thisform.olecontrol1.input)
IF W3=255
FLAGXXX=.F.
EXIT
ENDIF
w1=w1-6*int(w1/16)
w2=w2-6*int(w2/16)
w3=w3-6*int(w3/16)
zhongliang=w1+w2*100+w3*10000
flagxxx=.t.
endif
next
ENDDO
thisform.maobang1.value=zhongliang
******开始读取数据
flagxxx=.f.
DO WHILE !FLAGXXX
zhongliang=0
thisform.olecontrol1.rthreshold=10
*****如果缓冲区没有足够的数据,延时等待后再来!
IF thisform.olecontrol1.inbuffercount<10
FOR I=1 TO 100
NEXT
LOOP
ENDIF
for i=1 to 100
xx=thisform.olecontrol1.input
flagxx=asc(xx)
if flagxx=255
xxx=thisform.olecontrol1.input
flagxxx=asc(xxx)
w1=asc(thisform.olecontrol1.input)
IF W1=255
FLAGXXX=.F.
EXIT
ENDIF
w2=asc(thisform.olecontrol1.input)
IF W2=255
FLAGXXX=.F.
EXIT
ENDIF
w3=asc(thisform.olecontrol1.input)
IF W3=255
FLAGXXX=.F.
EXIT
ENDIF
w1=w1-6*int(w1/16)
w2=w2-6*int(w2/16)
w3=w3-6*int(w3/16)
zhongliang=w1+w2*100+w3*10000
flagxxx=.t.
endif
next
ENDDO
thisform.maobang1.value=zhongliang