USB transport¶
-
class
chess_link_usb.
Transport
(que, protocol_dbg=False)[source]¶ 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.
-
__init__
(que, protocol_dbg=False)[source]¶ 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
-
event_worker_thread
(que)[source]¶ Background thread that sends data received via usb to the queue que.
-
search_board
(iface=None)[source]¶ 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_board
(port)[source]¶ Test an usb port for correct answer on get version command.
- Returns
Version string on ok, None on failure.
-
usb_port_check
(port)[source]¶ Check usb port for valid ChessLink connection
- Returns
True on success, False on failure.
-
BLE transport¶
-
class
chess_link_bluepy.
Transport
(que, protocol_dbg=False)[source]¶ 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.
-
__init__
(que, protocol_dbg=False)[source]¶ 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
-
open_mt
(address)[source]¶ Open a bluetooth LE connection to ChessLink board.
- Parameters
address – bluetooth address
- Returns
True on success.
-
search_board
(iface=0)[source]¶ 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.
-