I have a nu开发者_如何学JAVAmber of POS printers and need to automatically recognize the type of the printer. I need do it without using POS.NET or printer drivers. How can I do that?
There is no standard way to recognize printers like this.
It's difficult or impossible in the general case (printers may use different COM port configuration - baud rate etc - and different protocols). It's complicated further by the fact that many printers can be configured in different ways by DIP switches or by sending commands.
If you have a reasonably small number of printers to recognize, for all of which you know the correct COM port configuration, you could experiment with sending commands / reading responses to find combinations that allow you to uniquely identify printers among the ones you support.
Many POS printers support variants of the ESC/POS protocol, and responses to status requests (look at each printer's manual) may have differences that enable you to make the distinction.
Of course you will then have an ongoing maintenance headache - each time you want to support a new printer model, you are going to have to again try to find some distinguishing characteristic and update your recognition software.
Take a look at this project which supports a lot of POS printers in the source codes:
http://dev.cyberplat.com/redmine/repositories/browse/pt/2.0/src/Modules/Devices/Printers/Printers/Implementation1/src
In the implementation of each printer, you can find recognition subroutine for auto-searching the connected printers.
Just did a quick google search, maybe you can just list the printers available, an example here: http://www.c-sharpcorner.com/UploadFile/mahesh/printerslisting06072007092859AM/printerslisting.aspx
and here:
How to get Printer Info in .NET?
Not sure if this just lists the installed printers or the ones online?
精彩评论