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.tar.gz (6.0 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-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reactive-uart2ip-0.2.tar.gz
  • Upload date:
  • Size: 6.0 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.tar.gz
Algorithm Hash digest
SHA256 9d1c5a1cbdbd9e0c290d70ede238e589a77e52e0b7f80b825822f8fbfa127da3
MD5 378e60729ce95f23cdf9436e03ccf1ec
BLAKE2b-256 cd10f5d59da744ec170390afd5554b6a64bdb648bbf5113c926aae51caaf2823

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reactive_uart2ip-0.2-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-py3-none-any.whl
Algorithm Hash digest
SHA256 ccd403fe66c83c48c4c8051468aa9560daec9c2fd694f42bf9e1e9ef50a4241c
MD5 24ad5bf809699673f33dede458aff18d
BLAKE2b-256 a8a48e860fd5a77adfd08c8db799c3c37b5311ad45aae77b71772e4cfda46b8b

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