我用串口读函数从一台彩色分析仪读数据,该分析仪处于不断数据输出状态,输出格式:P1(空格)***;***;****(空格) 共16个字节。我现要求程序总是从第一个程序“P”开始读,然后正确显示:P1(空格)***;***;****(空格) (如附件正确界面图片)。但实际上程序有时非从第一个字节开始读,造成错误显示,例如: ;****(空格)P1(空格)***;*** (如附件错误界面图片)。有什么办法可使程序总是从第一个字节“P”开始数据?附件有程序。
请看图片
<img src="attachments/dvbbs/2006-7/20067614463098288.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor=\'hand\'; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onclick="if(!this.resized) {return true;} else {window.open(\'attachments/dvbbs/2006-7/20067614463098288.jpg\');}" onmousewheel="return imgzoom(this);" alt="" />
<img src="attachments/dvbbs/2006-7/20067614465545460.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor=\'hand\'; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onclick="if(!this.resized) {return true;} else {window.open(\'attachments/dvbbs/2006-7/20067614465545460.jpg\');}" onmousewheel="return imgzoom(this);" alt="" />
pp<img src="attachments/dvbbs/2006-7/20067614481985161.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor=\'hand\'; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onclick="if(!this.resized) {return true;} else {window.open(\'attachments/dvbbs/2006-7/20067614481985161.jpg\');}" onmousewheel="return imgzoom(this);" alt="" />