This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Technology & Calculator Open Topic subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Community News & Discuss Nspire => Technology & Calculator Open Topic
Author Message
bwang


Member


Joined: 15 Mar 2009
Posts: 128

Posted: 14 May 2010 02:11:29 pm    Post subject:

Are there any libraries to output text on the Nspire (in C)? The sprintf() function in the Ndless package doesn't do anything.
I think I saw a post on TI-Bank talking about such a library. Where did it go?
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 14 May 2010 11:21:30 pm    Post subject:

sprintf() is supposed to be used to output characters to a string (thus the s before the printf). I don't know how to use the Nspire OS to output text to the screen, though.
Back to top
Lionel Debroux


Member


Joined: 01 Aug 2009
Posts: 170

Posted: 15 May 2010 11:37:34 am    Post subject:

No recent news on the library that was showcased in http://tibank.forumactif.com/programmation-f21/programmation-c-division-modulo-et-lib-d-affichage-t5143.htm .
Back to top
Armael


Newbie


Joined: 08 Jan 2010
Posts: 3

Posted: 18 May 2010 03:29:16 pm    Post subject:

Hi,
I'm the author of the library to output strings on the screen.
In fact, I have problems with static variables : I use them to stock X,Y coordonates, the color... but it seems that it is the fact that binaries are not properly loaded which cause the problem.
For example, when i run successively the program, it seems that some static variables are not cleary initialised : they got the value they had during the precedent run.

So i conclue the solution would be to wrote an ELF (or other binary format) loader...

But I saw yesterday that you use too static variables in your code Neutral .... Maybe we could work together on my code to debug it (or wrote a loader Very Happy ) ? , and I will open it to community after Smile ...

P.S : Sorry for my language mistakes (yet another ?), but I'm french...


Last edited by Guest on 20 May 2010 04:20:09 am; edited 1 time in total
Back to top
bwang


Member


Joined: 15 Mar 2009
Posts: 128

Posted: 22 May 2010 06:54:44 pm    Post subject:

Can you post or e-mail me the code (via the Forum e-mail system)?

Last edited by Guest on 22 May 2010 06:55:23 pm; edited 1 time in total
Back to top
bsl


Advanced Newbie


Joined: 09 Jan 2010
Posts: 94

Posted: 31 May 2010 05:24:44 pm    Post subject:

bwang wrote:

Are there any libraries to output text on the Nspire (in C)? The sprintf() function in the Ndless package doesn't do anything.
I think I saw a post on TI-Bank talking about such a library. Where did it go?


Try this:
Add to the ndless header files these lines:

Code:

add to os.h:
#define printf           (_oscall(int, printf_, const char *restrict format, ...))

add to os_1.1.9253.h:
#define printf_                       0x10182c60

add to os_cas_1.1.9170.h:
#define printf_                       0x10182968


Create a file called hello.c with the following line: [s]printf("Hello World\n");[/s]printf("%s\n","Hello World");
Compile and run it on the emulator that has ndless (easier than pulling batteries after a hang)
I have not tested this myself , but the entry points are unique on the flashes between OS1.1 and OS1.7 and
almost certainly correct.
If this does not print on the screen as expected - try starting the notepad application, then switch to the folders to click
on hello.tns, then see if it printed on the notepad. The notepad is more appropriate for printf() since it has cursor interaction like a console.
EDIT: Check the emulator console window too. If it prints there it could be a good development tool for the emulator.


Last edited by Guest on 01 Jun 2010 07:27:16 pm; edited 1 time in total
Back to top
ExtendeD


Advanced Newbie


Joined: 30 Aug 2009
Posts: 91

Posted: 01 Jun 2010 03:05:24 pm    Post subject:

I haven't checked recently but the text functions of the standard library will probably write to the RS232 (serial) output.

Last edited by Guest on 01 Jun 2010 03:05:33 pm; edited 1 time in total
Back to top
bwang


Member


Joined: 15 Mar 2009
Posts: 128

Posted: 01 Jun 2010 08:15:18 pm    Post subject:

Now if there were only a way to redirect the serial output to the screen...
Back to top
bsl


Advanced Newbie


Joined: 09 Jan 2010
Posts: 94

Posted: 03 Jun 2010 12:27:38 am    Post subject:

I will give you one more piece of code to try out before I try it myself later.
You may have to open a handle to the screen. If you look at nspire memory, you might guess the early OS
started out as a small UNIX kernel. There is a distinguishing string "/dev/console".
So here is some starting pseudo code:

Code:

/* hello.c */
#include <os.h>
main(){
FILE *SCREEN;

SCREEN = fopen("/dev/console", "w");
fprintf(SCREEN,"%s\n","Hello World");
/* put a statement here that pauses the program: like keyboard input to inspect output if any */
fclose(SCREEN);
}

