找回密码
 注册
LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 2074|回复: 6

串口通讯如何保证总是从第一字节开始读(附图)

[复制链接]
yekingger 该用户已被删除
发表于 2006-7-6 22:47:17 | 显示全部楼层 |阅读模式
我用串口读函数从一台彩色分析仪读数据,该分析仪处于不断数据输出状态,输出格式: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="" />

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2006-7-7 22:31:08 | 显示全部楼层
回复 顶

使用道具 举报

发表于 2006-7-8 05:59:43 | 显示全部楼层
在VISA里面有这个节点VISA Set I/O Buffer Size,兄弟你查找一下试试看行不行!
回复 顶

使用道具 举报

发表于 2006-7-10 02:14:16 | 显示全部楼层
显示的时候处理也可以啊,先把缓冲区的数都读出来,显示的时候从P开始显示就可以了。
回复 顶

使用道具 举报

发表于 2006-7-11 05:19:58 | 显示全部楼层
<>还有一个法,就是在VISA Read -byte count端口接VISA bytes at serial port</P>
<>这样可以按你仪器的输出来显示</P>
<>如果仪器显示方式不是按规定方式,可以用循环(移位寄存器)加字符处理match pattern</P>
<P>具体的你可以再看是否须要其它的,</P>
<P>应该可以实现大多显示的要求</P>
回复 顶

使用道具 举报

yekingger 该用户已被删除
 楼主| 发表于 2006-7-6 22:48:22 | 显示全部楼层

这是程序图

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="" />

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 顶

使用道具 举报

发表于 2006-7-6 23:46:59 | 显示全部楼层
回复 顶

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2026-9-29 14:19 , Processed in 0.066499 second(s), 13 queries , Gzip On, File On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表