Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => Topic started by: s3c on October 16, 2009, 08:55:21 pm

Title: Storing commands and history as macros.
Post by: s3c on October 16, 2009, 08:55:21 pm
I'm looking into completing issue 16 (Repeat previous command) and 17 (Store command sequences as macros) on the code issue page as well as storing the last commands executed since I find myself repeating the same commands over and over again.

The problem is that implementing additional macros for the history and user choice is how to represent these with the numbering scheme used. Since some modes have more macros than others starting at a set value might need an update later as more macros are added to these modes.

I'd think changing the macro syntax slightly would be better than changing macro sequences, for example, we could make history macro's range from (1) to (10), user macros from (11) to (20) and mode macros from (21) onward. Alternatively we could change the numbering scheme to something like (*1) to (*??) for history macros, (&1) to (&??) for user macros and keep mode macros as is.

Any ideas?
Title: Re: Storing commands and history as macros.
Post by: ian on October 17, 2009, 08:50:25 am
I worked on this a bit. In baseIO.c there's some commented code:

         //case 0x1b://escape, get 2 or 3 more bytes
            //get 2 bytes, ABCD are arrow keys, A is up
            //break;

My plan was to start with a simple 'press up arrow to show previous terminal input', and from there build a buffer system that keeps as much history as possible. Up arrow on VT100 terminal is 0x1b then the characters [A
Title: Re: Storing commands and history as macros.
Post by: s3c on October 17, 2009, 04:15:36 pm
"and from there build a buffer system that keeps as much history as possible."

That would probably entail defining a stack. How was the space used for the terminal buffer decided upon? most commands are rather short so you could easily store a couple of hundred commands in an equivalent buffer.
Title: Re: Storing commands and history as macros.
Post by: ian on October 18, 2009, 11:38:51 am
User terminal input is stored in a 4000byte buffer. I make it really big so that scripts could fill it with long commands. Since we have a new binary access mode, that doesn't make sense any more.

It might be easy to start with a 10 or 20 int array that holds the input indexes within the big buffer, then hold as many previous commands as possible (by space or indexes available). That would still allow for really long input when needed.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.00882044392session_write_close ( )...(null):0
20.00912175968ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.00912176744Database_MySQL->query( ).../DatabaseHandler.php:119
40.05442315456Database_MySQL->error( ).../Db-mysql.class.php:273