1
1
Fork
You've already forked Datamatrix
0

Problem with generating in binary mode. #2

Closed
opened 2026年02月17日 10:51:00 +01:00 by jipihorn · 17 comments
jipihorn commented 2026年02月17日 10:51:00 +01:00 (Migrated from github.com)
Copy link

I couldn't generate a DataMatrix with binary data.
For example, generating a 256 bytes (values from 0x00 to 0xff) gives a wrong size and/or wrong content DataMatrix.
When the encoding is automatic, the size is incorrect (some additional data is read when scanning the result).
If I force binary (with a buffer filled with 'b' as encodingptr), the content is wrong.
If I force to ASCII 'a', it works but the size is very big because ASCII is not well suited for random binary data.

Jerome.

I couldn't generate a DataMatrix with binary data. For example, generating a 256 bytes (values from 0x00 to 0xff) gives a wrong size and/or wrong content DataMatrix. When the encoding is automatic, the size is incorrect (some additional data is read when scanning the result). If I force binary (with a buffer filled with 'b' as encodingptr), the content is wrong. If I force to ASCII 'a', it works but the size is very big because ASCII is not well suited for random binary data. Jerome.
revk commented 2026年02月17日 11:23:48 +01:00 (Migrated from github.com)
Copy link

Wow, this library has not been touched for a very long time. I'd have thought all the bugs would be found by now. Sorry.

I'll have to take a look.

Wow, this library has not been touched for a very long time. I'd have thought all the bugs would be found by now. Sorry. I'll have to take a look.
jipihorn commented 2026年02月17日 12:57:08 +01:00 (Migrated from github.com)
Copy link

Hello,
That's very kind of you to answer !
It is not impossible that I do something wrong even though I only do a copy/paste into a visual studio project. Just check before that you can reproduce the problem ! I use every simple buffer of size 256 with the values from 0 to 255 inside for testing.
here is the barcode I obtain (automatic encoding):

[画像:Image]

Some online website read it with additional data, other fail to find any bar code.

Jerome.

Hello, That's very kind of you to answer ! It is not impossible that I do something wrong even though I only do a copy/paste into a visual studio project. Just check before that you can reproduce the problem ! I use every simple buffer of size 256 with the values from 0 to 255 inside for testing. here is the barcode I obtain (automatic encoding): <img width="512px" height="512px" alt="Image" src="https://github.com/user-attachments/assets/2fe325f5-953e-42a0-8ee4-7d3f861a8823" /> Some online website read it with additional data, other fail to find any bar code. Jerome.
revk commented 2026年02月17日 13:03:30 +01:00 (Migrated from github.com)
Copy link

The app on my phone scans it, but obviously has a hard time displaying, and looks like it ends in 34:79g somehow.

I'll have to look at reproducing is, and debug the actual encoding.

The app on my phone scans it, but obviously has a hard time displaying, and looks like it ends in `34:79g` somehow. I'll have to look at reproducing is, and debug the actual encoding.
jipihorn commented 2026年02月17日 13:06:32 +01:00 (Migrated from github.com)
Copy link

Here is what a online decoder gives :

