This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Newlines in memory and nrfjprog --memrd

Hi. My application uses an in-RAM log which I then read back to a terminal on the host using nrfjprog like this:

$/Users/eliot/dev/nRF5x_tools/nrfjprog/nrfjprog -c 1000 --family NRF52 --memrd 0x20002284 --n 0x400
0x20002284: 2D2D2D0A 0A2D2D2D 74752044 52206C69   |.------.D util R|
0x20002294: 74657365 61657220 736E6F73 440A0D3A   |eset reasons:..D|
0x200022A4: 69747520 2020206C 20555043 6B636F6C   | util   CPU lock|
0x200022B4: 0A0D7075 74732049 20657461 45534552   |up..I state RESE|
0x200022C4: 490A0D54 72777020 6D676D5F 6E492074   |T..I pwr_mgmt In|
0x200022D4: 0A0D7469 6F702044 20726577 72616843   |it..D power Char|
0x200022E4: 73206567 65746174 4843203A 45475241   |ge state: CHARGE|
0x200022F4: 4154535F 4E5F4554 435F544F 47524148   |_STATE_NOT_CHARG|
0x20002304: 0D474E49 7020440A 7265776F 61745320   |ING..D power Sta|

I can then make this a bit more readable using:

/Users/eliot/dev/nRF5x_tools/nrfjprog/nrfjprog -c 1000 --family NRF52 --memrd 0x20002284 --n 0x9000 | grep -o \|.*\| | tr -d '|'
.------.D util R
eset reasons:..D
 util   CPU lock
up..I state RESE
T..I pwr_mgmt In
it..D power Char
ge state: CHARGE
_STATE_NOT_CHARG
ING..D power Sta

But what I'd really like is the newlines I know are in that memory at the end of each log line to be preserved on the output, plus to be able to remove the newlines that nrfjprog adds. How do I do that?

Related