Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.13 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.13 KB

JacProtocol

Python implementation of the comunication protocol used in Jaculus (https://jaculus.org)

Installing

pip install https://github.com/c2coder/JacProtocol/archive/master.zip

Example encode code

from jacprotocol import jp

jp.put(97) # ascii code for "a"
# or jp.put(ord("a"))
channel = 16 # mux channel - 16 is monitor/terminal

for b in jp.serialize(channel):
    out += f"{hex(b)}  "
print(out)
from jacprotocol import jp
import serial # pip install pyserial

port = "/dev/ttyACM0"
baud = 921600

jp.put(97) # ascii code for "a"
# or jp.put(ord("a"))
channel = 16 # mux channel - 16 is monitor/terminal

# or if you want to send it over serial
with serial.Serial(port, baud, timeout=0) as ser:
    ser.write(jp.serialize(channel))

Example decode code

from jacprotocol import jp
import serial # pip install pyserial

port = "/dev/ttyACM0"
baud = 921600

# or if you want to send it over serial
with serial.Serial(port, baud, timeout=0) as ser:
    while True:
        l = list(ser.read_all()) # convert bytes to list of ints
        if len(l) == 0:
            continue
        print(jp.decode(l))