Giter Site home page Giter Site logo

hyominyang / fork_py_ymodem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexwoo1900/ymodem

1.0 0.0 0.0 37.65 MB

YMODEM (For cluster communication port) written by Python - 用Python实现的YMODEM串口通讯协议

License: MIT License

Python 100.00%

fork_py_ymodem's Introduction

ymodem-logo

The project is based on XMODEM implementation written by tehmaze.

Build Status license

README: ENGLISH | 简体中文

YMODEM Protocol: ENGLISH | 简体中文

Can YMODEM for Python work

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 test_receiver.py and test_sender.py on the command line

The specific transmission process is shown in the following figure (sender on the left and receiver on the right) cmd_test hash_result

How to use YMODEM for Python

  1. Import YModem in your target file
from YModem import YModem
  1. Define your own get() and put() and create YMODEM object
def getc(size):
    return serial_io.read(size) or None

def putc(data):
    return serial_io.write(data)

tester = YModem(getc, putc)
  1. Send file
tester.send_file(file_path)
  1. Receive file
tester.recv_file(root_path)

YMODEM for Python API

Create YMODEM object

def __init__(self, getc, putc, header_pad=b'\x00', data_pad=b'\x1a')
  • get: Custom function. Get size bytes of data from data source(size)
  • put: Custom function. Send size bytes to destination

Send data

def send_file(self, file_path, retry=20, callback=None)
  • file_path: target file path
  • retry: max resend tries
  • callback: implemented by the developer

Recv data

def recv_file(self, root_path, callback=None)
  • root_path: root path for storing the file
  • callback: implemented by the developer

Attention

This project does not include the following code related to business logic:

  • the callback that processing the internal data of YModem
  • Timeout mechanism and CAN instruction sending

Change logs

v1.0.0 (2020/5/14 14:00 +00:00)

  • Simplified the implementation of the original version of YModem

License

MIT License

fork_py_ymodem's People

Contributors

alexwoo1900 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.