Skip to content

Commit

Permalink
fixed a HID detection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dekuNukem committed Mar 1, 2023
1 parent 6da22f3 commit fc27be7
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 41 deletions.
50 changes: 25 additions & 25 deletions firmware/code_duckyscript3/MDK-ARM/lul.uvguix.Allen

Large diffs are not rendered by default.

Binary file modified firmware/code_duckyscript3/MDK-ARM/lul/lul.axf
Binary file not shown.
21 changes: 18 additions & 3 deletions firmware/code_duckyscript3/MDK-ARM/lul/lul.build_log.htm
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,26 @@ <h2>Project:</h2>
<h2>Output:</h2>
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'lul'
compiling main.c...
compiling my_tasks.c...
..\Src\my_tasks.c(529): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
if (f_opendir(&dir, hid_rx_buf+3) != FR_OK)
..\Src\my_tasks.c(548): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
strncpy(hid_tx_buf+4, this_filename, FILENAME_SIZE);
..\Src\my_tasks.c(581): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
if(f_open(&sd_file, hid_rx_buf+3, FA_READ) != 0)
..\Src\my_tasks.c(628): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
if(f_open(&sd_file, hid_rx_buf+3, FA_CREATE_ALWAYS | FA_WRITE) != 0)
..\Src\my_tasks.c(695): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
f_unlink(hid_rx_buf+3);
..\Src\my_tasks.c(714): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
if(f_mkdir(hid_rx_buf+3) != 0)
..\Src\my_tasks.c(736): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
delete_node(hid_rx_buf+3, HID_RX_BUF_SIZE - 3, &fno);
..\Src\my_tasks.c: 7 warnings, 0 errors
linking...
Program Size: Code=46716 RO-data=2848 RW-data=1420 ZI-data=14828
FromELF: creating hex file...
"lul\lul.axf" - 0 Error(s), 0 Warning(s).
"lul\lul.axf" - 0 Error(s), 7 Warning(s).

<h2>Software Packages used:</h2>

Expand All @@ -54,7 +69,7 @@ <h2>Collection of Component include folders:</h2>
<h2>Collection of Component Files used:</h2>

