Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: Mohammed Elborolossy on November 17, 2014, 02:47:47 pm

Title: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 17, 2014, 02:47:47 pm
Hi
I'm a new user and my calc is TI Nspire CX CAS
First: How can i write code in c++ not c ?
Second :I'm good in c++ but i can't make input from user how can i do this ?
Third : I write a code in c and I use "scanf()" to take input from user and when I test it on emulator , the emulator stuck what the problem ?
Forth : What is the important include that i should write before the program ? " the program contains input from user "
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 17, 2014, 03:19:29 pm
Quote
Hi
I'm a new user and my calc is TI Nspire CX CAS
First: How can i write code in c++ not c ?
Use .cpp as file extension, not .c.

Quote
Second :I'm good in c++ but i can't make input from user how can i do this ?
Use nspire-io, directly or indirectly. The new SDK at https://github.com/ndless-nspire/Ndless has nspire-io support built-in, just look at samples/newlib.
You can use scanf, std::cin, ifstream, whatever you like.

Quote
Third : I write a code in c and I use "scanf()" to take input from user and when I test it on emulator , the emulator stuck what the problem ?
It waits for serial input. By default std* are the first UART.

Quote
Forth : What is the important include that i should write before the program ? " the program contains input from user "
?

Quote
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?
There is only http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux. You can use some graphics libs like nSDL, n2dlib or nGL or rip an existing program apart and use its GUI stuff, like pyWrite.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 17, 2014, 03:57:31 pm
Thank you for reply

Quote
Use nspire-io, directly or indirectly. The new SDK at https://github.com/ndless-nspire/Ndless (https://github.com/ndless-nspire/Ndless) has nspire-io support built-in, just look at samples/newlib.
You can use scanf, std::cin, ifstream, whatever you like.
What is the header file that i will include it will be "#include <nspire-io> ?

Quote
It waits for serial input. By default std* are the first UART.
This is my code (I still learning and test small codes)

#include <os.h>
int main() {
   printf ("!!!Hello World!!!");
   int x ;
   scanf("%d" , &x);
   printf ("The  value is : %d" , x)
   return 0;
}
What is the problem for this code (The prog not start to write an input)

