小编Jon*_*220的帖子

使用PySerial发送ASCII命令

我正在尝试发送以下ASCII命令:close1

使用PySerial,下面是我的尝试:

import serial

#Using  pyserial Library to establish connection
#Global Variables
ser = 0

#Initialize Serial Port
def serial_connection():
    COMPORT = 3
    global ser
    ser = serial.Serial()
    ser.baudrate = 38400 
    ser.port = COMPORT - 1 #counter for port name starts at 0




    #check to see if port is open or closed
    if (ser.isOpen() == False):
        print ('The Port %d is Open '%COMPORT + ser.portstr)
          #timeout in seconds
        ser.timeout = 10
        ser.open()

    else:
        print ('The Port %d is closed' %COMPORT) …
Run Code Online (Sandbox Code Playgroud)

python hardware serial-port pyserial python-3.x

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

hardware ×1

pyserial ×1

python ×1

python-3.x ×1

serial-port ×1