如何使用pyserial连接到端口?

2024-10-03 06:26:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图连接到CashCode VAULT1500票据验证器。
我将它连接到Windows机器,并在DebianVmBox虚拟机中工作。下面是我如何将带有CashCode的COM端口连接到VMBox

VMBox screenshot

在debian上,我检查端口名:

python -m serial.tools.list_ports

得到:

/dev/ttyS3

现在我尝试连接到端口,如示例https://github.com/ubombi/cashcode_ccnet/tree/master/ccnet

import serial
ser = serial.Serial(port='/dev/ttyS3', baudrate=9600, timeout=None,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE)
t = ser.read(3)

但这里没有答案。
VMBox设置或代码中我会错过什么?你知道吗


Tags: 端口devcom机器windowsserialdebianser