mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org
Subject: libratp, libratp-barebox and ratp-barebox-cli
Date: Thu, 15 Jun 2017 13:18:41 +0200	[thread overview]
Message-ID: <CAAP7uc+itatZvN+dwD9TKfSFr=HXOQ0OWT6JUz9dBxbW+1G1FQ@mail.gmail.com> (raw)

Hey,

For anyone interested, I ended up preparing a pair of C libraries and
a CLI tool that allow controlling barebox remotely using RATP, in the
same way as bbremote does it. The libraries would allow easy
integration on C applications that may want to remotely control
barebox.

Repositories:
  https://github.com/aleksander0m/libratp
  https://github.com/aleksander0m/libratp-barebox

Some initial 0.0.2 tagged versions here:
  https://aleksander.es/software/libratp-0.0.2.tar.xz
  https://aleksander.es/software/libratp-barebox-0.0.2.tar.xz

APIs:
  https://aleksander0m.github.io/libratp
  https://aleksander0m.github.io/libratp-barebox

The libratp library provides a generic RATP implementation, much like
barebox' lib/ratp.c:
  * The library currently supports creating ratp_t objects for TTYs or
FIFO pairs (e.g. for barebox sandbox testing).
  * The library launches a background thread running a libevent main
loop, which takes care of all the async reading from the TTY (or
FIFO). all the timers in the RATP logic and all the link management
state machine.
  * Callbacks may be registered by the user to get reported when new
data arrives or when RATP link state changes. Worth noting that these
callbacks are called from within the support thread.
  * The ratp_close() and ratp_establish() operations in barebox'
lib/ratp.c are blocking, they will not return until the desired final
state has been reached or a timeout happened. In the libratp library
the equivalent operations would be ratp_link_active_open_sync() and
ratp_link_close_sync(); but the library also includes support for just
sending the active open or close requests, without waiting for the
final state to be reached, via ratp_link_active_open() and
ratp_link_close(). This allows to e.g. request an active open and
queue data to be sent, so that the data is directly sent on the ACK
finishing the establishment.
  * The library doesn't make any assumption on the maximum data length
chosen by each peer, so a peer may choose a MDL<255 to receive data in
shorter chunks or even choose MDL=0 to indicate no data may be
received.

The libratp-barebox library "extends" the libratp library with barebox
specific operations. Right now, these are implemented:
 * ratp_barebox_link_ping()
 * ratp_barebox_link_command()
 * ratp_barebox_link_getenv()

The ratp-barebox-cli implements the barebox specific operations in a
CLI, just a simple way to exercise the library APIs:

$ ratp-barebox-cli -t /dev/ttyUSB3 --ping
Sending PING...
PONG received...

$ ratp-barebox-cli -t /dev/ttyUSB3 --getenv global.boot.default
Sending getenv request: global.boot.default
global.boot.default: net

$ ratp-barebox-cli -t /dev/ttyUSB3 --command "ls /dev"
Sending command: ls /dev
Received response (errno Success):
cs0              eeprom0          eeprom1          full
imx-ocotp        mem              netconsole-1     null
prng             ram0             ratpconsole-1    serial0-1
serial1-1        serial2-1        zero

Cheers!

-- 
Aleksander
https://aleksander.es

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2017-06-15 11:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAP7uc+itatZvN+dwD9TKfSFr=HXOQ0OWT6JUz9dBxbW+1G1FQ@mail.gmail.com' \
    --to=aleksander@aleksander.es \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox