Omnimaga

Omnimaga => Completed => Our Projects => Nspire I/O => Topic started by: compu on November 19, 2013, 03:30:07 pm

Title: Nspire I/O - Now with C++ support
Post by: compu on November 19, 2013, 03:30:07 pm
After ExtendeD added support for C++ to Ndless (http://ndlessly.wordpress.com/2013/06/15/cpp-for-the-ti-nspire/) some months ago, I have added experimental C++ support to Nspire I/O now.
It has an iostream-like interface, so it should be easy to use (at least I hope it is :P )

The obligatory "Hello World":
Code: [Select]
#include <nspireio/console.hpp>

int main(void)
{
  nio::console c;
  c << "Hello World!" << nio::endl;

  return 0;
}

A more complete demo can be found here (https://github.com/compujuckel/nspire-io/blob/master/demo/cplusplus/cplusplus.cpp).
The output of that demo is attached below.

The source code can be found on Github (https://github.com/compujuckel/nspire-io) and in the attached zip file (that contains the compiled library file and demos as well).
Title: Re: Nspire I/O - Now with C++ support
Post by: DJ Omnimaga on November 19, 2013, 04:19:02 pm
Good to hear. :) I wonder if the PRIZM version has been cancelled or if it's still in development btw?
Title: Re: Nspire I/O - Now with C++ support
Post by: ajorians on November 19, 2013, 08:11:10 pm
That is awesome!  I like Nspire I/O.  Thanks! :)
Title: Re: Nspire I/O - Now with C++ support
Post by: Juju on November 20, 2013, 12:12:21 am
Good to hear. :) I wonder if the PRIZM version has been cancelled or if it's still in development btw?
I think I can call it an indefinite hiatus. I might pick it back up someday, but last time I tried, everything I compiled (NspireIO or not) crashed. Probably my installation of PrizmSDK. Anyway, I wonder if C++ support won't mess that up, since the Prizm have none of it...
Title: Re: Nspire I/O - Now with C++ support
Post by: Legimet on November 20, 2013, 08:42:24 am
That's great to hear. Did you solve the inheritance issues that you posted about in another thread?
Title: Re: Nspire I/O - Now with C++ support
Post by: compu on November 20, 2013, 10:45:36 am
Yup. I tried it with another approach without multiple inheritance and for now, everything seems to work more or less :P
Title: Re: Nspire I/O - Now with C++ support
Post by: Eiyeron on December 10, 2013, 05:11:48 am
Nice Juju, that can make me go back to nSpire! :p
Title: Re: Nspire I/O - Now with C++ support
Post by: Silversircel on December 16, 2013, 05:09:18 pm
Hi ,
every time i pass some variables to nspireio the programm crahes if i try to execute it.
I've no idea whats wrong.
I basicely only modified the exampel to display a cstring and a string. but it doesn't
work...
The programm crahes if i pass the variables with << operator.
Code: [Select]
#include <nspireio/console.hpp>
#include <nspireio/uart.hpp>
#include <string.h>
#include <string>
#include <iostream>

#ifndef NIO_TEST_UART
#define NIO_TEST_UART 0
#endif

using namespace std;
using namespace nio;

int main(void)
{
clrscr();
#if NIO_TEST_UART == 1
nio::uart u;
#endif
nio::console c;

int num = 123;
char cString[] = "Test";
string cppString = "Text";

c.foreground_color(COLOR_BLACK);
c << cString << endl;
c << cppString.c_str() << endl;

wait_key_pressed();
return 0;
}

Does anyone have a clue?
Thanks
Title: Re: Nspire I/O - Now with C++ support
Post by: ajorians on December 16, 2013, 07:23:05 pm
Hi Silversircel,

There isn't a port of the Standard library for the calculator.  Here is a link to the syscalls: http://hackspire.unsads.com/wiki/index.php/Syscalls

I tend to use the char pointer (char*) and strcpy, strcat, etc.  Hope that helps!
Title: Re: Nspire I/O - Now with C++ support
Post by: Legimet on December 16, 2013, 08:10:36 pm
Silversircel doesn't use the C standard library in his/her program.

Also, there's newlib, and many of the functions in it work.
Title: Re: Nspire I/O - Now with C++ support
Post by: ajorians on December 17, 2013, 09:05:55 am
Hey Legimet,

Oh?  I see the user does all of these:
#include <string>
using namespace std;
string cppString = "Text";

As I understand newlib (https://sourceware.org/newlib/libc.html#Strings) it gives you a lot but this user is using the C++ string header file; and I think the C++ string class can throw exceptions and other things.  I didn't think the C++ std::string class would work at all.  But I'll give it a try when I get the chance! :)

Sorry if I wasn't accurate!  Have a great day!