You will notice fprintf() is not in the ndless headers.
so here it is:

Code:

add to os.h:
define fprintf           (_oscall(int, fprintf_, FILE*  stream,const char *restrict format, ...))

add to os_1.1.9253.h:
/* #define fprintf_                      EDIT: 0x???????? undetermined */

add to os_cas_1.1.9170.h:
#define fprintf_                       0x10430fd0

[s]
The entry points here were a little tricky to get, you had to look at the disassembly.
Notice the difference between OS1.7 CAS and OS1.1 CAS , but similarites between OS1.1 CAS and OS1.1 NONCAS:
[/s]
EDIT : Note exact instruction match, only transfer instruction addresses should look different.

Code:

fprintf() disassembled entry points:

os1.7cas  0x102a46d0

debug> u 102a46d0
102a46d0: e1a0c00d      mov     r12,sp
102a46d4: e92d000e      stmdb   sp!,{r1-r3}
102a46d8: e92dd830      stmdb   sp!,{r4-r5,r11-r12,lr-pc}
102a46dc: e24cb010      sub     r11,r12,00000010
102a46e0: e24ddf43      sub     sp,sp,0000010c
102a46e4: e24b4e12      sub     r4,r11,00000120
102a46e8: e1a05000      mov     r5,r0
102a46ec: e59b1004      ldr     r1,[r11 + 004]
102a46f0: e28b2008      add     r2,r11,00000008
102a46f4: e3a03000      mov     r3,00000000
102a46f8: e1a00004      mov     r0,r4
102a46fc: eb0002a7      bl      102a51a0
102a4700: e250c000      subs    r12,r0,00000000
102a4704: e1a0000c      mov     r0,r12
102a4708: 0a00000c      beq     102a4740
102a470c: e37c0c01      cmn     r12,00000100

OS1.1 cas 0x10430fd0

debug> u 0x10430fd0
10430fd0: e1a0c00d      mov     r12,sp
10430fd4: e92d000e      stmdb   sp!,{r1-r3}
10430fd8: e92dd830      stmdb   sp!,{r4-r5,r11-r12,lr-pc}
10430fdc: e24cb010      sub     r11,r12,00000010
10430fe0: e24ddf43      sub     sp,sp,0000010c
10430fe4: e24b4e12      sub     r4,r11,00000120
10430fe8: e1a05000      mov     r5,r0
10430fec: e59b1004      ldr     r1,[r11 + 004]
10430ff0: e28b2008      add     r2,r11,00000008
10430ff4: e3a03000      mov     r3,00000000
10430ff8: e1a00004      mov     r0,r4
10430ffc: ebf548a4      bl      10183294
10431000: e250c000      subs    r12,r0,00000000
10431004: e1a0000c      mov     r0,r12
10431008: 0a00000c      beq     10431040
1043100c: e37c0c01      cmn     r12,00000100

OS1.1 noncas
EDIT: noncas undetermined


EDIT: you can substitute sprintf() and fwrite() for fprintf()
Enjoy .....


Last edited by Guest on 04 Jun 2010 01:09:47 pm; edited 1 time in total
Back to top
bwang


Member


Joined: 15 Mar 2009
Posts: 128

Posted: 03 Jun 2010 01:01:33 am    Post subject:

Nope, it just crashes the emulator.
The printf function indeed writes to the serial console.
EDIT: bsl, are your sure about your fprintf? It doesn't work even if I open a file "/documents/Examples/test.tns".


Last edited by Guest on 03 Jun 2010 01:18:56 am; edited 1 time in total
Back to top
bsl


Advanced Newbie


Joined: 09 Jan 2010
Posts: 94

Posted: 03 Jun 2010 12:51:18 pm    Post subject:

bwang wrote:

Nope, it just crashes the emulator.
The printf function indeed writes to the serial console.
EDIT: bsl, are your sure about your fprintf? It doesn't work even if I open a file "/documents/Examples/test.tns".

Try 0x10430fd0 for the CAS 1.1 . The entry code exactly matches OS1.7 , with the exception of the branch instruction
, but you would expect that. It was the NONCAS I was having trouble finding the entry point.
I will have to put the Toolchain back on my computer at some point, to do this testing myself. I have been
doing other things lately. If you don't have a CAS flash - make one, just to give yourself more choices.
There is an earlier flash getting around that may have a runtime bug in it.
EDIT: As a work around fprintf() is really a combination of sprintf() and fwrite().
Unix devices are usually accessed with the lower level unbuffered IO calls open(),read(),write(),close().
/dev/console could end up being the RS232 device driver. The advantage to that is now you have a handle that could be redirected.
I will look up entries for those 4 low level IO calls and standard string utilities.
EDIT: mispellings, additions.


Last edited by Guest on 07 Jun 2010 10:52:37 pm; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement