Read Serial and Log CSV

Easy Python IO
Solve this problem

Write a Python script to read lines from a serial port and log them into CSV format. Handle serial exceptions and close file safely.

Constraints

  • Use pyserial.
  • Com port and baud via args.
  • Write 'timestamp,value' format.
  • Ctrl+C exits cleanly.
Starter codePython
1import serial, time2# TODO