You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add --no-color so I can redirect the output of uart0 but to a file. #555
Consider using enviromental variable NO_COLOR as well
#include<stdbool.h>#include<stdio.h>#include<stdlib.h>intmain(intargc, char*argv[])
{
char*no_color=getenv("NO_COLOR");
boolcolor= true;
if (no_color!=NULL&&no_color[0] !='\0')
color= false;
/* do getopt(3) and/or config-file parsing to possibly turn color back on */
...
}
For those trying to solve this issue, but don't want to wait on the devs.
You can use sed -r "s/\x1B\[[0-9;]*[mK]//g" to strip out terminal colors then sed -r "s/\.\.$//" (Note you need to escape $ in bash so hence $$) to strip out the trailing dots
simavr -m atmega328p -f 16000000 --no-color ./example-avr.elf 2>&1>/dev/null | sed -r "s/\x1B\[[0-9;]*[mK]//g"| sed -r "s/\.\.$$//"> testoutput.md
Hmmm... that sounds like a lot of work just to get an output for testing purpose.
I would at least hope to be able to direct uart0 to stdout and have a way to return an error code
Returning from main() will not end the simulation: the firmware will jump to exit(), which runs an infinite loop, and simavr will faithfully simulate the loop. This behavior can be changed by this pull request:
Note that it should be possible to grab the value returned by main() (and passed to exit()) from r25:r24, and have run_avr return that. The above-mentioned pull request does not do that.
Activity
mofosyne commentedon Sep 19, 2025
FYI, having difficulties in implementing unit tests using simavr. I would prefer if the documentation has a section specifically on this application.
mofosyne commentedon Sep 19, 2025
https://no-color.org/
Consider using enviromental variable
NO_COLORas wellmofosyne commentedon Sep 19, 2025
For those trying to solve this issue, but don't want to wait on the devs.
You can use
sed -r "s/\x1B\[[0-9;]*[mK]//g"to strip out terminal colors thensed -r "s/\.\.$//"(Note you need to escape$in bash so hence$$) to strip out the trailing dotsThis will then give you
edgar-bonet commentedon Sep 19, 2025
Indeed, and this has been asked before:
Another common request is to connect the UART to a pty (pseudo-terminal):
That would make it easy to redirect the output to a file:
stty -F /tmp/simavr-uart raw cat /tmp/simavr-uart > testoutput.txtbuserror commentedon Sep 19, 2025
Lets not saddle poor old run_avr with too many system stuff, the pty support is present in simduino, we can either use that, or make another harness
mofosyne commentedon Sep 19, 2025
Hmmm... that sounds like a lot of work just to get an output for testing purpose.
I would at least hope to be able to direct uart0 to stdout and have a way to return an error code
e.g.
Where
Would print 'hello world' to
testoutput.mdand return-1which would trip CI with an error codeedgar-bonet commentedon Sep 19, 2025
Returning from
main()will not end the simulation: the firmware will jump toexit(), which runs an infinite loop, and simavr will faithfully simulate the loop. This behavior can be changed by this pull request:Note that it should be possible to grab the value returned by
main()(and passed toexit()) fromr25:r24, and have run_avr return that. The above-mentioned pull request does not do that.gatk555 commentedon Sep 20, 2025
There is a compilation option, NO_COLOUR, to remove the coloured text. See Makefile.common.
edgar-bonet commentedon Oct 2, 2025
As of v1.7-192-g70e9bec, now you can also use the
NO_COLORenvironment variable:NO_COLOR=1 run_avr -m atmega328p -f 16000000 example-avr.elf >testoutput.txtYou may still want to sed out the trailing dots though.