<commit_before>#!/usr/bin/env python3

from id003 import BillVal
import id003
import serial.tools.list_ports
import serial
import time


def main():
    #avail_ports = list(serial.tools.list_ports.comports())
    #if not len(avail_ports):
    #    raise Exception("No serial port available")
    #else:
    #    com_port = -1
    #    while -1 < com_port < len(avail_ports):
    #        for i, p in enumerate(avail_ports):
    #            print(i + ') ' + p)
    #        com_port = int(input("Which com port? "))
    #    port = avail_ports[com_port]
        
    baud = None
    while baud is None:
        baud = int(input("Baud rate? (Only 9600 and 19200 supported) "))
    
    timeout = 0.2
    
    bv = BillVal('COM11', baud, serial.EIGHTBITS, serial.PARITY_EVEN, timeout=timeout)
    #bv.send_command(id003.RESET)
    #bv.power_on()
    #bv.req_status()
    
    #if bv.init_status == id003.POW_UP:
    #    print("BV powered up normally, version:\n\t" + bv.bv_version)
    #elif bv.init_status == id003.POW_UP_BIA:
    #    print("BV powered up with bill in acceptor.")
    #elif bv.init_status == id003.POW_UP_BIS:
    #    print("BV powered up with bill in stacker.")
        
    while True:
        try:
            status, data = bv.req_status()
        except:
            print('Exception')
        
        #print(hex(status) + ' ' + data.decode())
        
        time.sleep(0.2)


if __name__ == '__main__':
    main()<commit_msg>clean up test code a little<commit_after>#!/usr/bin/env python3

from id003 import BillVal
import id003
import serial.tools.list_ports
import serial
import time


def main():
    
    timeout = 0.2
    baud = 9600
    port = 'COM11'  # JCM UAC device (USB serial adapter)
    
    bv = BillVal(port, baud, serial.EIGHTBITS, serial.PARITY_EVEN, timeout=timeout)
    bv.power_on()
    
    if bv.init_status == id003.POW_UP:
        print("BV powered up normally, version:\n\t" + bv.bv_version)
    elif bv.init_status == id003.POW_UP_BIA:
        print("BV powered up with bill in acceptor.")
    elif bv.init_status == id003.POW_UP_BIS:
        print("BV powered up with bill in stacker.")
        
    while True:
        status, data = bv.req_status()
        
        time.sleep(0.2)


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.11891180342255375, 'fraction_numerical': 0.02720491443615621, 'mean_word_length': 2.3529411764705883, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '428174', 'n_tokens_mistral': 852, 'n_tokens_neox': 791, 'n_words': 193}