Retrieve const strings from AVR program memory correctly#482
Retrieve const strings from AVR program memory correctly#482antonrotar wants to merge 1 commit intoThrowTheSwitch:masterfrom
Conversation
|
Does |
|
I fear no: https://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html#ga5749897c91c479d02054fc02128de482 |
dc62ddb to
aa94013
Compare
|
We got bitten by this yesterday, trying to run unit-tests on a physical AVR. As it stands, #431 broke this completely, as has been noted by this pull request, but this does not solve the problem either, since it assumes then that all strings are PROGMEM. Arduino solves this issue by using class typing and function overloading (explanation here) but that is obviously a C++ solution that is not available in C. @mvandervoord, I have a proposed solution, but it requires some significant changes, so I wanted to run them past you before doing the work. These would be:
So there would be no change to a typical users use of Unity, only the slight chance of confusion around the new function dedicated to constant strings from it's usage in If this is too substantial a change and muddies the clarity of the library too much just for this niche use case, then I suggest instead:
I'll note that we've worked around the issue by just commenting out the Thanks. |
|
Hi @neomanic, thanks for picking this up. Your suggestion with the @mvandervoord please consider that in the current state it is not possible to run tests on physical targets. |
The constant strings in Unity are stored in AVR program memory, which is a great way to reduce RAM consumption.
However retrieving them back to RAM for usage requires special operations, as described here:
https://www.nongnu.org/avr-libc/user-manual/pgmspace.html
This commit fixes that.
Tested on a atmega328p.