π
<-

RS232 with Nspire IO

C, C++, ASM...

RS232 with Nspire IO

Unread postby santacruz » 21 Mar 2016, 21:40

Hello,
I'm trying to communicate with my device via RS232. I'm running OS version: 4.2.0.532 and Ndless 4.2.0 cas cx

Initially I tried to communicate with LUA and the Asynchronous Serial Interface library with no prevail.

Next I installed ndless and downloaded the nspire io library.

I was having issues with the provided tests demo. When the code tried to write and save the file, I would get an ownership error. I removed this and now I have the following code.

Code: Select all
#include <os.h>
#include <nspireio/nspireio.h>


int main(void)
{
   assert_ndless_rev(874);
   clrscr();
   
   nio_console csl;
   nio_init(&csl,NIO_MAX_COLS,NIO_MAX_ROWS,0,0,NIO_COLOR_WHITE,NIO_COLOR_BLACK,TRUE);
   nio_set_default(&csl);
   nio_color(&csl,NIO_COLOR_BLACK,NIO_COLOR_WHITE);
   nio_puts("Nspire I/O testing tool\n");
   nio_color(&csl,NIO_COLOR_WHITE,NIO_COLOR_BLACK);
   nio_printf("Compiled %s %s\n",__DATE__,__TIME__);
   nio_puts("Press any key to flush console...\n");
   nio_drawing_enabled(&csl,FALSE);
   nio_putchar('A');
   nio_fputc('a',&csl);
   nio_putchar('\n');
   nio_puts("Color palette test:\n");
   int i, j;
   for(i = 0; i < 16; i++)
   {
      for(j = 0; j < 16; j++)
      {
         nio_color(&csl,i,j);
         nio_putchar('X');
      }
      nio_putchar('\n');
   }
   nio_color(&csl,NIO_COLOR_WHITE,NIO_COLOR_BLACK);
   nio_puts("This line is too long for the Nspire's screen so we have to continue it on the next line...\n");
   wait_key_pressed();
   nio_fflush(&csl);
   nio_drawing_enabled(&csl,TRUE);
   nio_puts("Enter text:\n");
   char input[100] = {0};
   nio_getsn(input,100);
   nio_printf("Your text was:\n%s\n",input);
   nio_puts("Enter a number: ");
   int num;

   nio_puts("Testing UART...\n");
   uart_puts("Nspire I/O testing tool\n");
   uart_printf("Compiled %s %s\n",__DATE__,__TIME__);
   
   uart_puts("Enter text: ");
   uart_getsn(input,100);
   uart_printf("Your text was: %s\n",input);
   
   
   nio_puts("Tests finished.");
   nio_free(&csl);
   wait_key_pressed();
   
   return 0;
}


I have my Nspire connected directly to my COM1 port via a 9 pin connector.

I start Putty listening to COM1 @ 115200 baud.
Data bits: 8
Parity: Even
Stop bits: 1
Flow control: None

When I run the test I get a string of nonsense, so this leads me to believe I have the wrong port settings. Does anyone know the correct settings?

Also when I look at the code I see uart_getsn(input,100);
Is this the serial port listening for input from the computer? When I execute the code it says "Testing Uart..." then straight to tests finished, shouldn't there be some type of pause there?


And on an unrelated note, how do I get the website to stay in English? It wants to change every time I reload a new page. I've tried the English flag in the upper right hand corner.
User avatar
santacruz
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 56%
 
Posts: 6
Joined: 21 Mar 2016, 21:17
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: RS232 with Nspire IO

Unread postby Vogtinator » 21 Mar 2016, 22:05

I have my Nspire connected directly to my COM1 port via a 9 pin connector

You're lucky that it still works! 12V from the D-Sub-9 connector is four times the voltage the calc accepts!
You need a level shifter to 3.3V.

And on an unrelated note, how do I get the website to stay in English? It wants to change every time I reload a new page. I've tried the English flag in the upper right hand corner.

Works for me here, I'm using Opera/Chromium/Blink/WebKit/KHTML.
User avatar
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Level up: 1.6%
 
Posts: 217
Joined: 29 Mar 2014, 15:55
Gender: Male
Calculator(s):
MyCalcs profile

Re: RS232 with Nspire IO

Unread postby santacruz » 21 Mar 2016, 23:29

I was only using pins 3,4, and 5. I measured and I was getting ~4V to ground.

I've moved everything to my Arduino and success!


Image
User avatar
santacruz
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 56%
 
Posts: 6
Joined: 21 Mar 2016, 21:17
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: RS232 with Nspire IO

Unread postby Adriweb » 21 Mar 2016, 23:31

Nice :D

FTR, Lua ASI is already working a little bit with some predefined boards, but will gain larger compatibility in the next update, as TI said :)

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.7%
 
Posts: 14820
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: RS232 with Nspire IO

Unread postby Vogtinator » 21 Mar 2016, 23:40

BTW: You should be able to do the same with stdout and stdin, either by "printf", "fwrite" or even c++ iostreams.
User avatar
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Level up: 1.6%
 
Posts: 217
Joined: 29 Mar 2014, 15:55
Gender: Male
Calculator(s):
MyCalcs profile

Re: RS232 with Nspire IO

Unread postby santacruz » 22 Mar 2016, 01:45

I'm trying to use uart_getsn to read data send from my computer and its not working too well.

If you look at the image above, I call uart_getsn after it prompts for "Enter text" and it won't take any user input. It will only print a previous string.

Is there a better method?
User avatar
santacruz
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 56%
 
Posts: 6
Joined: 21 Mar 2016, 21:17
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: ClaudeBot [spider] and 5 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1512 utilisateurs:
>1500 invités
>6 membres
>6 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)