]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/serial-tools.c
some bugs fixed for SHA1-C (some may be left)
[avr-crypto-lib.git] / test_src / serial-tools.c
index 47b64396985d5c448c3427bed1c38eb82c780d3c..6fb36bce8c43adb7dfff030e582f20ddeec3c0d2 100644 (file)
@@ -1,6 +1,6 @@
 /* serial-tools.c */
 /*
-    This file is part of the Crypto-avr-lib/microcrypt-lib.
+    This file is part of the AVR-Crypto-Lib.
     Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
 
     This program is free software: you can redistribute it and/or modify
  */
 
 #include "config.h"
-#include "uart.h"
+#include "uart_i.h"
 #include <string.h>
 #include <stdint.h>
 
-int getnextwordn(char *s, int n){ /* words are seperated by spaces */
+int getnextwordn(char *s, int n){ /* words are seperated by spaces, lf or cr */
        char c = ' ';
-       while ((c=uart_getc()) == ' ')
-               ;
+       do{
+               c=uart0_getc(); 
+       }while(c==' ' || c=='\r' || c=='\n');
        *s++ = c;
-       while (n && (*s++=uart_getc())!=' ')
-               ;
+       do{ 
+         *s++ = c = uart0_getc();
+       }while(c!=' ' && c!='\r' && c!='\n' && --n);
        *(s-1) = '\0';
        return n;
 }
@@ -48,7 +50,7 @@ void readhex2buffer(void* buffer, int n){
        
 //     DEBUG_S("\r\nDBG: n="); DEBUG_B(n&0xff); DEBUG_S("\r\n");
        for(i=0; i<n; ++i){
-               c = uart_getc();
+               c = uart0_getc();
                if ('0'<= c && '9'>=c){
                        ((uint8_t*)buffer)[i] = c - '0';
                } else {
@@ -62,7 +64,7 @@ void readhex2buffer(void* buffer, int n){
                
                ((uint8_t*)buffer)[i] <<= 4;
                
-               c = uart_getc();
+               c = uart0_getc();
                if ('0'<= c && '9'>=c){
                        ((uint8_t*)buffer)[i] |= c - '0';
                } else {
@@ -76,7 +78,7 @@ void readhex2buffer(void* buffer, int n){
        } /* for i=0 .. n */
 }
 
-void uart_putptr(void* p){
-       uart_hexdump((void*) &p,2);
+void uart0_putptr(void* p){
+       uart0_hexdump((void*) &p,2);
 }