Supports delimiters and super data
Charmsec ®
Error Correcting Characterization Code
Japan Pat. 7142977

 0x3dcafebabe → 'T:MKyEn

                 + sigle-character error

                 \T:MKyEn → 0x03dcafebabe (corrected) 

Dec. 17, 2021
Takayuki HOSODA (lyuka@finetune.co.jp)

JapaneseJapanese edition is here.

Summary

The Charmsec code is an error-correcting code invented by the author and is a block code that encodes data into printable characters.
The name 'Charmsec' is derived from Characterized Reminder Set Error Correcting code.
This code can tolerate errors in characters in the code characters and can decode them. The following example implementation can deal with a single character error.
There are a number of ranges (super data) that can be handled beyond the size of the data length by using the surplus of information entropy.
In the implementation example below, LF (0x0a) can be used as a code delimiter with 1-bit error correction.
It is suitable for device-to-device communications in asynchronous serial communications such as RS-232, RS-422, and RS-485.
Suitable for applications where both real-time performance and transmission efficiency are required (e.g., transmission of control signals for industrial robots and vehicles).
Printable characters facilitate logging and e-mail attachments.
As the required resource is as small as 8 kbytes, it can be easily implemented in a relatively small systems.
There are several types of Charmsec codes, the followings are some of the most popular ones in practical use.

Table of Contents

Code Comparison

Examples of Code Character Mapping

Example of Charmsec code character mapping to 7-bit ASCII code (Delimiter : LF, Excluded character : ∖)

Note 1 : NL (0x0A) can be used as a code block delimiter with 1-bit error correction since 1-bit errors in NL (0x0A) are mapped not to be a code character.
Note 2 : Since ∖ (0x5C) is also excluded from the code character, ∖ can be used as an error position indicator, etc.

Examples of Encoding and Decoding

Charmsec7_5C Single-character error correcting characterization code
Encodes 44-bit data into a 9-char ASCII string. Excluded characters are ∖.
The encoding rate is about 0.698. Compared to Base64, the encoded character is increased by approximately 22%.
Examples of Encoding and Decoding
Sun, 12 Jun 2022 17:32:26 +0900
Charmsec7_5c_demo : Rev.1.92 (Jun. 12, 2022) (c) 2004 Takayuki HOSODA, Finetune co., ltd.
Charmsec7_5c_demo : Using charmsec7_5c - a subset of the Charmsec CoDec library.
Charmsec7_5c_demo : '\' is to be used as the error position indicator here.
Charmsec7_5c_demo : txdata = 0x0000badcafebabe -> txcode = gMbVtv'no
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = \MbVtv'no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = g\bVtv'no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gM\Vtv'no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gMb\tv'no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gMbV\v'no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gMbVt\'no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gMbVtv\no - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gMbVtv'\o - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = gMbVtv'n\ - Corrected an error
Charmsec7_5c_demo : txdata = 0x000141d4a551717 -> txcode = ikquwyzdm (saturated)
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = \kquwyzdm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = i\quwyzdm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ik\uwyzdm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ikq\wyzdm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ikqu\yzdm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ikquw\zdm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ikquwy\dm (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ikquwyz\m (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = ikquwyzd\ (superdata) - Corrected an error

Implementation Examples in C

Charmsec7_5C Implementation Example (Click to expand)
Download Download archive : charmsec7_5c_demo-1.92.tar.gz [4kB tar.gz]

Example of Super Data Usage

One of the features of Charmsec is the use of super data to send one-shot data or control codes in between data streams, It can also be used for end of data stream, check bits, timestamps, etc.
The figure below shows an example of using Charmsec7 in RS-485 multi-drop communication between a device and a robot.

Technical Explanation (In Japanese)

▼ Excerpt from the patent specification (click to expand)

Technical Documents

Patent Gazette Patent No. 4142977 — Data Communication System, Transmitting Device, and Receiving Device

Change history

▼ Change history (click to expand)

SEE ALSO

© 2021, Takayuki HOSODA, Finetune co., ltd.

www.finetune.co.jp [Mail]