1

Summary of the problem

I want to decode the FNC1 codes in GS1-128 barcode in flutter.

We know the GS1-128 structure is the following:

enter image description here

and GS1-128 uses application identifiers to describe information contained in a barcode, in above image we can see I use 420 routing aplication identifier followed by rounting information, when the information followed by the identifier code is variable we use FNC1 separator.

enter image description here

Goal

I need to know where is the FNC1 code in order to know where a new aplication identifier starts.

What I have done

I'm using barcode_scan** library and my code is the following:

  ScanOptions options = ScanOptions(
    useCamera: -1,
  );
  ScanResult result = await BarcodeScanner.scan(options: options);
  print(result.rawContent);

What I get is 420 123456789 92 123 912345678 1234567 1 what I expect is 420 123456789{FNC1}92 123 912345678 1234567 1

**https://pub.dev/packages/barcode_scan

Terry Burton
  • 2,801
  • 1
  • 29
  • 41
Julian Solarte
  • 555
  • 6
  • 29
  • Doesn't Flutter itself have a barcode recognition function? You will need to use some library for that, what are you trying to use? How do you use it and when do you want to get the data? Please add such information. – kunif May 06 '20 at 03:36
  • I'm sorry I just updated it. Thanks for the comment – Julian Solarte May 06 '20 at 15:05
  • Please do not simply print `result.rawContent` as a character string, but convert it to a hexadecimal character string as binary data and check the value. `FNC1` may not be a normal printable character. Or is there an option in Zxing or ZBar used by the library as to what format to notify such data? – kunif May 06 '20 at 15:39
  • For example, these sources deal with FNC1. It seems that the first FNC1 is the type of barcode, and the FNC1 in the middle is notified by 0x1D. [zxing/core/src/main/java/com/google/zxing/oned/Code128Reader.java](https://github.com/zxing/zxing/blob/0cf3b9be71680f50c90a71ca26ce0d33664b0dd6/core/src/main/java/com/google/zxing/oned/Code128Reader.java), [ZBar/zbar/decoder/code128.c](https://github.com/ZBar/ZBar/blob/854a5d97059e395807091ac4d80c53f7968abb8f/zbar/decoder/code128.c) – kunif May 06 '20 at 16:57
  • I know well FNC1 is decoded in different way and it is up to the library, I already do what you told me, but when I convert it to ASCII it returns the same numbers, and if I convert it to HEX it returns non sense text... Here is my HEX text https://textuploader.com/1ca6p – Julian Solarte May 06 '20 at 20:56
  • This seems to be converting twice from a character to a decimal string and a decimal string to a hexadecimal string. The data shown has been converted to `415770999802139680200042997299390000000863009620200504`. However, it seems that the data corresponding to FNC1 is not included. – kunif May 06 '20 at 23:04
  • The [rawContent](https://pub.dev/documentation/barcode_scan/latest/model_scan_result/ScanResult/rawContent.html) of flutter's barcode_scan library is a string attribute, and the raw data in zxing's Result is a byte array([getRawBytes()](https://zxing.github.io/zxing/apidocs/com/google/zxing/Result.html#getRawBytes--)), so it's possible that somewhere there is conversion and the data is missing. Please ask the library author or make a request. – kunif May 07 '20 at 04:02
  • I got the raw bytes using zxing...what's should I do now? – Julian Solarte May 08 '20 at 13:45
  • You should confirm whether FNC1 is notified, and parse by referring to or applying such articles and libraries. [Extracting information from a scanned GS1-type barcode](https://stackoverflow.com/q/31738539/9014308), [PeterBrockfeld/BarcodeParser](https://github.com/PeterBrockfeld/BarcodeParser), [CODE 128 and GS1-128](https://www.keyence.com/ss/products/auto_id/barcode_lecture/basic/code128/) – kunif May 08 '20 at 14:44
  • Since this article was recently written, it is a different environment, but it may be helpful. [How to decode EAN128 barcode with zxing barcode scanning library](https://stackoverflow.com/q/61749317/9014308) – kunif May 12 '20 at 14:17

1 Answers1

0

The barcode_scan plugin seems to have been discontinued. I recommend using flutter_zxing - a port of the zxing library. It should have suppport for GS1-128. FNC1 will have a symbology ID of ]C1 as mentioned in this thread.

Omatt
  • 8,564
  • 2
  • 42
  • 144