Giter VIP home page Giter VIP logo

circuitpython_jupyter_kernel's People

Contributors

bboser avatar brentru avatar dhalbert avatar jposada202020 avatar mcauser avatar osterwood avatar pyup-bot avatar qwertimer avatar willingc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circuitpython_jupyter_kernel's Issues

kernel connecting, but not responding

Description

The notebook connects to the CircuitPython kernel, but hangs (solid dot to the right of of the kernel name 'CircuitPython' in the top right corner of the notebook) whenever code is executed.

What I Did

Connected a new notebook (v6.2.0, all latest jupyter packages from PyPI) to circuitpython_kernel, using a Feather RP2040 (adafruit-circuitpython-adafruit_feather_rp2040-en_US-6.2.0-beta.3.uf2). The new notebook has neopixel_simpletest.py from https://circuitpython.readthedocs.io/projects/neopixel/en/latest/examples.html pasted into it.

Note that CircuitPython kernel was installed with pip install . as the instructions to use python3 setup.py install failed. python3 -m circuitpython_kernel.install worked with "Completed kernel installation."

The test runs fine when copying neopixel_simpletest.py to code.py on the CIRCUITPY drive.

jupyter-notebook output:

[I 14:42:12.916 NotebookApp] Kernel started: 5a2c643b-321c-4f8a-8ecd-97030a8b9f69, name: circuitpython                                           
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:circuitpython_kernel.kernel:circuitpython_kernel version 0.3.0.dev
[W 14:42:15.231 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20210313144140 (192.168.0.5) 6.240000ms referer=http://192.168.0.11:8888/notebooks/test.ipynb
DEBUG:circuitpython_kernel.board:/dev/ttyACM1
DEBUG:circuitpython_kernel.board:CircuitPython Board Found at: /dev/ttyACM1
DEBUG:circuitpython_kernel.board:Connected? False
DEBUG:circuitpython_kernel.board:connect: open /dev/ttyACM1
DEBUG:circuitpython_kernel.board:serial already open
DEBUG:circuitpython_kernel.board:* enter raw repl ...

CircuitPython Error on Catalina -- "Port must be configured before it can be used"

  • CircuitPython Kernel version: 7.19.0
  • Python version: 3.8.6
  • Operating System: Mac OS Catalina 10.15.7
  • Board-ID: SAMD51G19A-Itsy-v0
  • Board boot_out.txt: Adafruit CircuitPython 6.0.1 on 2020-12-28; Adafruit ItsyBitsy M4 Express with samd51g19
  • UF2 Bootloader v3.10.0 SFHWRO

Description

When following the Adafruit Jupyter Circuit Python Guide, Jupyter fails to connect to the kernel/board with the error Port must be configured before it can be used displayed in the terminal

What I Did

  • cloned this repository
  • ran:
         $ python3 setup.py install
         $ cd circuitpython_kernel
         $ python3 -m circuitpython_kernel.install
    
  • Board is connected via known-good USB cable
  • Board neo-pixel is blinking green
  • Board appears as USB Drive "CIRCUITPY" in finder

Trouble Shooting Attempts:

Attempt: Restart Jupyter

  • Result:
    - Jupyter output: A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.
    - Terminal Output: (repeats 5 times)
[I 11:09:50.381 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/circuitpython_kernel/__main__.py", line 4, in <module>
    IPKernelApp.launch_instance(kernel_class=CircuitPyKernel)
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/traitlets/config/application.py", line 844, in launch_instance
    app.initialize(argv)
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/traitlets/config/application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 582, in initialize
    self.init_kernel()
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 444, in init_kernel
    kernel = kernel_factory(parent=self, session=self.session,
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/traitlets/config/configurable.py", line 537, in instance
    inst = cls(*args, **kwargs)
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/circuitpython_kernel/kernel.py", line 37, in __init__
    self.serial = connect()
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/circuitpython_kernel/board.py", line 58, in connect
    s.open()
  File "/Users/aaronciuffo/.pyenv/versions/3.8.6/Python.framework/Versions/3.8/lib/python3.8/site-packages/serial/serialposix.py", line 316, in open
    raise SerialException("Port must be configured before it can be used.")
serial.serialutil.SerialException: Port must be configured before it can be used.
... Repeats 5 times ...
[W 11:15:48.289 NotebookApp] KernelRestarter: restart failed
[W 11:15:48.289 NotebookApp] Kernel 3c7b0cdf-538d-481c-b159-7fa42722b61b died, removing from map.

Attempt: Reset M4 Board and restart kernel

  • Result: Same as above

Attempt: Reset unplug board and restart kernel

  • Result: Same as above

Access RTD

Hey @tannewt, I gave you admin/maintainer rights on the circuitpython_kernel docs on RTD if you wish to move it over to Adafruit or add other maintainers.

My code is @ladyada's code ;-)

Making use of Python magics

Hi

We're currently evaluating the potential of using something like Circuit Playground Express as a home experiment kit and I've been looking at what support there may be around for using Jupyter notebooks to work with them (my early notes here: https://ouseful-testing.github.io/circuit-playground-express/

The magics look like they could be interesting, but they still seem to be early days?

(The following is intended to be constructive rather than overly critical.)

One way I imagined using magics was to eg:

  • grab sensor values using Circuit Python into a Circuit Python variable
  • pass the variable into %%python block magic, churn the data in pandas, create matplotlib chart;
  • render the chart as cell output

BUT:

  • the cell doesn't seem to want to output anything (no repr_ defined? I also note that in the "native" Circuit Pyhton cells, the last object value is not displayed as cell output: you have to print() it. Nor is the IPython display() function, which would pick up a __repr__, seem to be implemented.

Support for ESP32 ?

Hi folks,

I wanted to give the CircuitPython kernel a try with my ESP32 Feather V2 board, but I see that it's not in the list of supported devices, and none of the ESP32 boards actually, even the newer ESP32-S3 for instance which does have native USB (unlike my ESP32 Feather V2..).

Is there a plan to make the CircuitPython kernel compatible with the ESP32 boards? It would be cool to program them from JupyterLab.

I tried the examples in https://github.com/adafruit/circuitpython_jupyter_kernel/tree/master/examples , but that didn't work, I get the error No connection to CiruitPython VM: found no board. The jupyter log in the terminal shows the correct serial port (/dev/ttyACM0) though.

Timeout waiting for kernel_info reply

  • CircuitPython Kernel version: 0.3.1
  • Python version: Circuitpython 3.0.3 on Metro M0, system Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37)
  • Operating System: MacOS 10.13.6

Description

Getting the following timeout on starting the notebook:

[I 08:51:21.622 NotebookApp] Kernel started: b851b856-352e-4dc3-8265-d57d19b68915
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:circuitpython_kernel.board:/dev/cu.Bluetooth-Incoming-Port
DEBUG:circuitpython_kernel.board:/dev/cu.RobinsiPhone6-Wirelessi
DEBUG:circuitpython_kernel.board:/dev/cu.Bluedio-BluetoothSerial
DEBUG:circuitpython_kernel.board:/dev/cu.usbmodem14141
DEBUG:circuitpython_kernel.board:CircuitPython Board Found at:
DEBUG:circuitpython_kernel.board:/dev/cu.usbmodem14141
DEBUG:circuitpython_kernel.board:* entering raw repl...
[W 08:51:31.680 NotebookApp] Timeout waiting for kernel_info reply from b851b856-352e-4dc3-8265-d57d19b68915

Note that I am NOT getting this issue with https://github.com/goatchurchprime/jupyter_micropython_kernel

Multiple CDC ports causing issues with Jupyter kernel?

  • CircuitPython Kernel version: 0.5.1
  • Python version: 3.6.13 (conda environment)
  • Operating System: macOS 11.2

Description

I am trying to use a Feather M4 Express with circuitpython (version 6.1.0) and Jupyter. I am intermittently having an issue where the kernel fails to automatically connect to the correct CDC port (circuitpython is presenting on two ports in my OS).

What I Did

Here are my serial ports:

❯ pio device list
/dev/cu.Bluetooth-Incoming-Port
-------------------------------
Hardware ID: n/a
Description: n/a

/dev/cu.usbmodem14303
---------------------
Hardware ID: USB VID:PID=239A:8026 SER=4CBE1F385364933502020233339110FF LOCATION=20-3
Description: Feather M4 Express - CircuitPython CDC2 data

/dev/cu.usbmodem14301
---------------------
Hardware ID: USB VID:PID=239A:8026 SER=4CBE1F385364933502020233339110FF LOCATION=20-3
Description: Feather M4 Express - CircuitPython CDC2 data

Here is an instance where the kernel automatically attempted to connect to the usbmodem140303 port. Notebook commands run in this state hang and never complete. It seems like the kernel always connects to whichever port for the board is listed first. In this error case, that is usbmodem14303. If the other port, usbmodem14301 is listed first, then the jupyter kernel will attempt to connect to that one. In that state things are functional.

circuitpy ❯ jupyter notebook
[I 15:34:47.261 NotebookApp] Serving notebooks from local directory: /Users/MYNAME/Desktop
[I 15:34:47.261 NotebookApp] Jupyter Notebook 6.2.0 is running at:
[I 15:34:47.261 NotebookApp] http://localhost:8888/?    token=28f9c073a686bd4938db0b8574b4158b08d286b24f46e205
[I 15:34:47.261 NotebookApp]  or http://127.0.0.1:8888/?    token=28f9c073a686bd4938db0b8574b4158b08d286b24f46e205
[I 15:34:47.261 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:34:47.264 NotebookApp] 

    To access the notebook, open this file in a browser:
        file:///Users/MYNAME/Library/Jupyter/runtime/nbserver-26094-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=28f9c073a686bd4938db0b8574b4158b08d286b24f46e205
     or http://127.0.0.1:8888/?token=28f9c073a686bd4938db0b8574b4158b08d286b24f46e205
[W 15:34:48.781 NotebookApp] 404 GET /apple-touch-icon-precomposed.png (::1) 8.050000ms referer=None
[W 15:34:48.785 NotebookApp] 404 GET /apple-touch-icon.png (::1) 1.250000ms referer=None
[I 15:34:54.107 NotebookApp] Creating new notebook in 
[I 15:34:55.045 NotebookApp] Kernel started: 412927db-5709-4a7c-b62e-cf65d6c6e615, name: circuitpython
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:circuitpython_kernel.kernel:circuitpython_kernel version 0.3.0.dev
DEBUG:circuitpython_kernel.board:/dev/cu.Bluetooth-Incoming-Port
DEBUG:circuitpython_kernel.board:/dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.board:CircuitPython Board Found at: /dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.board:Connected? False
DEBUG:circuitpython_kernel.board:connect: open /dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.board:serial already open
DEBUG:circuitpython_kernel.board:* enter raw repl ...
[I 15:35:17.427 NotebookApp] Kernel interrupted: 412927db-5709-4a7c-b62e-cf65d6c6e615
DEBUG:circuitpython_kernel.kernel:no connection failed to enter raw repl with /dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.kernel:Error:  'No connection to CiruitPython VM: failed to enter raw repl with     /dev/cu.usbmodem14303'
DEBUG:circuitpython_kernel.board:/dev/cu.Bluetooth-Incoming-Port
DEBUG:circuitpython_kernel.board:/dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.board:CircuitPython Board Found at: /dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.board:Connected? False
DEBUG:circuitpython_kernel.board:connect: open /dev/cu.usbmodem14303
DEBUG:circuitpython_kernel.board:serial already open
DEBUG:circuitpython_kernel.board:* enter raw repl ...

printing with CircuitPython Kernel

  • CircuitPython Kernel version: 0.3.2 - Adafruit Metro Express M0 - SAMD
  • Python version:3.6
  • Operating System: Windows 10 - Anaconda

Description

Im trying to use print() in Jupyterlab with CircuitPython Kernel
when i delete completely while True: it prints alright but when im in a loop it just doesnt work.
CircuitPython Kernel is not able to do this?
even the command line is not showing my prints im doing something wrong or this is not supported?

I can read print() in a while loop with MU
do i need to attach an external debugger?

Sorry about my english, is not my native language

What I Did

`import digitalio
from board import *
import time
led = digitalio.DigitalInOut(D13)
led.direction = digitalio.Direction.OUTPUT

boton = digitalio.DigitalInOut(D0)
boton.switch_to_input(pull = digitalio.Pull.UP)

while True:
print(str(boton.value))
led.value = True
time.sleep(5)
led.value = False
time.sleep(5)
print("Reset")`

![image](https://user-images.githubusercontent.com/8715770/51091524-332eb680-1751-11e9-8060-217031342f58.png)

image

Connecting to the kernel running against a notebook server running in a Docker container

Hi

I was wondering if there are any recipes for running the kernel against a notebook server inside a Docker container on the same host as a Circuit Playground Express device?

On a Mac, I had a guess at:

docker run --privileged --device /dev/cu.usbmodem14101 -p 8866:8888 cctpy

where cctpy is a simple Docker image with a Jupyter notebook server and the Circuit Python kernel installed, but that doesn't seem to want to play:

No connection to CiruitPython VM: found no board

Checking /dev, there is no cu.usbmodem14101 mounted there.

Naively trying to mount the device as a volume didn't seem to help.

Trying to access devices from inside a docker container is new to me, so any ideas on how this might be made work (assuming it can) would be most welcome...

Cannot print to notebook in "while True:" loop

  • CircuitPython Kernel version: 0.3.2
  • Python version: 3.9.7
  • Operating System: Mac OSX
  • Board: (sysname='samd21', nodename='samd21', release='4.1.2', version='4.1.2 on 2019-12-18', machine='Adafruit ItsyBitsy M0 Express with samd21g18')

Description

I am trying to get outputs from my board in a while True: loop. I can get outputs printed to the notebook outside the loop, but inside the loop I cannot.

What I Did

Most of this code is copied from an example in the repo, but I did have to change it to use my ItsyBitsy M0's dotstar instead of a neopixel.

import time
import board
import adafruit_dotstar

dot = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.5)

def flash_pixels(flash_speed=0.5):
    print('flashing R')
    dot.fill((255, 0, 0))
    dot.show()
    time.sleep(flash_speed)
    
    print('flashing G')
    dot.fill((0, 255, 0))
    dot.show()
    time.sleep(flash_speed)
    
    print('flashing B')
    dot.fill((0, 0, 255))
    dot.show()
    time.sleep(flash_speed)

flash_pixels() # prints fine
while True:
    flash_pixels() # no prints in terminal or notebook

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.