From: USB Device User on
I have a Zebra barcode printer connected to my pC with USB. The printer is
not a win USB device and neither do we use the vendor driver. The
enummeration process detects the printer as a USB raw device. How can use
bulk transfer to send/read data from the printer in the host app? Is there
any api calls I can use or do I have to write a simple driver? Is there any
C# sample code?
Thanks,
From: Tim Roberts on
USB Device User <USBDeviceUser(a)discussions.microsoft.com> wrote:
>
>I have a Zebra barcode printer connected to my pC with USB. The printer is
>not a win USB device...

What does that mean?

>...and neither do we use the vendor driver. The
>enummeration process detects the printer as a USB raw device. How can use
>bulk transfer to send/read data from the printer in the host app? Is there
>any api calls I can use or do I have to write a simple driver?

WinUSB can do that. WinUSB is a basic USB driver that Microsoft has
written for generic access to USB devices, plus a thin DLL that provides a
user-mode API for accessing it. You'll have to write an INF file to get
the driver loaded.

>Is there any C# sample code?

Most of the sample code is in C++, but the API is fairly simple.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: USB Device User on


"Tim Roberts" wrote:

> USB Device User <USBDeviceUser(a)discussions.microsoft.com> wrote:
> >
> >I have a Zebra barcode printer connected to my pC with USB. The printer is
> >not a win USB device...
>
> What does that mean?

The device does not use WINUSB driver. It uses USBPRINT as the default driver.

>
> >...and neither do we use the vendor driver. The
> >enummeration process detects the printer as a USB raw device. How can use
> >bulk transfer to send/read data from the printer in the host app? Is there
> >any api calls I can use or do I have to write a simple driver?
>
> WinUSB can do that. WinUSB is a basic USB driver that Microsoft has
> written for generic access to USB devices, plus a thin DLL that provides a
> user-mode API for accessing it. You'll have to write an INF file to get
> the driver loaded.

If a device is not developed as a WINUSB driver device, could I write an NF
file and install the WINUSB driver to make it a WINUSB device? From Host
requirements, should I also need to get a vendor provided application to
communicate to the printer to make WINUSB work for the printer?

>
> >Is there any C# sample code?
>
> Most of the sample code is in C++, but the API is fairly simple.

I tried to use the the WriteFile to send the text command to the printer and
WriteFile always returns 0x57 error. Here ia the code:
public bool WriteToUSB(SafeFileHandle fileHandle, string information)
{
Byte[] writeBuffer = new byte[information.Length]; //initialize buffer
int iCount = 0;
while (iCount < information.Length)
{
writeBuffer[iCount] =
System.Convert.ToByte(information.ToCharArray()[iCount]);
iCount++;
}
int bytesWritten = 0;
return WriteToUSB(fileHandle, writeBuffer, writeBuffer.Length, ref
bytesWritten);
}
public bool WriteToUSB(SafeFileHandle fileHandle,byte[] bWriteBuffer, int
bytesToWrite, ref int nBytesWritten)
{
return WriteFile(fileHandle, bWriteBuffer, bytesToWrite, ref
nBytesWritten, IntPtr.Zero);
}

Anyone knows why?


> --
> Tim Roberts, timr(a)probo.com
> Providenza & Boekelheide, Inc.
> .
>
From: Tim Roberts on
USB Device User <USBDeviceUser(a)discussions.microsoft.com> wrote:
>"Tim Roberts" wrote:
>> USB Device User <USBDeviceUser(a)discussions.microsoft.com> wrote:
>> >
>> >I have a Zebra barcode printer connected to my pC with USB. The printer is
>> >not a win USB device...
>>
>> What does that mean?
>
>The device does not use WINUSB driver. It uses USBPRINT as the default driver.

I'm confused. You said:

* The printer is not a win USB device
* neither do we use the vendor driver
* The enummeration process detects the printer as a USB raw device

If it is not enumerated as a printer, and you do not use a vendor driver,
then how did USBPRINT get involved?

>If a device is not developed as a WINUSB driver device, could I write an NF
>file and install the WINUSB driver to make it a WINUSB device? From Host
>requirements, should I also need to get a vendor provided application to
>communicate to the printer to make WINUSB work for the printer?

You can create your own INF and install WinUSB as the driver. However, you
will need to know which sequences to send to the printer to get it to do
things. Most label printers are strictly bitmap devices. You need to send
them a bitmap of some kind, in some format, at the proper resolution.

>I tried to use the the WriteFile to send the text command to the printer and
>WriteFile always returns 0x57 error. Here ia the code:
>public bool WriteToUSB(SafeFileHandle fileHandle, string information)
> {
> Byte[] writeBuffer = new byte[information.Length]; //initialize buffer

Where did you get the file handle?
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.