How can I get a GS1 datamatrix code (with separators) to a C# winforms application

380 views Asked by At

I use a barcode scanner to read medecine GS1 datamatrix codes. I need the entire data sequence, including Group Separators to parse the code in order to seek for Application identifiers (AI) and get the data accordingly. The target is a winforms C# application, it will call the NMVS services to check medecines status. Actually i put a TextBox as the target control but its content does not contain the GS anymore.

Thank you for your help

If I manually fill the textbox with 0x1D (ASCII 29) chars as separators, it works like a charm. The GS1 parser finds the AI and I can extract data. If I open Notepad++ with focus on it and scan a code, the special characters are present. I setup my scanner, NETUM C750 model, to map the function keys, so that the separators are included into the buffer.

2

There are 2 answers

0
Jean-marc Blanchet On BEST ANSWER

As Barcode scanner is considered a keyboard, I found out to catch the keypress event, so that I fill a char list.

List<char> charList = new List<char>();

private void textEditCode_KeyPress(object sender, KeyPressEventArgs e)
{
  charList.Add(e.KeyChar);
}
string datamatrix = new string(charList.ToArray()); //charList is filled      by pressing the keys, or when receiving data from the scanner
Aii = gS1.Parse(datamatrix); // Aii = new Dictionary<string, string>(); 

After that, I parse the char list as the GS1 content, and I can call the NMVS service :

string Batch = gS1.GetValue(EGS1AI.Batch);
string ProductCode = gS1.GetValue(EGS1AI.GTIN);
System.DateTime ExpDate = gS1.GetValue(EGS1AI.ExpirationDate);
string SerialNumber = gS1.GetValue(EGS1AI.SerialNumber);
string dat = ExpDate.ToString("yyMMdd");

Log log = new Log(App.LogFolder(), App.AppName);

G110Response response = G110.G110Verify(ProductCode, Batch, dat, 
SerialNumber, log);

then process response

0
Bart White On

I use barcode scanners to read GS1 data for incoming components. Ironically my better scanner (Netum NT-2128BL) drops the field separators while my worse one(Teradata 8100) passes them along. You might try another scanner. My separator is Unicode Character 'LEFT RIGHT ARROW' (U+2194). The separator is called a GS1 FNC1 character. GS1_datamatrix_sample