Simple serial port hardware loop back programming using Python.
I have used COM4 (USB-Serial converter) and shorted TX(pin-2) and RX(pin-3).
Code:
import serial
from time import sleep
ser = serial.Serial(port='COM4',baudrate=9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=0)
print("connected to: " + ser.portstr)
ser.write("Hello World")
sleep(1)
a=ser.readline()
print(a)
ser.close()
En esta página del sitio puede ver el video en línea Simple serial port example using Python. de Duración hora minuto segunda en buena calidad , que subió el usuario guru brahmayya 23 noviembre 2019, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 7,188 veces y le gustó 39 a los espectadores. Disfruta viendo!