Skip to main content
added 16 characters in body
Source Link
asheeshr
  • 3.8k
  • 3
  • 25
  • 61

wellWell, I don't know about your ino program, but here's how I'd do it:

get_serial.py

import serial, sys

with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
    while ser.isOpen():
        print(ser.readline())

theThe idea, here, is to print on stdoutstdout the data coming on the serial line:

python get_serial.py /dev/ttyACM0 115200 > output.log

or you can do it this way:

get_serial.py

import serial, sys

with open(sys.argv[3]) as f:
    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
        while ser.isOpen():
            f.write(ser.readline())

which is ran:

python get_serial.py /dev/ttyACM0 115200 output.log

HTHHope this helps!

well I don't know about your ino program, but here's how I'd do it:

get_serial.py

import serial, sys

with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
    while ser.isOpen():
        print(ser.readline())

the idea, here, is to print on stdout the data coming on the serial line:

python get_serial.py /dev/ttyACM0 115200 > output.log

or you can do it this way:

get_serial.py

import serial, sys

with open(sys.argv[3]) as f:
    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
        while ser.isOpen():
            f.write(ser.readline())

which is ran:

python get_serial.py /dev/ttyACM0 115200 output.log

HTH

Well, I don't know about your ino program, but here's how I'd do it:

get_serial.py

import serial, sys

with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
    while ser.isOpen():
        print(ser.readline())

The idea, here, is to print on stdout the data coming on the serial line:

python get_serial.py /dev/ttyACM0 115200 > output.log

or you can do it this way:

get_serial.py

import serial, sys

with open(sys.argv[3]) as f:
    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
        while ser.isOpen():
            f.write(ser.readline())

which is ran:

python get_serial.py /dev/ttyACM0 115200 output.log

Hope this helps!

Source Link
zmo
  • 1.5k
  • 10
  • 16

well I don't know about your ino program, but here's how I'd do it:

get_serial.py

import serial, sys

with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
    while ser.isOpen():
        print(ser.readline())

the idea, here, is to print on stdout the data coming on the serial line:

python get_serial.py /dev/ttyACM0 115200 > output.log

or you can do it this way:

get_serial.py

import serial, sys

with open(sys.argv[3]) as f:
    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
        while ser.isOpen():
            f.write(ser.readline())

which is ran:

python get_serial.py /dev/ttyACM0 115200 output.log

HTH