Author Topic: NspireIO - undefined reference problem- ndless-sdk  (Read 3511 times)

0 Members and 1 Guest are viewing this topic.

Offline Silversircel

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +0/-0
    • View Profile
NspireIO - undefined reference problem- ndless-sdk
« on: March 11, 2014, 06:30:58 pm »
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: [Select]
console c;

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

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: [Select]

#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);
        //...

part of cpp:
Code: [Select]

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

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

Offline Silversircel

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +0/-0
    • View Profile
Re: NspireIO - undefined reference problem- ndless-sdk
« Reply #1 on: March 13, 2014, 08:59:44 am »

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: [Select]

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


How do i capture which key was pressed?


Thanks

Offline CiriousJoker

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +1/-0
    • View Profile
Re: NspireIO - undefined reference problem- ndless-sdk
« Reply #2 on: July 24, 2014, 06:01:14 pm »
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
« Last Edit: July 24, 2014, 06:03:40 pm by Virusscript24 »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: NspireIO - undefined reference problem- ndless-sdk
« Reply #3 on: July 25, 2014, 01:13:08 pm »
Quote
I'm using "ndless-v3.1-beta-r914-sdk" to build the code.
The latest is ndless-sdk v3.6 r990 or rather https://github.com/OlivierA/Ndless

Quote
Problem solved^^
cant use c routine in c++
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
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
Are there any usable keys which are >= 0x80? Also "char" is unsigned by default (on arm-none-eabi-gcc)