Using Install program. not complete yet-;)
- Open Device BOOL bOpenHidDevice(HANDLE *HidDevHandle, USHORT vid, USHORT pid)
- Setup Baud Rate,Parity and Stop Bits
outbuffer[0] = 0; /* report ID is not used */
*(unsigned int *)&outbuffer[1] = 19200; /* BaudRate */
/*Configuration Byte
7 6 5 4 3 2 1 0
Reset 0 Parity Type Parity Enable Stop Bits 0 Data Bits
*/
outbuffer[5] = 0x03; /* Data Bits 8, Parity null, Stop Bits 1*/
bResult = HidD_SetFeature(HidDevHandle, outbuffer, Capabilities.FeatureReportByteLength);
if(bResult)
{
}else
printf("HidD_SetFeature failed %d\n",GetLastError());
- Read Write
outbuffer[0] = 0; /* report ID is not used*/
outbuffer[1] = 7; /* data len */
for(int i=0; i < 7; i++)
outbuffer[2+i] = 'a'+i;
bResult = WriteFile(HidDevHandle,
&outbuffer[0],
Capabilities.OutputReportByteLength,
&numBytesReturned,
NULL);
inbuffer[0] = 0; /* report ID is not used*/
bResult = ReadFile(HidDevHandle,
&inbuffer[0],
Capabilities.InputReportByteLength,
&numBytesReturned,
NULL);
if(bResult)
{
//dump data
printf("len = %d\n",inbuffer[1]);
for(int i=0; i < inbuffer[1]; i++)
printf("%c ",inbuffer[i+2]);
}
TODO.