Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 88
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
*.pyc
*.pyo
*.so
*.coverage

build/
__pycache__/
.mypy_cache/
.pytest_cache/
.vscode/
dist/
sdist/
env/
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributing
To contribute to this repository, use GitHub pull-requests to contribute code
to this repository.

A few things to pay attention to:

- Dependencies are managed using [poetry](https://python-poetry.org/).
- Code is formatted using [Black](https://github.com/psf/black) and imports are
sorted using [isort](https://pycqa.github.io/isort/).
- Documentation conforms to the
[Google Python Style Guide](https://google.github.io/styleguide/pyguide.html#doc-function-args).
- Your branch is linear and logical.
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014-2015 Bas Stottelaar
Copyright (c) 2014-2022 Bas Stottelaar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Frame-based streaming protocol for embedded applications.
[![Build Status](https://travis-ci.org/basilfx/python-tinylink.svg?branch=master)](https://travis-ci.org/basilfx/python-tinylink)

## Introduction
This is a general purpose Python module to provide a bi-directional frame-based streaming protocol for low-speed embedded applications, such as serial connected devices. It allowes the receiver to 'jump into' a stream of data frames. Every frame starts with a preamble, so the receiver can synchronize. Any mismatch in checksum will the receiver.
This is a general purpose Python module to provide a bi-directional frame-based
streaming protocol for low-speed embedded applications, such as serial
connected devices. It allowes the receiver to 'jump into' a stream of data
frames. Every frame starts with a preamble, so the receiver can synchronize.

A payload is optional.

Expand All @@ -22,28 +25,40 @@ X = Body payload (max. 65536 bytes)
Y = CRC32 checksum over header + body
```

The flags field can have arbitrary values, but the following flags are reserved.
The flags field can have arbitrary values, but the following flags are
reserved.

* `0x01 = RESET`
* `0x02 = ERROR`
* `0x04 = PRIORITY`

Error correction is not implemented and the bytes are not aligned. The endianness is customizable.
Error correction is not implemented and the bytes are not aligned. The
endianness is customizable.

## State chart diagram
Below is a simplified statechart diagram of the receiver.
![Alt text](docs/statechart.png)

## Installation
The latest development version can be installed via `pip install git+https://github.com/basilfx/python-tinylink`.

## Tests
Tests can be executed with `nosetests`. Check the `tests/` folder for more information.
The latest development version can be installed via
`pip install git+https://github.com/basilfx/python-tinylink`.

## CLI
A simple serial CLI is included. When installed, run `tinylink /dev/tty.PORT_HERE` to start it. You can use it to send raw bytes via the link and display what comes back.
A simple serial CLI is included. When installed, run
`tinylink /dev/tty.PORT_HERE` to start it. You can use it to send raw bytes via
the link and display what comes back.

The CLI supports so-called modifiers to modify the outgoing data. For example,
the input `\flags=1 hello world` would send a reset frame with the value
'hello world'.

PySerial is required to run this CLI.

## Tests
To run the tests, please clone this repository and run `poetry run pytest`.

## Contributing
See the [`CONTRIBUTING.md`](CONTRIBUTING.md) file.

## License
See the `LICENSE` file (MIT license).
See the [`LICENSE.md`](LICENSE.md) file (MIT license).
Loading