Skip to content

Haghighatbin/Srltool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SerialTool – STM32 Serial Communication Utility

SerialTool (srltool) - A tool to communicate with a Micropython-based STM32 device

"srltool" is a lightweight command-line tool to communicate with Micropython-based STM32 devices over serial (USB) connection. It automatically detects connected STM32 devices, establishes a serial connection, and provides convenient methods to interact with the device using MicroPython's raw REPL interface.

Current features include sending and receiving files/directories, creating and removing files or directories, and viewing memory usage and available flash space.

⚠️ Warning: This tool was developed for personal use. Exercise caution, especially with destructive commands like rmdir or rmfile.

Usage: cli.py [OPTIONS] COMMAND [ARGS]...

Options: -h, --help Show this message and exit.

Commands:
- ls Lists the content of the specified directory. - mkdir Creates the specified directory. - recv-dir Receives the specified directory. - recv-file Receives the specified file. - rmdir Removes the specified directory. - rmfile Removes the specified file. - send-dir Sends the specified directory. - send-file Sends the specified file. - flashstat Returns the details of allocated and available flash space. - memstat Returns the memory status of the device. - stats Returns the overall flash size details and memory status. - tree Lists the content of the specified directory in Tree format.

Installation

sudo pip install -r requirements.txt
sudo python setup.py develop

Usage

Note: You might have to use the srltool under superuser/admin privileges(sudo).
Note: srltool will find the accessible port to the available stm32 device and communicates over serial with a predefined baudrate of 115200.

$${\color{blue}[ls]}$$

Lists the content of the specified directory.

Examples:
srltool ls
or
srltool ls [directory]
srltool ls --help


$${\color{blue}[tree]}$$

Lists the content of the specified directory in a Tree format.

Examples:
srltool tree
or
srltool tree [folder]
or
srltool tree --show-hidden --dir-only
srltool tree --help


$${\color{blue}[memstat]}$$

Returns the memory status of the device.

Example:
srltool memstat
srltool memstat --help


$${\color{blue}[flashstat]}$$

Returns details of the allocated and available flash space.

Example:
srltool flashstat
srltool flashstat --help


$${\color{blue}[stats]}$$

Returns the overall flash size details and memory status.

Example:
srltool stats
srltool stats --help


$${\color{blue}[mkdir]}$$

Creates the specified directory.
The [--ignore-if-exists] option if passed then if the directory exists will be preserved ignoring the deletion.

Example:
srltool mkdir [directory_to_create]
or
srltool mkdir [directory_to_create] --ignore-if-exists
srltool mkdir --help


$${\color{blue}[rmfile]}$$

Removes the specified file without further notice, please be cautious!

Example:
srltool rmfile [file_to_delete]
srltool rmfile --help


$${\color{blue}[rmdir]}$$

Removes the specified directory.
If the [--forced or -f] option is passed then if the existed folder and all its contents including all files and subdirectories will be deleted recursively.
The default flag is True, please be cautious!

Examples:
srltool rmdir [dir_to_delete]
or
srltool rmdir [dir_to_delete] --forced
srltool rmdir --help


$${\color{blue}[sendfile]}$$

Sends the specified file [filename_to_send] and will save as the specified file [filename_to_save]. If the [filename_to_save] has not been specified as an argument, then the same name as the [filename_to_get] will be designated to save the file.
[buffer_size] argument may also be passed to adjust the size of the buffers to be transferred over serial; the default value is 32 bytes.
The [--forced or -f] option can be passed to overwrite the existing file, please be cautious!

Examples:
srltool send-file [filename_to_send] [filename_to_save]
or
srltool send-file [filename_to_send]
or
srltool send-file [filename_to_send] --forced buffer_size=128
srltool send-file --help


$${\color{blue}[senddir]}$$

[senddir]

Sends the specified directory [dirname_to_send] and all its included files to the specified directory [dirname_to_save].
If the [dirname_to_save] has not been specified as an argument, then the same name as the [dirname_to_send] will be designated to save the folder.
The [--forced or -f] option can be passed to overwrite the existing folder and all its included files, please be cautious!

Examples:
srltool send-dir [dirname_to_send] [dirname_to_save]
or

srltool send-dir [dirname_to_send]
or
srltool send-dir [dirname_to_send] --forced
srltool send-dir --help


$${\color{blue}[recvfile]}$$

Receives the specified file [filename_to_get] and will save as the specified file [filename_to_save].
If the [filename_to_save] has not been specified as an argument, then the same name as the [filename_to_get] will be designated to save the file.
[check_exist] argument may be passed to check if the file exists; the default value is True.
[buffer_size] argument may also be passed to adjust the size of the buffers to be transferred over serial; the default value is 32.

Examples:
srltool recv-file [filename_to_get] [filename_to_save]
or
srltool recv-file [filename_to_get]
or
srltool recv-file [filename_to_get] check_exist=True buffer_size=64
or
srltool recv-file [filename_to_get] [filename_to_save]
srltool recv-file --help


$${\color{blue}[recvdir]}$$

Receives the specified directory [dirname_to_get] and its included files and will save in the specified directory [dirname_to_save].
If the [dirname_to_save] has not been specified as an argument, then the same name as the [dirname_to_get] will be designated to save the folder.

Examples:
srltool recv-dir dirname_to_get dirname_to_save
or
srltool recv-dir dirname_to_get
srltool recv-dir --help


$${\color{blue}[astroid]}$$

Requests a list of coordinates and will plot an astroid as a serial test.
This module was written to assess the serial connection. It requests a list of coordinates to be generated by the STM32 device and returned to be plotted.

Examples:
srltool astroid [iterations]
or
srltool astroid 10
srltool astroid --help

License

MIT License


To-do

  • ESP32 compatibility

About

A tool to communicate with a Micropython(STM32) device

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages