Skip to content

Commit

Permalink
Bugfix: 'Serial.begin()' now needs to be called within every thread t…
Browse files Browse the repository at this point in the history
…hat wants to use it.
  • Loading branch information
aentinger committed Oct 20, 2021
1 parent e06adb3 commit 55b8dcd
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
9 changes: 6 additions & 3 deletions examples/Threading/Demo_Shared_Counter/Consumer.inot
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
void setup() {

void setup()
{
Serial.begin(9600);
while(!Serial) { }
}

void loop() {
void loop()
{
Serial.println(counter);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
void setup()
{
Serial.begin(115200);
while (!Serial) { }

Producer.start();
Consumer.start();
}
Expand Down
6 changes: 4 additions & 2 deletions examples/Threading/Demo_Shared_Counter/Producer.inot
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
void setup() {
void setup()
{

}

void loop() {
void loop()
{
static int i = 0;
counter = i;
i++;
Expand Down
3 changes: 2 additions & 1 deletion examples/Threading/Demo_Source_Sink_Counter/Consumer.inot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ SINK(counter, int, 10);

void setup()
{

Serial.begin(9600);
while(!Serial) { }
}

void loop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
* together using the "connectTo" method.
*/

void setup() {
void setup()
{
Source_Thread.led.connectTo(Sink_Thread.led);
Sink_Thread.start();
Source_Thread.start();
}

void loop() {
void loop()
{
rtos::ThisThread::yield();
}
3 changes: 3 additions & 0 deletions examples/Threadsafe_IO/Threadsafe_SPI/Threadsafe_SPI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ byte bmp388_read_reg(byte const reg_addr)

void bmp388_thread_func()
{
Serial.begin(9600);
while(!Serial) { }

for(;;)
{
/* Sleep between 5 and 500 ms */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ static char thread_name[NUM_THREADS][32];

void setup()
{
Serial.begin(9600);
while (!Serial) { }

pinMode(BMP388_CS_PIN, OUTPUT);
digitalWrite(BMP388_CS_PIN, HIGH);

Expand Down Expand Up @@ -70,6 +67,9 @@ byte bmp388_read_reg(byte const reg_addr)

void bmp388_thread_func()
{
Serial.begin(9600);
while(!Serial) { }

for(;;)
{
/* Sleep between 5 and 500 ms */
Expand Down
6 changes: 3 additions & 3 deletions examples/Threadsafe_IO/Threadsafe_Wire/Threadsafe_Wire.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ static char thread_name[NUM_THREADS][32];

void setup()
{
Serial.begin(9600);
while (!Serial) { }

/* Fire up some threads all accessing the LSM6DSOX */
for(size_t i = 0; i < NUM_THREADS; i++)
{
Expand Down Expand Up @@ -76,6 +73,9 @@ byte lsm6dsox_read_reg(byte const reg_addr)

void lsm6dsox_thread_func()
{
Serial.begin(9600);
while(!Serial) { }

for(;;)
{
/* Sleep between 5 and 500 ms */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ static char thread_name[NUM_THREADS][32];

void setup()
{
Serial.begin(9600);
while (!Serial) { }

/* Fire up some threads all accessing the LSM6DSOX */
for(size_t i = 0; i < NUM_THREADS; i++)
{
Expand Down Expand Up @@ -64,6 +61,9 @@ byte lsm6dsox_read_reg(byte reg_addr)

void lsm6dsox_thread_func()
{
Serial.begin(9600);
while(!Serial) { }

for(;;)
{
/* Sleep between 5 and 500 ms */
Expand Down

0 comments on commit 55b8dcd

Please sign in to comment.