int hexdump(unsigned char *data,int len) {
int i;
- printf("dump: ");
for(i=0;i<len;i++) printf("%02x ",data[i]);
printf("\n");
memcpy(txbuf+size,tx,tx_len);
/* crc check */
- gh->capabilities=GEMTAG_CAP_CRC;
if(gh->capabilities&GEMTAG_CAP_CRC) {
size+=tx_len;
crcptr=(u_int16_t *)(txbuf+size);
- *crcptr=gemtag_calc_crc(txbuf,size);
+ *crcptr=htons(gemtag_calc_crc(txbuf,size));
size+=2;
}
/* usb write */
+ printf("-> ");
hexdump(txbuf,size);
+ usb_clear_halt(gh->handle,0x02);
ret=usb_bulk_write(gh->handle,0x02,txbuf,size,0);
- if(ret<0) {
+ if(ret<=0) {
perror("usb bulk write");
return ret;
}
- printf("write of %d bytes successfull\n",ret);
/* usb read */
+ usb_clear_halt(gh->handle,0x81);
ret=usb_bulk_read(gh->handle,0x81,rxbuf,sizeof(rxbuf),0);
size=ret;
- if(ret<0) {
+ if(ret<=0) {
perror("usb bulk read");
return ret;
}
- printf("received %d bytes\n",ret);
+ printf("-> ");
+ hexdump(rxbuf,ret);
if(rxhdr->seq!=txhdr->seq)
- puts("transmitted/recieved header are not equal");
+ puts("transmitted/recieved sequence number do not match");
/* crc check */
unsigned int rlen;
unsigned int i,numconf;
unsigned int j,numint;
+ unsigned int k,numalt;
struct gemtag_handle *gh;
rlen=sizeof(rbuf);
memset(gh,0,sizeof(struct gemtag_handle));
numconf=gemtag->descriptor.bNumConfigurations;
- printf("found gemtag, %u configuration(s)\n",numconf);
+ printf("found gemtag (%02x/%02x), %u configuration(s)\n",
+ gemtag->descriptor.idVendor,
+ gemtag->descriptor.idProduct,numconf);
for(i=0;i<numconf;i++) {
numint=gemtag->config[i].bNumInterfaces;
- printf("config %u [nr %u] has %u interface(s)\n",
+ printf(" config %u [nr %u] has %u interface(s)\n",
i,gemtag->config[i].bConfigurationValue,
numint);
for(j=0;j<numint;j++) {
- printf("config %u interface %u has %u altsetting(s)\n",
- i,j,gemtag->config[i].interface[j].num_altsetting);
+ numalt=gemtag->config[i].interface[j].num_altsetting;
+ printf(" interface %u has %u altsetting(s): ",
+ j,numalt);
+ for(k=0;k<numalt;k++)
+ printf("%u ",
+ gemtag->config[i].interface[j].altsetting[k].bAlternateSetting);
+ printf("\n");
}
}
}
puts("interface 0 claimed");
-/* if(usb_set_altinterface(gh->handle,1)) {
- perror("set alt interface");
- goto out_free;
- }
- puts("alt setting 1 selected");
-*/
+ while(usb_set_altinterface(gh->handle,0))
+ printf("trying to set alt interface\n");
+ puts("alt setting 0 selected");
gh->capabilities|=GEMTAG_CAP_CRC;
- gemtag_transcieve(gh,0x22,NULL,0,rbuf,&rlen);
+ gemtag_transcieve(gh,GEMTAG_CMD_GET_FW_VERSION,
+ NULL,0,rbuf,&rlen);
return gh;