Sunday, August 30, 2009

Pos .Net Series, Post #5 – (TPG and Epson) Device Specific Issues

This is the fifth post in a series on my initial experiences with using Microsoft Pos .Net. The first post can be found here.

In my last post I discussed how the UPOS specification, and by extension Pos .Net (and OPOS) are supposed to provide device independence, but fail due to differences in service object implementation. In this post I am going to discuss some of the specific differences I have found with the hardware I have available.

Epson vs. Epson

I had a TM-T88III and a TM-T88IV both of which are Epson printers (the T88III has since died). Neither of these devices supported plug and play even when configured to using an xml file, and must be setup using the Epson SetupPOS program.

When you configure the TM-T88III there is relatively little to configure, except for port names and so on. When configuring the TM-T88IV, however, you get an option to say whether or not bitmaps stored in the printer using the SetBitmap command are stored in NVRAM or0 not. Event though the Epson TM-T88III also has NVRAM and can store and print images, it’s service object doesn’t support this setting. The TPG printer I have also doesn’t appear to have any option to use NVRAM.

There is also no way to determine how this setting is configured via the Pos .Net interfaces. This means you have no idea whether you need to call SetBitmap every time your application starts, or only when the image changes.

Not setting the image (with SetBitmap) often enough could mean your application won’t print images when you expect it to. Setting it too often could cause corruption to the memory or use up all it’s write cycles, depending on the type of memory used, and will cause an unnecessary performance hit to your application anyway.

There’s also a significant performance difference between the OPOS and native Pos .Net drivers from Epson, and sadly the native Pos .Net ones seem to be slower on the Open and Claim methods.

Epson vs. TPG

I also have a TPG A779, and this has distinct differences in implementation to the Epson TM-T88IV.

When calling SetBitmap on the Epson, it appears you can send any bitmap you want and the service object will convert it to the format required by the printer. The TPG printer, however, will throw an exception for any bitmap that isn’t a 1 bit per pixel monochrome bitmap (which is harder to create via a System.Drawing.Image object than you might expect).

Additionally, the SetBitmap method in the Epson service object will throw an exception if the extension of the image file isn’t .bmp, while the TPG one doesn’t seem to have this requirement.

The TPG printer can be setup to use plug and play if you create an appropriate xml file to map the hardware id’s to the service object, but the Epson one cannot because of the additional configuration it requires. That having been said, even the TPG doesn’t work exactly as expected when configured for plug and play, and has some odd issues around the claim functionality if the device is disconnected and reconnected after it has been claimed.

My current code also has issues with the TPG printer when trying to set the alignment for text. The code works perfectly with the Epson TM-T88IV for left, right and centre aligned, but with the TPG all text is left aligned. The TPG printer can print text in the other alignments, as my code has worked with it in the past, but I have changed some thing I can’t figure out that has broken it with the TPG device… this shouldn’t be possible though, it should work with both printers or neither.

The Epson service objects work fine when you are logged into"The TPG service objects throw an exception if the Windows user account is not at least a power user." Windows as a non-administrative user, however the TPG service objects throw an exception on open if the user account is not at least a power user. For most retail environments, even power user is too permissive for most staff, and this can cause you a problem at deployment time.

Also, as an aside, while both printers appear to print very quickly once started the Epson ones take a lot longer to start and stop printing than the TPG ones. I suspect this is because of work done in the service object at print start and end, possibly something to do with opening ports or some such.

These are just the differences I’ve found between three devices and service objects in the same device class. No doubt if I had more devices to test with I would find even more differences.

The worst differences are those where one service object throws an exception when another service object doesn’t. That will usually cause your system to either stop with an unhandled exception, or best case scenario, report the exception to the user and give them the option to retry the print or not… which is useless since reprinting will result in the same error (and possibly an incomplete receipt), and failing that the user is still going to the get error every time they print.

