我正在尝试编写连接到设备并读取一些信息的RS-232客户端应用程序,目前有一个Win32应用程序也是如此,我想通过创建一个python应用程序使其可移植做同样的事情。我运行了一个串行数据捕获(portmon.exe)软件,看看有哪种Tx Rx数据包,我试图使用我的python代码重新创建它们,没有太多帮助。当我比较我的python应用程序和Win32应用程序之间的portmon.exe输出时,我可以看到一些差异,尤其是在初始端口设置部分。所以,如果你们中的任何人能够帮助我更好地理解下面的请求响应转储,那就太棒了,因为TIA!
从win32应用程序请求响应转储:
0 4:22:29 PM ntvdm.exe IRP_MJ_CREATE Serial0 Options: Open
0 4:22:29 PM SUCCESS
1 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0
1 4:22:29 PM SUCCESS
2 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
2 4:22:29 PM SUCCESS
3 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_CHARS Serial0
3 4:22:29 PM SUCCESS
4 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_HANDFLOW Serial0
4 4:22:29 PM SUCCESS
5 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0
5 4:22:29 PM SUCCESS
6 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
6 4:22:29 PM SUCCESS
7 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_CHARS Serial0
7 4:22:29 PM SUCCESS
8 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_HANDFLOW Serial0
8 4:22:29 PM SUCCESS
9 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 Rate: 9600
9 4:22:29 PM SUCCESS
10 4:22:29 PM ntvdm.exe IOCTL_SERIAL_CLR_RTS Serial0
10 4:22:29 PM SUCCESS
11 4:22:29 PM ntvdm.exe IOCTL_SERIAL_CLR_DTR Serial0
11 4:22:29 PM SUCCESS
12 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 StopBits: 1 Parity: NONE WordLength: 5
12 4:22:29 PM SUCCESS
13 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_CHAR Serial0 EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
13 4:22:29 PM SUCCESS
14 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_HANDFLOW Serial0 Shake:0 Replace:0 XonLimit:2048 XoffLimit:512
14 4:22:29 PM SUCCESS
15 4:22:29 PM ntvdm.exe IOCTL_SERIAL_LSRMST_INSERT Serial0 Char: ffffffff
15 4:22:29 PM SUCCESS
16 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_QUEUE_SIZE Serial0 InSize: 8192 OutSize: 100
16 4:22:29 PM SUCCESS
17 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_TIMEOUTS Serial0
17 4:22:29 PM SUCCESS
18 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_TIMEOUTS Serial0 RI:-1 RM:0 RC:0 WM:0 WC:0
18 4:22:29 PM SUCCESS
19 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_DTR Serial0
19 4:22:29 PM SUCCESS
20 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_RTS Serial0
20 4:22:29 PM SUCCESS
21 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
21 4:22:29 PM SUCCESS
22 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 StopBits: 1 Parity: NONE WordLength: 8
22 4:22:29 PM SUCCESS
23 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
23 4:22:29 PM SUCCESS
24 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 StopBits: ERROR Parity: NONE WordLength: 8
24 4:22:29 PM SUCCESS
25 4:22:29 PM ntvdm.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
25 4:22:29 PM SUCCESS
26 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 StopBits: ERROR Parity: EVEN WordLength: 8
26 4:22:29 PM SUCCESS
27 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 Rate: 9600
27 4:22:29 PM SUCCESS
28 4:22:29 PM ntvdm.exe IOCTL_SERIAL_SET_WAIT_MASK Serial0 Mask: RXCHAR CTS DSR RLSD ERR RING
28 4:22:29 PM SUCCESS
29 4:22:29 PM ntvdm.exe IOCTL_SERIAL_WAIT_ON_MASK Serial0
从python应用程序请求响应转储:
0 4:23:35 PM python.exe IRP_MJ_CREATE Serial0 Options: Open
0 4:23:35 PM SUCCESS
1 4:23:35 PM python.exe IOCTL_SERIAL_SET_QUEUE_SIZE Serial0 InSize: 4096 OutSize: 4096
1 4:23:35 PM SUCCESS
2 4:23:35 PM python.exe IOCTL_SERIAL_GET_TIMEOUTS Serial0
2 4:23:35 PM SUCCESS
3 4:23:35 PM python.exe IOCTL_SERIAL_SET_TIMEOUTS Serial0 RI:0 RM:0 RC:0 WM:0 WC:0
3 4:23:35 PM SUCCESS
4 4:23:35 PM python.exe IOCTL_SERIAL_SET_WAIT_MASK Serial0 Mask: ERR
4 4:23:35 PM SUCCESS
5 4:23:35 PM python.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0
5 4:23:35 PM SUCCESS
6 4:23:35 PM python.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
6 4:23:35 PM SUCCESS
7 4:23:35 PM python.exe IOCTL_SERIAL_GET_CHARS Serial0
7 4:23:35 PM SUCCESS
8 4:23:35 PM python.exe IOCTL_SERIAL_GET_HANDFLOW Serial0
8 4:23:35 PM SUCCESS
9 4:23:35 PM python.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0
9 4:23:35 PM SUCCESS
10 4:23:35 PM python.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0
10 4:23:35 PM SUCCESS
11 4:23:35 PM python.exe IOCTL_SERIAL_GET_CHARS Serial0
11 4:23:35 PM SUCCESS
12 4:23:35 PM python.exe IOCTL_SERIAL_GET_HANDFLOW Serial0
12 4:23:35 PM SUCCESS
13 4:23:35 PM python.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 Rate: 9600
13 4:23:35 PM SUCCESS
14 4:23:35 PM python.exe IOCTL_SERIAL_SET_RTS Serial0
14 4:23:35 PM SUCCESS
15 4:23:35 PM python.exe IOCTL_SERIAL_SET_DTR Serial0
15 4:23:35 PM SUCCESS
16 4:23:35 PM python.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 StopBits: 1 Parity: NONE WordLength: 8
16 4:23:35 PM SUCCESS
17 4:23:35 PM python.exe IOCTL_SERIAL_SET_CHAR Serial0 EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
17 4:23:35 PM SUCCESS
18 4:23:35 PM python.exe IOCTL_SERIAL_SET_HANDFLOW Serial0 Shake:1 Replace:40 XonLimit:2048 XoffLimit:512
18 4:23:35 PM SUCCESS
19 4:23:35 PM python.exe IOCTL_SERIAL_PURGE Serial0 Purge: TXABORT RXABORT TXCLEAR RXCLEAR
19 4:23:35 PM SUCCESS