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?

Parents Reply
  • No IDE, just gcc and a Makefile.

    im not sure I made the issue clear. getchar() is present in the binary. Something has implemented it, and it’s not calling any of the normal retargeted functions (__getchar, _read, _fgetc, etc.). The getchar implementation appears to be in one of the binary-only libraries in SDK15.0, as grepping the entire source tree reveals nothing useful. 

    Because of this, I can’t call getchar() I my high level code and have it actually pull data from my data source. stdio works (fgetc, etc) but I’m trying to understand the getchar issue. 

Children
Related