Skip to content

A Quart server that attaches to a com-port and makes it possible to interact with it via REST and read output via WebSockets.

Notifications You must be signed in to change notification settings

pratclot/ranch_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Provides access to a com-port device via REST and WebSockets.

To quickly test this on Linux:

  • create a virtual com-port attached over USB, socat will run as a background job:
nohup sudo socat -d -d pty,raw,echo=0,link=/dev/ttyUSB100 pty,raw,echo=0,link=./local_com &
awk '/PTY is/ {a_prev=a; a=$NF} END{cmd="for i in " a_prev " " a "; do sudo chmod +777 $i; done"; system(cmd)}' nohup.out
  • connect to it. Use C-a C-c to turn local echo on, C-a C-q to exit:
picocom ./local_com
  • prepare virtualenv and activate it:
python3.8 -m virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
  • run the server like this:
venv/bin/hypercorn serious_quartz:app --error-log - --access-log -
  • connect with a WebSocket client:
wscat -c localhost:8000/api
  • type and send something in picocom:

youtube link

  • shut socat down:
a=$(jobs | awk -F'[][]' '/local_com/ {system("echo fg %"$2)}')
$a

About

A Quart server that attaches to a com-port and makes it possible to interact with it via REST and read output via WebSockets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages