Greetings,
I’m trying to port a library to mbed os6, but I can’t find what is the equivalent of “FunctionPointer”
Do you have any idea ?
Many thanks
Greetings,
I’m trying to port a library to mbed os6, but I can’t find what is the equivalent of “FunctionPointer”
Do you have any idea ?
Many thanks
Hello,
that is very old but probably the Callback API.
FunctionPointer has been replaced by Callback<void()> [since mbed-os-5.1]
BR, Jan
Many thanks,
do you also know how to replace the serial ?
(here is the lib i’m trying to adapt MTK3339 | Mbed)
BufferedSerial or UnbufferedSerial, but because the implementation inside the library use interrupts then you need the UnbufferedSerial.
These new APIs not use standart methods - getc, putc, printf
and so on. So take care about void MTK3339::uartIrq()
This maybe help
https://forums.mbed.com/t/mbed-os-6-5-serial/11166/2?u=johnnyk
BR, Jan
I see,
Yes It was my problem, I tried with unbufferd serial but got a problem with putc. I will look at it and tell you if I got something.
Well now I can compile it without any error,
I still have an other problem. When I compile my code, the nucleo send me the following message :
“Mutex, Not allowed in ISR context”.
I’ve seen that this might be caused by a printf in ISR but I don’t think it’s my case
#include "mbed.h"
#include "MTK3339.h"
static int waitData = 0;
static MTK3339 gps(D8,D2);
static void dataAvailable() {
waitData |= gps.getAvailableDataType();
}
int main(void) {
gps.start(&dataAvailable, (MTK3339::NmeaGga|MTK3339::NmeaVtg));
while(1) {
while(waitData == 0);
if ((waitData & MTK3339::NmeaGga) != 0) {
waitData &= ~(MTK3339::NmeaGga);
printf("gpa: fix=%d, sats=%d, alt=%f, lat=%f, lon=%f\n",
gps.gga.fix, gps.gga.satellites, gps.gga.altitude,
gps.getLatitudeAsDegrees(), gps.getLongitudeAsDegrees());
}
if ((waitData & MTK3339::NmeaVtg) != 0) {
waitData &= ~(MTK3339::NmeaVtg);
printf("vtg: course=%f, speed=%f km/h, mode=%c\n",
gps.vtg.course, gps.vtg.speedKmHour, gps.vtg.mode);
}
waitData &= (MTK3339::NmeaGga|MTK3339::NmeaVtg);
}
}
Not only by the printf
, but all methods what manipulate with input/output. So also putc, getc
and so on.
That is why you need UnbufferedSerial instead of BufferedSerial.
BR, Jan
Alternatively if you not need an RTOS functionality, you can try to use Mbed OS bare metal profile.
No RTOS = No Mutexes
BR, Jan
I’m not sure I have understood how to add No RTOS = No mutexes for the bare metal profile.
And do I just have to create a mbed_app.json and compile the projet to have a bare metal profile ?
Well, even with UnbufferedSerial, I still have the problem. Do I have to implement an EventQueue ? I’m not sure how to do that