π
<-

RS232 with Nspire IO

C, C++, ASM...

RS232 with Nspire IO

Message non lude 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: Tout sélectionner
#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.
Avatar de l’utilisateur
santacruz
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 56%
 
Messages: 6
Inscription: 21 Mar 2016, 21:17
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: RS232 with Nspire IO

Message non lude 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.
Avatar de l’utilisateur
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Prochain niv.: 1.6%
 
Messages: 217
Inscription: 29 Mar 2014, 15:55
Genre: Homme
Calculatrice(s):
MyCalcs profile

Re: RS232 with Nspire IO

Message non lude 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
Avatar de l’utilisateur
santacruz
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 56%
 
Messages: 6
Inscription: 21 Mar 2016, 21:17
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: RS232 with Nspire IO

Message non lude 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
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 82.2%
 
Messages: 14896
Images: 1211
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: RS232 with Nspire IO

Message non lude 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.
Avatar de l’utilisateur
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Prochain niv.: 1.6%
 
Messages: 217
Inscription: 29 Mar 2014, 15:55
Genre: Homme
Calculatrice(s):
MyCalcs profile

Re: RS232 with Nspire IO

Message non lude 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?
Avatar de l’utilisateur
santacruz
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 56%
 
Messages: 6
Inscription: 21 Mar 2016, 21:17
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile


Retourner vers Native: Ndless, Linux, ...

Qui est en ligne

Utilisateurs parcourant ce forum: ClaudeBot [spider] et 4 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
Ndless for CX 4.5.5 / CX II 6.2.0
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 !
12345
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
4383 utilisateurs:
>4339 invités
>36 membres
>8 robots
Record simultané (sur 6 mois):
43991 utilisateurs (le 10/09/2025)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)