Topic: is there a difference in sending a serial command at setup and during loop? (Read 1 time)previous topic - next topic

I think the subject says it all. I hava my arduino connected to a raspberry PI. I've got a sketch that sends serial commands to the Pi in the loop which works fine. When I try and send a serial command in the setup portion not all of the command is received by the PI. I would immagine that there shouldn't be any difference between the two right?

Serial1.println("ST"); would call a function on the PI to see if the PI had powered up before the arduino. If nothing is returned then the mega just continues waiting for the Pi to boot. If the PI did start before the mega the command recieved by the pi will then will go through a routine to relay some information to the Arduino.

Serial1.println("ST");Even though the PI may be off or booting, you send data, anyway. Then some portion of this two byte stream of data is lost. You didn't think it important to show the PI code, or explain which portion gets lost, but you want us to help you fix it. I doubt that that will happen.

response = serialport.readline(None); response = response[0:2]But, the Arduino sent a carriage return and line feed. What does None cause readline() to do?

None was part of an example I used. According to http://pyserial.sourceforge.net/shortintro.html the "None" parameter isn't listed as necessary. Its been removed and the python script still behaves the same.

Again the arduino mega is externally powered. The PI takes a minute or two to boot. There are two scenarios that could happen.

Scenario 1 (this works fine):

Arduino and PI boot at the same time. The arduino boots in two or three seconds and then sends the line "Serial1.println("ST");" but the PI isn't listening to input from the arduino yet. At the end of the boot sequence the PI runs the python script shown above and sends the information to the Mega.

Scenario 2 (this is what doesn't work):

The arduino gets powered up after the PI or resets for some reason. The mega boots and then sends the line "Serial1.println("ST");" after the PI has completed its boot sequence and the script is waiting for input. That is when I get no response.

The power source usually has nothing to do with resetting an arduino. Activity on the serial port causes the arduino to reset. When a pc opens a serial port it sends signals on the rts/dtr setial lines which cause the arduino reset (unless defeated).

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

The power source usually has nothing to do with resetting an arduino. Activity on the serial port causes the arduino to reset. When a pc opens a serial port it sends signals on the rts/dtr setial lines which cause the arduino reset (unless defeated).

Even if the mega is connected to the pc via two pins tx & rx on Serial1 via the GPIO?