int readRegOut(usb_dev_handle *udev,
unsigned char reg, unsigned char *val, int out) {
char command[4];
int ret;
command[0] = 1;
command[1] = reg;
command[2] = 0;
command[3] = 1;
ret = usb_bulk_write(udev, 0x03, command, 4, 500);
if (ret < 0)
return ret;
ret = usb_bulk_read(udev, 0x02, val, 1, 1000);
if (out)
printf("r-- %02x [01] : %i (%02x) : %i\n", reg, (int)(*val),
(int)(*val), ret);
return ret;
// readReg
}
这是visioneer xp100 usb scanner驱动的一段代码(读寄存器)
0x03为scanner USB bulk_out_endpoint地址
0x02为scanner USB bulk_in_endpoint地址
我的疑问是:
command[0] = 1;
command[1] = reg;
command[2] = 0;
command[3] = 1;
这种命令格式(写reg寄存器)是开发厂商定义的还是所有的usb设备都要这样写?
希望大家能帮帮我,谢谢!
--------------------next---------------------
阅读(377) | 评论(0) | 转发(0) |