Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Operating system
Development tools
Security and connectivity
Important update: Arm Announces End of Life Timeline for Mbed. This site will be archived in July 2026. Read the full announcement.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hello Angus,
I'm not sure, but I think the issue could result from the assumption that the size of a pointer is two bytes:
struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */ struct elem *next; char dummy[FREEMEM_CELL-2]; };
However, it is rather four bytes. So try:
struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */ struct elem *next; char dummy[FREEMEM_CELL-sizeof(struct elem*)]; };
or
struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */ struct elem *next; char dummy[FREEMEM_CELL-4]; };
and see how it works.
Hello Angus,
I'm not sure, but I think the issue could result from the assumption that the size of a pointer is two bytes:
struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */ struct elem *next; char dummy[FREEMEM_CELL-2]; };
However, it is rather four bytes. So try:
struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */ struct elem *next; char dummy[FREEMEM_CELL-sizeof(struct elem*)]; };
or
struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */ struct elem *next; char dummy[FREEMEM_CELL-4]; };
and see how it works.
Hi Zoltan,
Thanks for your reply. While it may have been outputting the wrong memory value, it seems that the thread hangs before it can output the next value. I can't therefore tell if memory is the issue or not, but thanks for pointing this out.
I'm sending {Command:{L1:3}}\n, and the *scanf* is waiting for the *\n* to complete a read of the buffer. The only other time I've seen this hang behaviour is when using *gets* and its waiting to fill the buffer before continuing. Anyone see any reason a *\n* might not be getting through?
Hello Angus,
Nice project! Try to avoid scanf
and make the ISR as short as possible by moving the logics from ISR to the main
function. For example:
//... RawSerial pc(USBTX, USBRX); //... void Rx_interrupt() { int i = 0; char c = 0; while pc.readable() { c = pc.getc(); Buffer[i++]= c; if ((i == 18) || (c == '\n')) break; } if (c == '\n') { Buffer[i - 1] = 0; // mark the end of a C-style string (replace '\n' with null char) status = 1; // flag that a complete command has been received } } int main() { //... while (true) { if (status == 1) { // new command received status = 0; // reset the flag for next use in ISR if (strcmp(Buffer, "{Command:{L1:3}}") == 0) { //... pc.printf("\r\n{Data:{Led1:%.3f,Led2:%.3f,Led3:%.3f,Led4:%.3f,Heater:%.3f,Temp:%.3f,Lux:%.1f,hPa:%04.2f,Hum:%2.2f}}",1-led1.read(), 1-led2.read(), 1-led3.read(), 1-led4.read(), 1-heater.read(), temp.read(), Lux.lux(), sensor.getPressure(), sensor.getHumidity()); pc.printf("\r\n{Free Memory:%d}", FreeMem()); } } }
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.
Hi All,
I'm working with OS2 and the Nucleo-F411RE. Seeing a strange thread hang on a Serial::RxIrq where the received event hangs the main thread and the LED being turned on/off in the method gets 'stuck' between states (flickering). I have buttons on InterruptIn which remain functional during the hang.
I'm not sure why, but the number of receives before a hang is random. At first I thought the number of 'strcmp' functions could be using up memory, so I output the 'free RAM' value to check that, and it appears unchanged at 109700 Bytes, so no runaway buffers. Anyone have any ideas? See below code and video of the problem.
main.cpp