I've been trying to make a very simple program that when run, outputs the output of a command to a serial port. For some reason I can't get this to work. I gave up with C++ as serial communication in C++ is very complex then read it's easier in Python. Keep in mind I barely know this language, actually my first time using it, but here goes.
Why is it that this does not work:
But if I replace input = 'allstates' with input = raw_input(": ") and type the command manually, then it works?
Why is it not accepting a static string?
Why is it that this does not work:
Code:
#!/usr/bin/python
import time
import serial
ser = serial.Serial('/dev/arduino-0',9600,timeout=1)
ser.isOpen()
time.sleep(1)
input = 'allstates'
ser.write(input + '\r\n')
time.sleep(2)
out = ser.read(1000)
print out
But if I replace input = 'allstates' with input = raw_input(": ") and type the command manually, then it works?
Why is it not accepting a static string?
