mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
added UART delete file and info command
This commit is contained in:
@@ -8,6 +8,7 @@ GPIO.setmode(GPIO.BCM)
|
||||
import usb4vc_shared
|
||||
import usb4vc_usb_scan
|
||||
import usb4vc_ui
|
||||
import usb4vc_uart
|
||||
|
||||
PBOARD_RESET_PIN = 25
|
||||
PBOARD_DFU_PIN = 12
|
||||
@@ -31,10 +32,12 @@ reset_pboard()
|
||||
os.system('sudo bash -c "echo 1 > /sys/module/bluetooth/parameters/disable_ertm"')
|
||||
|
||||
usb4vc_ui.ui_init()
|
||||
usb4vc_ui.ui_worker.start()
|
||||
usb4vc_ui.ui_thread.start()
|
||||
|
||||
usb4vc_usb_scan.usb_device_scan_thread.start()
|
||||
usb4vc_usb_scan.raw_input_event_parser_thread.start()
|
||||
|
||||
usb4vc_uart.uart_thread.start()
|
||||
|
||||
while 1:
|
||||
time.sleep(10)
|
||||
@@ -6,10 +6,9 @@ import subprocess
|
||||
import base64
|
||||
import threading
|
||||
|
||||
# import usb4vc_shared
|
||||
import usb4vc_shared
|
||||
# import usb4vc_usb_scan
|
||||
# import usb4vc_ui
|
||||
# subprocess.getoutput(f"timeout 5 bluetoothctl --agent NoInputNoOutput paired-devices")
|
||||
|
||||
ser = None
|
||||
try:
|
||||
@@ -22,7 +21,7 @@ def uart_worker():
|
||||
return
|
||||
while 1:
|
||||
received = ser.readline().decode().replace('\r', '').replace('\n', '')
|
||||
print("I received:", received)
|
||||
# print("I received:", received)
|
||||
line_split = received.split(' ', maxsplit=2)
|
||||
if len(line_split) < 2:
|
||||
continue
|
||||
@@ -32,6 +31,7 @@ def uart_worker():
|
||||
|
||||
if magic != 'U4':
|
||||
continue
|
||||
|
||||
if cmd_type == "QUIT":
|
||||
exit()
|
||||
|
||||
@@ -59,10 +59,6 @@ def uart_worker():
|
||||
base64_message = wf_args[1].strip()
|
||||
try:
|
||||
base64_bytes = base64.standard_b64decode(base64_message)
|
||||
except Exception as e:
|
||||
ser.write(f"U4 ERR {e}\n".encode('utf-8'))
|
||||
continue
|
||||
try:
|
||||
with open(file_path, 'wb') as myfile:
|
||||
myfile.write(base64_bytes)
|
||||
ser.write("U4 OK\n".encode('utf-8'))
|
||||
@@ -80,4 +76,21 @@ def uart_worker():
|
||||
continue
|
||||
ser.write("U4 OK\n".encode('utf-8'))
|
||||
|
||||
# ui_worker = threading.Thread(target=ui_worker, daemon=True)
|
||||
if cmd_type == 'SC':
|
||||
try:
|
||||
shell_result = subprocess.getoutput(payload).strip()
|
||||
base64_bytes = base64.standard_b64encode(shell_result.encode('utf-8'))
|
||||
base64_message = base64_bytes.decode('utf-8')
|
||||
ser.write(f"U4 OK {base64_message}\n".encode('utf-8'))
|
||||
except Exception as e:
|
||||
ser.write(f"U4 ERR {e}\n".encode('utf-8'))
|
||||
continue
|
||||
|
||||
if cmd_type == 'INFO':
|
||||
try:
|
||||
ser.write(f"U4 OK USB4VC RPi App v{usb4vc_shared.RPI_APP_VERSION_TUPLE[0]}.{usb4vc_shared.RPI_APP_VERSION_TUPLE[1]}.{usb4vc_shared.RPI_APP_VERSION_TUPLE[2]} dekuNukem 2022\n".encode('utf-8'))
|
||||
except Exception as e:
|
||||
ser.write(f"U4 ERR {e}\n".encode('utf-8'))
|
||||
continue
|
||||
|
||||
uart_thread = threading.Thread(target=uart_worker, daemon=True)
|
||||
|
||||
@@ -716,7 +716,7 @@ def ui_worker():
|
||||
def get_gamepad_protocol():
|
||||
return my_menu.current_gamepad_protocol
|
||||
|
||||
ui_worker = threading.Thread(target=ui_worker, daemon=True)
|
||||
ui_thread = threading.Thread(target=ui_worker, daemon=True)
|
||||
|
||||
def oled_sleep_refresh():
|
||||
global last_input_event
|
||||
|
||||
Reference in New Issue
Block a user