Giter Site home page Giter Site logo

reactive-uart2ip's Introduction

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.

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.