Rafael Zingler Posted March 21, 2017 Report Share Posted March 21, 2017 (edited) Hi, I´ve doubts about the console widget with in a project that uses FreeRTOS. There are calls to the gwinPrintf() function in more than one thread. When this function is called from a timer callback function and simultaneously in other thread, the console´s content is jumbled. Sometimes, even the characters are not correctly redrawn in such case. Is this behavior expected? Thanks. Edited March 21, 2017 by Rafael Zingler Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted March 21, 2017 Report Share Posted March 21, 2017 Hello Rafael, The characters being drawn incorrectly in the screen indicates that you didn't set GDISP_NEED_MULTITHREAD to TRUE which will make the entire GDISP API become thread safe. The GWIN console widget itself is however not multi-thread safe so you have to protect access to it yourself. The solution depends on your application. You can either go with a classic producer/consumer where you have just one consumer (the sole thread that writes to the console) and multiple producers. Alternatively you can simply use the a mutex to protect access inside your application. Note that we strongly recommend using the µGFX high-level API such as gfxMutexCreate() and similar to keep your application portable. They are simple wrappers (often just macros so no overhead) towards the corresponding FreeRTOS mutex API. I hope that helps. Link to comment Share on other sites More sharing options...
Rafael Zingler Posted March 21, 2017 Author Report Share Posted March 21, 2017 (edited) Thanks, Joel. The GDISP_NEED_MULTITHREAD option is already configured as TRUE in the gfxconf.h file. For now, to solve the problem, I´ll implement the consumer/producer scheme to guarantee "serial" access to the console, with only the consumer accessing this widget. I´m going to replace, then, the gwinPrintf () calls with xQueueSend() calls, to send the desired messages to the console. Thanks. Edited March 21, 2017 by Rafael Zingler Link to comment Share on other sites More sharing options...
inmarket Posted March 21, 2017 Report Share Posted March 21, 2017 Jumbled text may be expected but characters not being drawn correctly is definitely not. Characters are drawn by the gdisp layer either one by one or as a string. If GDISP_NEED_MULTITHREAD is TRUE is should be impossible to get character corruption. Please check carefully exactly what is happenning. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted March 21, 2017 Report Share Posted March 21, 2017 Agreed. If the characters themselves are not being drawn then there's something very wrong. Don't forget to make a clean-build if you changed something in the configuration file. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now