<commit_before><commit_msg>Very simple script to control the ESC over CAN bus<commit_after>#!/usr/bin/env python
#
# This is actually a quickly implemented testing tool, it is not intended for real use
#

import sys, threading, struct, time
from itertools import count
import pycanbus
try:
    import readline
except ImportError:
    pass

NODE_ID = 254
DATA_TYPE = 2
CAN_ID = 200

dc = None

def can_thread(sock):
    for i in count():
        #print sock.recv()
        time.sleep(0.1)
        if dc is not None:
            data = struct.pack('>BBBBf', NODE_ID, DATA_TYPE, 0, i & 0xFF, dc)
            sock.send(pycanbus.Frame(data, CAN_ID, False))

sock = pycanbus.Socket('slcan0')

thd = threading.Thread(target=can_thread, args=(sock,))
thd.daemon = True
thd.start()

while 1:
    try:
        dc = float(raw_input('Duty cycle: '))
    except ValueError:
        dc = 0.0
{'fraction_non_alphanumeric': 0.10718358038768529, 'fraction_numerical': 0.01710376282782212, 'mean_word_length': 3.102803738317757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7424528', 'n_tokens_mistral': 309, 'n_tokens_neox': 297, 'n_words': 94}