Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: compu on August 18, 2011, 03:51:12 pm

Title: rshell - A simple RS232 shell for the Nspire
Post by: compu on August 18, 2011, 03:51:12 pm
rshell is a command-line interface for Nspire using the RS232 port.

It has the ability to launch ndless executables and pass C's argc and argv to them.

I have included some programs for filesystem operations:

ls - list content of a directory
cp - Copy a file
mkdir - Create a directory
stat - Show size and type of a file
rm - Remove a file (for some reason buggy sometimes)

All these commands are in their own TNS-File that has to be located in /documents/bin or the current directory.

Built-in commands are:

cd - Change directory
exit - Exit rshell

Demonstration:

ls
Code: [Select]
A:\documents\>ls.tns
.\
..\
Examples\
bin\
A:\documents\>ls.tns /
dev\
tmp\
phoenix\
documents\
ti84\
logs\
widgets\

cp
Code: [Select]
A:\documents\>cp.tns
USAGE: cp.tns SOURCE DESTINATION
Copies a file from SOURCE to DESTINATION.
A:\documents\>cp.tns bin/stat.tns copied.tns
A:\documents\>ls.tns
.\
..\
Examples\
bin\
copied.tns

mkdir
Code: [Select]
A:\documents\>mkdir.tns
USAGE: mkdir.tns NAME
Creates a directory named NAME.
A:\documents\>mkdir.tns lol
A:\documents\>ls.tns
.\
..\
Examples\
bin\
copied.tns
lol\

stat
Code: [Select]
A:\documents\>stat.tns
USAGE: stat.tns FILE
Shows stat data for FILE.
A:\documents\>stat.tns copied.tns
Mode: File
Size: 0 KBytes
(Shows 0KB here, because it is smaller than 0.5KB and got rounded down...)

rm
Code: [Select]
A:\documents\>rm.tns
USAGE: rm.tns FILE
Removes the FILE.
A:\documents\>rm.tns copied.tns
A:\documents\>ls.tns
.\
..\
Examples\
bin\
lol\

cd
Code: [Select]
A:\documents\>cd examples
A:\documents\examples\>cd ..
A:\documents\>cd /
A:\>cd phoenix
A:\phoenix\>cd /documents
A:\documents\>cd \
A:\>
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: Jim Bauwens on August 18, 2011, 03:52:57 pm
Looks very nice :)
Good job!
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: Adriweb on August 18, 2011, 03:54:12 pm
This is even more than awesome, really nice indeed !
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: willrandship on August 18, 2011, 03:54:43 pm
WANT. Also, any chance of integrating such a shell into the nspire without the RS232? :P
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: compu on August 18, 2011, 03:57:06 pm
WANT. Also, any chance of integrating such a shell into the nspire without the RS232? :P
Maybe I can use one of my older projects (http://nspforge.unsads.com/p/nspireio) for on-screen output and keyboard input, it shouldn't be too hard to integrate.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: willrandship on August 18, 2011, 03:57:48 pm
yay, because that's been something I've wanted for a while.

Oh, also, if we cp to a non-tns name, will it then not show up in the menu, but still be in the calc? That would rock.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: compu on August 19, 2011, 01:52:48 am
yay, because that's been something I've wanted for a while.

Oh, also, if we cp to a non-tns name, will it then not show up in the menu, but still be in the calc? That would rock.
Yes, files with a non-tns extension will not be shown by the document browser, but you can "hack" the OS (http://ourl.ca/10562) :P
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: willrandship on August 20, 2011, 01:33:16 am
well, of course, but I was thinking it'd be a lot more organized to not see all the roms from gbc4nspire, or all the text files from that one text editor, and only the things we can actually execute in the main menu.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: pianoman on August 20, 2011, 08:02:19 pm
Nice job, compu!
Just one question though: does this require Ndless?
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: willrandship on August 20, 2011, 08:13:00 pm
I'd bet on it: Lua doesn't have any RS232 support as far as I'm aware, so it'd have to be ndless.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: pianoman on August 20, 2011, 08:14:17 pm
Awwwww :(
Oh well... Still, great job!!! :)
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: willrandship on August 21, 2011, 12:00:58 am
Ndless for 3.0 will come, just wait!
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: compu on August 21, 2011, 07:33:05 am
I'd bet on it: Lua doesn't have any RS232 support as far as I'm aware, so it'd have to be ndless.
Lua has a function to send data via RS232, but you can't receive any data with it. So yes, this requires Ndless.

Ndless for 3.0 will come, just wait!
Lua + C would be awesome :D
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: Adriweb on August 21, 2011, 07:36:01 am
About that Lua outputting to the RS232 port, it's just a print() actually that outputs stuff to the console, which is actually the serial port
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: willrandship on August 21, 2011, 11:51:00 pm
so, TI essentially set up the RS232 to be a shell, and ended it at that? Or is it just marked as stdout?

How hard would it be for you to integrate rshell into the calc if there was a way to display whatever went into and out of RS232 on-screen, in a terminal-like fashion? Just curious.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: fb39ca4 on August 22, 2011, 01:08:32 am
The rs232 is stdout, using printf in ndless programs outputs to there.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: ExtendeD on August 22, 2011, 04:28:48 pm
Nice compu :)

I really should export Ndless's program launcher to let you call it instead of replicating it in your shell. This would avoid:
- bugs duplication such as the missing clear_cache() in your code which may make the launch crash in some conditions
- breaking your shell if the program format changes, which may happen when new features are included (such as compatibility flags or other programs metadata)
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: compu on September 10, 2011, 03:14:36 pm
Update :)

- Using on-screen console instead of RS232
- Launched programs can use Nspire I/O (http://ourl.ca/9468) to write to (and read from) rshell's console
- Programs that need to be run with rshell have the header "RSH\0" instead of "PRG\0" to prevent errors when launching with the standard loader
- Included program rshell_header.exe to replace "PRG\0" with "RSH\0"
- Launching a program does not require the .tns ending anymore
  (for example you can type "ls" instead of "ls.tns")

My solution isn't very memory-efficient yet, because I didn't get shared variables/functions (http://ourl.ca/12697) to work.
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: fb39ca4 on September 10, 2011, 11:48:28 pm
Is that a run indicator I see in the corner?
Title: Re: rshell - A simple RS232 shell for the Nspire
Post by: compu on September 11, 2011, 06:21:53 am
Unfortunately not, it is a bug. :P
Title: Re: rshell - A simple on-screen console for Nspire
Post by: compu on April 15, 2012, 10:42:29 am
Update:

Made compatible with Nspire I/O 2.0.
+ I have ported argtable2 (http://argtable.sourceforge.net/) which allows us to have fancy command-line arguments, and therefore to create powerful console applications :)

Download can be found at http://nspforge.unsads.com/p/rshell/downloader

And a screenshot of what argtable2 can do: