How to use IOCTL_USBPRINT_VENDOR_GET_COMMAND and IOCTL_USBPRINT_VENDOR_SET_COMMAND

J

Jeth

Hello,

I'm trying to use IOCTL_USBPRINT_VENDOR_GET_COMMAND and
IOCTL_USBPRINT_VENDOR_SET_COMMAND to communicate with UsbMon(UsbPrint) in my
language monitor but I have no idea how to set parametes of device io
contorI that will be passed to portmonitor.

I need to call GetPrinterDataFromPort of USBMon (portmonitor) inside
GetPrinterDataFromPort of Language monitor to get/set some vendor specific
data using IOCTL_USBPRINT_VENDOR_GET_COMMAND and
IOCTL_USBPRINT_VENDOR_SET_COMMAND command.

Are the following codes correct?

In case of IOCTL_USBPRINT_VENDOR_GET_COMMAND,

cbOutBuffer = 13; //3 1st:Vendor specific code,
// 2nd:Vendor Request value - Most Significant Byte
// 3rd:Vendor Request value - Lease Significant Byte
//+10 size of data to receive
lpOutBuffer[0] = VENDOR_SPECIFIC_CODE1;
lpOutBuffer[1] = 0;
lpOutBuffer[2] = 10;
bRet = (*pIniPort->fn.pfnGetPrinterDataFromPort)
(pIniPort->hPort, IOCTL_USBPRINT_VENDOR_GET_COMMAND, NULL,
NULL, //pInput,
0, //cbInput,
lpOutBuffer, cbOutBuffer,
lpcbReturned);
//...wait until this function finished...
// Can I assume that lpOutBuffer[0] is the first byte of data after call
above ?

In case of IOCTL_USBPRINT_VENDOR_SET_COMMAND,

cbOutBuffer = 13; //3 1st:Vendor specific code,
// 2nd:Vendor Request value - Most Significant Byte
// 3rd:Vendor Request value - Lease Significant Byte
//+10 size of data to receive
lpOutBuffer[0] = VENDOR_SPECIFIC_CODE2;
lpOutBuffer[1] = 0;
lpOutBuffer[2] = 10;
lpOutBuffer[3] = 0x01; lpOutBuffer[4] = 0x02;....;lpOutBuffer[12] = 0x0A;
//Set data here to sent.
bRet = (*pIniPort->fn.pfnGetPrinterDataFromPort)
(pIniPort->hPort, IOCTL_USBPRINT_VENDOR_SET_COMMAND, NULL,
NULL, //pInput,
0, //cbInput,
lpOutBuffer, cbOutBuffer,
lpcbReturned);
//...wait until this function finished...

Because I have a situation that I can't verify, so I need to know correct
implementation.
Please give an advise for this.
Thanks

Jeth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top