Report
3 weeks, 6 days ago.

Thread question

Hello,

I am using a B-L475E-IO1A1 and I am trying to use Threads. I checked the MBed platform site and it says that my board uses OS5 which, as far as I understand, should have the ROTS libraries included (correct me if I am wrong)

However, when I try something like this (as per the OS5 documentation):

<<code>># AnalogIn ain(A1); void myFunction(){ printf("%in", ain); }

int main{ Thread thread; thread.start(myFunction ); } <</code>>

it gives me an error that Thread is not identified.

Then I downloaed the mbed-rtos library and included it in my project. It then allowed me to compile and burn my program on my board. However, nothing gets printed either. Anyone has any ideas? I am confused if I need to actual include the rtos library or if it's actually included. If it were, why did I get that Thread error to start with? Also the compiler keeps crushing and I am not sure if it's my connection, heavy code or just the compiler itself.

Any helps is appreciated.

Hello. To enable rtos just with mbed.h include my solution is open rtos blink example and then modify it.

posted by Kamil M 17 Nov 2018
Comment on this question

2 Answers

3 weeks, 5 days ago.

You not need import RTOS lib when you use MbedOS5 lib.

Your code

// missing #include "mbed.h"

/*Thread thread;*/ //probably correct place
AnalogIn ain(A1);

void myFunction(){
    printf("%in", ain); //probably you need to declare Serial and something more in parameters
}

int main{ // missing ()
    Thread thread; //probably wrong place
    thread.start(myFunction);
}

so...

Try this

#include "mbed.h"

DigitalOut led1(LED1);
AnalogIn ain(A1);
Serial pc(USBTX, USBRX);   
Thread thread;


void myFunction(){
    //while(1){
        pc.printf("Input: %f", ain.read());
        //wait(0.5);
    //}
}

int main(){
    pc.printf("Running…\n");
    thread.start(myFunction);
    while(true){
        led1 =! led1;
        wait(0.5);        
    }
    //while (osWaitForever);
} 

gl hf

3 weeks, 5 days ago.

sir please tell me the way so that i can download the video from youtube so that i can watch it offline. i have more question son please visit https://geeksquads.xyz/geek-squad-chat-support/


To post an answer, please log in.