小弟初学linux驱动,希望大家能帮帮我,谢谢![code]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
}[/code]这是xp100 scanner驱动的一段代码(读寄存器)
0x03为scanner USB bulk_out_endpoint地址
0x02为scanner USB bulk_in_endpoint地址,其它的看变量名便能明白
我的疑问是:[code] command[0] = 1;
command[1] = reg;
command[2] = 0;
command[3] = 1;[/code]这种命令格式(将1写入reg这个寄存器)是开发厂商定义的还是所有的设备都要这样写?

