Initial commit
This commit is contained in:
165
.gitignore
vendored
165
.gitignore
vendored
@@ -1,137 +1,50 @@
|
|||||||
# Byte-compiled / optimized / DLL files
|
# ── Python ──────────────────────────────────────────────────────────────────
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
*.pyc
|
||||||
|
|
||||||
# C extensions
|
# ── Environnements virtuels ──────────────────────────────────────────────────
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
|
||||||
downloads/
|
|
||||||
eggs/
|
|
||||||
.eggs/
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
wheels/
|
|
||||||
share/python-wheels/
|
|
||||||
*.egg-info/
|
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
MANIFEST
|
|
||||||
|
|
||||||
# PyInstaller
|
|
||||||
# Usually these files are written by a python script from a template
|
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
||||||
*.manifest
|
|
||||||
*.spec
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.nox/
|
|
||||||
.coverage
|
|
||||||
.coverage.*
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
*.cover
|
|
||||||
*.py,cover
|
|
||||||
.hypothesis/
|
|
||||||
.pytest_cache/
|
|
||||||
cover/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
.pybuilder/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# IPython
|
|
||||||
profile_default/
|
|
||||||
ipython_config.py
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
|
||||||
# .python-version
|
|
||||||
|
|
||||||
# pipenv
|
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
||||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
||||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
||||||
# install all needed dependencies.
|
|
||||||
#Pipfile.lock
|
|
||||||
|
|
||||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
||||||
__pypackages__/
|
|
||||||
|
|
||||||
# Celery stuff
|
|
||||||
celerybeat-schedule
|
|
||||||
celerybeat.pid
|
|
||||||
|
|
||||||
# SageMath parsed files
|
|
||||||
*.sage.py
|
|
||||||
|
|
||||||
# Environments
|
|
||||||
.env
|
|
||||||
.venv
|
|
||||||
env/
|
|
||||||
venv/
|
venv/
|
||||||
|
.venv/
|
||||||
|
env/
|
||||||
ENV/
|
ENV/
|
||||||
env.bak/
|
Pipfile.lock
|
||||||
venv.bak/
|
|
||||||
|
|
||||||
# Spyder project settings
|
# ── Secrets ───────────────────────────────────────────────────────────────────
|
||||||
.spyderproject
|
.env
|
||||||
.spyproject
|
.env.*
|
||||||
|
secret.env
|
||||||
|
secrets.py
|
||||||
|
*.secret
|
||||||
|
credentials.json
|
||||||
|
token.json
|
||||||
|
|
||||||
# Rope project settings
|
# ── Logs ─────────────────────────────────────────────────────────────────────
|
||||||
.ropeproject
|
*.log
|
||||||
|
logs/
|
||||||
|
|
||||||
# mkdocs documentation
|
# ── IDE ───────────────────────────────────────────────────────────────────────
|
||||||
/site
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
# mypy
|
# ── Tests / Coverage ─────────────────────────────────────────────────────────
|
||||||
.mypy_cache/
|
.coverage
|
||||||
.dmypy.json
|
htmlcov/
|
||||||
dmypy.json
|
.pytest_cache/
|
||||||
|
|
||||||
# Pyre type checker
|
# ── Build ─────────────────────────────────────────────────────────────────────
|
||||||
.pyre/
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
# pytype static type analyzer
|
# ── Modèles IA (trop lourds pour git) ───────────────────────────────────────
|
||||||
.pytype/
|
*.gguf
|
||||||
|
*.bin
|
||||||
# Cython debug symbols
|
*.safetensors
|
||||||
cython_debug/
|
models/
|
||||||
|
weights/
|
||||||
|
|||||||
@@ -1,27 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Primadiag SAS - Paris
|
|
||||||
# Author: Gino D.
|
|
||||||
# Copyright (c) 2023 Primadiag
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
|
||||||
# copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
# SOFTWARE
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@@ -43,9 +21,10 @@ from dotenv import dotenv_values
|
|||||||
from typing import List, Optional, Tuple, Union
|
from typing import List, Optional, Tuple, Union
|
||||||
|
|
||||||
|
|
||||||
BUFFER_SIZE: int = 256
|
BUFFER_SIZE: int = 512
|
||||||
LISTENING_TO: str = os.getcwd()
|
LISTENING_TO: str = os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
class Tab():
|
class Tab():
|
||||||
bordered: bool = False
|
bordered: bool = False
|
||||||
colsize: List = []
|
colsize: List = []
|
||||||
@@ -330,6 +309,7 @@ class Pyboard(object):
|
|||||||
self.transfer_status()
|
self.transfer_status()
|
||||||
|
|
||||||
self.serial.write(command[i: min(i + BUFFER_SIZE, len(command))])
|
self.serial.write(command[i: min(i + BUFFER_SIZE, len(command))])
|
||||||
|
# time.sleep(0.0001)
|
||||||
|
|
||||||
if not self.read_until(self.send_ok()):
|
if not self.read_until(self.send_ok()):
|
||||||
raise Exception('Terminal: could not execute command')
|
raise Exception('Terminal: could not execute command')
|
||||||
@@ -337,11 +317,13 @@ class Pyboard(object):
|
|||||||
data = self.read_until(b'\x04', stream_output=stream_output, show_status=not stream_output)
|
data = self.read_until(b'\x04', stream_output=stream_output, show_status=not stream_output)
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
|
self.send_ctrl_d()
|
||||||
raise Exception('Terminal: timeout waiting for first EOF reception')
|
raise Exception('Terminal: timeout waiting for first EOF reception')
|
||||||
|
|
||||||
exception = self.read_until(b'\x04')
|
exception = self.read_until(b'\x04')
|
||||||
|
|
||||||
if not exception:
|
if not exception:
|
||||||
|
self.send_ctrl_d()
|
||||||
raise Exception('Terminal: timeout waiting for second EOF reception')
|
raise Exception('Terminal: timeout waiting for second EOF reception')
|
||||||
|
|
||||||
data, exception = (data[:-1].decode('utf-8'), exception[:-1].decode('utf-8'))
|
data, exception = (data[:-1].decode('utf-8'), exception[:-1].decode('utf-8'))
|
||||||
@@ -644,6 +626,13 @@ class Picowatch(object):
|
|||||||
""")
|
""")
|
||||||
self.interrupt()
|
self.interrupt()
|
||||||
|
|
||||||
|
def flash(self):
|
||||||
|
self.terminal("""
|
||||||
|
import machine
|
||||||
|
machine.bootloader()
|
||||||
|
""")
|
||||||
|
self.interrupt()
|
||||||
|
|
||||||
def interrupt(self):
|
def interrupt(self):
|
||||||
self.filesystem.pyboard.send_ctrl_c()
|
self.filesystem.pyboard.send_ctrl_c()
|
||||||
self.filesystem.pyboard.until_nothing_in_waiting()
|
self.filesystem.pyboard.until_nothing_in_waiting()
|
||||||
@@ -949,6 +938,7 @@ while True:
|
|||||||
tab.line('ctrl + Z', 'exit', '', 'Same as ctrl + D, Exit Picowatch Terminal.')
|
tab.line('ctrl + Z', 'exit', '', 'Same as ctrl + D, Exit Picowatch Terminal.')
|
||||||
tab.line('system', 'os', '', 'Pyboard name and version.')
|
tab.line('system', 'os', '', 'Pyboard name and version.')
|
||||||
tab.line('reset', 'rs', '', 'Perform a soft reset from the REPL.')
|
tab.line('reset', 'rs', '', 'Perform a soft reset from the REPL.')
|
||||||
|
tab.line('flash', 'fl', '', 'Perform a flash disk from the REPL.')
|
||||||
tab.line('scan', 'ls', '[<path>] (default: /)', 'List information about the file(s) on the Pyboard.')
|
tab.line('scan', 'ls', '[<path>] (default: /)', 'List information about the file(s) on the Pyboard.')
|
||||||
tab.line('edit', 'vim', '<file> [<use vim>]', 'Edit specified file from the PC (vim or vscode is required).')
|
tab.line('edit', 'vim', '<file> [<use vim>]', 'Edit specified file from the PC (vim or vscode is required).')
|
||||||
tab.line('source', 'cat', '<file>', 'Concatenate source code to standard output.')
|
tab.line('source', 'cat', '<file>', 'Concatenate source code to standard output.')
|
||||||
@@ -997,6 +987,8 @@ while True:
|
|||||||
picowatch.boot()
|
picowatch.boot()
|
||||||
case ['rs' | 'reset']:
|
case ['rs' | 'reset']:
|
||||||
picowatch.reset()
|
picowatch.reset()
|
||||||
|
case ['fl' | 'flash']:
|
||||||
|
picowatch.flash()
|
||||||
case ['exit']:
|
case ['exit']:
|
||||||
sys.exit('Picowatch Terminal disconnected!')
|
sys.exit('Picowatch Terminal disconnected!')
|
||||||
case _:
|
case _:
|
||||||
|
|||||||
Reference in New Issue
Block a user