I would like to send one string over the serial port; it works in a loop but not when I send only one string:
I have two Raspberry Pi 2. Each one have a xbee module. I want to send data from one to the other. They are correctly connected.
To test sending data I have this little Python script:
import serial
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=.5)
while True:
ser.write('Hello world!\r\n')
My other Raspberry Pi connected with minicom
receives correct data:
Hello world!
Hello world!
Hello world!
...
Everything works, but I want to send only one string and remove the loop, however with this code:
import serial
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=.5)
ser.write('Hello world!\r\n')
I received nothing... I don't know why. Does anyone know what's wrong?