I am completely new to python.
I am using the following code to draw data from a USB device, which is printing data to my raspberry Pi using printf(). I am using the following python code to read this data and print it to screen:
#!/usr/bin/python
import serial
ser = serial.Serial(
port='/dev/ttyUSB0',\
baudrate=115200,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=0)
print("connected to: " + ser.portstr)
ser.write("help\n");
while True:
line = ser.readline();
if line:
print(line),
ser.close()
the code prints the following result as is expected (this is what I'm using printf() for):
Received Ticks are: 380 and nodeID is: 1
How can I parse the line variable so that I can save the number of Ticks (380) and nodeID (1), to two variables so that I can use those variables for a HTTP POST request in python?