0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ~~~~~~~~~~~~~~~~ |
0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f | ~~~~~~~~~~~~~~~~ |
0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./ |
0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f | 0123456789:;<=>? |
0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f | @ABCDEFGHIJKLMNO |
0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f | PQRSTUVWXYZ[\]^_ |
0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f | `abcdefghijklmno |
0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f | pqrstuvwxyz{|}~~ |
0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | ~~~~~~~~~~~~~~~~ |
0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f | ~~~~~~~~~~~~~~~~ |
00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af | ~~~~~~~~~~~~~~~~ |
00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf | ~~~~~~~~~~~~~~~~ |
00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf | ~~~~~~~~~~~~~~~~ |
00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df | ~~~~~~~~~~~~~~~~ |
00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef | ~~~~~~~~~~~~~~~~ |
00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | ~~~~~~~~~~~~~~~~ |
0100 44 9e a0 a1 a2 a2 a4 a4 a7 a8 a8 aa aa ad ae ae | D~~~~~~~~~~~~~~~ |
0110 b0 b0 b2 b4 b5 b6 b6 b8 b8 bb bc bc be be c1 c2 | ~~~~~~~~~~~~~~~~ |
0120 c3 c4 c4 c6 0d 33 34 3a 37 39 67 | ~~~~~34:79g |

It is coherent with what you get. Now, can you reproduce this barcode generation from your side? That is the question 😁.

Jerome.

Here is what a online decoder gives : <pre> 0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ~~~~~~~~~~~~~~~~ | 0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f | ~~~~~~~~~~~~~~~~ | 0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./ | 0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f | 0123456789:;<=>? | 0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f | @ABCDEFGHIJKLMNO | 0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f | PQRSTUVWXYZ[\]^_ | 0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f | `abcdefghijklmno | 0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f | pqrstuvwxyz{|}~~ | 0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | ~~~~~~~~~~~~~~~~ | 0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f | ~~~~~~~~~~~~~~~~ | 00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af | ~~~~~~~~~~~~~~~~ | 00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf | ~~~~~~~~~~~~~~~~ | 00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf | ~~~~~~~~~~~~~~~~ | 00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df | ~~~~~~~~~~~~~~~~ | 00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef | ~~~~~~~~~~~~~~~~ | 00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | ~~~~~~~~~~~~~~~~ | 0100 44 9e a0 a1 a2 a2 a4 a4 a7 a8 a8 aa aa ad ae ae | D~~~~~~~~~~~~~~~ | 0110 b0 b0 b2 b4 b5 b6 b6 b8 b8 bb bc bc be be c1 c2 | ~~~~~~~~~~~~~~~~ | 0120 c3 c4 c4 c6 0d 33 34 3a 37 39 67 | ~~~~~34:79g | </pre> It is coherent with what you get. Now, can you reproduce this barcode generation from your side? That is the question 😁. Jerome.
revk commented 2026年02月17日 13:21:14 +01:00 (Migrated from github.com)
Copy link

OK what is your code to make this...

OK what is your code to make this...
revk commented 2026年02月17日 13:22:21 +01:00 (Migrated from github.com)
Copy link

Also, have you tried with the library working out optimal coding itself?

Also, have you tried with the library working out optimal coding itself?
jipihorn commented 2026年02月17日 13:40:46 +01:00 (Migrated from github.com)
Copy link

It's something like this :

	for (int i = 0; i < 256; i++)
		EncodeBuffer[i] = i;
	StringSize = 256;
	iec16022ecc200_t Opts = { 0 };
	Opts.Wptr = &W; // Width (pre fill 0 for auto, sets actual)
	Opts.Hptr = &H; // Height (pre fill 0 for auto, sets actual)
	Opts.barcode = EncodeBuffer; // Code string
	Opts.barcodelen = StringSize; // Lengths of code
	Opts.square = 1; // Force square (also setting Wptr==Hptr does this)
	Opts.noquiet = 1; //no border
	Opts.lenp=&LenP; // Stores data length before any final unlatch or pad
	Opts.maxp=&Maxp; // Stores max storage of this size code
	Opts.eccp=&Eccp; // Stores the number of ecc bytes used in this size
	unsigned char* DataMatrix = iec16022ecc200_opts(Opts);

I didn't touch the code itself, it compiles without modifications.
I've tested with Opts.encodingptr pointing to a buffer with all 'a' or all 'b'. In ascii mode (all 'a'), the barcode is ok, albeit very large. In binary, it does not work. Here is the picture in full binary :

[画像:Image]

The code is :

	for (int i = 0; i < 256; i++)
	{
		EncodeBuffer[i] = i;
		encoding[i] = 'b';
	}
	StringSize = 256;
	iec16022ecc200_t Opts = { 0 };
	Opts.Wptr = &W; // Width (pre fill 0 for auto, sets actual)
	Opts.Hptr = &H; // Height (pre fill 0 for auto, sets actual)
	Opts.encodingptr = &pencoding; // Fills in encoding string if set
	Opts.barcode = EncodeBuffer; // Code string
	Opts.barcodelen = StringSize; // Lengths of code
	Opts.square = 1; // Force square (also setting Wptr==Hptr does this)
	Opts.noquiet = 1; //no border
	Opts.lenp=&LenP; // Stores data length before any final unlatch or pad
	Opts.maxp=&Maxp; // Stores max storage of this size code
	Opts.eccp=&Eccp; // Stores the number of ecc bytes used in this size
	unsigned char* DataMatrix = iec16022ecc200_opts(Opts);

