I am programming on a hid printer now, after "CreateFile", and
according to Attributes.VendorID and Attributes.ProductID, I am sure I
got correct Handle.

then I used "WriteFile" to send message to the printer, it was always
False returned, and when I used "ReadFile", the program would hang
there. so I checked "OutputReportByteLength", it was zero, and
"InputReportByteLength" and "FeatureReportByteLength" were non-zero.
then I think maybe the printer do not suport "WriteFile", then I used
HidD_SetFeature and HidD_GetFeature to communicate with the printer.

the problem is, HidD_SetFeature always return TRUE but nothing happen
with the printer and HidD_GetFeature always return FALSE with
GetLastError 23.


BYTE * sendBuffer = new BYTE[2];
sendBuffer[0] = 0x02;
sendBuffer[1] = 0;
HidD_SetFeature(hDeviceHandle, sendBuffer, 2);

BYTE * receiveBuffer = new BYTE[FeatureReportByteLength];
receiveBuffer[0] = 0x0A;
HidD_SetFeature(hDeviceHandle, receiveBuffer,
FeatureReportByteLength);

anyone knows why I cannot communicate with it?

Thanks in advance!

Re: How can communicate with a hid device after I get its handle? by Doron

Doron
Fri Dec 14 10:24:23 PST 2007

why are you using HID to talk to a printer? there is a class specification
for printers already (that is obviously not hid)

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Gang Wu" <mywugang@gmail.com> wrote in message
news:41cfde6a-9d02-4bdd-b6cd-0c45d1e8b137@d21g2000prf.googlegroups.com...
>I am programming on a hid printer now, after "CreateFile", and
> according to Attributes.VendorID and Attributes.ProductID, I am sure I
> got correct Handle.
>
> then I used "WriteFile" to send message to the printer, it was always
> False returned, and when I used "ReadFile", the program would hang
> there. so I checked "OutputReportByteLength", it was zero, and
> "InputReportByteLength" and "FeatureReportByteLength" were non-zero.
> then I think maybe the printer do not suport "WriteFile", then I used
> HidD_SetFeature and HidD_GetFeature to communicate with the printer.
>
> the problem is, HidD_SetFeature always return TRUE but nothing happen
> with the printer and HidD_GetFeature always return FALSE with
> GetLastError 23.
>
>
> BYTE * sendBuffer = new BYTE[2];
> sendBuffer[0] = 0x02;
> sendBuffer[1] = 0;
> HidD_SetFeature(hDeviceHandle, sendBuffer, 2);
>
> BYTE * receiveBuffer = new BYTE[FeatureReportByteLength];
> receiveBuffer[0] = 0x0A;
> HidD_SetFeature(hDeviceHandle, receiveBuffer,
> FeatureReportByteLength);
>
> anyone knows why I cannot communicate with it?
>
> Thanks in advance!
>
>
>