
import sys
import serial

def log_serial(filename, device='/dev/ttyACM0', baud=9600):
    ser = serial.Serial(device, baud)
    outfile = open(filename, 'w')
    while True:
        line = ser.readline()
        outfile.write(line)

if __name__ == '__main__':
    filename = sys.argv[1]
    log_serial(filename)



import sys
import serial

def log_serial(filename, device='/dev/ttyACM0', baud=9600):
    ser = serial.Serial(device, baud)
    outfile = open(filename, 'w')
    while True:
        line = ser.readline()
        print(line)
        outfile.write(line)

if __name__ == '__main__':
    filename = sys.argv[1]
    log_serial(filename)


Print lines that are logged
Print lines that are logged

  
  import sys
  import serial
  
  def log_serial(filename, device='/dev/ttyACM0', baud=9600):
      ser = serial.Serial(device, baud)
      outfile = open(filename, 'w')
      while True:
          line = ser.readline()
+         print(line)
          outfile.write(line)
  
  if __name__ == '__main__':
      filename = sys.argv[1]
      log_serial(filename)
  
  
Print lines that are logged
## Code Before:

import sys
import serial

def log_serial(filename, device='/dev/ttyACM0', baud=9600):
    ser = serial.Serial(device, baud)
    outfile = open(filename, 'w')
    while True:
        line = ser.readline()
        outfile.write(line)

if __name__ == '__main__':
    filename = sys.argv[1]
    log_serial(filename)


## Instruction:
Print lines that are logged
## Code After:

import sys
import serial

def log_serial(filename, device='/dev/ttyACM0', baud=9600):
    ser = serial.Serial(device, baud)
    outfile = open(filename, 'w')
    while True:
        line = ser.readline()
        print(line)
        outfile.write(line)

if __name__ == '__main__':
    filename = sys.argv[1]
    log_serial(filename)

