| 发表于:2007-11-07 16:35:42 楼主 |
数据为9位ascii码方式输出,每帧数据共有9组组成(包括小数点),每组数据由10位组成,第一位为起始位第十位为停止位,中间8位为数据位,数据传送先低位后高位,每帧数据间有一组是分隔符“=”,重为89.03,数据连续发送30.98000=30.98000=......... 程序如下:(但是出来的是乱码) private sub command1_click() '开始接收 label1.caption = "" strwight = "" with mscomm1 if .portopen then .portopen = false end if .commport = 1 .settings = "2400,n,8,1 " '.inputlen = 1 .inbuffersize = 1024 .inputmode = cominputmodetext ' .inputmode = cominputmodebinary .rthreshold = 9 .portopen = true end with end sub private sub mscomm1_oncomm() dim bytinput() as byte dim intinputlen as integer select case me.mscomm1.commevent case comevreceive '此处添加处理接收的代码 'intinputlen = me.mscomm5.inbuffercount strdata = me.mscomm1.input dim i as integer label1.caption = strdata if len(strdata) = 9 and mid(strdata, 9, 1) = "=" then label1.caption = strreverse(strdata) end if strdata = "" end select end sub private sub command2_click() '停止接收 if mscomm1.portopen = true then mscomm1.portopen = false end if end sub 下面是用超级终端读出来的前部份资料(前面是乱码最后面也是乱码只有中间的不会): hyperterminal 1.0 -- hyperterminal data file please do not attempt to modify this file directly. e xv4 h d ansi ? 鴙, ?tg新建连接 & 稦tg & 灶 鴙, 搭 * 茴 稦tg * x_ 鴙, `_ 茴 ?tg鴙, -dsg * x_ " < ? 新宋体 # $ d a v b 0316 c d 衭!zf g h com1 q r ) * 2? = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0 0 0 - = 0 5 0 . 0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