Pyserial Works Fine in Python Interpreter, But Not Standalone

pySerial works fine in Python interpreter, but not standalone

I think it's probably a race condition between when the serial port is opened and when the data are sent. I'd probably stick a sleep in between the open and the write calls.

Alternatively, instead of using this library "serial" you might want to just open and write directly to the device, perhaps it's doing something funny (see the double open mentioned in other posts)

pySerial not working when stand alone

Try adding a delay after the serial port has been opened. May not be fully ready to go by the time data is going in/out. Just for safety do it on both platforms!

Basically sleep/delay after:

ser = serial.Serial(port_name, 9600)

and

Serial.begin(9600); 

Python serial without pyserial

Looking around I found this example.

From the site:

arduinoserial.py is a Python port of Tod E. Kurt's arduino-serial.c program for communicating with an Arduino microcontroller board over a serial port. It only uses standard Python modules (notably termios and fcntl) and does not require any special serial communications modules.

Like Tod's program, you can use it from the command line.



Related Topics



Leave a reply



Submit