1 serialString = "" # Used to hold data coming over UART
2
3
4while(1):
5
6 # Wait until there is data waiting in the serial buffer
7 if(serialPort.in_waiting > 0):
8
9 # Read data out of the buffer until a carraige return / new line is found
10 serialString = serialPort.readline()
11
12 # Print the contents of the serial data
13 print(serialString.decode('Ascii'))
14
15 # Tell the device connected over the serial port that we recevied the data!
16 # The b at the beginning is used to indicate bytes!
17 serialPort.write(b"Thank you for sending data \r\n")
18