Quote
Forth : What is the important include that i should write before the program ? " the program contains input from user "
I mean what is the main (#include <>) that without it the app doesn't run ?

Quote
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?
There is only http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux (http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux). You can use some graphics libs like nSDL, n2dlib or nGL or rip an existing program apart and use its GUI stuff, like pyWrite.

can you give me link contains example for GUI code ?
Thanks in advance
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 17, 2014, 04:03:36 pm
Thank you for reply

Quote
Use nspire-io, directly or indirectly. The new SDK at https://github.com/ndless-nspire/Ndless (https://github.com/ndless-nspire/Ndless) has nspire-io support built-in, just look at samples/newlib.
You can use scanf, std::cin, ifstream, whatever you like.
What is the header file that i will include it will be "#include <nspire-io> ?
#include <nspireio/nspireio.h>

Quote
Quote
It waits for serial input. By default std* are the first UART.
This is my code (I still learning and test small codes)

#include <os.h>
int main() {
   printf ("!!!Hello World!!!");
   int x ;
   scanf("%d" , &x);
   printf ("The  value is : %d" , x)
   return 0;
}
What is the problem for this code (The prog not start to write an input)
Try a newline or puts instead of printf.
Quote
Quote
Forth : What is the important include that i should write before the program ? " the program contains input from user "

I mean what is the main (#include <>) that without it the app doesn't run ?
There is no such #include, although you need to #include <os.h> on the old sdk to do something useful.


Quote
Quote
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?

There is only http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux (http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux). You can use some graphics libs like nSDL, n2dlib or nGL or rip an existing program apart and use its GUI stuff, like pyWrite.

can you give me link contains example for GUI code ?
That depends on how you want to do GUI development, which library you use.



Quote

Thanks in advance
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 17, 2014, 04:20:49 pm
for the GUI
I still in the start and I don't know anything of them
So I wish you recommend me anyone of them to start learn it
I need a simple gui .
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 17, 2014, 04:35:53 pm
Quote
for the GUI
I still in the start and I don't know anything of them
So I wish you recommend me anyone of them to start learn it
I need a simple gui .
Well, if text is enough you can use nspire-io to display text at specified positions and move using the cursor keys. Or if you want 2d graphics, use nSDL, nGC, n2DLib or nGL.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 17, 2014, 04:42:51 pm
Edited (I make some edit in the code but still has a problem)
The code is :
#include <os.h>
#include <iostream>
#include <stdlib.h>
#include <libndls.h>
using namespace std;
int main() {
   cout<<"!!!Hello World!!!";
   int x ;
   cin>> x;
   cout<<"The  value is :" << x ;
   return 0;
}
The compile result :
>C:\ndless-sdk-v3.6-r53.464a532/mingw-get/msys/1.0/bin/sh -l -c 'PATH="$PATH":\'/C/ndless-sdk-v3.6-r53.464a532/ndless/bin:/C/ndless-sdk-v3.6-r53.464a532/yagarto/bin\' C_INCLUDE_PATH="$C_INCLUDE_PATH":\'/C/ndless-sdk-v3.6-r53.464a532/ndless_pc/include\' LIBRARY_PATH="$LIBRARY_PATH":\'/C/ndless-sdk-v3.6-r53.464a532/ndless_pc/lib\' \'/C/ndless-sdk-v3.6-r53.464a532/ndless/bin/nspire-gcc\' -Os -c hello.cpp'
>Exit code: 0

The Build result :
Please choose a name for the program below.
Makefile created. You can now build with the 'make' command or Ndless Editor's Tools>Build command.
mkdir -p .
nspire-ld-bflt hello.o -o ./First.tns  --cpp
c:/ndless-sdk-v3.6-r53.464a532/yagarto-20121222/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol lf2flt; defaulting to 00000000
Built.

When i test it on emu (I'm already install ndless on  emu and check before i run the prog.)
apper a message that prog. not supported
other thing the cpp file is 1 kB
The TNS file is 4.1 MB ? it seems large 
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 18, 2014, 04:02:04 am
That's expected, to use libstdc++ you have to use the new SDK.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 02:34:16 am
That's expected, to use libstdc++ you have to use the new SDK.
I still has the same problem
I tried the two version from  the official ndless site
If you Anyone has the (Ndless sdk) and work fine with c++ and emulator please upload the folder
Thanks in advance
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 05:41:34 am
Quote
I tried the two version from  the official ndless site
They're both the old sdk. The new SDK is on Github.

Quote
If you Anyone has the (Ndless sdk) and work fine with c++ and emulator please upload the folder
Windows? Cygwin?
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 01:33:23 pm

Windows? Cygwin?

I'm using windows 8.1
What do you mean about Cygwin ?
Title: Re: How to get input from user in ndless sdk ?
Post by: Eiyeron on November 19, 2014, 01:34:52 pm
Cygwin is a program which gives a unix-like mini environment to a Windows user. It installs some binaries, a folder with the structure of a Linux distribution, a shell ( a command line program, like command invite) and you have a similar environement as a Linux should be.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 01:46:21 pm
Cygwin is a program which gives a unix-like mini environment to a Windows user. It installs some binaries, a folder with the structure of a Linux distribution, a shell ( a command line program, like command invite) and you have a similar environement as a Linux should be.
I have Ubuntu and windows 8.1 and I try the booth
In Ubuntu : I follow this tutorial : http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux
After this code "./build_toolchain.sh" and after download i get two errors and try to solve them but not success
In windows 8.1 : I download the sdk and a download yagarto additional files and write a c++ program the compile complete but in build there is an error : cannot find entry symbol lf2flt; defaulting to 00000000


[/size]
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 02:00:29 pm
It's better if you use Linux.
Quote
After this code "./build_toolchain.sh"  and after download i get two errors and try to solve them but not success
Which two errors?
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 02:08:36 pm
I think that this is one :

configure: error: no termcap library found
I search for "termcap" in synaptic but not found it
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 02:10:48 pm
this is the last lines in the Terminal :
checking for library containing waddstr... no
configure: WARNING: no enhanced curses library found; disabling TUI
checking for library containing tgetent... no
configure: error: no termcap library found
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `/home/mohammed/Ndless/ndless-sdk/toolchain/build'
make: *** [all] Error 2
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 02:14:12 pm
It's called "libtinfo-dev" in Ubuntu.


PS: Please don't double-port, the Modify button is there for a reason.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 02:31:55 pm
It's called "libtinfo-dev" in Ubuntu.


PS: Please don't double-port, the Modify button is there for a reason.

I'm sorry for that.

The download complete and Done
What is the next?
I can't understand this code
when i write it in the terminal and change the path there no thing done
i skip to the next code "make"
the result is : "make: *** No targets specified and no makefile found.  Stop."
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 02:38:53 pm
If you ran build_toolchain.sh successfully and set PATH, execute "make" in the ndless-sdk directory.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 02:52:22 pm
I'm sorry for disturbance
but with each step there a lot of errors
There is an Error with luna.o


the result after write "make" :

make all in ndless-sdk...
make[1]: Entering directory `/home/mohammed/Ndless/ndless-sdk'
make all in tools...
make[2]: Entering directory `/home/mohammed/Ndless/ndless-sdk/tools'
make all in luna...
make[3]: Entering directory `/home/mohammed/Ndless/ndless-sdk/tools/luna'
gcc -W -Wall -DUSE_FILE32API   -c -o luna.o luna.c
luna.c:1:33: fatal error: openssl/opensslconf.h: No such file or directory
 #include <openssl/opensslconf.h>
                                 ^
compilation terminated.
make[3]: *** [luna.o] Error 1
make[3]: Leaving directory `/home/mohammed/Ndless/ndless-sdk/tools/luna'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/mohammed/Ndless/ndless-sdk/tools'
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/mohammed/Ndless/ndless-sdk'
make: *** [all] Error 1
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 02:54:11 pm
If openssl is missing, install openssl. It's likely libssl-dev.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 04:16:16 pm
Another Error  :/

make[1]: Leaving directory `/home/mohammed/Ndless/ndless-sdk/libsyscalls'
make all in libndls...
make[1]: Entering directory `/home/mohammed/Ndless/ndless-sdk/libndls'
nspire-gcc -Os -nostdlib -Wall -Werror -Wextra -c any_key_pressed.c
make[1]: nspire-gcc: Command not found
make[1]: *** [any_key_pressed.o] Error 127
make[1]: Leaving directory `/home/mohammed/Ndless/ndless-sdk/libndls'
make: *** [all] Error 1
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 04:52:42 pm
You didn't set PATH correctly. It has to include ndless-sdk/bin.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 04:57:10 pm
You didn't set PATH correctly. It has to include ndless-sdk/bin.
How to include the path?
I write it like this :
mohammed@mohammed-HP:~$ export PATH="/home/mohammed/Ndless/ndless-sdk/toolchain/install/bin:/home/mohammed/Ndless/ndless-sdk/toolchain/bin:${PATH}"
I put the Ndless in Home file
/home/mohammed/Ndless/ndless-sdk
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 04:58:29 pm
Yeah, like that. The second path doesn't exist, though.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 05:03:53 pm
Yeah, like that. The second path doesn't exist, though.
I think it's solved now
I'm very thankful for your effort with me
The last question where I will write my code ( will I write a c++ on any ide or Terminal?)
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 19, 2014, 05:25:21 pm
That's your decision.
Most IDEs support plain Makefile projects. You only need to execute "nspire-tools new <program name>" and you can start coding in that directory.
Your IDE just has to run "make" to build the program. I know that the following IDEs definitely work:
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 19, 2014, 06:59:32 pm
I'm sorry to say that i can't run any program till now
i follow the tutorial as i said before
in the sample example the tns file obtained but not working on the emulator
When I try to make a prog. and write : nspire-tools new <main> "main is my program name that error appear

bash: syntax error near unexpected token `newline'
What is the problem ??
I write a code on codeblocks and eclipse but how to complete after that ?



Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 20, 2014, 05:04:12 am
Quote
in the sample example the tns file obtained but not working on the emulator
Try the .prg.tns file.

Quote
When I try to make a prog. and write : nspire-tools new <main> "main is my program name that error appear
Leave the "<>" out.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 20, 2014, 06:11:37 am
Quote
Try the .prg.tns file.
Already try and it didn't open any thing.

Quote
Leave the "<>" out.
Can you write a helloworld prog in c++ and mention the steps from terminal or using an exist CPP file
I am very sorry about asking alot
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 20, 2014, 06:16:30 am
Quote
Already try and it didn't open any thing.
Then please upload the generated file.

Quote
Can you write a helloworld prog in c++ and mention the steps from terminal or using an exist CPP file
I am very sorry about asking alot

Code: [Select]
echo "int main() { return 0; }" > main.cpp
nspire-tools new test
make
Done. The program does nothing, though.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 20, 2014, 06:33:35 am
There is an error that nspire-tools command not found ?
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 20, 2014, 06:34:38 am
Then your PATH isn't set up correctly.
Title: Re: How to get input from user in ndless sdk ?
Post by: Mohammed Elborolossy on November 20, 2014, 05:11:00 pm
Then your PATH isn't set up correctly.
I'm sorry for late
Is there a specific path ?
Title: Re: How to get input from user in ndless sdk ?
Post by: Vogtinator on November 20, 2014, 05:12:53 pm
nspire-tools in in ndless-sdk/bin