Calculator Community > Calculator C

NspireIO - undefined reference problem- ndless-sdk

(1/1)

Silversircel:
Hi everyone,


i'm working on a project that organize my mathematical formula.[/size]Therfor i have to print text on screen.
[/size]If i use nspireIO like the example shows everything works
[/size]
--- Code: ---console c;

c << "Print Text" << endl;
return 0;

--- End code ---

But if i try to use the functions in "nspireio.h", i get the message:
Screen.cpp:(.text+0x64): undefined reference to `nio_fprintf(...)
I'm using "ndless-v3.1-beta-r914-sdk" to build the code. The "libnspireio.a" is located in the .../ndless/lib folder
My code: part of header-file

--- Code: ---
#include <os.h>
#include <nspireio/console.hpp>
#include <nspireio/uart.hpp>
#include <nspireio/nspireio.h>
#include <string.h>



class Screen
{
private:
    static bool instanceFlag;
    static Screen *screen;


    Screen() { //private constructor
}


//Member Var
nio_console c;


public:
    static Screen* getInstance();


    ~Screen()
    {
        instanceFlag = false;
    }


//Member Func
void print(char *cString);
        //...

--- End code ---

part of cpp:

--- Code: ---
void Screen::print(char *cString)
{
nio_fprintf(&c, cString);
}

--- End code ---

I would like to read single chars from keyboard. After one char has been tipped a searchList() function will search for matches and display them. Next received char will be added to the first one and search,display repeat...
Does anyone knows how to solve the undefined reference problem?
Thanks

Silversircel:

Problem solved^^
cant use c routine in c++


But I have another question
Is it possible to read single chars from console without tip enter each time? (unbuffered read)


nio examples show:

--- Code: ---
c << "unitbuf test. Press any key" << nio::endl;
c.unsetf(console::unitbuf);
c << "Key pressed!" << nio::endl;
wait_key_pressed();

--- End code ---


How do i capture which key was pressed?


Thanks

CiriousJoker:
I don't know if you still need this, but can't you use something like this?



char choice[1];
nio_printf(csl, "> ");         // wait for input
nio_fgets(choice,3,csl);      // store input in choice[]
return (int)choice[0];      // return choice


If it doesn't help you, maybe it helps others  ;)

 
However it doesn't accept buttons like the keypad, etc. only printable chars
If you set it to unsigned char, you may be able to use the second part of the ascii table, but i haven't tested it


~virus

Vogtinator:

--- Quote ---I'm using "ndless-v3.1-beta-r914-sdk" to build the code.
--- End quote ---
The latest is ndless-sdk v3.6 r990 or rather https://github.com/OlivierA/Ndless


--- Quote ---Problem solved^^
cant use c routine in c++
--- End quote ---
You can. You just have to surround the declaration with extern "C" {}


--- Quote ---char choice[1];
nio_printf(csl, "> ");         // wait for input
nio_fgets(choice,3,csl);      // store input in choice[]
return (int)choice[0];      // return choice
--- End quote ---
Buffer overflow? BTW: nio_getch()


--- Quote ---If you set it to unsigned char, you may be able to use the second part of the ascii table, but i haven't tested it
--- End quote ---
Are there any usable keys which are >= 0x80? Also "char" is unsigned by default (on arm-none-eabi-gcc)

Navigation

[0] Message Index

Go to full version