Ejemplo n.º 1
0
 def __init__(self):
     QtGui.QDialog.__init__(self)
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.usb = USB()
     self.usb_disk = ""
     self.imager_iso_link = ""
     self.iso_size = ""
     self.process = QtCore.QProcess(self)
 def start_algorithm(self, config, pyboard_port, recreate_usb=True):
     """
     Connect with board using usb, send config and START command
     @param config: board readable communicate with required parameters
     @param pyboard_port: `board communciation USB port
     @param recreate_usb: if False usb is not initialized (when unpausing)
     """
     operation = "START"
     print(recreate_usb)
     if recreate_usb:
         pyboard_port = pyboard_port
         if len(pyboard_port) != 0:
             self.usb = USB(pyboard_port)
         else:
             self.usb = USB()
             pyboard_port = "/dev/ttyACM1 (default Linux PyBoard port)"
     self.usb.attach("type", 2)
     self.usb.attach("config", config)
     self.usb.send()
     self.usb.attach("type", 4)
     self.usb.attach("operation", operation)
     self.usb.send()
     self.is_running = True
     return pyboard_port
Ejemplo n.º 3
0
def main():
    # uart = UART(0, 115200)
    # hid = RN42(uart)
    usb_hid = pyb.USB_HID()
    hid = USB(usb_hid)

    k = Keyboard()

    # last_scan_codes hold the last scan codes to detect key press and key release
    last_scan_codes = bytearray(b'\x00\x00\x00\x00\x00\x00')
    last_modifier = 0

    while 1:
        scan_codes, modifier = k.read_matrix()

        # Send scan codes if the scan codes is different from the last data.
        if last_scan_codes != scan_codes or last_modifier != modifier:
            hid.send_keyboard_report(scan_codes, modifier)
            last_scan_codes = scan_codes
            last_modifier = modifier
            # print(scan_codes, modifier)

        pyb.delay(1)
Ejemplo n.º 4
0
 def __init__(self):
     self.usb = USB()
Ejemplo n.º 5
0
 def __init__(self):
     self.usb_disk = config.usb_disk
     self.usb = USB()
Ejemplo n.º 6
0
 def __init__(self):
     from usb import USB
     self.usb = USB()
Ejemplo n.º 7
0
import config
import threading
import time

from g4_logger import G4
from usb import USB

if config.console_only == 'True':
    while True:
        time.sleep(1800)
        config.logging.warning("No app running, console only")
else:
    config.logging.info(' ----> Main App Running! <---- ')
    # Create Lock for running file in permanent USB memory
    running_file_lock = threading.Lock()

    # launch USB Drive scanning and file backup process
    usb_storage = USB(running_file_lock)
    scan_and_backup = threading.Thread(target=usb_storage.check_for_devices)
    scan_and_backup.daemon = True
    scan_and_backup.start()

    # launch polling to serial device
    serial_g4_device = G4(running_file_lock)
    polling = threading.Thread(target=serial_g4_device.serial_polling)
    polling.daemon = True
    polling.start()

    while True:
        pass