Skip to content

Commit

Permalink
powerusb.c:send_cmd: delete unuseable variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
nakj committed Mar 10, 2012
1 parent e30774f commit 3529310
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions powerusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define CMD_GET_STATE2 0xa2
#define CMD_GET_STATE3 0xac

//#define DEBUG
#define DEBUG

#ifdef DEBUG
#define Dprintf printf
Expand All @@ -27,7 +27,7 @@

void send_cmd(struct libusb_device_handle *devh,int cmd)
{
int r,i;
int i;
uint8_t buf[64],buf2[64];
int size=0;
Dprintf("send_cmd:%x\n",cmd);
Expand All @@ -37,12 +37,15 @@ void send_cmd(struct libusb_device_handle *devh,int cmd)

buf[0] = cmd;

r = libusb_interrupt_transfer(devh,ENDPOINT_OUT,buf, sizeof(buf),&size, 1000);
if(r<0) {

if((libusb_interrupt_transfer(devh,ENDPOINT_OUT,buf, sizeof(buf),&size, 1000)) < 0 ) {
perror("libusb_interrupt_transfer");
exit(1);
}
if((libusb_interrupt_transfer(devh,ENDPOINT_IN,buf2, sizeof(buf2),&size, 1000)) < 0 ) {
perror("libusb_interrupt_transfer");
exit(1);
}
r = libusb_interrupt_transfer(devh,ENDPOINT_IN,buf2, sizeof(buf2),&size, 1000);

Dprintf("send_cmd:read:");
for(i=0;i<2;i++){
Expand All @@ -60,21 +63,17 @@ int main(int argc, char **argv)
int r=1;


r = libusb_init(&ctx);
if (r < 0 ) {
if ((r = libusb_init(&ctx)) < 0) {
perror("libusb_init\n");
exit(1);
} else {
libusb_set_debug(ctx,3);
Dprintf("init done\n");
}

devh = libusb_open_device_with_vid_pid(ctx,USB_VENDOR_ID,USB_PRODUCT_ID);
if (devh < 0 ) {
perror("libusb_open_device_with_vid_pid");
//printf("can't find PowerUSB device\n");
if ((devh = libusb_open_device_with_vid_pid(ctx,USB_VENDOR_ID,USB_PRODUCT_ID)) < 0 ) {
perror("can't find PowerUSB device\n");
goto out;

} else {
Dprintf("device opened\n");
}
Expand Down

0 comments on commit 3529310

Please sign in to comment.