Command Line Interface
Matthias1992
Posts: 7
Hey there!
First of all, I am new to the forums and new to the propeller. I did research if any topic/thread existed on what I am about to ask but I could not find any. Please bare with me, I might ask some stupid questions...
I have the Propellor USB proto board + VGA and 2 PS2 connectors. They all work fine. I want to make a command line interface with the propellor. I did manage to get text on the VGA monitor and I could type stuff and all that but now I want to program the chip to recognize commands. Preferably I would type the commands without prefix so that I could type
1+1
But if easier I could also resort to this:
?1+1
in which the "?" tells the chip that a command is coming. My point is this, since I am using the included libraries (keyboard, vga, vga_text_demo(in which vga_text_demo is the top module)) how can I recognize commands?
So far I have tried to get the par_key buffer from the keyboard.spin file but I can't acces it from the top module (i 've tried # and @). Once again, I am a complete newbie (altough i did read trough the entire propellor spin programming manual/tutorial) so bare with me.
I know this is the most hated question in forums but, could anybody give me a small code example on how to achieve such a feat? So far example code that would output "You typed the add command" when I type ADD (or ?ADD).
Thanks!!
First of all, I am new to the forums and new to the propeller. I did research if any topic/thread existed on what I am about to ask but I could not find any. Please bare with me, I might ask some stupid questions...
I have the Propellor USB proto board + VGA and 2 PS2 connectors. They all work fine. I want to make a command line interface with the propellor. I did manage to get text on the VGA monitor and I could type stuff and all that but now I want to program the chip to recognize commands. Preferably I would type the commands without prefix so that I could type
1+1
But if easier I could also resort to this:
?1+1
in which the "?" tells the chip that a command is coming. My point is this, since I am using the included libraries (keyboard, vga, vga_text_demo(in which vga_text_demo is the top module)) how can I recognize commands?
So far I have tried to get the par_key buffer from the keyboard.spin file but I can't acces it from the top module (i 've tried # and @). Once again, I am a complete newbie (altough i did read trough the entire propellor spin programming manual/tutorial) so bare with me.
I know this is the most hated question in forums but, could anybody give me a small code example on how to achieve such a feat? So far example code that would output "You typed the add command" when I type ADD (or ?ADD).
Thanks!!
Comments
You can also have a look into PropBasic or FemtoBasic or PropCMD in the ObjectExchange.
The way I go with ConfigReader is to read input until the buffer limit has been reached or the return key has been pressed. The command-line is simply a command followed by up to 9 parameters. The space separates command/parameters. The command is converted to a hash-value. This way you can use the SPIN instruction "switch" for checking the command and calling the appropriate function. The parameters are already parsed, which means that numeric strings you pass in hex, binary or decimal format are converted to a long. All other input is recognized as string and the start address of the string is stored in a parameter array.
Allocate some HUB memory
Stick the getkey method's return value in memory.
Well, you just go along sticking item in memory until <enter> is pressed (13). Then parse the expression and execute some logic. There's probably some encoding and decoding involved and validation but that's the basic idea. I'm sure you can come up with something a little more robust.
Andy
There have been a number of command line programs written. PropCmd is one such. It has SD card but you could strip it out. MagIo has suggested a few.
Once you add an SD card, a whole new world opens up. This is easy to add - buy a SD to microSD converter card and solder wires to it. There are instructions in one of the threads. Otherwise buy an SD card expansion and wire it. Sphinx is an OS of sorts and it will compile on the prop itself, and edit. All still in development, but any help is always welcome.
How would I clear cmdstring? Also would it be possible to make some sort of langauge to develop further on, on the propeller itself? So I would make a core application and then I can make new programs on-chip? Has this already been done?
Thanks!
P.S. As far as SphinxOs goes, thanks for the tip but for now I will have to rely on a non-SD system, or make one myself...
Yes, you can find several in the OBEX.
Thanks!
And Sphinx is a real Spin compiler but you need an SD card.
Regarding the String clear, that is not necessary, I just have forgotten to write the ending zero, which terminatres the String: shoud be:
Andy
Second question is that since I have no SD card how can I now save a program in femto? Prefferably I would like it to run at startup but that is not neccessary.