Commit 0b685142f87e242840784d2afc123a0eac24dd1d

Authored by Jeff Buchbinder
Committed by GitHub
2 parents 8ce4858d d9bd0541

Merge pull request #25 from papapel/master

Python script to test tty0tty kernel module with pyserial
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
... ...