"Tim Roberts" wrote:
> USB Device User <> 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,
> Providenza & Boekelheide, Inc.
> .
>