Hello,
I need to pass a variable from the CM7 to the CM4.
I used the excellent exemple from "jerteach" on this forum
: my-examples-for-the-arduino-portentaH7/my02c-dual-core-RPC-variable.ino at master · hpssjellis/my-examples-for-the-arduino-portentaH7 · GitHub
Except I'm reversing the flow of data ( CM7 to CM4 instead of CM4 to CM7 in the exemple.
The code compile and works. but stopped (Portanta blink red and I need to reset it) after a certain number of "Call" function as been initiated.
I am sure it comes from the Call function and is relative to the number of time (1560) it is initiated, as if I add a delay, it will take longer before the Portanta freeze, and If I remove the Call function, everything works fine.
The thing is I don't exactly understand how the RPC is working and what could cause that. Any ideas ?
Thanks.
#ifdef CORE_CM7 //M7 Programming
#include "RPC_internal.h"
int j = 0;
void setup() {
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
bootM4();
Serial.println("M4 Booted");
RPC1.begin();
}
void loop()
{
Serial.println(RPC1.call("Multiple_variable", 24,255,80,229,0,0,0,0,0,0,0,0,0,10).as<int>());
j = j+1;
Serial.println(j);
while (RPC1.available())
{
Serial.write(RPC1.read()); // check if the M4 has sent an RPC println
}
//delay (100);
}
#endif
#ifdef CORE_CM4 // Start M4 programming
#include "RPC_internal.h"
int i = 0;
long OperationVar = 0;
int Multiple_variables[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int Multiple_variable(int id1, int id2, int id3, int id4, int Ext, int Len, int Data1, int Data2, int Data3, int Data4, int Data5, int Data6, int Data7, int Data8)
{
Multiple_variables[0] = (long)id1;
Multiple_variables[1] = (long)id2;
Multiple_variables[2] = (long)id3;
Multiple_variables[3] = (long)id4;
Multiple_variables[4] = (long)Ext;
Multiple_variables[5] = (long)Len;
Multiple_variables[6] = (long)Data1;
Multiple_variables[7] = (long)Data2;
Multiple_variables[8] = (long)Data3;
Multiple_variables[9] = (long)Data4;
Multiple_variables[10] = (long)Data5;
Multiple_variables[11] = (long)Data6;
Multiple_variables[12] = (long)Data7;
Multiple_variables[13] = (long)Data8;
return id1;
}
void setup()
{
RPC1.begin();
RPC1.bind("Multiple_variable", Multiple_variable);
}
void loop()
{
i = i+1;
OperationVar = (Multiple_variables[0] << 8) | Multiple_variables[1];
OperationVar = (OperationVar << 8) | Multiple_variables[2];
OperationVar = (OperationVar << 8) | Multiple_variables[3];
RPC1.println("From M4 " + String(OperationVar) + " " + String(i));
delay(100);
}
#endif