Current C# POS.NET Printing Issue:
PrintNormal() Throws Exception = 'It is not initialized'
CheckHealth = 'It is not initialized'
'It is not initialized' exception when Printing to Epson TM-T88IV
Using POS for .NET 1.12 and the Epson OPOS ADK for .NET (v1.11.9) service-objects
Successfully able to Open, Claim and Set the DeviceEnabled-true for PosPrinter
Issue sending anything to the printer after this
PrintNormal() results in a 'It is not initialized' exception being thrown.
CheckHealth Utility that came with the Epson OPOS ADK results in exactly the same error. When using PrintNormal(PrinterStation.Receipt the exception is 'The specified station is not mounted."
printer prints fine using direct parallel
printer itself prints
How can we not throw the exemption with the message - 'It is not initialized'?
void K8POSPrint()
{
/// <summary>
/// PosPrinter object
/// </summary>
PosPrinter m_Printer = null;
try
{
//Use a Logical Device Name which has been set on the SetupPOS.
string strLogicalName = "PosPrinter";
try
{
//Create PosExplorer
PosExplorer posExplorer = new PosExplorer();
DeviceInfo deviceInfo = null;
try
{
// Device Info is not null when the printer has the logical name
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
}
catch (Exception ExDevice)
{
}
//Open the device
m_Printer.Open();
//Get the exclusive control right for the opened device. Then the device is disable from other application.
m_Printer.Claim(1000);
//Enable the device.
m_Printer.DeviceEnabled = true;
// ////CheckHealth.
//m_Printer.CheckHealth(Microsoft.PointOfService.HealthCheckLevel.Interactive);
// //As using the PrintNormal method, send strings to a printer, and print it [\n] is the standard code for starting a new line.
/// Current Issue Next Line thows an exception - 'It is not initialized'
m_Printer.PrintNormal(PrinterStation.Receipt, "Hey Now OPOS for .NET\n");
// the next line would throw the exception 'The specified station is not mounted.'
// m_Printer.PrintNormal(PrinterStation.Slip,"Hey Now Slip OPOS.NET\n");
}
catch (PosControlException)
{
}
}
catch (Exception ex)
{
}
}
Additional Information:
Programs installed while attempting to print on the pos printer are:
1. Installed APD4 Printer Driver Epson TI88IV
APD_412EWM.exe
https://www.epsonexpert.com/ee/techRes/index.htm?ProductId=570
After this set in control panel printers I can select the printer's properties & print a test to the printer successfully.
2. Installed Microsoft POS.NET 1.12
POSfor.NET.msi
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=eaae202a-0fcc-406a-8fde-35713d7841ca
3. Installed Epson OPOS ADK v2.67
ADK267ER4.exe
https://www.epsonexpert.com/ee/appDev/appDevOPOS.htm
4. Installed EPSON OPOS ADK for .NET 1.11.8
OPOSN 1 11 18.exe
https://www.epsonexpert.com/ee/appDev/appDevOPOS.htm
5. Installed OPOS Common Control Objects 1.13.001
OPOS_CCOs_1.13.001.msi
http://monroecs.com/oposccos_current.htm
6. SetupPOS - Added device & Logical Name
7. Check Health still throws the errors
It is not initialized
OPOS_E_ILLEGAL 10007 (0x00002717)
The problem might not be software, but hardware. I saw a similar question (at http://social.msdn.microsoft.com/Forums/vstudio/en-US/446fd4cc-db6b-4822-b3c8-7d9a98bf7eb4/it-is-not-initialized-when-trying-to-printnormal?forum=posfordotnet), where the developer was using an extension cable which was not parallel. As soon as he connected the parallel cable directly to the printer (without the extension cable), his software worked. This was after he called Epson and ordered a newer printer, because they told him his original printer was not compatible with .NET, so that could also be your problem.
I had the same error "It is not initialized" on brand new Epson TM-T88VI.
The printer came with IDN Card and default the ethernet card was partially blocked. You can use the ethernet card to connect to "Epson Net Config", but it did not work when you try to print by OPOS ADK for NET.
The solution was to set switches on IDN Card as:
DS1
DS2
DS3
DS4
DS5
DS6
DS7
OFF
OFF
OFF
OFF
ON
ON
ON
Make sure Power OFF when you changing the switches.
Related
I would like to use a barcode scanner with Windows 10 (Build 15063) via the Windows.Devices.PointOfService namespace. The scanner is a Datalogic Quickscan QD2430 and I tried with all RS-232 and Keyboard mode.
I used the official sample application https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BarcodeScanner with no luck. It can detect a device but it's definitely the in-built webcam (HP laptop).
I tried to modify the source, the DeviceHelpers's GetFirstDeviceAsync function https://github.com/Microsoft/Windows-universal-samples/blob/master/SharedContent/cs/DeviceHelpers.cs.
The DeviceInformation.FindAllAsync also returns only the camera's info as result.
string selector = BarcodeScanner.GetDeviceSelector(PosConnectionTypes.All);
DeviceInformation.FindAllAsync(selector);
It returns nothing.
DeviceInformation.FindAllAsync(DeviceClass.ImageScanner);
It returns every connected and I think the previously connected but currently offline devices too. I tried to filter the scanner by name. There was a lot filterd result too, but the convertAsync function returned null for all excepts one, it thrown an Exception "A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)".
DeviceInformationCollection infos = await DeviceInformation.FindAllAsync(DeviceClass.All);
foreach(DeviceInformation info in infos)
{
if (info.Name.ToUpper().Contains("BARCODE"))
{
T scanner = await convertAsync(info.Id);
if (scanner != null)
{
return scanner;
}
}
}
Datalogic Quickscan QD2430 is not in the list of devices supported by Windows.Devices.PointOfService.
Ask Datalogic to provide a device driver that supports Windows.Devices.PointOfService, or change the scanner to the one described in the supported list.
Alternatively, create your own device driver according to the Point of Service (POS) of Windows Driver Kit.
I am working with Epson Thermal printer and Cash Drawer. Cash Drawer is connected with the printer. Reference to http://keyhut.com/popopen.htm, the code to kick cash drawer is 27,112,0,50,250. I tried to send this code to printer but nothing happens. I used POS for .NET and the printer is registed in SetupPos.
Here is my code:
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
m_Printer.Open();
m_Printer.Claim(1000);
m_Printer.DeviceEnabled = true;
//command = "ESC|p|0|25|251";
command = "\x1B|\x70|\x00|\x19|\xFB";
m_Printer.PrintImmediate(PrinterStation.Receipt, command);
//m_Printer.CutPaper(100);
m_Printer.DeviceEnabled = false;
m_Printer.Release();
m_Printer.Close();
Print text is ok, but send code is not working. What can I do? Thanks.
POS for.NET(UnifiedPOS) specification does not support CashDrawer opening by the PrintNormal()/PrintImmediate() method of POSPrinter device.
Since there is a independent CashDrawer device associated with the POSPrinter device, please open() the corresponding device as a CashDrawer and open the drawer with the OpenDrawer() method.
However, depending on the vendor, there is a possibility of supporting usage like you.
I do not have information on whether EPSON POSPrinter supports such usage or not.
Please ask EPSON or your distributor whether or not you can use such a way.
In addition:
Instead of POS for.NET, there is a way to install and use a device driver as a regular Windows Printer.
Some vendors offer Windows Printer Driver for receipt printers and also support paper cutting and drawer opening functions.
In EPSON, it is provided under the name Advanced Printer Driver.
The questioner seems to have solved the problem using this.
However, this device driver is often used exclusively with POS for.NET/OPOS/JavaPOS, and when printing, it is necessary to use Windows standard printing API.
The third code from open drawer kick code "ESC|p|0|25|251" to send is actually a symbol to control cash drawer 1 or 2, which is using '0' or '1'. The 0 or 1 symbol in the ASCII table is mapped to decimal 48 or 49. So you need to use the Hex x30 or x31 not x00.
Just to add more info, the forth and the fifth code are the time when the signal kick is ON or OFF by sending decimal (value between 0 to 255) * 2ms.
I hope this solve the problem if you still want to use the cash drawer kick code and attach the device to the printer.
I'm trying to pair from a Universal Windows C# app to a Bluetooth - Serial converter, without user interaction.
Development is in Visual Studio 2015 under Windows 10 Pro, but app is intended to run in any Windows 10 based device with a Bluetooth adapter.
For security reasons, BT-serial converter isn't discoverable and is protected by a pin, so I'm not able to perform any enumeration procedure to detect and pair it.
My application only knows BT address (MAC) and PIN's device (Also it knows friendly Bluetooth name, but I never used it).
Previously I'd been able to perform this task under Windows Mobile 6 Pocket PC, using Windows Mobile SDK and C++, but unfortunately code isn't portable to Universal Windows Platform.
Playing with MS samples for Universal Windows(https://github.com/Microsoft/Windows-universal-samples) I achieved to write a code that achieves to pair device, creating from strings some objects that in source sample are derived from enumeration process.
But it only works if device is visible. This is the code:
using System;
using Windows.UI.Xaml.Controls;
using Windows.Networking;
using Windows.Devices.Enumeration;
using Windows.Devices.Bluetooth;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace UWPBTTest
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
DoPairing();
}
async public void DoPairing()
{
UInt64 targetMAC = 32217180653; //target MAC in decimal, this number corresponds to my device (00:07:80:4b:29:ed)
BluetoothDevice btDev = await BluetoothDevice.FromBluetoothAddressAsync(targetMAC); //We create target BT device object, here app throws 0x80070002 exception
DeviceInformation infDev = btDev.DeviceInformation; //We need this aux object to perform pairing
DevicePairingKinds ceremoniesSelected = DevicePairingKinds.ConfirmOnly | DevicePairingKinds.ProvidePin; //Only confirm pairing, we'll provide PIN from app
DevicePairingProtectionLevel protectionLevel = Windows.Devices.Enumeration.DevicePairingProtectionLevel.Encryption; //Encrypted connection
DeviceInformationCustomPairing customPairing = infDev.Pairing.Custom; //Our app takes control of pairing, not OS
customPairing.PairingRequested += PairingRequestedHandler; //Our pairing request handler
DevicePairingResult result = await customPairing.PairAsync(ceremoniesSelected, protectionLevel); //launc pairing
customPairing.PairingRequested -= PairingRequestedHandler;
if ((result.Status == DevicePairingResultStatus.Paired) || (result.Status == DevicePairingResultStatus.AlreadyPaired))
{
//success, now we are able to open a socket
}
else
{
//pairing failed
}
}
//Adapted from https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/DeviceEnumerationAndPairing , scenario 9
private async void PairingRequestedHandler(
DeviceInformationCustomPairing sender,
DevicePairingRequestedEventArgs args)
{
switch (args.PairingKind)
{
case DevicePairingKinds.ConfirmOnly:
// Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile
// If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation.
args.Accept();
break;
case DevicePairingKinds.ProvidePin:
// As function must be asyn, we simulate a delay of 1 second on GetPinAsync
var collectPinDeferral = args.GetDeferral();
string pin = "1234"; //BT converter pin, currently is "1234" for testing purposes
args.Accept(pin);
collectPinDeferral.Complete();
break;
}
}
}
}
This prototype app uses a blank form, as all data are hardcoded.
Also in Package.appxmanifest -> Capabilities, I checked all fields to discard any permission lack.
Currently this code only can perform pairing operation if BT-serial converter is visible.
If BT device isn't visible, BluetoothDevice.FromBluetoothAddressAsync throws an exception (Resource not found: 0x80070002), instead of creating the BluetoothDevice object.
Is as if Windows "needed" to know something of BT device in order to perform operation, I suspect that when I call FromBluetoothAddressAsync, OS internally lists all devices in system (this includes detected BT devices in range) looking for and item with given address.
I've been looking for other methods to perform mac-based pairing against hidden bt devices, but without success (maybe some type of "pre-pairing"? I didn't find anything)
Thanks.
A line similar to the following threw the above exception:
PrintServer ps = new PrintServer(#"\\prntsrv");
When I use "Run..." on Windows the address above does work and take me to the list of print jobs so why does the line of code not work?
Apparently, the address \\prntsrv was a DNS alias to \\prntserv and the PrintServer constructor was unable to deal with it. To get around this issue I used the following code (I could also use just the code in the catch block instead and it would work, but preferred not to):
try
{
// Create object to monitor the printer queue
PrintServer printServer = new PrintServer(serverPath);
mPrintQueue = printServer.GetPrintQueue(printerName);
}
catch (PrintServerException ex)
{
// If the problem might be creating the server because the name is an alias
if (ex.Message.Contains("printer name is invalid."))
{
string actualServerHostname = "\\\\" + Dns.GetHostEntry(serverPath.TrimStart('\\')).HostName;
// Create object to monitor the printer queue
PrintServer printServer = new PrintServer(actualServerHostname);
mPrintQueue = printServer.GetPrintQueue(printerName);
// Write to log about the use of a different address
}
else
{
throw;
}
}
hey i was facing similar issue, this is what i observed and made following changes, just try and let me know.
This issue was occuring due to windows feature/role "Print and Document service" is missing on the system. This role is required for managing multiple printers or print servers and migrating printers to and from other windows servers.
To add the role Go To Control Panel->Turn windows feature on or off->click on check box "Print and Document Service"->install.
See with network administrator for installing this rule if you unable to add it.
After adding the role you can able to create print server object and get the all the printqueues on respective server.
I am using POS for .Net framework version 1.12 for one of my project.
Microsoft POS for .NET is a class library that is part of Microsoft Windows Embedded for Point of Service.
http://msdn.microsoft.com/en-us/library/ms828083%28v=winembedded.10%29.aspx
private PosPrinter GetReceiptPrinter()
{
PosExplorer posExplorer = new PosExplorer(this);
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
}
above is the sample code for find the printer. Now my issue is that POS is not able to detect the printer but only open simulator with data when i run my application.
can anyone please help me ?
I had developed an application for a POS running Windows CE as the operating System but for that POS, the manufacturer provided a custom dll for invoking the operations of the printer which I consumed in my C# code. Check with the POS manufacturer and see if they are providing custom dll for the same.
Your line of code
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
will return the default or first PosPrinter found, which in your case looks like it is the simulator.
You need to either (1) Iterate over the collection of printers and somehow select the one you want. i.e.
foreach (DeviceInfo deviceInfo in explorer.GetDevices(DeviceType.PosPrinter))
{
if (isThisThePrinterIWant(deviceInfo)) // user defined function (maybe lookup saved preference file)
{
return (PosPrinter)posExplorer.CreateInstance(deviceInfo );
}
} // Note: GetDevices() not GetDevice()
or (2) Set a logical name for your printer (using software that came with your printer, or the POSDM utility included with Pos for .Net SDK) and change the above line to
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "madeUpLogicalName");
or (3) Simply set the desired printer as the default printer, and leave your code the way it is.