ymodem


Nameymodem JSON
Version 1.5.1b2 PyPI version JSON
download
home_page
SummaryYmodem Python3 implementation
upload_time2024-02-03 00:21:39
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords pyserial serial xmodem ymodem python python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![ymodem-logo](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/ymodem-logo.png)

Fork of the YMODEM project by [alexwoo1900](https://github.com/alexwoo1900/ymodem)
Now available on PyPi, also now it can be used as cli tool for Serial ports
The YMODEM project is based on XMODEM implementation written by tehmaze. 
It is also compatible with XMODEM mode.


[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)
[![PyPI Version](https://img.shields.io/pypi/v/ymodem?label=PyPI&logo=pypi)](https://pypi.org/project/ymodem/)

README: [ENGLISH](https://github.com/alexwoo1900/ymodem/blob/master/README.md) | [简体中文](https://github.com/alexwoo1900/ymodem/blob/master/README_CN.md)

- [**Installation**](#installation)
- [**Usage**](#usage)
  - [CLI TOOL](#cli-tool) 
    - [Sending a batch of files](#sending-a-batch-of-files)
    - [Receive a file](#receive-a-file)
  - [Demo](#demo)
  - [Interact with SecureCRT](#interact-with-securecrt)
  - [Quick start](#quick-start)
- [API](#api)
  - [Create MODEM Object](#create-modem-object)
  - [Send files](#send-files)
  - [Receive files](#receive-files)
  - [Debug](#debug)
- [Changelog](#changelog)
- [License](#license)

## Installation
```Bash
pip install ymodem
```

## Usage

### CLI TOOL

```Bash
# To get help
ymodem -h
# or
python -m ymodem -h
```

#### Sending a batch of files
```Bash
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
```Bash
ymodem recv ./ -p COM4 -b 115200
# or
python -m ymodem recv ./ -p COM4 -b 115200
```



## Demo

### Test the sending and receiving functions

If you want to run the test sample, please do the following:
1. use virtual serial port tool to generate COM1 and COM2 that can communicate
2. run the FileReceiver.py and FileSender.py on the command line

The specific transmission process is shown in the following figure:
![SenderAndReceiver](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/console_test.gif)

### Interact with SecureCRT

Interact with SecureCRT as sender
![SecureCRT1](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/sender.gif)

Interact with SecureCRT as Finder
![SecureCRT2](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/receiver.gif)

## Quick start

```python
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 the demo/FileReceiver.py and demo/FileSender.py files.

## API

### Create MODEM Object

```python
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

```python
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

```python
def recv(self, 
         path: str, 
         callback: Optional[Callable[[int, str, int, int], None]] = None
        ) -> bool:
```

- callback: callback function. Same as the callback of send().

## Debug

If you want to output debugging information, set the log level to DEBUG.

```python
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
```

## Changelog

### v1.5.1b1 (2024/02/03)

- Added additional options to cli tool

### v1.5.1b0 (2024/02/03)

- Added cli tool to iteract with YMODEM via Serial bus
- Fix of transaction end logic in send()

### 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
[MIT License](https://opensource.org/licenses/MIT)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ymodem",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "pyserial,serial,xmodem,ymodem,python,python3",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ee/dc/3e45f9859f6d13c0fa8c242eedbc5e10c45f135c6a8041a0655ae7b5e995/ymodem-1.5.1b2.tar.gz",
    "platform": null,
    "description": "![ymodem-logo](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/ymodem-logo.png)\n\nFork of the YMODEM project by [alexwoo1900](https://github.com/alexwoo1900/ymodem)\nNow available on PyPi, also now it can be used as cli tool for Serial ports\nThe YMODEM project is based on XMODEM implementation written by tehmaze. \nIt is also compatible with XMODEM mode.\n\n\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)\n[![PyPI Version](https://img.shields.io/pypi/v/ymodem?label=PyPI&logo=pypi)](https://pypi.org/project/ymodem/)\n\nREADME: [ENGLISH](https://github.com/alexwoo1900/ymodem/blob/master/README.md) | [\u7b80\u4f53\u4e2d\u6587](https://github.com/alexwoo1900/ymodem/blob/master/README_CN.md)\n\n- [**Installation**](#installation)\n- [**Usage**](#usage)\n  - [CLI TOOL](#cli-tool) \n    - [Sending a batch of files](#sending-a-batch-of-files)\n    - [Receive a file](#receive-a-file)\n  - [Demo](#demo)\n  - [Interact with SecureCRT](#interact-with-securecrt)\n  - [Quick start](#quick-start)\n- [API](#api)\n  - [Create MODEM Object](#create-modem-object)\n  - [Send files](#send-files)\n  - [Receive files](#receive-files)\n  - [Debug](#debug)\n- [Changelog](#changelog)\n- [License](#license)\n\n## Installation\n```Bash\npip install ymodem\n```\n\n## Usage\n\n### CLI TOOL\n\n```Bash\n# To get help\nymodem -h\n# or\npython -m ymodem -h\n```\n\n#### Sending a batch of files\n```Bash\nymodem send ./file.bin ./file2.bin -p COM4 -b 115200\n# or\npython -m ymodem send ./file.bin ./file2.bin -p COM4 -b 115200\n```\n\n#### Receive a file\n```Bash\nymodem recv ./ -p COM4 -b 115200\n# or\npython -m ymodem recv ./ -p COM4 -b 115200\n```\n\n\n\n## Demo\n\n### Test the sending and receiving functions\n\nIf you want to run the test sample, please do the following:\n1. use virtual serial port tool to generate COM1 and COM2 that can communicate\n2. run the FileReceiver.py and FileSender.py on the command line\n\nThe specific transmission process is shown in the following figure:\n![SenderAndReceiver](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/console_test.gif)\n\n### Interact with SecureCRT\n\nInteract with SecureCRT as sender\n![SecureCRT1](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/sender.gif)\n\nInteract with SecureCRT as Finder\n![SecureCRT2](https://raw.githubusercontent.com/alexwoo1900/ymodem/master/docs/assets/receiver.gif)\n\n## Quick start\n\n```python\nfrom ymodem.Socket import ModemSocket\n\n# define read\ndef read(size, timeout = 3):\n    # implementation\n\n# define write\ndef write(data, timeout = 3):\n    # implementation\n\n# create socket\ncli = ModemSocket(read, write)\n\n# send multi files\ncli.send([file_path1, file_path2, file_path3 ...])\n\n# receive multi files\ncli.recv(folder_path)\n```\n\nFor more detailed usage, please refer to the demo/FileReceiver.py and demo/FileSender.py files.\n\n## API\n\n### Create MODEM Object\n\n```python\ndef __init__(self, \n             read: Callable[[int, Optional[float]], Any], \n             write: Callable[[Union[bytes, bytearray], Optional[float]], Any], \n             protocol_type: int = ProtocolType.YMODEM, \n             protocol_type_options: List[str] = [],\n             packet_size: int = 1024,\n             style_id: int = _psm.get_available_styles()[0]):\n```\n- protocol_type: Protocol type, see Protocol.py\n- protocol_type_options: such as g representing the YMODEM-G in the YMODEM protocol.\n- packet_size: The size of a single packet, 128/1024 bytes, may be adjusted depending on the protocol style\n- style_id: Protocol style, different styles have different support for functional features\n\n### Send files\n\n```python\ndef send(self, \n         paths: List[str], \n         callback: Optional[Callable[[int, str, int, int], None]] = None\n        ) -> bool:\n```\n\n- callback: callback function. see below.\n\n    Parameter | Description\n    -|-\n    task index | index of current task\n    task (file) name | name of the file\n    total packets | number of packets plan to send\n    success packets | number of packets successfully sent\n\n### Receive files\n\n```python\ndef recv(self, \n         path: str, \n         callback: Optional[Callable[[int, str, int, int], None]] = None\n        ) -> bool:\n```\n\n- callback: callback function. Same as the callback of send().\n\n## Debug\n\nIf you want to output debugging information, set the log level to DEBUG.\n\n```python\nlogging.basicConfig(level=logging.DEBUG, format='%(message)s')\n```\n\n## Changelog\n\n### v1.5.1b1 (2024/02/03)\n\n- Added additional options to cli tool\n\n### v1.5.1b0 (2024/02/03)\n\n- Added cli tool to iteract with YMODEM via Serial bus\n- Fix of transaction end logic in send()\n\n### v1.5 (2023/05/20 11:00 +00:00)\n\n- Rewritten send() and recv()\n- Support YMODEM-G. \n    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.\n\n## License\n[MIT License](https://opensource.org/licenses/MIT)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Ymodem Python3 implementation",
    "version": "1.5.1b2",
    "project_urls": {
        "Bug Reports": "https://github.com/o-murphy/ymodem/issues",
        "Homepage": "https://github.com/o-murphy/ymodem",
        "Source": "https://github.com/o-murphy/ymodem"
    },
    "split_keywords": [
        "pyserial",
        "serial",
        "xmodem",
        "ymodem",
        "python",
        "python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e63563c01c34220b08f7117f43b0ee9dd683a10db66e30a8c6592f73b800cdf",
                "md5": "335578de726ac8ee29f6e61b662cab32",
                "sha256": "803783f9138bc03f90234a68af1a5871dec3b8d93355660379a639e6d4e0ec02"
            },
            "downloads": -1,
            "filename": "ymodem-1.5.1b2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "335578de726ac8ee29f6e61b662cab32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 21629,
            "upload_time": "2024-02-03T00:21:38",
            "upload_time_iso_8601": "2024-02-03T00:21:38.259892Z",
            "url": "https://files.pythonhosted.org/packages/4e/63/563c01c34220b08f7117f43b0ee9dd683a10db66e30a8c6592f73b800cdf/ymodem-1.5.1b2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eedc3e45f9859f6d13c0fa8c242eedbc5e10c45f135c6a8041a0655ae7b5e995",
                "md5": "e96d76fbdc46ef20d46bc915e8612f30",
                "sha256": "691c04a0940a70f7944c599f19d0fb8ef75c88fac1ed01b7b6e92eaaba3a11a2"
            },
            "downloads": -1,
            "filename": "ymodem-1.5.1b2.tar.gz",
            "has_sig": false,
            "md5_digest": "e96d76fbdc46ef20d46bc915e8612f30",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 22602,
            "upload_time": "2024-02-03T00:21:39",
            "upload_time_iso_8601": "2024-02-03T00:21:39.987475Z",
            "url": "https://files.pythonhosted.org/packages/ee/dc/3e45f9859f6d13c0fa8c242eedbc5e10c45f135c6a8041a0655ae7b5e995/ymodem-1.5.1b2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-03 00:21:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "o-murphy",
    "github_project": "ymodem",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ymodem"
}
        
Elapsed time: 0.17510s