Outils pour utilisateurs

Outils du site


issue174:micro-ci_micro-la

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
issue174:micro-ci_micro-la [2021/10/31 18:28] – créée auntieeissue174:micro-ci_micro-la [2021/11/04 09:39] (Version actuelle) auntiee
Ligne 1: Ligne 1:
-Sometimes, when you update your microcontroller with a new version of MicroPython, your entire memory gets erased. When that happens, of course, all of the code that you worked on gets erased as well. If you are using Thonny, you have the ability to copy any files that you want to keep safe off of the Microcontroller onto your main computer. But only one file at a time.+**Sometimes, when you update your microcontroller with a new version of MicroPython, your entire memory gets erased. When that happens, of course, all of the code that you worked on gets erased as well. If you are using Thonny, you have the ability to copy any files that you want to keep safe off of the Microcontroller onto your main computer. But only one file at a time.
  
 I found a neat utility called mpfshell that can make your life a whole lot easier. You can find their repository at https://github.com/wendlers/mpfshell, and it’s well worth your time to download, install and learn how to use it. I found a neat utility called mpfshell that can make your life a whole lot easier. You can find their repository at https://github.com/wendlers/mpfshell, and it’s well worth your time to download, install and learn how to use it.
  
-According to the repository main page, the utility is “A simple shell based file explorer for ESP8266 and WiPy Micropython based devices.” Just so you know, mpfshell works on more than just the ESP8266 and the WiPy. I’ve tested it on the ESP8266, the ESP32, and the Raspberry Pi Pico, and it works just fine on all three devices. For complete transparency, I haven’t tried all the commands on all three Microcontrollers, because I use it only to copy and push files to and from the Microcontroller devices so far. Let’s examine how you would use it.+According to the repository main page, the utility is “A simple shell based file explorer for ESP8266 and WiPy Micropython based devices.” Just so you know, mpfshell works on more than just the ESP8266 and the WiPy. I’ve tested it on the ESP8266, the ESP32, and the Raspberry Pi Pico, and it works just fine on all three devices. For complete transparency, I haven’t tried all the commands on all three Microcontrollers, because I use it only to copy and push files to and from the Microcontroller devices so far. Let’s examine how you would use it.**
  
-Of course, you need to install the program to be able to use it, which is easy since it is on PyPi. In a terminal, you need to use only pip. On your main machine, open a terminal and type+Parfois, lorsque vous mettez à jour votre microcontrôleur avec une nouvelle version de MicroPython, toute votre mémoire est effacée. Lorsque cela se produit, bien sûr, tout le code sur lequel vous avez travaillé est également effacé. Si vous utilisez Thonny, vous avez la possibilité de copier tous les fichiers que vous voulez garder en sécurité depuis le microcontrôleur vers votre ordinateur principal. Mais seulement un fichier à la fois. 
 + 
 +J'ai trouvé un utilitaire appelé mpfshell qui peut vous rendre la vie beaucoup plus facile. Vous pouvez trouver son dépôt à l'adresse https://github.com/wendlers/mpfshell, et il vaut la peine de le télécharger, de l'installer et d'apprendre à l'utiliser. 
 + 
 +Selon la page principale du dépôt, l'utilitaire est « un simple explorateur de fichiers basé sur un shell pour les appareils ESP8266 et WiPy basés sur Micropython ». Pour votre information, mpfshell ne fonctionne pas que sur l'ESP8266 et le WiPy. Je l'ai testé sur l'ESP8266, l'ESP32 et le Raspberry Pi Pico, et il fonctionne très bien sur les trois appareils. Pour une transparence totale, je n'ai pas essayé toutes les commandes sur les trois microcontrôleurs, car, jusqu'à présent, je ne l'utilise que pour copier et pousser des fichiers vers et depuis les microcontrôleurs. Voyons comment vous pourriez l'utiliser. 
 + 
 +**Of course, you need to install the program to be able to use it, which is easy since it is on PyPi. In a terminal, you need to use only pip. On your main machine, open a terminal and type
  
 $  pip install mpfshell $  pip install mpfshell
Ligne 24: Ligne 30:
 -- Running on Python 3.7 using PySerial 3.4 -- -- Running on Python 3.7 using PySerial 3.4 --
  
