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()
In questa pagina del sito puoi guardare il video online Simple serial port example using Python. della durata di ore minuti seconda in buona qualità , che l'utente ha caricato guru brahmayya 23 novembre 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 7,188 volte e gli è piaciuto 39 spettatori. Buona visione!