Microsoft Pos .Net is (almost certainly) the best way to control point of sale peripherals from your .NET retail application. It allows you to easily control receipt and slip printers, barcode scanners, cash drawers, MICR (magnetic ink character recognition), MSR (magnetic swipe reader), line display devices, and more.
Some time ago my boss and I decided we wanted to build Pos .Net drivers for the point of sale application I work on, Ontempo Store. Unfortunately we had trouble finding suitable service objects at the time, and as we only needed to drive a receipt printer and cash drawer so we implemented an alternate solution. Recently we got some new hardware on short-term loan, and it came with OPOS drivers (which are compatible with Pos .Net). We’ve also had better success in finding Pos .Net service objects for our existing hardware, recently and so I spent some time building a new set of drivers while we still had the loan hardware to test with.
This is a first in a series of posts on my experiences with Pos .Net. On the whole, it’s pretty good, but there are a few pitfalls to be aware of (a lot of these aren’t really Pos .Net’s fault, but you have to live with them anyway so I’m blogging about them).
Pos .Net has three really great features;
- It allows you to control many different brands and model of devices in a device independent way… you don’t have to build a separate driver or write different code for each specific peripheral. While OPOS also does this, OPOS implementations are often built using COM components, which are an old technology and not ideal for use for .Net languages if you can help it.
- It has a neat plug and play system that allows automatic detection of (connecting and disconnecting) USB devices, with no additional configuration of the device required to use it.
- If your application is running on a terminal server but your devices are plugged into each local client, Pos .Net can access the devices back across the Remote Desktop connection, allowing your system to operate like a client application with regards to devices.
Pos .Net is the Microsoft implementation of the UPOS (Unified Point Of Service) standard, which is the follow up to the original OPOS standard, but features like the plug and play support have been added specifically by Microsoft as added extras.
In order for Pos .Net to work with a given device you must have either a native .net ‘Service Object’, or a legacy OPOS service object. Service objects are the ‘middleware’ that contain the brand/model specific code for a particular peripheral.
Once you have an appropriate service object (and you can write your own if need be) controlling a device with Pos .Net is very easy. Performance is generally great (although some what dependent on the service object).
If you’re new to Pos .Net and looking to get started I recommend downloading the Pos .Net SDK and looking at it’s samples. It has some good samples for dealing with barcode scanners and building your own service objects. If you want some samples for printers and cash drawers then I recommend downloading the Epson OPOS ADK for .Net. To get that, you’ll need to register at www.epsonexpert.com, and once logged in go to Application Development –> OPOS then scroll to the bottom of the page to find the download links. Even if you’re not using Epson hardware, the Epson samples will work (because Pos .Net is device independent) and they cover most aspects of using the Pos .Net PosPrinter class. There’s also this Microsoft hands on lab which is quite good too.
For Pos .Net resources and links see my earlier post.
If you’re wondering why you should use Pos .Net over other methods (such as using the Win32 print API) for driving printers and cash drawers, here are a few good reasons;
- Universal escape codes… even Epson’s escape codes don’t necessarily work the same on all models, and across different brands there’s even more variation.
- Better status handling and error detection. Detect conditions cover open, paper low, paper out, offline etc.
- Capability reporting, know whether your device can report it’s status, print bitmaps, handle rotation etc.
- Easy and elegant ways to detect/get notified of changes to the cash drawer (so you can close/clear your change window when it’s closed, or provide a warning or alarm if it is open too long).
- Easily and efficiently print to two stations at once (i.e receipt and journal).