'communicating with serial virtual COM port using python
I have written snippet below to communicate (send a simple '1' character) with serial virtual COM3 port, which is connected to a STM32 board, using python. But the code does not works. I should also mention that by using Terminal app, I can send and receive data to COM port. The figure shows the setting in Terminal app: Terminal setting
The code is as follows:
@pyqtSlot() # the snippet is part of a pyqt5 code.
def on_click(self):
print("here")
ser = serial.Serial('COM3', 115200, timeout = 1, bytesize = serial.EIGHTBITS, parity = serial.PARITY_NONE, stopbits = STOPBITS_ONE)
ser.open()
ser.write('1') #I used also ser.write('1'.encode('UTF-8'))
ser.close()
Thanks for your time.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|