I've been tasked with establishing a USB connection which I can use to send and receive data. More specifically, I need to send ZPL commands to a Zebra Label Printer ZD421 and the whole process needs to be done in C#.
I looked at around 10 different stackoverflow questions, which sadly did not help me much.
I first tried searching if an out of the box solution exists.
I tried the following nugets: Zebra.Printer.Sdk, LibUsbDotNet, Usb.Net
The newest update from Zebra uses MAUI, which is not compatible with my other projects. The 2.14 updates are too old and thus also not compatible. The 2.15 versions have the wrong docs, but through the Class View in Visual Studio I saw that there is no UsbDiscoverer.
LibUsbDotNet simply did not want to work, even though I looked at working examples, I did not get it to work.
Usb.Net is what I imagine could probably work? But I think I'm missing something. I tried looking through the documentation but I was none the wiser. I wanted to create an UsbDevice like this:
GetUsbInterfaceManager getUsbInterfaceManager = null;
CancellationToken cancellationToken = new CancellationToken();
IUsbInterfaceManager usbInterfaceManager = await getUsbInterfaceManager(comm.SelectedPrinterDevice.GetPropertyValue("DeviceID").ToString(), cancellationToken);
UsbDevice usbDevice = new UsbDevice(comm.SelectedPrinterDevice.GetPropertyValue("DeviceID").ToString(), (IUsbInterfaceManager)usbInterfaceManager);
But this is obviously wrong, because getUsbInterfaceManager is still null at line 3. I still don't know how to instantiate a GetUsbInterfaceManager. But I believe as it is a delegate, I need to implement it myself? Apparently I need that to get the IUsbInterfaceManager?
Apparently the Usb.Net docs are also out of date and I'm more confused by the minute it seems.
The only thing that worked at all was the System.Management, with which I was able to list all Zebra Printers that are currently connected.
I'd appreciate any help a lot.