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

cannot retarget getchar/read/getch

I'm using SDK 15.0 on an nRF52840 dongle. I've been able to retarget the output functions (outputting through the CDC UART) but so far I can't seem to use getchar() in my higher level code and have it correctly hook into the received data stream from the PC.

I've tried retargeting fgetc, _read and __getchar() -- my code builds and there are no linker errors, but when my higher level code calls getchar() it looks like it's getting lost in some binary library -- there is no reference to getchar() in the SDK 15 source code, yet the function that is being executed is not my getchar() code.


I understand that I do not need to retarget and can simply call the usb_read() function, but the entire point of retargeting is to avoid having to change the higher level code. I have successfully retargeted for output to UART, USB and even CAN on other architectures, but it seems there is a specific bug in the Nordic SDK when it comes to being able to retarget the input functions.

Is there a working example of getch/getchar/fgetc/read retargeting with SDK15?

Related