* Component: ARM::CMSIS:CORE:5.3.0
Build Time Elapsed: 00:00:02
Build Time Elapsed: 00:00:01
</pre>
</body>
</html>
2 changes: 1 addition & 1 deletion firmware/code_duckyscript3/MDK-ARM/lul/lul.htm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title>Static Call Graph - [lul\lul.axf]</title></head>
<body><HR>
<H1>Static Call Graph for image lul\lul.axf</H1><HR>
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Tue Feb 21 16:24:30 2023
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Wed Mar 01 23:44:47 2023
<BR><P>
<H3>Maximum Stack Usage = 496 bytes + Unknown(Cycles, Untraceable Function Pointers)</H3><H3>
Call chain for Maximum Stack Depth:</H3>
Expand Down
2 changes: 1 addition & 1 deletion firmware/code_duckyscript3/MDK-ARM/lul/lul_lul.dep
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ I (../Inc/fonts.h)(0x63BF1B78)
I (../Inc/animations.h)(0x63D5A4CE)
I (../Inc/usbd_desc.h)(0x63A5DA89)
F (..\Inc\my_tasks.h)(0x63BF0F90)()
F (..\Src\my_tasks.c)(0x63F3B286)(-c --cpu Cortex-M0 -D__MICROLIB -g -O2 --apcs=interwork --split_sections -I ../Inc -I ../Drivers/STM32F0xx_HAL_Driver/Inc -I ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I ../Drivers/CMSIS/Include -I ../Middlewares/Third_Party/FatFs/src -I ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0 -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I ../Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc --C99-I.\RTE\_lul-IC:\Users\allen\AppData\Local\Arm\Packs\ARM\CMSIS\5.6.0\CMSIS\Core\Include-IC:\Users\allen\AppData\Local\Arm\Packs\Keil\STM32F0xx_DFP\2.0.0\Drivers\CMSIS\Device\ST\STM32F0xx\Include-D__UVISION_VERSION="529" -D_RTE_ -DSTM32F072xB -DUSE_HAL_DRIVER -DSTM32F072xB-o lul\my_tasks.o --omf_browse lul\my_tasks.crf --depend lul\my_tasks.d)
F (..\Src\my_tasks.c)(0x63FFE33C)(-c --cpu Cortex-M0 -D__MICROLIB -g -O2 --apcs=interwork --split_sections -I ../Inc -I ../Drivers/STM32F0xx_HAL_Driver/Inc -I ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I ../Drivers/CMSIS/Include -I ../Middlewares/Third_Party/FatFs/src -I ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0 -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I ../Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc --C99-I.\RTE\_lul-IC:\Users\allen\AppData\Local\Arm\Packs\ARM\CMSIS\5.6.0\CMSIS\Core\Include-IC:\Users\allen\AppData\Local\Arm\Packs\Keil\STM32F0xx_DFP\2.0.0\Drivers\CMSIS\Device\ST\STM32F0xx\Include-D__UVISION_VERSION="529" -D_RTE_ -DSTM32F072xB -DUSE_HAL_DRIVER -DSTM32F072xB-o lul\my_tasks.o --omf_browse lul\my_tasks.crf --depend lul\my_tasks.d)
I (C:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x5D9B429A)
I (C:\Keil_v5\ARM\ARMCC\include\string.h)(0x5D9B4298)
I (C:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x5D9B429A)
Expand Down
Binary file modified firmware/code_duckyscript3/MDK-ARM/lul/my_tasks.crf
Binary file not shown.
Binary file modified firmware/code_duckyscript3/MDK-ARM/lul/my_tasks.o
Binary file not shown.
11 changes: 7 additions & 4 deletions pc_software/duckyscript3/duckypad_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@
1.2.1 2023 02 21
added hid busy check
1.2.2 2023 03 01
fixed HID busy detection bug
"""

THIS_VERSION_NUMBER = '1.2.1'
THIS_VERSION_NUMBER = '1.2.2'
MIN_DUCKYPAD_FIRMWARE_VERSION = "1.1.2"

ENV_UI_SCALE = os.getenv("DUCKYPAD_UI_SCALE")
Expand Down Expand Up @@ -1201,9 +1203,10 @@ def t1_worker():
time.sleep(0.2)
if current_hid_op == HID_NOP:
continue
if hid_op.is_idle() is False:
messagebox.showerror("Error", "duckyPad is busy!")
dp_root_folder_display.set("duckyPad is busy!")
is_idle, comment = hid_op.is_idle()
if is_idle is False:
messagebox.showerror("Error", comment)
dp_root_folder_display.set("")
current_hid_op = HID_NOP
continue
if current_hid_op == HID_DUMP:
Expand Down
Binary file modified pc_software/duckyscript3/duckypad_config_latest_source.zip
Binary file not shown.
19 changes: 12 additions & 7 deletions pc_software/duckyscript3/hid_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ def __str__(self):

h = hid.device()

def is_idle():
pc_to_duckypad_buf = [0] * PC_TO_DUCKYPAD_HID_BUF_SIZE
pc_to_duckypad_buf[0] = 5 # HID Usage ID, always 5
h.write(pc_to_duckypad_buf)
result = _read_duckypad()
return result[2] == 0

def _check_hid_err(result):
"""
Check the HID result and raise a python exception if it is one that
Expand Down Expand Up @@ -131,6 +124,18 @@ def duckypad_list_files(root_dir = None):
duckypad_hid_resume()
return ret

def is_idle():
pc_to_duckypad_buf = [0] * PC_TO_DUCKYPAD_HID_BUF_SIZE
pc_to_duckypad_buf[0] = 5 # HID Usage ID, always 5
try:
duckypad_hid_close()
duckypad_hid_init()
h.write(pc_to_duckypad_buf)
result = _read_duckypad()
except Exception as e:
return False, str(e)
return result[2] == 0, 'duckyPad is busy!'

def duckypad_hid_resume():
pc_to_duckypad_buf = [0] * PC_TO_DUCKYPAD_HID_BUF_SIZE
pc_to_duckypad_buf[0] = 5 # HID Usage ID, always 5
Expand Down

0 comments on commit fc27be7

Please sign in to comment.