it seem that it is related to the binary format. I've modified the code to avoid binary in automatic mode and it works (with a smaller size than full ascii, but larger than full binary). I wouldn't care if the amount of data is small, but the DataMatrix can contains more than 1000 bytes in it.

Jerome.

It's something like this : <pre> for (int i = 0; i < 256; i++) EncodeBuffer[i] = i; StringSize = 256; iec16022ecc200_t Opts = { 0 }; Opts.Wptr = &W; // Width (pre fill 0 for auto, sets actual) Opts.Hptr = &H; // Height (pre fill 0 for auto, sets actual) Opts.barcode = EncodeBuffer; // Code string Opts.barcodelen = StringSize; // Lengths of code Opts.square = 1; // Force square (also setting Wptr==Hptr does this) Opts.noquiet = 1; //no border Opts.lenp=&LenP; // Stores data length before any final unlatch or pad Opts.maxp=&Maxp; // Stores max storage of this size code Opts.eccp=&Eccp; // Stores the number of ecc bytes used in this size unsigned char* DataMatrix = iec16022ecc200_opts(Opts); </pre> I didn't touch the code itself, it compiles without modifications. I've tested with Opts.encodingptr pointing to a buffer with all 'a' or all 'b'. In ascii mode (all 'a'), the barcode is ok, albeit very large. In binary, it does not work. Here is the picture in full binary : <img width="512" height="512" alt="Image" src="https://github.com/user-attachments/assets/f45f60d5-be36-4598-a0d0-d002084f5706" /> The code is : <pre> for (int i = 0; i < 256; i++) { EncodeBuffer[i] = i; encoding[i] = 'b'; } StringSize = 256; iec16022ecc200_t Opts = { 0 }; Opts.Wptr = &W; // Width (pre fill 0 for auto, sets actual) Opts.Hptr = &H; // Height (pre fill 0 for auto, sets actual) Opts.encodingptr = &pencoding; // Fills in encoding string if set Opts.barcode = EncodeBuffer; // Code string Opts.barcodelen = StringSize; // Lengths of code Opts.square = 1; // Force square (also setting Wptr==Hptr does this) Opts.noquiet = 1; //no border Opts.lenp=&LenP; // Stores data length before any final unlatch or pad Opts.maxp=&Maxp; // Stores max storage of this size code Opts.eccp=&Eccp; // Stores the number of ecc bytes used in this size unsigned char* DataMatrix = iec16022ecc200_opts(Opts); </pre> it seem that it is related to the binary format. I've modified the code to avoid binary in automatic mode and it works (with a smaller size than full ascii, but larger than full binary). I wouldn't care if the amount of data is small, but the DataMatrix can contains more than 1000 bytes in it. Jerome.
revk commented 2026年02月17日 14:37:19 +01:00 (Migrated from github.com)
Copy link

Not sure how urgent this is for you - but on my list. Not 100% sure if I can start on this today.

