LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the printer of USB interface

Hello

 

I installed the windows driver, but I need to communicate with printer through NI-VISA, and send the command to control printer with labview, I open the NI-MAX, it can't find the printer hardware? how to install the VISA USB Driver of printer?thanks

 

Lchjxlz_0-1652196317250.pngLchjxlz_1-1652196352719.png

Lchjxlz_2-1652196381867.png

 

 

0 Kudos
Message 1 of 23
(3,528 Views)

What type of printer are you trying to communicate with? Normally you would need to create a driver to use VISA to communicate with the printer. However, Windows 10 requires all drivers to be signed so that complicates things.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 23
(3,505 Views)

Does this printer support VISA? or remote control?

Do you have an example in other programming language?

What you try to do?

 

George Zou
0 Kudos
Message 3 of 23
(3,481 Views)

C# can't communicate with printer, I used HUAWEI printer, I tried to install the VISA USB driver with NI-VISA Driver Wizard but no successful 

 

 

Lchjxlz_0-1652230634797.pngLchjxlz_1-1652230653155.png

 

0 Kudos
Message 4 of 23
(3,448 Views)

how to create a driver to use VISA? I try to install  USB driver with NI-VISA driver wizard but not success, do you have other method to install USB driver?thanks

0 Kudos
Message 5 of 23
(3,447 Views)

It is hard to understand what you want to do. I think your printer is a consumer-grade device that is not supposed to be controlled by low-level access.

 

Do you want to print a page? Then you can use the windows driver to do so, for example https://zone.ni.com/reference/en-XX/help/371361R-01/lvreport/report_gen_vis/ with https://zone.ni.com/reference/en-XX/help/371361R-01/lvreport/print_report/

 

Or do you want to mess around with the printer command language? Then you need to create a custom driver for that printer model to allow low level access and you will probably need the documentation for the printer. Or, depending on what you want to actually do, there are a million other options.

 

You can also try "printui /s" in a command line and see if it helps.

0 Kudos
Message 6 of 23
(3,433 Views)

Please take a step back from your computer and take a deep breath. And then try to explain what you really want to do. Generally trying to talk with a printer, especially a commercial grade laser printer or similar, yourself is not only highly unusual but pretty much impossible. The printer driver system in any modern OS is a huge and very complicated system that you can't just plug into at will. Trying to do so is normally at best unsuccessful and at worst will render your system inoperable.

 

So what printer are you talking about? Is it a laser printer to print normal documents on? Or a label printer? From the driver page you show it seems to be a Huawei Pixlab series printer using a WIA driver, so something like a normal laser printer. Do you understand that trying to talk to such a printer will require you to understand communication protocols such as PLC, PS (PostScript) and possibly other even more complicated things?

 

In general you can not access this printer driver through VISA. Printer drivers are a different USB class than what VISA can handle. VISA is only able to directly talk to USB VCD (Virtual Communication Device aka Virtual COMM Port), and USB-TMC (Test and Measurement Class) devices.

 

Your printer uses an entirely different type of USB class interface  And while you might want to try to use VISA RAW mode to talk to that device, this approach is wrought with lots of problems. Simply generating a VISA Raw device is just the start of your trouble. A device can NOT be accessed by multiple device drivers under Windows, so you would have to disable the Windows printer driver first before you could do that, making the printer totally unavailable to any other Windows application. In addition, since Windows 7 a driver needs to be signed in order for Windows to let it be installed. To sign a driver you need a signing certificate from a globally recognized certification agency (CA). They are not for free but you need to pay a yearly fee to have such a certificate. Since Windows 10 1804 your driver should not only be signed by yourself but actually counter signed by the Windows Hardware Dev Center Dashboard to convince Windows to install it. This also applies to VISA INF style only drivers as it grants the actual VISA device driver full and unfettered access to your device.

 

Then you need to implement the low level USB class interface on top of VISA (if you haven't directly talked to an USB device before on the lowest USB protocol level, expect a few weeks or more for that). And once you have that working , you can start to implement PCL or whatever your printer uses on top of that. This could take anywhere from days to many man months of work to get it right. Are you sure you want to do all this?

 

Most likely you just want to print your VI or a front panel to that printer. In that case you should use the standard Windows printing function instead!

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 7 of 23
(3,426 Views)

Thanks so much your answer , you are correct , it's laser printer, it's get lots of trouble if use the USB raw class, need to disable windows printer driver ,

actually, I need to test this laser printer function with labview, so need to connect printer USB interface and send the command to read and write SN,FW, print,MAC etc information to control it

do you have any suggestion how to communicate with printer use USB interface of labview if don't use VISA USB raw? thanks

0 Kudos
Message 8 of 23
(3,421 Views)

We produce this type printer, so need to test printer function ,We have the printer communication protocol ,so need to read printer information(SN,FW version,MAC,print,copy etc) and to control it,thanks

0 Kudos
Message 9 of 23
(3,419 Views)

Well, that is at least one of many problems solved. Still NI VISA is almost certainly NOT the way to solve this. Writing a USB Raw device driver is almost as much work as writing a real device driver for your operating system. And if you produce this printer, you sure have device driver developers that can create such a device driver and/or give you proprietary information how to access some undisclosed interface in the normal driver, that will allow you to syphon such communication through it.

 

Windows printer drivers normally support a passthrough interface that can be used to access functionality directly. This passthrough interface is however only accessible through Windows API calls (and possibly some .Net wrappers around it). So someone with a full understanding of the official device driver developed for this device should be able to give you the necessary information.

 

Doing that all from LabVIEW directly is however not a feasible solution. It involves calls to the EnumPrinters() Windows API to enumerate your Windows printer drivers and then connect to the specific driver you want, before you can call the ExtEscape() Windows API function to pass data directly to the printer driver. It's a lot of C programming, that while not impossible to replace by all LabVIEW code, is simply very difficult, as it requires actually more knowledge about how a C compiler works than if you would write that code in C and compile a DLL from it to call it in LabVIEW.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 10 of 23
(3,403 Views)