Detailed Explanation of Base 256 Mode in Data Matrix Codes |
Data Matrix codes use different encoding modes to efficiently represent various types of data. One such mode is the Base 256 mode, which is specifically designed for encoding byte-oriented data. Here's a detailed breakdown of how Base 256 mode works: |

|
1. Structure of Base 256 Mode Data |
The encoded data in Base 256 mode consists of: 1)Length Indicator: Indicates the length of the data bytes. 2)Data Bytes: The actual data to be encoded. |
2. Encoding the Length |
The length indicator is encoded based on the length of the data bytes: For lengths 1 to 249, the length is encoded as a single byte. For lengths 250 and above, the length is encoded as two bytes using the following formula: |

|
3. Avoiding Long Strings of Zeros |
Long strings of zeros in the encoded message can cause issues with scanning the Data Matrix symbol. To mitigate this, the length and data bytes are obscured using a pseudorandom value R(n)R(n)R(n). |
4. Pseudorandom Value Calculation |
The pseudorandom value R(n)R(n)R(n) is calculated as: R(n)=(149×n)mod??255+1R(n) = (149 \times n) \mod 255 + 1R(n)=(149×n)mod255+1 Here, nnn is the position in the byte stream (starting from 1). |
5. Obscuring the Data |
To obscure the data, each byte (including the length byte(s)) is modified by adding the corresponding pseudorandom value R(n)R(n)R(n): Obscured Byte=(Original Byte+R(n))mod??256\text{Obscured Byte} = (\text{Original Byte} + R(n)) \mod 256Obscured Byte=(Original Byte+R(n))mod256 |

|
Example |
Let's walk through an example to see how this works in practice. |
Given: Data to encode: 'Hello' ASCII values: [72, 101, 108, 108, 111] Length of data: 5 |
Step-by-Step Encoding: |

|
Encoded Byte Stream: [155, 116, 38, 195, 88, 241] |
This process ensures that the Data Matrix code is less likely to have long strings of zeros, enhancing its reliability when scanned. |

|
Summary |
Base 256 mode starts with a length indicator followed by the actual data bytes. Length encoding varies based on the length of data. Pseudorandom values are used to obscure the length and data bytes to avoid long strings of zeros. The pseudorandom value is calculated as (149×n)mod??255+1(149 \times n) \mod 255 + 1(149×n)mod255+1 where nnn is the byte position. The obscured bytes are computed by adding the pseudorandom values to the original bytes modulo 256. |

|
By following these steps, Data Matrix codes in Base 256 mode ensure robust and efficient encoding of byte-oriented data. |