Menu

#9 Barcodes are not readable

1.0
closed
nobody
None
2020-04-22
2020-03-03
No

The following barcodes are not readable ZXing and Scanner

[01]04610044273054[21]g2gsiKr,RFeBP[91]8029[92]2pCgkX8afzBWSyXmjg9T+z5cpVqo7VltiIwbTHAv2T0+BfRaCcmul5dVAzU9C2pmNyC041qMxpbsXAXhual/LA==

[01]04610044273054[21]g2gsiKr,RFeBP[91]8029[92]2pCgkX8afzBWSyXmjg9T+z5cpVqo7VltiIwbTHAv2T0+BfRaCcmul5dVAzU9C2pmNyC041qMxpbsXAXhual/LA==

1 Attachments

Discussion

  • Sergey Smirnov

    Sergey Smirnov - 2020-03-03

    3-line barcode
    [01]04610044273252[21]LRFX)k<C7ApWJ[91]003A[92]
    K8rNAqdvjmdxsmCVuj3FhaoNzQuq7Uff0sHXfz1TT/
    doiMaGQqNF+VPwMvwVbm1fxjzuDt6jxLCcc8o/tqbEDA==

    other barcode
    [01]04610044273054[21]g2gsiKr,RFeBP[91]8029[92]
    2pCgkX8afzBWSyXmjg9T+z5cpVqo7VltiIwbTHAv2T0
    +BfRaCcmul5dVAzU9C2pmNyC041qMxpbsXAXhual/LA==

     
  • Sergey Smirnov

    Sergey Smirnov - 2020-03-03

    Old DataMatrixEncoder.cs generate good barcode.

     

    Last edit: Sergey Smirnov 2020-03-03
  • Sergey Smirnov

    Sergey Smirnov - 2020-03-03

    Zxingb Error 0
    void ProcessRemainingData(
    ....
    case EDIFACT:
    ....
    if (dataBytesLeft == 1)
    {
    dataStream.Add((byte)((processBuffer[0] << 2) + ((31 & 0x30) >> 4)));
    dataStream.Add((byte)((31 & 0x0f) << 4));
    dataStream.Add((byte)0);

    Maybe you don't need to add the last element
    ZXing https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/datamatrix/decoder/DecodedBitStreamParser.cs

    ///

    <summary>
    /// See ISO 16022:2006, 5.2.8 and Annex C Table C.3
    /// </summary>
    private static bool decodeEdifactSegment(BitSource bits, StringBuilder result)
    {
    while (bits.available() > 16)
    {
    for (int i = 0; i < 4; i++)
    {
    int edifactValue = bits.readBits(6);
    if (edifactValue == 31)
    {
    int bitsLeft = 8 - bits.BitOffset;
    if (bitsLeft != 8)
    {
    bits.readBits(bitsLeft);
    }
    return true; //!!!! the next character is 0
    }
    if ((edifactValue & 32) == 0)
    {
    edifactValue |= 64;
    }
    result.Append((char)edifactValue);
    }
    if (bits.available() <= 0)
    {
    return true;
    }
    }
    return true;
    }

    Then switch to reading ASCII ENCODE

    oneByte = bits.readBits(8);
    if (oneByte == 0)
    {
    break;// error
    }

     

    Last edit: Sergey Smirnov 2020-03-04
  • Sergey Smirnov

    Sergey Smirnov - 2020-03-04

    https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/datamatrix/encoder/EdifactEncoder.cs

    private static String encodeToCodewords(StringBuilder sb, int startPos)

        {
    
            int len = sb.Length - startPos;
    
            if (len == 0)
    
            {
    
                throw new InvalidOperationException("StringBuilder must not be empty");
    
            }
    
            char c1 = sb[startPos];
    
            char c2 = len >= 2 ? sb[startPos + 1] : (char)0;
    
            char c3 = len >= 3 ? sb[startPos + 2] : (char)0;
    
            char c4 = len >= 4 ? sb[startPos + 3] : (char)0;
    
    
    
            int v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4;
    
            char cw1 = (char)((v >> 16) & 255);
    
            char cw2 = (char)((v >> 8) & 255);
    
            char cw3 = (char)(v & 255);
    
            var res = new StringBuilder(3);
    
            res.Append(cw1);
    
            if (len >= 2)
    
            {
    
                res.Append(cw2);
    
            }
    
            if (len >= 3)
    
            {
    
                res.Append(cw3);
    
            }
    
            return res.ToString();
    
        }
    
     
  • Milton Neal

    Milton Neal - 2020-03-13

    Hello Sergey
    I have uploaded a patched version on DatamatrixEncoder.cs.
    You can download it from the repository.
    This now generates and scans correctly. I tested this with your sample data.
    Let me me if you have any more problems.
    Milton

     
    • Sergey Smirnov

      Sergey Smirnov - 2020-03-13

      Thank you very much! I'll check it out in a week. Now we are working at home because of the coronavirus! Be healthy!

       
  • Milton Neal

    Milton Neal - 2020-04-06
    • status: open --> closed
     
  • Vadim Cherevkovsky

    Hello, Milton!

    What was the exact reason of this bug? How can I find which strings caused this behavior of the library?
    I'll explain. I work for company that has a huge amount of barcodes for special labels used in its production process. And we want to find which barcodes was generated incorrectly to reissue the labels with them. It's impossible to reissue all labels, so we want to replace only defecive labels.

    Thank you.

     
  • Vadim Cherevkovsky

    For example, some more strings which caused unreadable barcodes.

    I can't see, what they have in common...

     
  • Milton Neal

    Milton Neal - 2020-04-12

    Hello Vadim
    As you may know the ZintNet library is a port of the C Zint library. So a lot of code was converted from C to C#. Some of the issues were typing errors in converting the code. Some were bug fixes in the original Zint C code which I hadn't applied to the ZintNet code.
    In my code I found that an ECI was being inadvertently added the beginning of the symbol, which shouldn't have affected scanning of the barcode, as all you lastest samples scanned correctly with my scanner.
    I'll look deeper into this and post a patch for you to try as soon as I complete my test.
    Milton

     
  • Milton Neal

    Milton Neal - 2020-04-13

    Hello Vadim
    I've uploaded a code fix for DataMatrix.cs to the repository.
    You can download it into your project. Let me know how you get on.
    Cheers Milton

     
    • Vadim Cherevkovsky

      Hello Milton

      All our existing labels generated correctly, but we found a new string which causes unreadable barcode:

      [01]04680065199121[21]SOIP5XD3XtmjV[91]002A[92]WSV7Nv2lqcL3YH/Fm5hjs4klyF7LjRjojuu2Jhvga/T4ZtH2rJg6WSvn6GsIO7c6VR+Mae8VpqyulBpX/GRP+Q==

      I hope it will help to find another reason.

      Thank you.

       
  • Milton Neal

    Milton Neal - 2020-04-19

    Vadim
    Can you try the lastest patch for me.
    Thanks Milton

     
    • Vadim Cherevkovsky

      Hello, Milton!

      It seems that it's ok now
      010468006519912121SOIP5XD3XtmjV 91002A 92WSV7Nv2lqcL3YH/Fm5hjs4klyF7LjRjojuu2Jhvga/T4ZtH2rJg6WSvn6GsIO7c6VR+Mae8VpqyulBpX/GRP+Q==

      I'll rebuild my application with your latest patch a bit later and check it once again.

      Thank you!

       
    • Vadim Cherevkovsky

      Hello Milton!

      I checked a big list of our barcodes with the new patch, they all generated correct now.

      (I wrote a small application for barcode checking. It uses a handheld barcode scanner in automatic mode. A list of source string is loaded into the app and it displays generated barcodes one by one, waiting a response from scanner. When response is receved, next barcode is shown, otherwise the app shows an error message.)

      Thank you again.

       
  • Milton Neal

    Milton Neal - 2020-04-22

    Hi Vadim
    Thanks for the feedback. I've re-check all the dm code and all appears correct. Hopefully we have sovled all the issues. :)

     

Log in to post a comment.