It appears there's a discrepancy between what the serial monitor displays and the actual serial output.
Hi folks. I'm pretty new to all this so please be gentle! I am working on a project that is exhibiting some unexpected (to me) behaviour and I hoped somebody could shine some light. I have stripped the code down to the bare minimum that demonstrates the problem.
I have a slave Nano which sends text messages to a master Nano over via PJON. This works nicely.
I get the master Nano to place the received messages into a string variable. It then prints the variable's contents to the serial monitor. This also works nicely.
I created a string variable on the master Nano for testing and populated it locally. This also prints to the serial monitor in exactly the way I expected.
BUT
...if I connect the master Nano to a Raspberry Pi running the simplest Python serial script, ITS monitor prints the master's locally generated variable and not the network-populated one.
It appears there's a discrepancy between what the serial monitor displays and the actual serial output.
I suspect that there might be something about the way the master Nano copies from a *pointer variable that is causing this, but I'm a little out of my depth. Can anyone offer some advice as to what I should try next?
Thanks for reading!
Here's the code.
The slave Nano:
#include <PJONSoftwareBitBang.h>
PJONSoftwareBitBang bus(10);
void setup() {
bus.strategy.set_pin(12);
bus.begin();
}
void loop() {
bus.send(100, "remote", 9);
bus.update();
}
The master Nano:
#include <PJONSoftwareBitBang.h>
PJONSoftwareBitBang bus(100);
String local_var;
String remote_var;
void receiver_function(uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info) {
remote_var = payload;
};
void setup() {
bus.strategy.set_pin(12);
bus.begin();
bus.set_receiver(receiver_function);
Serial.begin(9600);
};
void loop() {
bus.receive(1000);
local_var = "local ";
Serial.print(local_var);
Serial.println(remote_var);
};
The Pi's Python code:
import serial
ser = serial.Serial("/dev/ttyUSB0", 9600)
while True:
cc=str(ser.readline())
print(cc[2:][:-5])
The Master's serial monitor:

The Pi's Output
