circuitpython_kernel package

Submodules

circuitpython_kernel.board module

Serial Connection to a Board

class circuitpython_kernel.board.Board[source]

Bases: object

Connect to CP VM, reconnect if connection lost

close()[source]

Close serial connection with board.

connect()[source]

(re)connect to board and enter raw repl

enter_raw_repl()[source]

Enters the RAW circuitpython repl.

read_all()[source]

Attempts to read all incoming msgs from board.

read_until(msg)[source]

Reads board until end of msg.

softreset()[source]

Resets the circuitpython board (^D) from a jupyter cell.

write(msg)[source]

Writes to CircuitPython Board.

exception circuitpython_kernel.board.BoardError(msg)[source]

Bases: Exception

Errors relating to board connections

circuitpython_kernel.install module

Kernelspec installation.

circuitpython_kernel.install.install_my_kernel_spec(user=True, prefix=None)[source]

Install circuitpython kernel to list of kernels.

circuitpython_kernel.install.main(argv=None)[source]

circuitpython_kernel.kernel module

Basic functionality of CircuitPython kernel.

class circuitpython_kernel.kernel.CircuitPyKernel(*args, **kwargs)[source]

Bases: ipykernel.kernelbase.Kernel

CircuitPython kernel implementation.

banner = 'CircuitPython'
do_complete(code, cursor_pos)[source]

Support code completion.

do_execute(code, silent, store_history=True, user_expressions=None, allow_stdin=False)[source]

Execute a user’s code cell.

Parameters
  • code (str) – Code, one or more lines, to be executed.

  • silent (bool) – True, signals kernel to execute code quietly, and output is not displayed.

  • store_history (bool) – Whether to record code in history and increase execution count. If silent is True, this is implicitly false.

  • user_expressions (dict, optional) – Mapping of names to expressions to evaluate after code is run.

  • allow_stdin (bool) – Whether the frontend can provide input on request (e.g. for Python’s raw_input()).

Returns

Execution results.

Return type

dict

do_shutdown(restart)[source]

Handle the kernel shutting down.

implementation = 'circuitpython_kernel'
implementation_version = '0.3.0.dev'
classmethod is_comment(line)[source]

Returns true if the line of code is empty or a comment.

It is much faster to check and skip these lines on the host then to send them to the MCU (with an upload_delay between each one).

is_magic(line)[source]

Returns true if line was handled

language_info = {'codemirror_mode': {'name': 'python', 'version': 3}, 'file_extension': '.py', 'mimetype': 'text/x-python', 'name': 'python', 'pygments_lexer': 'python3', 'version': '3'}
protocol_version = '4.5.2'
run_code(code)[source]

Run a code snippet.

Parameters

code (str) – Code to be executed.

Returns

  • out – Decoded bytearray output result from code run.

  • err – Decoded bytearray error from code run.

circuitpython_kernel.version module

CircuitPython Kernel version info

Module contents

A Jupyter kernel for CircuitPython