<commit_before>#!/usr/bin/python

import serial
import time
import datetime
import os

def modVout(orig) :
    return orig*16

def headerFinder(ttyPort) :
    while True :
        read = port.read(1)
        if read[0] == '\xaa' :
            read = port.read(6)
            if read[5] == '\xff' :
                return
    

port = serial.Serial("/dev/rfcomm0", baudrate=2400,timeout=3)
print "Port opened."
headerFinder(port)
while True :
    rcv = port.read(7)
    origV = ord(rcv[1])*256+ord(rcv[2])
    modV = modVout(origV)
    modVH = modV>>8
    modVL = modV & 255
    refVH = ord(rcv[3])
    refVL = ord(rcv[4])
    veri = (modVH+modVL+refVH+refVL)&255
    wrt = rcv[0]+''.join(map(lambda b: chr(b), [modVH, modVL, refVH, refVL,veri]))+rcv[6]
    port.write(wrt)
    origstr = ':'.join(map(lambda c: format(ord(c), "02x"), rcv))
    modstr = ':'.join(map(lambda c: format(ord(c), "02x"), wrt))
    print origstr+" --> "+modstr
    if rcv[0] != '\xaa' or rcv[6] != '\xff':
        headerFinder(port)
    <commit_msg>Update votage modification algorithm.<commit_after>#!/usr/bin/python

import serial
import time
import datetime
import os

def modVout(orig) :
    if orig<10 :
        return orig*5
    if orig<20 :
        return orig*3
    if orig<40 :
        return orig*1.5
    return orig

def headerFinder(ttyPort) :
    while True :
        read = port.read(1)
        if read[0] == '\xaa' :
            read = port.read(6)
            if read[5] == '\xff' :
                return
    

port = serial.Serial("/dev/rfcomm0", baudrate=2400,timeout=3)
print "Port opened."
headerFinder(port)
while True :
    rcv = port.read(7)
    if rcv[0] != '\xaa' or rcv[6] != '\xff':
        headerFinder(port)
        continue
    origV = ord(rcv[1])*256+ord(rcv[2])
    modV = modVout(origV)
    modVH = modV>>8
    modVL = modV & 255
    refVH = ord(rcv[3])
    refVL = ord(rcv[4])
    veri = (modVH+modVL+refVH+refVL)&255
    wrt = rcv[0]+''.join(map(lambda b: chr(b), [modVH, modVL, refVH, refVL,veri]))+rcv[6]
    port.write(wrt)
    origstr = ':'.join(map(lambda c: format(ord(c), "02x"), rcv))
    modstr = ':'.join(map(lambda c: format(ord(c), "02x"), wrt))
    print origstr+" --> "+modstr

    
{'fraction_non_alphanumeric': 0.1721014492753623, 'fraction_numerical': 0.035326086956521736, 'mean_word_length': 2.6153846153846154, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '162868', 'n_tokens_mistral': 906, 'n_tokens_neox': 874, 'n_words': 186}