I have a ticket printer I am trying to send raw print commands to,
I am currently sending the commands by pinvoke to winspool.drv and calling WritePrinter. This is working for most of the commands I am sending, but I cannot get feedback from the printer this way (for example, the printer has a barcode reader on it, I can send them command read barcode but I cannot receive the data back as it is stopped by the windows spooler).
Is there a way to open a USB port and send a byte[] of commands in C#?
Many Thanks
Shaun
You can exchange data over USB in a similar manner as you read/write to a file. Here's an interesting article on that topic.
Using the windows printer driver has some advantages though. Are you sure you want to do this yourself?
Related
I have this system ive been working on where in the user has to print in a bluetooth thermal printer after every transaction. Can someone give me a source reference or a sample code for this particular function? he bluetooth printer brand is just generic, most of the sources in the website all have brands particularly Zebra. But i wont be using that since it might be different. any help would be nice. Thanks!
Please see inTheHand (or 32feet.net) for a framework using Bluetooth.
You need to discover and connect to the BT printer and then use a socket stream to send print commands.
You may also use RegisterDevice with the BT mAC address and then use the provided serial COM port to communicate with the printer.
To be more detailed you need to describe your needs in more details and shorter english sentences.
I have a device which sends data by com port on my computer.
I know how to simulate it, but the controller must be plugged in to simulate sending data (using Proteus)
Is it possible to simulate the com port sending data without having any external device plugged in?
For example: I want to write a C# program which opens the com port and waits for data, and another c# program which writes data on the same port.
The best way to do this is to use a software COM port emulator. I use com0com :
Null-modem emulator
This provides virtual NM COM port pairs on the system (ie: what is output to one is input to the other and vice-versa). The devices show up in Device Manager just like a real COM port so you interact with them in C# as though they were real hardware devices.
For simplicity's sake, get yourself a com port or null modem emulator. You'll get very far off track, and maybe waste a lot of time, trying to do this yourself.
See this post, too:
Faking an RS232 Serial Port
The office recently bought a Minolta printer that can also fax. I need to send faxes from an input from sharepoint. The problem doesnt rely in the connection between the fax sending software and sharepoint but rather in trying to send the right data to the fax.
Minolta created drivers for sending faxes, here is a screenshot of this.
It is accessed by trying to print and then selecting the minolta bizhub as a fax.
I tried to use FAXCOMLib as connect to it has if it was a fax server but i got en error while trying to connect. I called the support service of minolta and they have no idea how to achieve this.
FAXCOMLib is usable as a Fax driver on Windows computers without an external device. The Fax logic is built into the software. All you need in the computer is a RJ11 port, a telephone port.
I'd say if you want to programmatically send a fax, just use FaxComLib and don't worry about the external fax-capable printer. And using FaxComLib from .NET/C# is prety straightforward.
There may also be a way to programmatically invoke a printer driver; in fact I know you can do this in WCF. On the other hand, that wouldn't be through FaxComLib; it would likely be through some other interface, or at the last resort, it would be through the UI Automation classes in Windows.
I developed a c# application which is read the device through serial port. I achieve write to it but not properly. Now my sceneraio is the formatting the device through serial port automatically. First of all i have to send a keypress when the device wait for it(when i see in the richtextbox "hit any key to stop autoboot"). How can I do that? I achieve this with writing to the serial port (serialport1.write("xxxx\r\n")) when i get the hit message in the richtextbox but i think it is not a good idea to fallow the richtextbox. Can you suggest any other way?
My important question is let's think about we handle the hit message and stop autobooting. Now we have to send commands to the device for formating. For example first one is fdisk command, second one is ext3format and third one is fatformat. These commands takes time when you send these to the device. how can i sync my commands and the device, because when i trying to do that i got some problems. The problem is i have to send other command after the first command sent and device finished its job. I can only fallow the richtextbox and according to the output i m trying to send the fallowing commands. Can you suggest any other way? Do i have to fallow richtextbox outputs, is there any other way to understand the device finishes its job after sending commands?
THANK YOU
Apparently, you are using a remote console into the device via a serial port connection (telnet?), and the device is using linux. so basically you are simulating user input and output in your program.
You need to recognize the output the device is sending byte by byte, first of all. Do not focus on the "richtextbox", you are only using that to display what you get from the device.
You need to process the serial data as it comes in and look for patterns of data that you recognize (for example, the result code from the format command, the text sent over when the command prompt is visible again, etc).
When it says "hit any key", you need to send a character over the serial port that the device recognizes.
you also need to know which terminal mode emulation (google this) the device is expecting you to use, because this affects how you should format codes sent to the device and how you should interpret characters you receive from it.
What you want to do is straightforward, basically you are writing an automated remote terminal for the device, but it does require some reading on your part, and stop focusing on what a textbox displays and start focusing on the data bytes going into and out of your device.
I'd like to write a simple C# app to collect the output of a Zebra printer's magnetic card reader. (Model RW420) My only interface to the device is USB. The CPCL language specifies an MCR command for this purpose, but I cannot figure out how to issue this command to the printer via .NET. Neither the online documentation nor support staff can tell me. Does anyone have an idea?
You need to write native code in order to read back from USB (using pInvoke). You need to find the usb device path with Zebra's vendor ID in it. You would pass this device path to CreateFile
see: MSDN Create File
Please note that the RW420 manual (page 29) states:
Note that the RW series USB port is
intended for setup and maintenance of
the printer only and not for permanent
communications use to a terminal.
We have networked Zebra printers here, so my best guess is that if you can communicate over USB, in the way you intend, there will be a serial (or parallel) port exposed to talk to given by Zebra's USB driver. Start by looking in the Device Manager in Windows. If this is the case, you should be able to do standard serial communications to the printer, and follow the CPCL manual for querying the magstripe reader (see page 10-23 of the CPCL manual)