Hi,
I have a project where I use and ethernet shield, and that requires multitasking through the use of FreeRTOS.
After encountering problems with the project at debug time, I ended with the conviction that it came from the fact that when two tasks access the shield, there must be a protection scheme around the read and write functions of the W5100.cpp module, to keep the SPI transactions atomic.
I started to implement the changes to the Ethernet library, but as far as I understand, each library is compiled separately before the sketch itself.
As a consequence, I cannot call from the Ethernet library functions that are defined in the FreeRTOS library. So far, the only obvious solution is to merge both libraries, which is a thing I do not want.
Is there a means to call from one library functions of another library, while keeping both libraries separate?
Mutual awareness of libraries
(4 posts) (2 voices)-
Posted 2 months ago #
-
How are you building and linking your program and the two libraries now? Are you using the Maple IDE?
The linker can link calls from one library to another.
To achieve that, either
a. the libraries can not be independent, one must depend on the other, or
b. all operations which need to be atomic must be 'wrap' with some code which protects them.Neither of these approaches prevent the libraries being compiled separately.
(Full disclosure: I am not a member of LeafLabs staff.)
Posted 2 months ago # -
Yes, I am using the (legacy) maple IDE 0.0.12.
So far, I have modified the Ethernet library with a few #ifdef around the changes, and added some #include that refer to the FreeRTOS library. What I miss, is being able to put a #define somewhere in the sketch to tell the Ethernet library whether it should use the original or the modified version.
A side question : I have duplicated the Ethernet subdirectory in the library directory, to keep the original one, that I have renamed EthernetOriginal. But when I put in my sketch the line
#include "Ethernet.h"
How can I tell the compiler which version to take, from the original or the modified directory?
I suspect that this is not possible. Does it mean that no two files in the library should have the same name even if they are in two different directories?Posted 2 months ago # -
@Phono - I think it's been a few years since anyone posted about injecting a new '#define symbol'. I've just done a quick search, and can't see anything, and I can't remember any of the details. Clearly, you could change one of the common include files to have an #define.
IIRC, without control of the build system, the only ways I can suggest to have two files with the same name, with the Maple IDE, are to
a. replicate up the directory tree until you get above the directory name it is using, or
b. put an 'Archive' directory into the directories effected, and write a little script to 'swizzle' the changed files between the real and archive directories, or
c. use a source code control system which is 'friendly' to your process, and keep them on separate branches. You could probably use git for this.You might consider looking at http://www.stm32duino.com/
They have added a LeafLabs Maple compatible build system to the Arduino IDE. They may have a more direct way to control builds.Posted 2 months ago #
Reply
You must log in to post.