USB transport

ChessLink transport implementation for USB connections.

This class does automatic hardware detection of any ChessLink board connected via USB and support Linux, macOS and Windows.

This transport uses an asynchronous background thread for hardware communcation. All replies are written to the python queue que given during initialization.

Initialize with python queue for event handling. Events are strings conforming to the ChessLink protocol as documented in magic-link.md.

Parameters
  • que – Python queue that will eceive events from chess board.

  • protocol_dbg – True: byte-level ChessLink protocol debug messages

Background thread that sends data received via usb to the queue que.

Get name of this transport.

Returns

‘chess_link_usb’

Check, if hardware connection is up.

Returns

True on success.

Open an usb port to a connected ChessLink board.

Returns

True on success.

Initiate worker-thread stop

Search for ChessLink connections on all USB ports.

Parameters

iface – not used for USB.

Returns

Name of the port with a ChessLink board, None on failure.

Test an usb port for correct answer on get version command.

Returns

Version string on ok, None on failure.

Check usb port for valid ChessLink connection

Returns

True on success, False on failure.

Get a list of all usb ports that have a connected ChessLink board.

Returns

array of usb port names with valid ChessLink boards, an empty array if none is found.

Synchronous reads for initial hardware detection.

Encode and write a message to ChessLink.

Parameters

msg – Message string. Parity will be added, and block CRC appended.

BLE transport

ChessLink transport implementation for Bluetooth LE connections using bluepy.

This class does automatic hardware detection of any ChessLink board using bluetooth LE and supports Linux and Raspberry Pi.

This transport uses an asynchronous background thread for hardware communcation. All replies are written to the python queue que given during initialization.

For the details of the Chess Link protocol, please refer to: magic-link.md.

Initialize with python queue for event handling. Events are strings conforming to the ChessLink protocol as documented in magic-link.md.

Parameters
  • que – Python queue that will eceive events from chess board.

  • protocol_dbg – True: byte-level ChessLink protocol debug messages

Get name of this transport.

Returns

‘chess_link_bluepy’

Check, if hardware connection is up.

Returns

True on success.

Open a bluetooth LE connection to ChessLink board.

Parameters

address – bluetooth address

Returns

True on success.

Initiate worker-thread stop

Search for ChessLink connections using Bluetooth LE.

Parameters

iface – interface number of bluetooth adapter, default 1.

Returns

Bluetooth address of ChessLink board, or None on failure.

Test dummy.

Returns

Version string “1.0” always.

Background thread that handles bluetooth sending and forwards data received via bluetooth to the queue que.

Encode and asynchronously write a message to ChessLink.

Parameters

msg – Message string. Parity will be added, and block CRC appended.