Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
MultiCore MP_RECV_POLLING not working
-
Hi,
After several tries within the arduino IDE I can't get the MessageHello to work. The MessageData example does work and looked at the differences.
I found out that the MessageHello example makes use of
MP.RecvTimeout(MP_RECV_POLLING);
When I tried to add this Polling part to the working example I got the same problem.
MP.Send error = -11
is the error I get. I can't find anything in any documentation or what so ever. I have tried to use the polling system in my own written code as well but got the same error.
I need the polling system for my project for the communication between the cores. Is there anything I am overlooking?
Thanks in advance.
-
Hello, Jamu!
I'm going to ask a few follow up questions to see if we are able to get to the bottom of your problem.- Could you send me the whole output you see in the serial terminal?
- What is the memory configuration under Tools -> Memory?
- Could you send source code for your modified MessageData example?
-
Could you send me the whole output you see in the serial terminal?
The output is the picture underneath.
What is the memory configuration under Tools -> Memory?
768KB (default)
Could you send source code for your modified MessageData example?
UNCHANGED MAIN
#ifdef SUBCORE #error "Core selection is wrong!!" #endif #include <MP.h> int subcore = 1; /* Communication with SubCore1 */ void setup() { int ret = 0; Serial.begin(115200); while (!Serial); /* Launch SubCore1 */ ret = MP.begin(subcore); if (ret < 0) { printf("MP.begin error = %d\n", ret); } randomSeed(100); } void loop() { int ret; uint32_t snddata; uint32_t rcvdata; int8_t sndid = 100; /* user-defined msgid */ int8_t rcvid; snddata = random(32767); /* Echo back from SubCore */ printf("Send: id=%d data=0x%08lx\n", sndid, snddata); ret = MP.Send(sndid, snddata, subcore); if (ret < 0) { printf("MP.Send error = %d\n", ret); } /* Timeout 1000 msec */ MP.RecvTimeout(1000); ret = MP.Recv(&rcvid, &rcvdata, subcore); if (ret < 0) { printf("MP.Recv error = %d\n", ret); } printf("Recv: id=%d data=0x%08lx : %s\n", rcvid, rcvdata, (snddata == rcvdata) ? "Success" : "Fail"); delay(1000); }
CHANGED SUBCORE
The change is highlighted in with item#if (SUBCORE != 1) #error "Core selection is wrong!!" #endif #include <MP.h> void setup() { int ret = 0; ret = MP.begin(); if (ret < 0) { errorLoop(2); } **MP.RecvTimeout(MP_RECV_POLLING);** } void loop() { int ret; int8_t msgid; uint32_t msgdata; /* Echo back */ ret = MP.Recv(&msgid, &msgdata); if (ret < 0) { errorLoop(3); } ret = MP.Send(msgid, msgdata); if (ret < 0) { errorLoop(4); } } void errorLoop(int num) { int i; while (1) { for (i = 0; i < num; i++) { ledOn(LED0); delay(300); ledOff(LED0); delay(300); } delay(1000); } }
EXTRA
The same results happens with the other example code "MessageHello" created by sony. Code downbelow#include <MP.h> #define MSGLEN 64 #define MY_MSGID 10 struct MyPacket { volatile int status; /* 0:ready, 1:busy */ char message[MSGLEN]; }; #ifdef SUBCORE #if (SUBCORE == 1) #define SUBID "Sub1" #elif (SUBCORE == 2) #define SUBID "Sub2" #elif (SUBCORE == 3) #define SUBID "Sub3" #elif (SUBCORE == 4) #define SUBID "Sub4" #elif (SUBCORE == 5) #define SUBID "Sub5" #endif MyPacket packet; void setup() { memset(&packet, 0, sizeof(packet)); MP.begin(); } void loop() { int ret; static int count = 0; if (packet.status == 0) { /* status -> busy */ packet.status = 1; /* Create a message */ snprintf(packet.message, MSGLEN, "[%s] Hello %d", SUBID, count++); /* Send to MainCore */ ret = MP.Send(MY_MSGID, &packet); if (ret < 0) { printf("MP.Send error = %d\n", ret); } } delay(500); } #else /* MAINCORE */ void setup() { int ret = 0; int subid; Serial.begin(115200); while (!Serial); /* Boot SubCore */ for (subid = 1; subid <= 5; subid++) { ret = MP.begin(subid); if (ret < 0) { printf("MP.begin(%d) error = %d\n", subid, ret); } } /* Polling */ MP.RecvTimeout(MP_RECV_POLLING); } void loop() { int ret; int subid; int8_t msgid; MyPacket *packet; /* Receive message from SubCore */ for (subid = 1; subid <= 5; subid++) { ret = MP.Recv(&msgid, &packet, subid); if (ret > 0) { printf("%s\n", packet->message); /* status -> ready */ packet->status = 0; } } } #endif
Hope this helps, thank you in advance
-
Hey, Jamu!
As we can see from the MessageHello example, the polling command (MP.RecvTimeout(MP_RECV_POLLING);) is in the code for the maincore, not the subcore.
So could you try to leave the subcore code to the Message data example unchanged and instead change the maincore code to add the polling command?
Please let me know how that worked out for you. -
@CamilaSouza Hi Camila!
I've tried this as well but it gave the same result. As well as that the MessageHello example (with the MP_RECV_POLLING on the main core) gives the same error. Sadly it did not work for me.
-
I'm having trouble reproducing your problem on my end.
One thing that I noticed is that the output from your terminal looks different than mine.
This is what my terminal looks like with the application (MessageData) working correctly:Send: id=100 data=0x0000159d
Recv: id=100 data=0x0000159d : Success
Send: id=100 data=0x000004e3
Recv: id=100 data=0x000004e3 : Success
Send: id=100 data=0x00004606
Recv: id=100 data=0x00004606 : SuccessThis is what it looks like when I try to force an error:
Send: id=100 data=0x000052f2
MP.Recv error = -116
Recv: id=0 data=0x00000000 : Fail
Send: id=100 data=0x00006e77
MP.Recv error = -116
Recv: id=0 data=0x00000000 : Fail
Send: id=100 data=0x00005ab6
MP.Recv error = -116
Recv: id=0 data=0x00000000 : FailYou see that either way I get the message with Send: id=xxx data=xxxxxxx and Recv: id=xxx data=xxxxxx
So a couple of things I'm thinking:
I'd like to see your terminal when you have MessageData working perfectly and see if it is exactly like mine. Could you send me a picture?
(This is me trying to investigate if your flash is still intact, otherwise we could try and format it)Another thing is you could try to connect to the board using minicom
minicom -D /dev/ttyUSB0 -b 115200
We can see board initialization messages here, so we can check if your board is initializing correctly. -
@CamilaSouza said in MultiCore MP_RECV_POLLING not working:
Could you send me a picture?
This is the working output that seems as expected
EDIT
After changing adding MP_RECV_POLLING I get this error:
-
Ok. So this exact error happens to me when I put the line MP.RecvTimeout(MP_RECV_POLLING); on the setup of my Sub1 code.
When I put this line only on the setup of my Main code it works perfectly.I know you said you already tried it, but I'll ask you to try again and make sure the polling is happening only in the main core. I'm also providing code for both cores so you can see where in the code I made the change.
MAIN:
/* * Main.ino - MP Example to communicate message data * Copyright 2019 Sony Semiconductor Solutions Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef SUBCORE #error "Core selection is wrong!!" #endif #include <MP.h> int subcore = 1; /* Communication with SubCore1 */ void setup() { int ret = 0; Serial.begin(115200); while (!Serial); /* Launch SubCore1 */ ret = MP.begin(subcore); if (ret < 0) { printf("MP.begin error = %d\n", ret); } randomSeed(100); MP.RecvTimeout(MP_RECV_POLLING); } void loop() { int ret; uint32_t snddata; uint32_t rcvdata; int8_t sndid = 100; /* user-defined msgid */ int8_t rcvid; snddata = random(32767); /* Echo back from SubCore */ printf("Send: id=%d data=0x%08lx\n", sndid, snddata); ret = MP.Send(sndid, snddata, subcore); if (ret < 0) { printf("MP.Send error = %d\n", ret); } /* Timeout 1000 msec */ MP.RecvTimeout(1000); ret = MP.Recv(&rcvid, &rcvdata, subcore); if (ret < 0) { printf("MP.Recv error = %d\n", ret); } printf("Recv: id=%d data=0x%08lx : %s\n", rcvid, rcvdata, (snddata == rcvdata) ? "Success" : "Fail"); delay(1000); }
SUBCORE1
/* * Sub1.ino - MP Example to communicate message data * Copyright 2019 Sony Semiconductor Solutions Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if (SUBCORE != 1) #error "Core selection is wrong!!" #endif #include <MP.h> void setup() { int ret = 0; ret = MP.begin(); if (ret < 0) { errorLoop(2); } } void loop() { int ret; int8_t msgid; uint32_t msgdata; /* Echo back */ ret = MP.Recv(&msgid, &msgdata); if (ret < 0) { errorLoop(3); } ret = MP.Send(msgid, msgdata); if (ret < 0) { errorLoop(4); } } void errorLoop(int num) { int i; while (1) { for (i = 0; i < num; i++) { ledOn(LED0); delay(300); ledOff(LED0); delay(300); } delay(1000); } }