I want to get the code of a device from COM6, I easily get the output from C# using the code below:
serialPort1.Encoding = System.Text.Encoding.GetEncoding(28591);
but I don't know how to do it in Python.
I already tried:
import serial
import time
ser = serial.Serial()
ser.port='COM6'
ser.baudrate=9600
ser.parity=serial.PARITY_NONE
ser.stopbits=serial.STOPBITS_ONE
ser.bytesize=serial.EIGHTBITS
ser.timeout=2
if ser.is_open:
ser.close()
else:
ser.open()
print("connected to: " + ser.portstr)
while True:
ser.flushInput()
time.sleep(0.01)
data_raw = (ser.readline())
print(data_raw.decode("utf-8"))