Skip to content

Bugfix: 'Serial.begin()' now needs to be called within every thread that wants to use it. #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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