Hello lovely community!
I am using a HP 2x20 Integrated Display with HP RP 7800 Retail System and decided to play with it and write some small programs for it to learn coding.
The sample tool provided with the SDK works perfectly.
First I wrote a simple program using Microsoft.IO.Ports and simple functions like this:
SerialPort COM3 = new SerialPort("COM3", 9600, Parity.None, 8);
COM3.Open();
COM3.Write(Clear); // string Clear = "\x1B\x40" - hex value of a control character for the display
COM3.Write("Hello community");
It actually worked okay but I didnt manage to apply some of the control characters provided from HP manual and therefore I decided to move on to POS for .NET.
So now straight to the point. I wrote a C# program with basic functionality and buttons.
using Microsoft.PointOfService;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
LineDisplay lineDisplay;
PosExplorer explorer;
public Form1()
{
InitializeComponent();
try
{
explorer = new PosExplorer(this);
DeviceCollection devColl = explorer.GetDevices(DeviceType.LineDisplay); // is this line the problem?
//DeviceCollection devColl = explorer.GetDevice("LineDisplay", "HPLCM220Display"); // this one shows errors so I couldnt use it instead of the line above
if (devColl == null || devColl.Count <= 0)
{
MessageBox.Show("Device not found");
return;
}
lineDisplay = (LineDisplay)explorer.CreateInstance(devColl[0]);
lineDisplay.Open();
lineDisplay.Claim(10000);
lineDisplay.DeviceEnabled = true;
lineDisplay.DisplayText("Hello World.!");
lineDisplay.DisplayTextAt(1, 0, "Hey MSDN");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
private void btn_Clear_Click(object sender, EventArgs e)
{
lineDisplay.ClearText();
}
private void btn_SendText_Click(object sender, EventArgs e)
{
lineDisplay.DisplayText(textBox1.Text);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//this.textBox1.TextChanged -= textBox1_TextChanged;
}
}
}
And when I launch it it shows me a LineDisplay Simulator which can be cleared and the text can be altered, but the real display doesnt even show anything or gets cleared.
So the question is: how do I make my app show text on my display instead of the simulator. Debugging doesnt really help me. What I noticed is that in AUTOS it shows Microsoft.PointOfService.DeviceSimulators.LineDisplaySimulator in LineDisplay Value so it somehow usess DeviceSimulators but I dont know how and why..
I used POS for .net documentation but sadly didnt succeed https://msdn.microsoft.com/en-us/library/microsoft.pointofservice.linedisplay(v=winembedded.11).aspx
I assume its somehow around - Device Collection line
DeviceCollection devColl = explorer.GetDevices(DeviceType.LineDisplay);
//DeviceCollection devColl = explorer.GetDevice("LineDisplay", "HPLCM220Display");
but if i use the commented line instead of the first une it shows the error:
Error CS0029 Cannot implicitly convert type 'Microsoft.PointOfService.DeviceInfo' to 'Microsoft.PointOfService.DeviceCollection' WindowsFormsApplication14 C:\Users\admin\Documents\Visual Studio 2015\Projects\WindowsFormsApplication14\WindowsFormsApplication14\Form1.cs 27 Active
I tried to look for a solution to CS0029 but unfortunately I failed at finding any connection to my problem.
Ive never programmed anything so I am a newbie with shitty code but im striving to learn so please if anybody is so kind to shed some light onto this issue I would be very thankful :)
Your machine may have a number of point-of-sale devices (line displays, POS printers, barcode scanners, etc.) attached to it. All these devices are grouped into so-called classes (namely, LineDisplay, PosPrinter, Scanner, etc.) A system may have several devices of one class attached. For example, it is quite common to have two barcode scanners on a regular POS station - a flatbed one to scan normal items and handheld for oversized items.
The
PosExplorer
class allows you to enumerate all installed POS devices and instantiate selected ones.The
explorer.GetDevices(DeviceType.LineDisplay)
returns descriptors of all line displays installed on your system. The descriptors are returned in a collection of typeDeviceCollection
. Each item in this collection hasDeviceInfo
type. You may iterate through this collection, check items properties and pick up ones for further manipulation.The
explorer.GetDevice("LineDisplay", "HPLCM220Display")
returns descriptor of the exact device by class and name ("HPLCM220Display"
line display in your case). The returned descriptor has typeDeviceInfo
. That's why you had a compilation error - you wouldn't have it if you used the correct classPlease note, the second parameter to
GetDevice()
has to be a logical name or an alias of the device. You can list these names by the following command:or (on x64 systems):
After you have found a descriptor (
DeviceInfo
) of a desired device you may use it to instantiate the device object which provides you with actual interface to control the device:So your code may look like this:
Answering the question of
devColl[0]
anddevColl[2]
in your comments:Your system clearly has at least three line displays installed. The first one is a virtual display device installed with POS for .NET SDK. You accessed it via the
devColl[0]
. Can't say anything about the second. And the third one is your real HP 2x20 Integrated Display which you accessed with thedevColl[2]
descriptor. You may list all the devices with theposdm
command as I've shown above.