removing old commands from cmd-tool
authorbg <daniel.otte@rub.de>
Sat, 19 Oct 2013 15:32:27 +0000 (17:32 +0200)
committerbg <daniel.otte@rub.de>
Sat, 19 Oct 2013 15:32:27 +0000 (17:32 +0200)
hostware/commandline/main.c

index 8b8b2b0..e5c7eab 100644 (file)
@@ -174,154 +174,6 @@ void get_token(char *param){
     }
 }
 
-void read_mem(char* param){
-       int length=0;
-       uint8_t *buffer, *addr;
-       int cnt;
-       FILE* f=NULL;
-       if(fname){
-               f = fopen(fname, "wb");
-               if(!f){
-                       fprintf(stderr, "ERROR: could not open %s for writing\n", fname);
-                       exit(1);
-               }
-       }
-       sscanf(param, "%i:%i", (int*)&addr, &length);
-       if(length<=0){
-               return;
-       }
-       buffer = malloc(length);
-       if(!buffer){
-               if(f)
-                       fclose(f);
-               fprintf(stderr, "ERROR: out of memory\n");
-               exit(1);
-       }
-       cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_READ_MEM, (intptr_t)addr, 0, (char*)buffer, length, 5000);
-       if(cnt!=length){
-               if(f)
-                       fclose(f);
-               fprintf(stderr, "ERROR: received %d bytes from device while expecting %d bytes\n", cnt, length);
-               exit(1);
-       }
-       if(f){
-               cnt = fwrite(buffer, 1, length, f);
-               fclose(f);
-               if(cnt!=length){
-                       fprintf(stderr, "ERROR: could write only %d bytes out of %d bytes\n", cnt, length);
-                       exit(1);
-               }
-
-       }else{
-               hexdump_block(stdout, buffer, addr, length, 8);
-       }
-}
-
-void write_mem(char* param){
-       int length;
-       uint8_t *addr, *buffer, *data=NULL;
-       int cnt=0;
-       FILE* f=NULL;
-
-       if(fname){
-               f = fopen(fname, "rb");
-               if(!f){
-                       fprintf(stderr, "ERROR: could not open %s for writing\n", fname);
-                       exit(1);
-               }
-       }
-       sscanf(param, "%i:%i:%n", (int*)&addr, &length, &cnt);
-       data += cnt;
-       if(length<=0){
-               return;
-       }
-       buffer = malloc(length);
-       if(!buffer){
-               if(f)
-                       fclose(f);
-               fprintf(stderr, "ERROR: out of memory\n");
-               exit(1);
-       }
-       memset(buffer, (uint8_t)pad, length);
-       if(!data && !f && length==0){
-               fprintf(stderr, "ERROR: no data to write\n");
-               exit(1);
-       }
-       if(f){
-               cnt = fread(buffer, 1, length, f);
-               fclose(f);
-               if(cnt!=length && pad==-1){
-                       fprintf(stderr, "Warning: could ony read %d bytes from file; will only write these bytes", cnt);
-               }
-       }else if(data){
-               char xbuffer[3]= {0, 0, 0};
-               uint8_t fill=0;
-               unsigned idx=0;
-               while(*data && idx<length){
-                       while(*data && !isxdigit(*data)){
-                               ++data;
-                       }
-                       xbuffer[fill++] = *data;
-                       if(fill==2){
-                               uint8_t t;
-                               t = strtoul(xbuffer, NULL, 16);
-                               buffer[idx++] = t;
-                               fill = 0;
-                       }
-               }
-
-       }
-       cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_WRITE_MEM, (intptr_t)addr, 0, (char*)buffer, length, 5000);
-       if(cnt!=length){
-               fprintf(stderr, "ERROR: device accepted ony %d bytes out of %d\n", cnt, length);
-               exit(1);
-       }
-
-}
-
-void read_flash(char* param) {
-       int length=0;
-       uint8_t *buffer, *addr;
-       int cnt;
-       FILE* f=NULL;
-       if (fname) {
-               f = fopen(fname, "wb");
-               if (!f) {
-                       fprintf(stderr, "ERROR: could not open %s for writing\n", fname);
-                       exit(1);
-               }
-       }
-       sscanf(param, "%i:%i", (int*)&addr, &length);
-       if (length <= 0){
-               return;
-       }
-       buffer = malloc(length);
-       if (!buffer) {
-               if (f)
-                       fclose(f);
-               fprintf(stderr, "ERROR: out of memory\n");
-               exit(1);
-       }
-       cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_READ_FLASH, (intptr_t)addr, 0, (char*)buffer, length, 5000);
-       if (cnt != length){
-               if (f)
-                       fclose(f);
-               fprintf(stderr, "ERROR: received %d bytes from device while expecting %d bytes\n", cnt, length);
-               exit(1);
-       }
-       if (f) {
-               cnt = fwrite(buffer, 1, length, f);
-               fclose(f);
-               if (cnt != length) {
-                       fprintf(stderr, "ERROR: could write only %d bytes out of %d bytes\n", cnt, length);
-                       exit(1);
-               }
-
-       } else {
-               hexdump_block(stdout, buffer, addr, length, 8);
-       }
-}
-
 void soft_reset(char* param){
        unsigned delay = 0;
        if (param) {
@@ -337,32 +189,6 @@ void read_button(char* param){
        printf("button is %s\n",v?"on":"off");
 }
 
-void wait_for_button(char* param){
-       volatile uint8_t v = 0, x = 1;
-       if(param){
-               printf("DBG: having param: %s\n", param);
-               if (!(strcmp(param,"off") && strcmp(param,"0"))) {
-                       x = 0;
-               }
-       }
-       do{
-               usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_READ_BUTTON, 0, 0, (char*)&v, 1, 5000);
-       }while(x!=v);
-       printf("button is %s\n",v?"on":"off");
-}
-
-void read_temperature(char* param){
-       uint16_t v;
-       int cnt;
-       cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_READ_TMPSENS, 0, 0, (char*)&v, 2, 5000);
-       if (cnt == 2) {
-           printf("temperature raw value: %hd 0x%hx\n", v, v);
-       } else {
-        fprintf(stderr, "Error: reading %d bytes for temperature, expecting 2\n", cnt);
-       }
-}
-
-
 static struct option long_options[] =
              {
                /* These options don't set a flag.