<commit_before># Requires bitstring module
# $ pip install bitstring

import socket
import time
from bitstring import ConstBitStream
from lib.Adafruit_PWM_Servo_Driver import PWM


udp_bind_ip = "0.0.0.0"
udp_port = 5040

pwm = PWM(0x40)
pwm.setPWMFreq(1000)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((udp_bind_ip, udp_port))

while True:
    data = s.recv(1024)
    length = len(data) * 8
    if length < 16 or length % 16 != 0:
        continue

    bits = ConstBitStream(bytes=data, length=length)
    servo = 0
    while bits.pos <= length - 16:
        servo_value = bits.read('uint:16')
        print "Servo:", servo, "Value:", servo_value
        pwm.setPWM(servo, 0, servo_value)
        servo = servo + 1<commit_msg>Updated receiver to use new format.<commit_after># Requires bitstring module
# $ pip install bitstring

import socket
import time
from bitstring import ConstBitStream
from lib.Adafruit_PWM_Servo_Driver import PWM

input_min = 980
input_max = 2010

udp_bind_ip = "0.0.0.0"
udp_port = 5040

pwm = PWM(0x40)
servo_min = 150
servo_max = 600
pwm.setPWMFreq(60)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((udp_bind_ip, udp_port))

while True:
    data = s.recv(1024)
    length = len(data) * 8
    if length < 16 or length % 16 != 0:
        continue

    bits = ConstBitStream(bytes=data, length=length)
    servo = 0
    while bits.pos <= length - 16:
        servo_value = float((bits.read('uint:16') - input_min)) / input_max * servo_max + servo_min
        print "Servo:", servo, "Value:", servo_value
        pwm.setPWM(servo, 0, int(servo_value))
        servo = servo + 1
{'fraction_non_alphanumeric': 0.10948012232415902, 'fraction_numerical': 0.045871559633027525, 'mean_word_length': 3.4097035040431267, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4248584', 'n_tokens_mistral': 674, 'n_tokens_neox': 599, 'n_words': 152}