I am trying to use the first example of arduino's library "Arduino_Threads" which is called "Shared_Counter.ino" in my Portenta H7 but I get the error:
C:\Users\usuario\AppData\Local\Temp\.arduinoIDE-unsaved20231015-1068-172vtf7.klxl\Shared_Counter\Shared_Counter.ino: In function 'void setup()':
C:\Users\usuario\AppData\Local\Temp\.arduinoIDE-unsaved20231015-1068-172vtf7.klxl\Shared_Counter\Shared_Counter.ino:9:3: error: 'Producer' was not declared in this scope
Producer.start();
^~~~~~~~
C:\Users\usuario\AppData\Local\Temp\.arduinoIDE-unsaved20231015-1068-172vtf7.klxl\Shared_Counter\Shared_Counter.ino:10:3: error: 'Consumer' was not declared in this scope
Consumer.start();
^~~~~~~~
C:\Users\usuario\AppData\Local\Temp\.arduinoIDE-unsaved20231015-1068-172vtf7.klxl\Shared_Counter\Shared_Counter.ino:10:3: note: suggested alternative: 'osTimer'
Consumer.start();
^~~~~~~~
osTimer
exit status 1
Compilation error: 'Producer' was not declared in this scope
If I manually try to create a .inot file Arduino IDE doesn't let me as it recalls that this is not a valid extension. How can I make this basic example work?
Any advice would be very much appreciated.
Shared_Counter.ino :
/* This example demonstrates data exchange between
* threads using a shared counter variable defined
* within 'SharedVariables.h'.
*/
void setup()
{
Producer.start();
Consumer.start();
}
void loop()
{
SharedVariables.h :
/* Define a shared variable named 'counter' of type 'int'. */
SHARED(counter, int);
Consumer.inot :
void setup()
{
Serial.begin(9600);
while(!Serial) { }
}
void loop()
{
/* If a value is available for reading within the internal
* queue then the value is removed from the queue and made
* available to the calling function. Should no data be
* available, then this thread is suspended until new data
* is available for reading.
*/
Serial.println(counter.pop());
}
Producer.inot :
void setup()
{
}
void loop()
{
static int i = 0;
/* Every 100 ms a new value is inserted into the shared variable
* 'counter'. Internally this is stored within a queue in a FIFO
* (First-In/First-Out) manner.
*/
counter.push(i);
i++;
delay(100);
}