Lappy is a backend for AMB TranX-2 timing system.
- Read passing and noise events from serial device
- Store passing events in sqlite database with race id
- Publish noise and passing events as server-sent events
- Associate metadata with race records
- Systemd files
- HTTP API
- Starting and stopping recoring and publishing passing events
- Subscribe to SSE
- CRUD for metadata like drivers names and car numbers
- Fetch records per race
- Fetch top records
Required environment variables:
LOG_LEVEL
: debug|info|errorDSN
: sqlite3 DSN eg.file:test.db
LISTEN_ADDR
: address to listen eg.0.0.0.0:8000
SERIAL_PORT
: path to serial device eg./dev/usbTTY11
Create tunnel with socat
socat -d -d PTY,raw,echo=0 PTY,raw,echo=0
2018/09/12 13:33:11 socat[31301] N PTY is /dev/pts/4
2018/09/12 13:33:11 socat[31301] N PTY is /dev/pts/5
2018/09/12 13:33:11 socat[31301] N starting data transfer loop with FDs [5,5] and [7,7]
Start container and mount /dev/pts to access just created /dev/pts/4
docker run --rm -it \
-v /dev/pts:/dev/pts \
-p 8000:8000 \
-e LOG_LEVEL='debug' \
-e DSN='file:test.db' \
-e LISTEN_ADDR=':8000' \
-e SERIAL_PORT='/dev/pts/4' \
bitbrewers/lappy:latest
Install simulator and start it to create trafic
go get github.com/bitbrewers/tranx2/cmd/tranx2sim
tranx2sim -i 10000 -t 5 -j 2000 > /dev/pts/5
Instructions for basic linux setup
- socat
- go
- tranx2sim
- Install socat and go from repos
- Install tranx2sim:
go get github.com/bitbrewers/tranx2/cmd/tranx2sim
- Use socat for piping serial data:
socat PTY,raw,link=ttyS10,echo=0 PTY,raw,link=ttyS11,echo=0
- Start simulator
tranx2sim -i 10000 -t 5 -j 2000 > ./ttyS10
- Start lappy with
SERIAL_PORT=./ttyS11
Clone repo and run make dev
.
For more check the Makefile.