The morale of the story is… even though you’re using Pos .Net or OPOS, always test your system with a specific device and service object before telling a customer to purchase and install it.


  1. yort
    i'm trying to configure an epson tm t88iv to print from a pos application
    when i sent the 'printnormal' or 'checkhealth' methods, everytime i get an 'it is not initialized' exception
    can you help me??
    thanks in advice!

  2. Hi,

    Have you succesfully called the Open and Claim methods ? After you do that, have you set DeviceEnabled = true ?

    You must do these things before you can use the device to print.

    Failing that, use the SetupPOS application installed with the Epson OPOS for .Net ADK to ensure the device is configured for the right port/printer type etc.

  3. hi Yort,
    I have just got an Epson TM-T88IV. I have no knowledge of how to set up my logo to print on top of the receipt. any help would be hugely appreciated.
    you could email me directly if you wish at
    thanks so much

  4. Hi Parv,

    Sorry for the delayed reply, the notification of your email got lost in a backlog in my inbox.

    To answer your question, it depends on whether you're using Pos .Net or not.

    If you're using Pos .Net then you need to call SetLogo and PrintLogo on the POSPrinter object. That is after you've created an instance of the correct printer object, opened, claimed and enabled it (which is all standard Pos .Net stuff explained in the documentation and to some degree in my blog posts on Pos .Net). You need to call SetLogo at least once everytime your application starts, as well as everytime you want to change the logo. The logo is not persisted across runs of your application (actually some Epson Pos .Net drivers have an option for this, but I don't recommend using it since other manufacturers don't). That also assumes you have Pos .Net installed and the Epson drivers (all linked to from my other blog posts).

    If you're not using Pos .Net, then you need to install a standard Windows printer driver for the printer (the Epson Advanced Printer Driver, or ADP available from Epson or on the CD with your printer will do, or you can just use the Generic Text / Only printer driver that comes with Windows). Once that's setup, you need to print escape code strings to the printer. To do that, you need to use the Win32 API to open the printer, start a document, send the string, then close the document and then the printer. The API's you need are (roughly) GetPrinter, OpenPrinter, ClosePrinter, StartDocPrinter, EndDocPrinter, WritePrinter. Unfortunately I don't have any sample code I can publish for this.

    Once you have code working that sends a string to the printer, you need to upload the logo into the printers memory using the TMFLogo application provided by Epson. Once that is done, just send the correct escape code sequence for printing a logo to the printer. Epson publish a document (should be included with the APD driver download) that lists the ESC/P commands. Just send that string to the printer and it will print the logo stored in the printers memory.

    A note on printing logos (as mentioned in some of my posts), the logo image typically needs to be a 1 bit per pixel monochrome bitmap. The Epson stuff will often convert full colour jpg files for you so that will appear to work, but doing this with other printer makes and models will usually break, so I suggest always using an image of that format.

  5. hello sir,
    I am using EPSON TM-T88V receipt printer. along with adk 1.12.3 And i installed software also. All these in running on windows 7 64-bit. i referred this link to write configuration file.

    But still i am getting error when my code hits myprinter.PrintNormal(PrinterStation,String) this method. It Giving error Like "It is not initialized". I tried a lot. But still no results.
    Please suggest me any helpful Answer.

    Thank you in advance

  6. Hi,

    I'm afraid it's been really long time since I used POS .NET and I'm not sure exactly what your problem is. I do recall there being issued in the past with 64 bit systems - can you try a 32 bit one and see if that helps ?

    Also, the EPSON devices require a setup program to be run to configure the devices. The program should be part of the Epson OPOS ADK for .NET. Have you run that app and configured the device correctly ?

    Finally, if you are on a 64 bit system it's possible the paths in the article you linked to are incorrect.- 64 systems have program files and program files (x86) folders. Whichever folder you have used, you may need to use the other one.

    Unfortunately those are the only issues I can think of. You could try posting in the POS .NET forum yourself, there are many talented people there who may be able to help.

    1. Thank you sir, I got solution, its working now. i Had Eposn OPOS ADKk for .NET. But still inwas getting error. after serching in google many times i got solution. The solution is that we need ti set flags that indicate that printer devices has to support on 64 bit os also. so that we need to download CorFlags.exe application. and we have to store it on this path : C:\Program Files\epson\OPOS for .NET\SetupPOS

      And in Command line window we have to set flag that
      C:\Program Files\epson\OPOS for .NET\SetupPOS>CorFlags.exe /32BIT+
      If we run like this EPSON will support 64 bit os also.

      Hope it help full for others.

      Thank you.

    2. Excellent, I'm glad you found a solution and thanks for posting it here to help others in the future. 64 bit has always been a bit of a problem for OPOS and POS .Net so I'm not surprised you had to do additional configuration to make it work, but I've never had that situation so I wasn't able to help more. Sorry.