]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/cli.c
forgot hfal_shabval.*
[avr-crypto-lib.git] / test_src / cli.c
index 68d6cf6fbbbdff3ff8895841da5d44b4e82c7922..95b027215edaf495ce724af25af67eb0894544e4 100644 (file)
@@ -80,7 +80,7 @@ uint16_t cli_getc_cecho(void){
 /**
  * \brief ouputs a zero-terminated string from ram to the console 
  */
-void cli_putstr(char* s){
+void cli_putstr(const char* s){
        if(!cli_tx)
                return;
        while(*s)
@@ -126,7 +126,7 @@ uint8_t cli_getsn(char* s, uint16_t n){
  * Dumps length bytes from data to the console ouput. The dump
  * will have 2*n continous hexadecimal characters.
  */
-void cli_hexdump(void* data, uint16_t length){
+void cli_hexdump(const void* data, uint16_t length){
        if(!cli_tx)
                return;
        while(length--){
@@ -142,7 +142,7 @@ void cli_hexdump(void* data, uint16_t length){
  * bytes are dumped in reverse order. This is usefull to dump
  * integers which ar e in little endian order.
  */
-void cli_hexdump_rev(void* data, uint16_t length){
+void cli_hexdump_rev(const void* data, uint16_t length){
        if(!cli_tx)
                return;
        data = (uint8_t*)data + length -1;
@@ -158,7 +158,7 @@ void cli_hexdump_rev(void* data, uint16_t length){
  * Like cli_hexdump but bytes are seperated with a single space
  * on the console output.
  */
-void cli_hexdump2(void* data, uint16_t length){
+void cli_hexdump2(const void* data, uint16_t length){
        if(!cli_tx)
                return;
        while(length--){
@@ -169,6 +169,29 @@ void cli_hexdump2(void* data, uint16_t length){
        }
 }
 
+/**
+ * \brief dumps the contents of a buffer to the console
+ * Like cli_hexdump but bytes are seperated with a single space
+ * on the console output.
+ */
+void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width){
+       uint16_t i;
+       uint8_t  j;
+       if(!cli_tx)
+               return;
+       for(i=0; i<length; ++i){
+               if(i%width==0){
+                       cli_putstr_P(PSTR("\r\n"));
+                       for(j=0; j<indent; ++j){
+                               cli_tx(' ');
+                       }
+               }
+               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
+               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
+               cli_tx(' ');
+               data = (uint8_t*)data +1;
+       }
+}
 
 static
 void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist){