当前位置:编程学习 > VB >>

真心求高人赐教,关于com口

以前用过的一个串口的数据采集盒,就是那种接收八个串口的模拟信号转成数字信号然后通过一个串口传到电脑上。软件不知是用什么编的。现在想自己编个vb程序只读取一下数据。怎么编都读不到数据。下面是用portmon监视得到的原软件的串口过程,第一段是刚开始时,第二段是传出第一个数据时的。发送什么数据才能使采集盒上传数据。
0.00004526 Tgw.exe IRP_MJ_CREATE Serial0 SUCCESS Options: Open 
0.00000391 Tgw.exe IOCTL_SERIAL_SET_WAIT_MASK Serial0 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BRK ERR RING 
0.00000140 Tgw.exe IOCTL_SERIAL_SET_TIMEOUTS Serial0 SUCCESS RI:-1 RM:0 RC:0 WM:0 WC:0
0.00000112 Tgw.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS
0.00000140 Tgw.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS
0.00000140 Tgw.exe IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS
0.00000084 Tgw.exe IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS
0.00000726 Tgw.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 SUCCESS Rate: 9600
0.00000363 Tgw.exe IOCTL_SERIAL_CLR_RTS Serial0 SUCCESS
0.00000419 Tgw.exe IOCTL_SERIAL_CLR_DTR Serial0 SUCCESS
0.00000251 Tgw.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8
0.00000140 Tgw.exe IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
0.00000335 Tgw.exe IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0 Replace:0 XonLimit:2048 XoffLimit:512
0.00000559 Tgw.exe IOCTL_SERIAL_GET_COMMSTATUS Serial0 SUCCESS
0.00000112 Tgw.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS
0.00000168 Tgw.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS
0.00000112 Tgw.exe IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS
0.00000084 Tgw.exe IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS
0.00000782 Tgw.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 SUCCESS Rate: 9600
0.00000363 Tgw.exe IOCTL_SERIAL_CLR_RTS Serial0 SUCCESS
0.00000363 Tgw.exe IOCTL_SERIAL_CLR_DTR Serial0 SUCCESS
0.00000223 Tgw.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 SUCCESS StopBits: 1 Parity: MARK WordLength: 8
0.00000140 Tgw.exe IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
0.00000335 Tgw.exe IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0 Replace:0 XonLimit:2048 XoffLimit:512




0.00001844 Tgw.exe IRP_MJ_WRITE Serial0 SUCCESS Length 1: 02 
0.00000140 Tgw.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS
0.00000084 Tgw.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS
0.00000112 Tgw.exe IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS
0.00000112 Tgw.exe IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS
0.00000754 Tgw.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 SUCCESS Rate: 9600
0.00000363 Tgw.exe IOCTL_SERIAL_CLR_RTS Serial0 SUCCESS
0.00000363 Tgw.exe IOCTL_SERIAL_CLR_DTR Serial0 SUCCESS
0.00000223 Tgw.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 SUCCESS StopBits: 1 Parity: SPACE WordLength: 8
0.00000112 Tgw.exe IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
0.00000251 Tgw.exe IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0 Replace:0 XonLimit:2048 XoffLimit:512
0.00001592 Tgw.exe IRP_MJ_WRITE Serial0 SUCCESS Length 3: 08 00 F6 
0.00000307 Tgw.exe IOCTL_SERIAL_GET_COMMSTATUS Serial0 SUCCESS
0.00000140 Tgw.exe IOCTL_SERIAL_GET_COMMSTATUS Serial0 SUCCESS
0.00000363 Tgw.exe IRP_MJ_READ Serial0 SUCCESS Length 23: 01 08 CF 02 F9 02 F9 02 F9 0F B2 0F D3 0F DF 0F 89 1B 88 0C 2E 00 31  --------------------编程问答-------------------- mscomm控件
--------------------编程问答-------------------- 既然是串口操作,建议直接监视收发的数据即可,其它操作方式无需关注.

你使用COMM控件模拟一下发送过去的数据即可,看看设备是否返回同样的数据. --------------------编程问答-------------------- 没有通信协议吗?没有通信协议就不好做了。
建议你使用串口调试器来调试一下。
http://download.csdn.net/source/1262066
http://download.csdn.net/source/1441583 --------------------编程问答-------------------- Rate: 9600 
StopBits: 1 Parity: SPACE WordLength: 8 
WRITE Serial0 SUCCESS Length 1: 02 
WRITE Serial0 SUCCESS Length 3: 08 00 F6
READ  Serial0 SUCCESS Length 23: 01 08 CF 02 F9 02 F9 02 F9 0F B2 0F D3 0F DF 0F 89 1B 88 0C 2E 00 31 
波特率9600,停止位1,数据位8 --------------------编程问答--------------------
引用 4 楼 zdingyun 的回复:
Rate: 9600
StopBits: 1 Parity: SPACE WordLength: 8
WRITE Serial0 SUCCESS Length 1: 02
WRITE Serial0 SUCCESS Length 3: 08 00 F6
READ  Serial0 SUCCESS Length 23: 01 08 CF 02 F9 02 F9 02 F9 0F B2 0F D3 0F DF 0F 89 1B 88 0C 2E 00 31
波特率9600,停止位1,数据位8

建议LZ用串口助手调试,选DTR及RTS为真.参考上述的指令发送16进制数据0X02及0X08 0X00 0XF6测试. --------------------编程问答-------------------- 感谢大家帮忙,还有地方不懂,也还没读到数据。
原软件:  IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13 
         IOCTL_SERIAL_SET_HANDFLOW    Serial0 SUCCESS Shake:0 Replace:0 XonLimit:2048 XoffLimit:512 
监控自己写的程序有两项很不同
自己编的:IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:1a ERR:30 BRK:30 EVT:0 XON:11 XOFF:13
 IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:1 Replace:4 XonLimit:64 XoffLimit:64
一个是handflow和char,这两个是什么意思,vb里怎么设置?
补充:VB ,  COM/DCOM/COM+
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,