summaryrefslogtreecommitdiffstats
path: root/mig_test/software/monitor.c
diff options
context:
space:
mode:
authorBert Lange <b.lange@hzdr.de>2015-04-15 13:54:39 +0200
committerBert Lange <b.lange@hzdr.de>2015-04-15 13:54:39 +0200
commit8c5a743259480ebd0cfdbb17fbde8584e34b2aa4 (patch)
tree794887f475d6abb4bdde21c94105f7fcdde1bdd4 /mig_test/software/monitor.c
parenta1c964908b51599bf624bd2d253419c7e629f195 (diff)
downloadzpu-8c5a743259480ebd0cfdbb17fbde8584e34b2aa4.zip
zpu-8c5a743259480ebd0cfdbb17fbde8584e34b2aa4.tar.gz
clean up
Diffstat (limited to 'mig_test/software/monitor.c')
-rw-r--r--mig_test/software/monitor.c225
1 files changed, 0 insertions, 225 deletions
diff --git a/mig_test/software/monitor.c b/mig_test/software/monitor.c
deleted file mode 100644
index c5131e6..0000000
--- a/mig_test/software/monitor.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * $HeadURL: https://svn.fzd.de/repo/concast/FWF_Projects/FWKE/hw_sp605/bsp_zpuahb/software/monitor.c $
- * $Date$
- * $Author$
- * $Revision$
- */
-
-#include "monitor.h"
-
-////////////////////////////////////////////////////////////
-// monitor functions
-
-static char command_list[MAX_COMMANDS][MAX_COMMAND_LENGTH];
-static char help_list [MAX_COMMANDS][MAX_HELP_LENGTH];
-static command_ptr_t command_ptr_list[MAX_COMMANDS];
-
-uint8_t buffer[BUFFER_LENGTH];
-uint8_t command_number;
-uint8_t buffer_position;
-command_ptr_t exec_function;
-
-
-
-/*
- reset some values for monitor
-*/
-void monitor_init( void)
-{
- buffer_position = 0;
- command_number = 0;
- exec_function = 0;
-}
-
-
-/*
- add an command to the monitor list
-*/
-void monitor_add_command(char* new_command, char* new_help, command_ptr_t new_command_ptr)
-{
- if (command_number < MAX_COMMANDS)
- {
- strcpy( command_list[ command_number], new_command);
- strcpy( help_list[ command_number], new_help);
- command_ptr_list[ command_number] = new_command_ptr;
- command_number++;
- }
- else
- {
- putstr("ERROR: too much commands.\n");
- }
-}
-
-
-/*
- print out a nice promt
-*/
-void monitor_prompt( void) {
- putstr("> ");
-}
-
-
-/*
- check the line buffer content and search command
-*/
-void process_buffer( void) {
- uint8_t command_index;
- uint8_t i;
-
- i = 0;
-
- while ( !((buffer[i] == ' ') || (buffer[i] == 0)) ) i++;
-
- if (!i) {
- monitor_prompt();
- return;
- }
-
- for ( command_index = 0; command_index < command_number; command_index++) {
- if ( !strncmp( command_list[ command_index], buffer, i) ) {
- exec_function = command_ptr_list[ command_index];
- return;
- }
- }
- putstr("command not found.\n");
- monitor_prompt();
-}
-
-
-uint8_t monitor_run;
-
-
-/*
- execute the command
-*/
-void monitor_mainloop( void)
-{
- uint32_t return_value;
-
- // execute selected function
- if (exec_function) {
- return_value = exec_function();
- exec_function = 0;
-
- // print return value (as hex)
- if (return_value > 0)
- {
- putstr("0x");
- if (return_value > 0xffff)
- puthex(32, return_value);
- else
- if (return_value > 0xff)
- puthex(16, return_value);
- else
- puthex(8, return_value);
- putchar('\n');
- }
-
- monitor_prompt();
- }
-}
-
-
-/*
- add an character to the monitor line buffer
-*/
-void monitor_input(uint8_t c) {
-
- // carrige return
- if (c == CR) {
- putchar( LF);
- buffer[ buffer_position++] = 0;
- process_buffer();
- buffer_position = 0;
-
- // backspace or delete
- } else if ( (c == BS) || (c == DEL)) {
- if (buffer_position > 0) {
- putchar( BS);
- putchar( ' ');
- putchar( BS);
- buffer_position--;
- }
- } else {
- // add to buffer
- if ((c >= 0x20) && (buffer_position < (BUFFER_LENGTH-1))) {
- putchar( c);
- buffer[ buffer_position++] = c;
- }
- }
-}
-
-
-/*
- parse the argument as string
-*/
-char* monitor_get_argument_string(uint8_t num)
-{
- uint8_t index;
- uint8_t arg;
-
- // example line:
- // " command arg1 arg2 arg3 "
-
- index = 0;
-
- // search for first char (non space)
- while (( buffer[ index] != 0) && (buffer[ index] == ' ')) index++;
-
- for ( arg = 0; arg < num; arg++)
- {
- // next space
- while (( buffer[ index] != 0) && (buffer[ index] != ' ')) index++;
- // next non space
- while (( buffer[ index] != 0) && (buffer[ index] == ' ')) index++;
- }
- return &buffer[ index];
-}
-
-
-/*
- parse the argument as integer
-*/
-int monitor_get_argument_int(uint8_t num)
-{
- char *endptr;
- return strtol( monitor_get_argument_string(num), &endptr, 0);
-}
-
-
-/*
- parse the argument as hex number
-*/
-uint32_t monitor_get_argument_hex(uint8_t num)
-{
- char *endptr;
- return strtoul( monitor_get_argument_string(num), &endptr, 16);
-}
-
-
-
-/*
- print all avalible functions as help screen
-*/
-uint32_t help_function( void)
-{
- uint8_t command_index;
- uint8_t i;
-
- putchar( LF);
- putstr("supported commands:\n\n");
- for ( command_index = 0; command_index < command_number; command_index++) {
- putstr( command_list[ command_index]);
- if (strlen( help_list[ command_index]) > 0 )
- {
- for (i = strlen( command_list[ command_index]); i < MAX_COMMAND_LENGTH; i++) putchar(' ');
- putstr( " - ");
- putstr( help_list[ command_index]);
- }
- putchar('\n');
- }
- putchar( LF);
- return command_number;
-}
-
-
OpenPOWER on IntegriCloud