Anyway, I want to keep a log of Serial communication from a device connected by USB right now. You can use it in such a case.
The environment is assumed to be Mac.
The language uses Python.
Since pySerial is also used, let's install it with `$ pip install pyserial`
.
The source is below
logger.py
import serial
com = serial.Serial('/dev/....')
while True:
line = com.readline().strip().decode('utf-8')
print(line)
f = open('data.txt', 'a+')
f.writelines(line)
f.close()
com.close()
On Mac, you can check the list with the following command.
$ ls -l /dev/tty.usb*
Thank you for visiting us so far! We would appreciate it if you could comment on any improvements or unclear points.
Recommended Posts