-mpfs [/]> +mpfs [/]> ** 
 + 
 +Bien sûr, vous devez installer le programme pour pouvoir l'utiliser, ce qui est facile puisqu'il est sur PyPi. Dans un terminal, vous devez utiliser uniquement pip. Sur votre machine principale, ouvrez un terminal et tapez 
 + 
 +$ pip install mpfshell 
 + 
 +Vous pouvez également télécharger le dépôt complet et l'installer à partir de celui-ci. 
 + 
 +Une fois installé, ouvrez un terminal dans le dossier où vous souhaitez copier les fichiers de l'ordinateur principal vers le microcontrôleur, ou du microcontrôleur vers l'ordinateur principal. 
 + 
 +Avant de commencer, vous devez savoir à quel port série votre appareil est connecté (voir ci-dessus). 
 + 
 +Habituellement, le périphérique sera sur /dev/ttyUSB0 ou /dev/ttyACM0, mais le port réel auquel votre périphérique se connecte peut changer en fonction de ce qui est branché à votre système à ce moment-là. Dans l'exemple ci-dessus, ma machine est connectée à un ESP32 sur /dev/ttyUSB0.  
 + 
 +Maintenant, il suffit de lancer le programme : 
 + 
 +$ mpfshell 
 + 
 +** Micropython File Shell v1.1.2, sw@kaltpost.de & junhuanchen@qq.com & lht856@foxmail.com ** 
 +-- Exécuté sur Python 3.7 en utilisant PySerial 3.4 -- 
 + 
 +mpfs [/]> ** 
  
-Next, you have to tell mpfshell to connect to the device on the correct serial port with the open {port} command. I’ve seen this just seems to lock up sometimes. If that happens just do a <Ctrl> C in the terminal and start the shell again. It almost always works the second time.+**Next, you have to tell mpfshell to connect to the device on the correct serial port with the open {port} command. I’ve seen this just seems to lock up sometimes. If that happens just do a <Ctrl> C in the terminal and start the shell again. It almost always works the second time.
  
 mpfs [/]> open /dev/ttyUSB0 mpfs [/]> open /dev/ttyUSB0
Ligne 46: Ligne 74:
 mpfs [/]> mpfs [/]>
  
-Of course, the files on your Microcontoller will be different from what’s on mine, but you get the idea.+Of course, the files on your Microcontoller will be different from what’s on mine, but you get the idea.**
  
-Now, let’s do a complete copy from the ESP32 (or whatever your Microcontroller is) to the computer’s hard drive. To do this, you need to use the mget command. However, you need to use a special command. The command is mget .*\.py . You might recognize that this command uses a regular expression (regex) to get all files.+Ensuite, vous devez dire à mpfshell de se connecter au périphérique sur le bon port série avec la commande open {port}. J'ai vu que cela semble se bloquer parfois. Si cela arrive, faites simplement un <Ctrl> C dans le terminal et redémarrez le shell. Cela fonctionne presque toujours la deuxième fois. 
 + 
 +mpfs [/]> open /dev/ttyUSB0 
 +Connected to esp32 
 +mpfs [/]>  
 + 
 +Remarquez que mpfshell vous indique le type de périphérique auquel vous êtes connecté. Cela peut être très utile si vous avez plusieurs périphériques connectés. Maintenant que vous êtes connecté à votre microcontrôleur, faites un ls pour trouver les fichiers et dossiers présents sur votre périphérique. 
 + 
 +mpfs [/]> ls 
 +Remote files in '/': 
 +       boot.py 
 +       esp32i2cscan.py 
 +       gfx.py 
 +       image1.py 
 +       image2.py 
 +       rnerd_ssd1306_esp32.py 
 +    rnerd_ssd1306_esp32_graphics1.py 
 +       ssd1306.py 
 +mpfs [/]> 
 + 
 +Bien sûr, les fichiers sur votre microcontrôleur seront différents de ceux qui se trouvent sur le mien, mais vous avez compris l'idée. 
 + 
 +**Now, let’s do a complete copy from the ESP32 (or whatever your Microcontroller is) to the computer’s hard drive. To do this, you need to use the mget command. However, you need to use a special command. The command is mget .*\.py . You might recognize that this command uses a regular expression (regex) to get all files.
  
 mpfs [/]> mget .*\.py mpfs [/]> mget .*\.py
