Skip to main content

TCP server that mediates UART serial communication

Project description

reactive-uart2ip

Application that works as a "bridge" between the Sancus FPGA (through UART) and an external client using TCP/IP. This is implemented with the specific purpose to handle Authentic Execution messages, hence this application is not "general purpose", but strongly dependent to the Sancus application running inside the FPGA.

Installation

# Install reactive-uart2ip - you must be in the root of this repository
pip install .

# run reactive-uart2ip
### <loglevel>: log level, e.g., "debug". Default "info"
### <device>: UART device. Default "/dev/ttyUSB1"
### <port>: port used by the app to listen for TCP connections
reactive-uart2ip -l <loglevel> -d <device> -p <port>

Run reactive-uart2ip with Docker

# Run the reactive-uart2ip Docker image
### <loglevel>, <device> and <port> are the same as above
make run LOG=<loglevel> DEVICE=<device> PORT=<port>

How it works

The application is implemented using asyncio tasks.

Serial task

A first task reads for messages from the serial communication.

  • The messages can either be commands or results (see reactive-net)
  • A Command received from the device is immediately sent to the destination (ip and port are received as well), and there is no response.
    • Sancus only sends RemoteOutput commands
  • A Result of a command previously sent to the device is added to a queue, where the task of the TCP connection that has sent the command will retrieve and send back to the client.

TCP/IP tasks

For each new TCP connection, an asynchronous task is created, but only one task at a time uses the UART (by means of a lock).

  • Each TCP connection has the purpose to send a command to the device. If the command expects a result, the task will wait until it is received (without releasing the lock). A timeout is set to avoid endless wait of other tasks, but this should never happen in a normal situation.
  • Before starting the transmission of the data, a handshake is performed. This is necessary to "wake up" the device, in order not to lose bytes during the transmission. The handshake consists on the exchange of one single dummy byte between the application and the FPGA.
  • Since the FPGA has a RX buffer limited to 127 bytes, we need to split large packets in several chunks. In order not to lose any bytes, the FPGA sends an ACK byte after each chunk received. The application, after sending the chunk, waits for the ACK, and after that continues the transmission.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reactive-uart2ip-0.2.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reactive_uart2ip-0.2.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file reactive-uart2ip-0.2.1.tar.gz.

File metadata

  • Download URL: reactive-uart2ip-0.2.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for reactive-uart2ip-0.2.1.tar.gz
Algorithm Hash digest
SHA256 151c04a010a1837e5629d2a8c2ddf8a0f7e5a14bf1729245e2572b40c584b1b3
MD5 446de965bd7f88e4f3acfe0515ab1c37
BLAKE2b-256 fb2495e24d732bd6bbb9e524fe38f2f10113f9766558c7be37219c063e74aa5f

See more details on using hashes here.

File details

Details for the file reactive_uart2ip-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: reactive_uart2ip-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for reactive_uart2ip-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe21dfc6b3a956928c74723519cb81cd6265d49d4fedb7bc3e30f64c3b37f267
MD5 d5ee3df9aa9c3a5722b6f3f822f639b5
BLAKE2b-256 d9d4acd1779c098232e606f475c15ccb39f9784c9157e6695698a8b0183378c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page