I'm trying to send the output of a BNO055 sensor through RPC, from the M7 core to the M4 core, but sometimes the code doesn't run, or there's no output in the Serial Monitor, since the M4 can't use the Serial Monitor, we print the output in the M7.
#include <RPC.h>
void setup() {
Serial.begin(9600);
RPC.begin();
}
void loop() {
String buffer = "";
while (RPC.available()) {
buffer += (char)RPC.read(); // Fill the buffer with characters
}
if (buffer.length() > 0) {
Serial.print(buffer);
}
}
If this demo-code that is 100,000% the demo-code.
And if this demo-code does not work you know:
there is a different and very basic problem which must be solved first.
If it does work I would do a tiny small modification which would be counting up a variable
in the M4-core
M4-Sketch
#include <RPC.h>
int myInt = 0;
void setup() {
RPC.begin();
}
void loop() {
myInt++;
RPC.print("Printed from M4 core myInt="); // intentionally FIXED text to make sure that SOME bytes are printed for SURE
RPC.println(myInt);
delay(1000);
}
Your M4-code does only
Which could be one problem that variable "msg" could - for whatever reason -
be "empty" or holding a not printable character
possible that using Serial.begin(115200); in your M4-Code is causing the problem.
The Demo-code does NOT have a Serial.begin(115200); in the M4-code
RPC is a method that allows programs to make requests to programs located elsewhere. It is based on the client-server model (also referred to as caller/callee), where the client makes a request to the server.
An RPC is a synchronous operation, and while a request is being made from the caller to another system, the operation is suspended. On return of the results, the operation is resumed.
The server side then performs the subroutine on request, and suspends any other operation as well. After it sends the result to the client, it resumes its operation, while waiting for another request.
sounds more like a communications mechanism the way it's described by, and used by the OP
the code below suggests it's a replacement for Serial. I don't see any code to associate the RPC on the processor with some other processor or task on another processor
and not unusually, the receive buffer is processed regardless if anything is received.