LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the printer of USB interface

Thanks, Developer only provide the communication protocol, but no any passthrough interface to access it, can we use a module of USB transfer to RS232? thanks

 

so you mean need the printer driver developer to provide window API? thanks

0 Kudos
Message 11 of 23
(1,367 Views)

But why the C# can communicate with the printer directly not install additional driver except windows printer driver?thanks

0 Kudos
Message 12 of 23
(1,365 Views)

I work with Zebra printers quite a bit and what we have done is to write our own driver package as a dll which utilizes the low level Windows USB functions. Effectively we created our own driver. You will need to do the same thing in order to communicate with your printer.



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 13 of 23
(1,358 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

 

But why the C# can communicate with the printer directly not install additional driver except windows printer driver?

 

You provided inconsistent answer about C#.  Please explain.

Although the driver is  not Windows certified, if your company made it, you should install it.

 

If C# CAN communicate with the printer, we can help you "translate" it to LabVIEW.

Or, you can build the C# code into a .net assembly, we can help you call it in LabVIEW.

 

George Zou
0 Kudos
Message 14 of 23
(1,350 Views)

@zou wrote:

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

 

But why the C# can communicate with the printer directly not install additional driver except windows printer driver?

 

You provided inconsistent answer about C#.  Please explain.

Although the driver is  not Windows certified, if your company made it, you should install it.

 

If C# CAN communicate with the printer, we can help you "translate" it to LabVIEW.

Or, you can build the C# code into a .net assembly, we can help you call it in LabVIEW.

 


The driver may not worked. Our own internal driver we had created stopped working when we switched to Windows 10. We ultimately had to create the DLL which we created to give us USB support. Anything created using the driver wizard will be rejected by Windows unless it is signed.



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 15 of 23
(1,344 Views)

@Lchjxlz wrote:

But why the C# can communicate with the printer directly not install additional driver except windows printer driver?thanks


Then show us the C# code that can do that. It probably consists of accessing the aforementioned ExtEscape() function but without more detailed information from you, we can keep guessing and tossing ifs and whens in the room until the hell freezes over.

 

I showed a possible method which I have used in the past with other devices. It may or may not work with your specific device but you are the only person in this thread who can make an educated guess. And without more detailed information other than it is a printer and I somehow have to access its low level interface directly, we can't help you more.

 

The main fact so far is that using the VISA USB Raw interface is almost certainly barking up the wrong tree. It almost always is nowadays, by the way. Back in the late 90ies when VISA was introduced it seemed like a great idea to support that in VISA. But OS development and security requirements have changed significantly since then. Nowadays it is nothing more than a liability in NI VISA that should never have been released.

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

OK,thank you, I try to get the C# code which communicate with printer, and how to connecting ..I'm not sure can get it,thanks

0 Kudos
Message 17 of 23
(1,322 Views)

If your printer driver is a GDI based driver you may also be able to use this method:

 

https://docs.microsoft.com/en-us/windows/win32/printdocs/sending-data-directly-to-a-printer

 

The DocInfo.pDatatype = (LPTSTR)_T("RAW"); is the thing that tells the spooler to pass the data directly to the printer driver, most likely through the aforementioned ExtEscape() call. It's a higher level method but it all depends on your printer and its driver and what exactly you need to do with it to pass it directly your commands.

 

Converting this into LabVIEW VIs using the Call Library Node isn't that difficult but definitely some work.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 18 of 23
(1,305 Views)

Yes, I'm sure it's GDI based driver printer,  I don't know how to use the GDI to send the command, windows GDI only print paper, can you help to show me the demo? how to use the GDI to control printer and send the command?thanks

0 Kudos
Message 19 of 23
(1,279 Views)

In the MSDN link I posted there is a sample code that shows what you need to do. It is C code and that means you might have to experiment a bit with C compilers. With some extra work you can also call these functions from LabVIEW through the Call Library Node but that is a bit more involved and complicated and I have the feeling it may be a bit a steep step to just jump into this.

 

We still have no idea what you exactly need to do and how you can reach your printer exactly through the driver interface to send it the commands you want to send. So it is still up to you to verify, test and understand what needs to be done. We can only pose options that might or might not work for your specific printer. All the rest is up to you.

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