amirhmzz / mpbridge Goto Github PK
View Code? Open in Web Editor NEWCLI tool to synchronise and manage files on MicroPython running devices
Home Page: https://pypi.org/project/mpbridge
License: MIT License
CLI tool to synchronise and manage files on MicroPython running devices
Home Page: https://pypi.org/project/mpbridge
License: MIT License
It is better to allow any directory to contain it's mpbridge.ignore
file like .gitignore
.
~$ mpbridge dev /dev/ttyACM0 /home/wind/temp
- Syncing files on /dev/ttyACM0 with /home/wind/temp
- Entering raw repl
- Syncing files
✓ Synced files successfully
? Press [Enter] to Sync >> Hard Reset >> Enter REPL Press [Ctrl + C] to exit
- Syncing files
✓ Synced files successfully
✓ Hard reset board successfully
R Entering REPL using mpremote
Connected to MicroPython at /dev/ttyACM0
Use Ctrl-] to exit this shell
device disconnected
R Exiting REPL
Traceback (most recent call last):
File "/home/wind/.local/bin/mpbridge", line 8, in <module>
sys.exit(main())
File "/home/wind/.local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/home/wind/.local/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/wind/.local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/wind/.local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/wind/.local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/wind/.local/lib/python3.10/site-packages/mpbridge/shell.py", line 64, in dev
bridge.start_dev_mode(port, dir_path)
File "/home/wind/.local/lib/python3.10/site-packages/mpbridge/bridge.py", line 59, in start_dev_mode
pyb = SweetPyboard(device=port)
File "/home/wind/.local/lib/python3.10/site-packages/mpremote/pyboard.py", line 292, in __init__
raise PyboardError("failed to access " + device)
mpremote.pyboard.PyboardError: failed to access /dev/ttyACM0
Tested in Ubuntu 22.04.1 LTS and Windows10, same err.
I think an additional syncing mode could be useful when you have several project on the same board, and you don't want to erase them every time you you switch project.
In this mode, which could be activated by another modifier, say --push instead of --clean, mpbridge copies the files that have changed in the local folder to the board, but it doesn't neither erase other files in the board nor copies any board file to the local folder.
I've been using mpbridge lately and, on purpose, I've stopped using other 3rd party tools.
I hope this uncovers some of the more pressing needs of using mpbridge.
I found that I needed to close mpbridge anyway, and then use other tools to connect to the port, because only one program can occupy the port at a time.
Of course, I directly use mpremote to connect to the port and view the REPL.
I would like to make an initial suggestion.
When there is no operation on the file, enable REPL on the terminal, allowing users to use REPL to interact with micropython devices. When any changes occur in the local temporary folder, interrupt REPL, start synchronizing files, and continue to enable REPL after completion.
If you type ctrl-c
the program quits, but the USB is left in an unusable state. To run tools such as mpremote
a reboot is required.
It would be really useful to have an option on the sync command that just previews the sync but doesn't actually perform the sync.
Thoughts?
Releases v1.19 , mpy 6 description
Briefly, add a function to batch convert .py to .mpy, then sync only the .mpy files to the device.
The .mpy runs faster on the device than .py and takes up less space.
At present, mpy-cross can only convert files one by one through commands, and batch conversion can obviously improve efficiency.
The hash checking feature already in place can continue to be used.
Convert .py to .mpy again only if the .mpy file in the device is different from local.
When mpbridge is run, the Linux default file manager opens. It would be good if there were a means of specifying an alternative.
If that is impractical, printing the location of the temporary filesystem would provide a hint for those wishing to use an alternative.
I attempted to run this under Linux Mint 20.3 with this error message which I've never seen before:
$ ./main.py
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/408.
The system was in a peculiar state with the mouse cursor visible as a cross but not functional. I tried to break in with ctrl-c
without success. I then tried to close the Bash window, which did break into the program with this traceback:
^C
^C^X
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/408.
from: can't read /var/mail/typing
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/408.
./main.py: line 8: syntax error near unexpected token `('
./main.py: line 8: `from watchdog.events import ('
I had installed the latest version of watchdog.
Running as root had no effect, producing the same symptoms.
Accept auto
keyword as port in all commands and detect port automatically. This might need to iterate over serial ports and try them one by one.
import machine
machine.reset()
Is there a way to automatically reconnect the serial port REPL during any hard reset?
🤔
It would be really useful to be able to delete just one directory.
Maybe a new command or a parameter could be supplied to "clear" eg. "clear /logs"?
High... Excellent tool ... Have a couple of issues... When running the ESP32 with a program, in many cases it is difficult to interrupt the process for new update of python code by using "ctr alt ]". In the end i have to stop the mpbridge and erase the ESP code using esptool doing a flash erease and flash innstall of micropython. (esptool IS able to connect to the ESP32 even if mpbridge cannot)
I do not know if this is caused by me not installing with "sudo pip install -U mpbridge" in a conda environment since sudo gave an error i skipped it , using "pip install -U mpbridge" instead.
This works fine if no SD card is fitted, showing a /flash
directory with contents. If a card is fitted, the progress gets to 50% then stops.
Many file system events inspected by watchdog seems to be duplicate. As it effects on user experience these events must be detected and get ignored.
Currently, sync will perform a check and compare, and then pull the files that are not in the local folder from the board to the local, and then push the files that are not on the board or have changed locally to the board.
But what if we need to delete some files on the board?
Suppose, when we need to switch projects to use on the same board, the content of many files or folders will be useless and occupy the flash.
At this time, some methods are needed, such as setting an additional requirement when syncing, only based on the files in the local folder, checking redundant files or subfolders on the board, and deleting them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.