ChessLink protocol¶

Helper functions for the Chess Link protocol for character-based odd-parity and message-block-parity.

The chess link protocol sends ASCII messages. Each ASCII character gets an additional odd-parity-bit. Each block of ASCII+odd-parity bytes gets an additional block parity.

Details of the Chess Link protocol are documented in magic-board.md.

chess_link_protocol.add_block_crc(msg)[source]¶

Add block parity at the end of the message

Parameters
  • msg – a message byte array (each byte must have already been encoded with odd parity). This function adds two bytes of block CRC at the end of the message.

  • msg – byte array with a message (incl. odd-parity bits set already)

Returns

two byte longer message that includes 2 CRC bytes.

chess_link_protocol.add_odd_par(b)[source]¶

The chess link protocol is 7-Bit ASCII. This adds an odd-parity-bit to an ASCII char

Parameters

b – an ASCII character (0..127)

Returns

a byte (0..255) with odd parity in most significant bit.

chess_link_protocol.check_block_crc(msg)[source]¶

Chess link messages consist of 7-bit-ASCII characters with odd parity. At the end of each message, an additional block-parity is added. Valid chess link messages must have correct odd parity for each character and a valid block parity at the end.

Parameters

msg – a byte array with the message.

Returns

True, if the last two bytes of msg contain a correct CRC, False otherwise.

chess_link_protocol.hex2(num)[source]¶

Convert integer to 2-digit hex string. Most numeric parameters and the block CRC are encoded as such 2-digit hex-string.

Parameters

num – uint_8 integer 0..255

Returns

Returns a 2-digit hex code ‘00’..’FF’

chess_link_protocol.hexd(digit)[source]¶

Returns a hex digit ‘0’..’F’ for an integer 0..15

Parameters

digit – integer 0..15

Returns

an ASCII hex character ‘0’..’F’

mchess

Navigation

Contents:

  • ChessLink object
  • ChessLink protocol
  • USB transport
  • BLE transport

Related Topics

  • Documentation overview
    • Previous: ChessLink object
    • Next: USB transport

Quick search

©2018-2020, Dominik Schlösser. | Powered by Sphinx 3.0.3 & Alabaster 0.7.12 | Page source