Ligne 72: Ligne 122:
  * put esp32i2cscan.py  * put esp32i2cscan.py
  * put .python-version  * put .python-version
 + * put gfx.py
 +mpfs [/]> **
 +
 +Maintenant, faisons une copie complète de l'ESP32 (ou de votre microcontrôleur, quel qu'il soit) vers le disque dur de l'ordinateur. Pour ce faire, vous devez utiliser la commande mget. Cependant, vous devez utiliser une commande spéciale. Cette commande est mget .*\.py . Vous pouvez reconnaître que cette commande utilise une expression régulière (regex) pour obtenir tous les fichiers.
 +
 +mpfs [/]> mget .*\.py
 + * get boot.py
 + * get esp32i2cscan.py
 + * get gfx.py
 + * get image1.py
 + * get image2.py
 + * get rnerd_ssd1306_esp32.py
 + * get rnerd_ssd1306_esp32_graphics1.py
 + * get ssd1306.py
 +mpfs [/]> 
 +
 +Pour effectuer une copie en masse de votre ordinateur vers le microcontrôleur, vous pouvez utiliser la commande mput.
 +
 +mpfs [/]> mput .*\.py
 + * put ssd1306.py
 + * put boot.py
 + * put image2.py
 + * put rnerd_ssd1306_esp32_graphics1.py
 + * put rnerd_ssd1306_esp32.py
 + * put image1.py
 + * mettre esp32i2cscan.py
 + * put esp32i2cscan.py
  * put gfx.py  * put gfx.py
 mpfs [/]>  mpfs [/]> 
  
-You can copy a single file by just using the get or put command.+**You can copy a single file by just using the get or put command.
  
 mpfs [/]> get boot.py mpfs [/]> get boot.py
Ligne 92: Ligne 169:
 cd          exec      lcd         lpwd      mput  open        quit      rm   cd          exec      lcd         lpwd      mput  open        quit      rm  
  
-mpfs [/]> +mpfs [/]> ** 
 + 
 +Vous pouvez copier un seul fichier en utilisant tout simplement les commandes get ou put. 
 + 
 +mpfs [/]> get boot.py 
 +mpfs [/]> put boot.py 
 +       boot.py 
 +mpfs [/]> 
 + 
 +Si, à un moment donné, vous ne vous souvenez plus de la commande que vous devez utiliser, tapez simplement help. 
 + 
 +mpfs [/]> help 
 + 
 +Documented commands (type help <topic>): 
 +======================================== 
 +EOF  close  execfile  lef    ls   mpyc   put           runfile                  get  lexecfile        md    mrm  pwd    repl      v       
 +cat  ef     help      lls    mget        o             rf          view    
 +cd          exec      lcd         lpwd      mput  open        quit      rm   
 + 
 +mpfs [/]> 
  
-You can also get help on any of the commands...+**You can also get help on any of the commands...
  
 mpfs [/]> help mget mpfs [/]> help mget
Ligne 111: Ligne 208:
 I sincerely hope that you find this utility as helpful as I do. I sincerely hope that you find this utility as helpful as I do.
  
-Until next time, as always; stay safe, healthy, positive and creative!+Until next time, as always; stay safe, healthy, positive and creative!** 
 + 
 +Vous pouvez également obtenir de l'aide sur n'importe laquelle des commandes : 
 + 
 +mpfs [/]> help mget 
 +mget <SELECTION REGEX> 
 +  Download all remote files that match the given regular expression. 
 +  The local files will be named the same as the remote files. 
 +  "mget" does not get directories, and it is not recursive. 
 +  #Télécharge tous les fichiers distants qui correspondent à l'expression régulière donnée. 
 +  #Les fichiers locaux seront nommés de la même manière que les fichiers distants. 
 +  #« mget » ne récupère pas les répertoires, et il n'est pas récursif. 
 + 
 +mpfs [/]>  
 + 
 +Et pour quitter mpfshell, tapez simplement quit. 
 + 
 +mpfs [/]> quit 
 +greg@earth : $  
 + 
 +J'espère sincèrement que vous trouverez cet utilitaire aussi utile que moi. 
 + 
 +Jusqu'à la prochaine fois, comme toujours ; restez en sécurité, en bonne santé, positif et créatif ! 
issue174/micro-ci_micro-la.1635701336.txt.gz · Dernière modification : 2021/10/31 18:28 de auntiee