HW: 2 Arduino ProMini 16Mhz, 5V Software serial directly connected using male jumpers on bredboard.
I have creates a software serial port for communication between two arduinos, Parent and child
as per the documentation http://arduino.cc/en/Reference/SoftwareSerialAvailable
mySerial.available()
should return the number of bytes available in the buffer. and
mySerial.read();
should give me the byte or return -1 (255) on error. http://arduino.cc/en/Reference/SoftwareSerialRead
here is my code snippet where i read the values
if(child1.available() > 0){
Serial.print("ParentReceived Something from child 1\n");
while(child1.available()){
recvBuffer1[i] = child1.read();
Serial.print(recvBuffer1[i], DEC); Serial.print(" ");
Serial.print(i, DEC); Serial.print(" ");
i++;
if(i == FRAME_SIZE) break;
}
}
the Serial outputs are for debugging, The condition for while is true. we go inside. Now what i receive with child1.read() is the following
ParentReceived Something from child 2
255 0 255 1 255 2 255 3 255 4 255 5 255 6 255 7
all i see is 255.
what i did: I first suspected the child of sending these data, but i used a TTL to USB converter to directly read the values being sent by the child and they are received correctly as they should be. even if i TAP the serial ports to another TTL to USB converter i get 255 on my arduino Serial monitor and the correct data on the sniffer.
recvBuffer
and directly write the value to the serial window to see if that variable is the issue or not. – Anonymous Penguin Jan 31 '15 at 0:11