GithubHelp home page GithubHelp logo

paulober / pyboard-serial-com Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 548 KB

This project is a node package for a simple communication with the Raspberry Pi Pico and Pico W boards. It includes a wrapper for the pyboard.py tool from MicroPython and other helpers.

License: Apache License 2.0

Python 57.76% JavaScript 0.66% TypeScript 41.57%
nodejs raspberry-pi-pico raspberry-pi-pico-w serialport esp32 esp32c3 esp32s3 pico pico-w

pyboard-serial-com's Introduction

pyboard-serial-com

A straightforward library for establishing communication with Raspberry Pi Pico (W) boards using the pyboard.py utility (from the MicroPython project) via the serial port.

Now with experimental ESP32-WROOM, ESP32-S3, ESP32-C3 and Teensy 4.0 support!

This projects main/initial purpose is to offload the communication core and utilities from the MicroPico repo into a seperate repository for development and usability reasons. Also it is/was meant to replace the old ugly asynchronous mess of a communication piece to allow the developement of new more complex features based on the official pyboard.py module developed on the MicroPython repo.

Installation

Before installing, make sure to authenticate with GitHub Package Registry or using a .npmrc file. See "Configuring npm for use with GitHub Package Registry."

$ npm install @paulober/pyboard-serial-com

Or add this package to your package.json file:

"dependencies": {
    "@paulober/pyboard-serial-com": "3.0.9"
}

NOTE: requires the scripts directory to be present in your work-/output directory

Supported platforms

Platform Architectures
Windows x64
Linux x64, arm64, (armhf)
macOS (10.9 or higher) x64, arm64

Usage

import { PyboardRunner } from "@paulober/pyboard-serial-com"

const pyboardRunner = new PyboardRunner(
    "COM3",
    115200,
    (data: Buffer | undefined) => {
        if (data !== undefined) {
            console.error(`stderr: ${data?.toString()}`)
        } else {
            // connected sucessfully
            console.debug("Connected!")
        }
    },
    (code: number, signal: string) => {
        if (code) {
            console.error(`child process exited with code ${code}`)
        }
        if (signal) {
            console.error(`child process killed with signal ${signal}`)
        }
        console.debug("Done - exit")
    }
)

pyboardRunner.disconnect()

Planed changes

  • Maybe switch to RXJS compared to the current custom solution for queueing

Known issues

...

pyboard-serial-com's People

Contributors

chrischoke avatar paulober avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chrischoke

pyboard-serial-com's Issues

wrapper scan_ports exception behavior

Hey Paul,

as i tested my last commit i was wondering about a behavior.

if you use python3 wrapper.py --scan-ports i got something like /,d printed out. this is the case if you end up in the exception block of find_pico_ports() function.
if the function return normal we return a list with a tuple within, line 108:

return [(port.device, BAUDRATES_BY_PID[port.pid]) for port in list_ports.comports() if port.pid in SUPPORTED_USB_PIDS and port.vid in SUPPORTED_USB_VIDS]
except Exception:
devs = list_ports.comports()
if len(devs) > 0:
return [devs[0].device]
return []

but in exception on line 112 we return a list with a string inside. i think we need something like

if isinstance(ports[0], tuple):
    print("\n".join(map(lambda x: str(f'{x[0]},{x[1]}'), ports))+"\n"+EOO, flush=True)
else:
    print("\n".join(map(lambda x: str(f'{x}'), ports))+"\n"+EOO, flush=True)

at

print("\n".join(map(lambda x: str(f'{x[0]},{x[1]}'), ports))+"\n"+EOO, flush=True)

or return a tuple in the list with a defaulted hard coded baudrate or something.

and if the function return normal but i plugged in a unsupported device the function returned with an empty list, what i think thats okay. because else we maybe get the device returned from the exception block.

i hope you can understand what i mean :-)

i dont dare submit a suggestion in that case, because i am a hobby developer 😊

Chris

Regression in v3.7.7

What are the steps to reproduce this issue?

Not sure there is any steps to reproduce as it happens during vscode startup when the extension is enabled.

What happens?

Extension seems to throw during initialization. Regression was introduced in v3.7.7 since everything seems to work fine in v3.7.6.

What were you expecting to happen?

Any logs, error output, etc?

(To get extension logs see Terminal > Output > Extension Host and copy output concerning pico-w-go or micropico)
(If it’s long, please paste to https://gist.github.com and insert the link here)

2024-05-30 22:50:40.794 [error] Activating extension paulober.pico-w-go failed due to an error:
2024-05-30 22:50:40.794 [error] Error: spawn Unknown system error -86
  at ChildProcess.spawn (node:internal/child_process:414:11)  at Object.spawn (node:child_process:799:9)
  at new e (/Users/nestor/.vscode/extensions/paulober.pico-w-go-3.7.7-darwin-x64/dist/extension.cjs:1:5181)  at Wh.activate (/Users/nestor/.vscode/extensions/paulober.pico-w-go-3.7.7-darwin-x64/dist/extension.cjs:8:86711)
  at async exports.activate (/Users/nestor/.vscode/extensions/paulober.pico-w-go-3.7.7-darwin-x64/dist/extension.cjs:8:105526)  at async h.n (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6281)
  at async h.m (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6244)  at async h.l (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:5701)

Any other comments?

I can provide more details if necessary since it seems I can reproduce it 100% of times just by launching the editor.

Which version of MicroPico are you using?

v3.7.7

Support info

Version: 1.89.1 (Universal)
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:14:24.611Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin x64 23.5.0

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.