Pedro Gouveia
2010-06-08 19:42:21 UTC
Hei,
I am trying to develop a new driver for usb device. The device is an
Endurance R/C PCTx.
They give away a sample code to start programming for this device. The
problem is that this code is for windows machines, and I want to port it for
linux.
I already initialized the device with libusb, and the device is claimed by
my program with no problem.
The problem that I found, and I would like your help is that on windows
code, they use a function WriteFile to write an array of chars into the
device, and I've been trying to do the same with libusb, but until now it
didn't work.
CHAR OutputReport[10]; //Holds the data
to be sent to the PCTx or Servo Controller
OutputReport[0] = 0; //do not remove, must be 0
OutputReport[1] = delay1; //ch1
OutputReport[2] = delay2; //ch2
OutputReport[3] = delay3; //ch3
OutputReport[4] = delay4; //ch4
OutputReport[5] = delay5; //ch5
OutputReport[6] = delay6; //ch6
OutputReport[7] = delay7; //ch7
OutputReport[8] = delay8; //ch8
OutputReport[9] = delay9; //ch9
if(!WriteFile(DeviceHandle, OutputReport,
Capabilities.OutputReportByteLength, &BytesWritten, NULL)) {
CloseHandle(DeviceHandle);
connected = false;
return false;
}
Here's my last tested code:
char cmd[10];
cmd[0] = 1;
cmd[1] = 1;
cmd[2] = 1;
cmd[3] = 1;
cmd[4] = 1;
cmd[5] = 1;
cmd[6] = 1;
cmd[7] = 1;
cmd[8] = 1;
cmd[9] = 1;
//int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int
size, int timeout);
ret = usb_bulk_write(_hDevice, 0x01, const void *cmd, 10, 50);
cout <<"value of write: "<< ret<<endl;
Thanks,
Pedro
I am trying to develop a new driver for usb device. The device is an
Endurance R/C PCTx.
They give away a sample code to start programming for this device. The
problem is that this code is for windows machines, and I want to port it for
linux.
I already initialized the device with libusb, and the device is claimed by
my program with no problem.
The problem that I found, and I would like your help is that on windows
code, they use a function WriteFile to write an array of chars into the
device, and I've been trying to do the same with libusb, but until now it
didn't work.
CHAR OutputReport[10]; //Holds the data
to be sent to the PCTx or Servo Controller
OutputReport[0] = 0; //do not remove, must be 0
OutputReport[1] = delay1; //ch1
OutputReport[2] = delay2; //ch2
OutputReport[3] = delay3; //ch3
OutputReport[4] = delay4; //ch4
OutputReport[5] = delay5; //ch5
OutputReport[6] = delay6; //ch6
OutputReport[7] = delay7; //ch7
OutputReport[8] = delay8; //ch8
OutputReport[9] = delay9; //ch9
if(!WriteFile(DeviceHandle, OutputReport,
Capabilities.OutputReportByteLength, &BytesWritten, NULL)) {
CloseHandle(DeviceHandle);
connected = false;
return false;
}
Here's my last tested code:
char cmd[10];
cmd[0] = 1;
cmd[1] = 1;
cmd[2] = 1;
cmd[3] = 1;
cmd[4] = 1;
cmd[5] = 1;
cmd[6] = 1;
cmd[7] = 1;
cmd[8] = 1;
cmd[9] = 1;
//int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int
size, int timeout);
ret = usb_bulk_write(_hDevice, 0x01, const void *cmd, 10, 50);
cout <<"value of write: "<< ret<<endl;
Thanks,
Pedro