The YMODEM project is based on XMODEM implementation written by tehmaze. It is also compatible with XMODEM mode.
Demo
Test the sending and receiving functions
Interact with SecureCRT
Interact with SecureCRT as sender
Interact with SecureCRT as Finder
Installation
pip install ymodem
Usage
CLI TOOL
# To get help
ymodem -h
# or
python -m ymodem -h
Sending a batch of files
ymodem send ./file.bin ./file2.bin -p COM4 -b 115200
# or
python -m ymodem send ./file.bin ./file2.bin -p COM4 -b 115200
Receive a file
ymodem recv ./ -p COM4 -b 115200
# or
python -m ymodem recv ./ -p COM4 -b 115200
Source Code
from ymodem.Socket import ModemSocket
# define read
def read(size, timeout = 3):
# implementation
# define write
def write(data, timeout = 3):
# implementation
# create socket
cli = ModemSocket(read, write)
# send multi files
cli.send([file_path1, file_path2, file_path3 ...])
# receive multi files
cli.recv(folder_path)
For more detailed usage, please refer to main.py.
API
Create MODEM Object
def __init__(self,
read: Callable[[int, Optional[float]], Any],
write: Callable[[Union[bytes, bytearray], Optional[float]], Any],
protocol_type: int = ProtocolType.YMODEM,
protocol_type_options: List[str] = [],
packet_size: int = 1024,
style_id: int = _psm.get_available_styles()[0]):
- protocol_type: Protocol type, see Protocol.py
- protocol_type_options: such as g representing the YMODEM-G in the YMODEM protocol.
- packet_size: The size of a single packet, 128/1024 bytes, may be adjusted depending on the protocol style
- style_id: Protocol style, different styles have different support for functional features
Send files
def send(self,
paths: List[str],
callback: Optional[Callable[[int, str, int, int], None]] = None
) -> bool:
-
callback: callback function. see below.
Parameter Description task index index of current task task (file) name name of the file total packets number of packets plan to send success packets number of packets successfully sent
Receive files
def recv(self,
path: str,
callback: Optional[Callable[[int, str, int, int], None]] = None
) -> bool:
- path: folder path for storing the target file
- callback: callback function. Same as the callback of send().
ATTENTION
Depending on different communication environments, developers may need to manually adjust timeout parameters in _read_and_wait or _write_and_wait.
Debug
If you want to output debugging information, set the log level to DEBUG.
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
Changelog
v1.5 (2024/02/03)
- Added cli tool to iteract with YMODEM via Serial bus
v1.5 (2023/05/20 11:00 +00:00)
- Rewritten send() and recv()
- Support YMODEM-G. The success rate of YMODEM-G based on pyserial depends on the user's OS, and after testing, the success rate is very low without any delay.
License
Metadata
Release files for ymodem 1.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ymodem-1.5.3.tar.gz | 1.4 MB | Without provenance | Details for ymodem-1.5.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ymodem-1.5.3-py3-none-any.whl | Python 3 | none | any | Details for ymodem-1.5.3-py3-none-any.whl |
Total release size: 1.4 MB
Release files / ymodem-1.5.3.tar.gz
| Download URL | ymodem-1.5.3.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e53628d9f538abcac93bc9ffb72919df7467b026646f755d8cf05c5d552289d
|
|
BLAKE2b-256 checksum How to use checksums |
487c44f340e03a738686262799aa6b69f0744a02fcb87f02c4b98bcc42060a12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ymodem-1.5.3-py3-none-any.whl
| Download URL | ymodem-1.5.3-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79b4e88c70afc277369183c98d1443e57d545e5e3cecb6144aa07138a69aaf10
|
|
BLAKE2b-256 checksum How to use checksums |
ff6b66ffe5ce3359981e8517c4e26d59e80d29ccbd9766d2abdc1c6eb199775b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ymodem 1.5.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.