-  int i, j;
-
-  for (i=0;i<len;i+= 16) {
-    printf ("%04x:  ", i);
-    for (j=0;j < MIN(len-i, 16);j++) {
-      printf (" %02x", pkt[i+j]);
-      if (j == 7) printf ("  ");
-    }
-    if (j < 7) printf ("  ");
-    for (;j<17;j++)
-      printf ("   ");
-
-    for (j=0;j < MIN(len-i, 16);j++) {
-      printf ("%c", printable (pkt[i+j]));
-    }
-    printf ("\n");
-  }
-}
-
-//Send a scpi-command to the scope. The response goes into the buffer
-//called resp, with a size of resplen. If resp==NULL, no response
-//is requested.
-int sendscpi(usb_dev_handle *dev, unsigned char* cmd, 
-             unsigned char *resp, int resplen) {
-    char *buff;
-    int len,r,i;
-    buff=malloc(0x40);
-    seq++;
-    buff[0]=1; //func
-    buff[1]=seq; buff[2]=~seq; //nseq
-    buff[3]=0;
-    int2chars(buff+4,strlen(cmd));
-    buff[8]=1;
-    buff[9]=0x37;
-    buff[10]=0x39;
-    buff[11]=0x39;
-    //    fprintf(stderr,"Writing header len=%d\n", strlen (cmd));
-//    printb(buff,12);
-    r=usb_bulk_write(dev,1,buff,12,1000);
-//    fprintf(stderr,"%i bytes written. Writing cmd\n",r);
-//    printb(cmd,strlen(cmd));
-    r=usb_bulk_write(dev,1,cmd,strlen(cmd),1000);
-//    fprintf(stderr,"%i bytes written.\n",r);
-    if (resp != NULL && resplen != 0) {
-       //send read command
-       buff[0]=2; //func
-       seq++;
-       buff[1]=seq; buff[2]=~seq; //nseq
-       int2chars(buff+4,0x40);
-       buff[8]=1;
-       buff[9]=0xA;
-       buff[10]=0;
-       buff[11]=0;
-//     fprintf(stderr,"Writing resp req header\n");
-//     printb(buff,12);
-       r=usb_bulk_write(dev,1,buff,12,1000);
-//     fprintf(stderr,"%i bytes written. Reading response hdr\n",r);
-       r=usb_bulk_read(dev,2,buff,0x40,1000);
-//     printb(buff,r);
-       len=chars2int(buff+4);
-       //      fprintf(stderr,"%i bytes read. Resplen=%i\n",r,len);
-       for (i=0; i<(r-12); i++) {
-           if (i<resplen) resp[i] = buff[i+12];
-       }
-//     printb(resp,r-12);
-       if (len > 0x40-12) {
-//         fprintf(stderr," Reading response:\n");
-           if (resplen<len) len=resplen;
-           r=usb_bulk_read(dev,2,resp+(0x40-12),len-(0x40-12),1000);
-           //      fprintf(stderr,"%i bytes read, wanted %i.\n", r, len-(0x40-12));
-           return r+(0x40-12);