From d9bd054194f9cb3c6f00920064fd5af24bb188ae Mon Sep 17 00:00:00 2001 From: avialletelle Date: Fri, 10 Apr 2020 11:36:52 +0200 Subject: [PATCH] python script example to test tty0tty kernel module after having installed it --- examples/tnt1_echo_tnt0.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+), 0 deletions(-) create mode 100644 examples/tnt1_echo_tnt0.py diff --git a/examples/tnt1_echo_tnt0.py b/examples/tnt1_echo_tnt0.py new file mode 100644 index 0000000..c765c59 --- /dev/null +++ b/examples/tnt1_echo_tnt0.py @@ -0,0 +1,17 @@ +import serial + +serialPort_tnt0 = serial.Serial(port = "/dev/tnt0", baudrate=115200, + bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE) +serialPort_tnt1 = serial.Serial(port = "/dev/tnt1", baudrate=115200, + bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE) +serialPort_tnt0.write(b"hello there \r\n") + +while(1): + # Wait until there is data waiting in the serial buffer + if(serialPort_tnt1.in_waiting > 0): + # Read data out of the buffer until a carraige return / new line is found + serialString = serialPort_tnt1.readline() + # Print the contents of the serial data + print(serialString.decode('Ascii')) + # exit + break -- libgit2 0.21.4