<commit_before>import proto.dolos_pb2
import time
import utils
import threading
import socket
import serial
from usb import core

# TODO: Stream resync on magic number 
# Get XBee Device File - for SparkFun XBee Explorer
# This could be done less cruftily
snum = core.find(idVendor=0x0403, idProduct=0x6015).serial_number
prod = 'FTDI_FT231X_USB_UART'
dev = '/dev/serial/by-id/usb-{}_{}-if00-port0'.format(prod, snum)

class State(object):
    def __init__(self):
        self.aileron = 0.0
        self.elevator = 0.0
        self.rudder = 0.0
        self.motor = 0.0

state = utils.LockedWrapper(State())

def runClient():
    ser = serial.Serial(dev, baudrate=9600)
    while True:
        pkt = proto.dolos_pb2.control_packet()
        pkt.direct.d_a = state.aileron
        pkt.direct.d_e = state.elevator
        pkt.direct.d_r = state.rudder
        pkt.direct.motor_pwr = state.motor
        utils.heartbeat(pkt.hb)
        utils.serialWriteBuffer(pkt, ser)
        time.sleep(0.1)

clientThread = threading.Thread(target=runClient)
clientThread.start()

while True:
    cmd = input("> ").split()
    if len(cmd) != 2:
        print('Bad Syntax (CMD ARG)')
        continue
    try:
        if cmd[0] == 'aileron':
            state.aileron = float(cmd[1])
            continue
        if cmd[0] == 'elevator':
            state.elevator = float(cmd[1])
            continue
        if cmd[0] == 'rudder':
            state.elevator = float(cmd[1])
            continue
        if cmd[1] == 'motor':
            state.motor = float(cmd[1])
            continue
        print('Bad Command')
    except:
        print('Error')
<commit_msg>Working comms!<commit_after>import proto.dolos_pb2
import time
import utils
import threading
import socket
import serial
from usb import core

# TODO: Stream resync on magic number 
# Get XBee Device File - for SparkFun XBee Explorer
# This could be done less cruftily
snum = core.find(idVendor=0x0403, idProduct=0x6015).serial_number
prod = 'FTDI_FT231X_USB_UART'
dev = '/dev/serial/by-id/usb-{}_{}-if00-port0'.format(prod, snum)

class State(object):
    def __init__(self):
        self.aileron = 0.0
        self.elevator = 0.0
        self.rudder = 0.0
        self.motor = 0.0

state = utils.LockedWrapper(State())

def runClient():
    ser = serial.Serial(dev, baudrate=9600)
    while True:
        pkt = proto.dolos_pb2.control_packet()
        pkt.direct.d_a = state.aileron
        pkt.direct.d_e = state.elevator
        pkt.direct.d_r = state.rudder
        pkt.direct.motor_pwr = state.motor
        utils.heartbeat(pkt.hb)
        utils.serialWriteBuffer(pkt, ser)
        time.sleep(0.1)

clientThread = threading.Thread(target=runClient)
clientThread.start()

while True:
    cmd = input("> ").split()
    if len(cmd) != 2:
        print('Bad Syntax (CMD ARG)')
        continue
    try:
        if cmd[0] == 'aileron':
            state.aileron = float(cmd[1])
            continue
        if cmd[0] == 'elevator':
            state.elevator = float(cmd[1])
            continue
        if cmd[0] == 'rudder':
            state.rudder = float(cmd[1])
            continue
        if cmd[1] == 'motor':
            state.motor = float(cmd[1])
            continue
        print('Bad Command')
    except:
        print('Error')

{'fraction_non_alphanumeric': 0.12002430872075356, 'fraction_numerical': 0.0249164387724096, 'mean_word_length': 2.331983805668016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3443808', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1116, 'n_words': 249}