Commit d9bd054194f9cb3c6f00920064fd5af24bb188ae
1 parent
5f8d18dd
python script example to test tty0tty kernel module after having installed it
Showing
1 changed file
with
17 additions
and
0 deletions
examples/tnt1_echo_tnt0.py
0 → 100644
| 1 | +import serial | |
| 2 | + | |
| 3 | +serialPort_tnt0 = serial.Serial(port = "/dev/tnt0", baudrate=115200, | |
| 4 | + bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE) | |
| 5 | +serialPort_tnt1 = serial.Serial(port = "/dev/tnt1", baudrate=115200, | |
| 6 | + bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE) | |
| 7 | +serialPort_tnt0.write(b"hello there \r\n") | |
| 8 | + | |
| 9 | +while(1): | |
| 10 | + # Wait until there is data waiting in the serial buffer | |
| 11 | + if(serialPort_tnt1.in_waiting > 0): | |
| 12 | + # Read data out of the buffer until a carraige return / new line is found | |
| 13 | + serialString = serialPort_tnt1.readline() | |
| 14 | + # Print the contents of the serial data | |
| 15 | + print(serialString.decode('Ascii')) | |
| 16 | + # exit | |
| 17 | + break | ... | ... |