Do not be surprised to find this moved to codeberg (I'll move this issue as well) as I am doing this generally.

Not sure how urgent this is for you - but on my list. Not 100% sure if I can start on this today. Do not be surprised to find this moved to codeberg (I'll move this issue as well) as I am doing this generally.
jipihorn commented 2026年02月17日 14:56:29 +01:00 (Migrated from github.com)
Copy link

Don't worry, for the moment, I'll use ASCII mode for my test and application debugging. Afterwards, I'll transform it for embedded code using different memory allocation mechanisms and purely binary mode. This does not block me and I'm not in a position to give you some orders or obligations 😁 !
So you could find a bug there ?

Jerome.

Don't worry, for the moment, I'll use ASCII mode for my test and application debugging. Afterwards, I'll transform it for embedded code using different memory allocation mechanisms and purely binary mode. This does not block me and I'm not in a position to give you some orders or obligations 😁 ! So you could find a bug there ? Jerome.
revk commented 2026年02月17日 14:59:41 +01:00 (Migrated from github.com)
Copy link

LOL, no, but this is code that is old enough to vote (19 years) and I really should not have bugs like this. So I do plan to sort it shortly. Just been an annoying day.

LOL, no, but this is code that is old enough to vote (19 years) and I really should not have bugs like this. So I do plan to sort it shortly. Just been an annoying day.
jipihorn commented 2026年02月17日 15:26:23 +01:00 (Migrated from github.com)
Copy link

Tomorrow should be better...

Greetings from Belgium !

Tomorrow should be better... Greetings from Belgium !
revk commented 2026年02月18日 09:17:55 +01:00 (Migrated from github.com)
Copy link

Moving to codeberg.org now.

Moving to codeberg.org now.
Owner
Copy link

Unfortunately that lost your images, grrr, OK.

Unfortunately that lost your images, grrr, OK.
Owner
Copy link

OK, without encoding, the encoding is calculated to be

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAATTTTTTTTTTTTTTTTTTTTTTTTAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

Now the barcode generated seems to decode as 👎

0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ~~~~~~~~~~~~~~~~ |
0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f | ~~~~~~~~~~~~~~~~ |
0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./ |
0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f | 0123456789:;<=>? |
0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f | @ABCDEFGHIJKLMNO |
0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f | PQRSTUVWXYZ[\]^_ |
0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f | `abcdefghijklmno |
0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f | pqrstuvwxyz{|}~~ |
0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | ~~~~~~~~~~~~~~~~ |
0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f | ~~~~~~~~~~~~~~~~ |
00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af | ~~~~~~~~~~~~~~~~ |
00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf | ~~~~~~~~~~~~~~~~ |
00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf | ~~~~~~~~~~~~~~~~ |
00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df | ~~~~~~~~~~~~~~~~ |
00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef | ~~~~~~~~~~~~~~~~ |
00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | ~~~~~~~~~~~~~~~~ |
0100 44 9e a0 a1 a2 a2 a4 a4 a7 a8 a8 aa aa ad ae ae | D~~~~~~~~~~~~~~~ |
0110 b0 b0 b2 b4 b5 b6 b6 b8 b8 bb bc bc be be c1 c2 | ~~~~~~~~~~~~~~~~ |
0120 c3 c4 c4 c6 0d 33 34 3a 37 39 67 | ~~~~~34:79g |

What is interesting is that does decode all 00 to FF, but then has extra on the end.

This suggests an issue with length encoding bytes used for binary.

Investigating further.

OK, without encoding, the encoding is calculated to be ``AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAATTTTTTTTTTTTTTTTTTTTTTTTAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB`` Now the barcode generated seems to decode as 👎 ``` 0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ~~~~~~~~~~~~~~~~ | 0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f | ~~~~~~~~~~~~~~~~ | 0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./ | 0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f | 0123456789:;<=>? | 0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f | @ABCDEFGHIJKLMNO | 0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f | PQRSTUVWXYZ[\]^_ | 0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f | `abcdefghijklmno | 0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f | pqrstuvwxyz{|}~~ | 0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | ~~~~~~~~~~~~~~~~ | 0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f | ~~~~~~~~~~~~~~~~ | 00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af | ~~~~~~~~~~~~~~~~ | 00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf | ~~~~~~~~~~~~~~~~ | 00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf | ~~~~~~~~~~~~~~~~ | 00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df | ~~~~~~~~~~~~~~~~ | 00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef | ~~~~~~~~~~~~~~~~ | 00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | ~~~~~~~~~~~~~~~~ | 0100 44 9e a0 a1 a2 a2 a4 a4 a7 a8 a8 aa aa ad ae ae | D~~~~~~~~~~~~~~~ | 0110 b0 b0 b2 b4 b5 b6 b6 b8 b8 bb bc bc be be c1 c2 | ~~~~~~~~~~~~~~~~ | 0120 c3 c4 c4 c6 0d 33 34 3a 37 39 67 | ~~~~~34:79g | ``` What is interesting is that *does* decode all `00` to `FF`, but then has extra on the end. This suggests an issue with length encoding bytes used for binary. Investigating further.
Owner
Copy link

Manually working on the coding, all looks OK for 00-7F using the various types.

Indeed the last 5 ASCII mode code as FE 7C 7D 7E 7F 80 which is correct, FE to switch to ASCII, and coding 7B 7C 7D 7E 7F as +1 value correctly.

Then we code 128 bytes using binary, which is coded as

E7 80 F2 89 1F B6 4C E3 79 10 A7 3D D4 6A 01 98 2E C5 5B F2 88 1F B6 4C E3 79 10 A7 3D D4 6A 01 97 2E C5 5B F2 88 1F B6 4C E3 79 10 A6 3D D4 6A 01 97 2E C5 5B F2 88 1F B5 4C E3 79 10 A6 3D D4 6A 01 97 2E C5 5B F2 88 1F B5 4C E3 79 10 A6 3D D4 6A 01 97 2E C4 5B F2 88 1F B5 4C E3 79 10 A6 3D D3 6A 01 97 2E C4 5B F2 88 1F B5 4C E2 79 10 A6 3D D3 6A 01 97 2E C4 5B F1 88 1F B5 4C E2 79 10 A6

This is E7 for binary, then 80 for 128 bytes, then 128 bytes coding with the pseudo random padding. The decoder decodes all of this correctly.

We then have

81 70 08 9E 35 CB 62 F8 90 27 BD 54 EA 82 19 AF
46 DC 73 0B A1 38 CE 65 FB 93 2A C0 57 ED 85 1C
B2 49 DF 76 0E A4 3B D1 68

The 81 is padding, so end of coding. But the decode above shows extra data, starting 44 9E A0 A1 A2 ... Presumably considering this part of the data coding.

Now, if the length was wrong, the byte 44 at that position in binary coding would code as 81, similarly 9E would code 70, and so on. So it is length of binary that is somehow wrong. It is treating it as 169 bytes of data, it seems.

But 80 is clearly 128 bytes... So trying to find more details in spec.

Manually working on the coding, all looks OK for `00`-`7F` using the various types. Indeed the last 5 ASCII mode code as `FE 7C 7D 7E 7F 80` which is correct, `FE` to switch to ASCII, and coding `7B 7C 7D 7E 7F` as +1 value correctly. Then we code 128 bytes using binary, which is coded as ``E7 80 F2 89 1F B6 4C E3 79 10 A7 3D D4 6A 01 98 2E C5 5B F2 88 1F B6 4C E3 79 10 A7 3D D4 6A 01 97 2E C5 5B F2 88 1F B6 4C E3 79 10 A6 3D D4 6A 01 97 2E C5 5B F2 88 1F B5 4C E3 79 10 A6 3D D4 6A 01 97 2E C5 5B F2 88 1F B5 4C E3 79 10 A6 3D D4 6A 01 97 2E C4 5B F2 88 1F B5 4C E3 79 10 A6 3D D3 6A 01 97 2E C4 5B F2 88 1F B5 4C E2 79 10 A6 3D D3 6A 01 97 2E C4 5B F1 88 1F B5 4C E2 79 10 A6 `` This is `E7` for binary, then `80` for 128 bytes, then 128 bytes coding with the pseudo random padding. The decoder decodes all of this correctly. We then have ``` 81 70 08 9E 35 CB 62 F8 90 27 BD 54 EA 82 19 AF 46 DC 73 0B A1 38 CE 65 FB 93 2A C0 57 ED 85 1C B2 49 DF 76 0E A4 3B D1 68 ``` The `81` is padding, so end of coding. But the decode above shows extra data, starting `44 9E A0 A1 A2` ... Presumably considering this part of the data coding. Now, if the length was wrong, the byte `44` at that position in binary coding would code as `81`, similarly `9E` would code `70`, and so on. So it is length of binary that is somehow wrong. It is treating it as 169 bytes of data, it seems. But `80` is clearly 128 bytes... So trying to find more details in spec.
Owner
Copy link

OK this is crazy, the length bytes are also scrambled. Fixed now.

OK this is crazy, the length bytes are *also* scrambled. Fixed now.
RevK referenced this issue from a commit 2026年02月18日 10:59:50 +01:00

Hey, it works !
That's really cool.

Many thanks for all,

Jérome.

Hey, it works ! That's really cool. Many thanks for all, Jérome.
Sign in to join this conversation.
No Branch/Tag specified
master
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
RevK/Datamatrix#2
Reference in a new issue
RevK/Datamatrix
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?