Aug-24-2018, 12:16 PM
I am new to the Python coding , so anyone please guide me. I want to store the output into a text file. From the below code, i am able to read the data in a Python Shell.
[python]
import serial.tools.list_ports
list = serial.tools.list_ports.grep('VID:PID=10C4:EA60','hwid')
connected = []
for element in list:
connected.append(element.device)
a=str(connected)
try:
port = connected[0]
baud = 115200
ser = serial.Serial(port, baud, timeout=1)
#input1.encode('UTF-8')
if ser.isOpen():
print(ser.name + ' is open...')
while (1):
out1 = ser.read()
print out1,
ser.close()
except:
pass
For above code, i got the below output
[python]
import serial.tools.list_ports
list = serial.tools.list_ports.grep('VID:PID=10C4:EA60','hwid')
connected = []
for element in list:
connected.append(element.device)
a=str(connected)
try:
port = connected[0]
baud = 115200
ser = serial.Serial(port, baud, timeout=1)
#input1.encode('UTF-8')
if ser.isOpen():
print(ser.name + ' is open...')
while (1):
out1 = ser.read()
print out1,
ser.close()
except:
pass
For above code, i got the below output
Output:tx data=10513
tx data=10514
tx data=10515
tx data=10516
tx data=10517
tx data=10518
tx data=10519
4
tx data=10520
tx data=10521
tx data=10522