Skip to content

Commit fc27be7

Browse files
committed
fixed a HID detection bug
1 parent 6da22f3 commit fc27be7

File tree

10 files changed

+64
-41
lines changed

10 files changed

+64
-41
lines changed

firmware/code_duckyscript3/MDK-ARM/lul.uvguix.Allen

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.
0 Bytes
Binary file not shown.

firmware/code_duckyscript3/MDK-ARM/lul/lul.build_log.htm

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,26 @@ <h2>Project:</h2>
2727
<h2>Output:</h2>
2828
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
2929
Build target 'lul'
30-
compiling main.c...
30+
compiling my_tasks.c...
31+
..\Src\my_tasks.c(529): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
32+
if (f_opendir(&dir, hid_rx_buf+3) != FR_OK)
33+
..\Src\my_tasks.c(548): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
34+
strncpy(hid_tx_buf+4, this_filename, FILENAME_SIZE);
35+
..\Src\my_tasks.c(581): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
36+
if(f_open(&sd_file, hid_rx_buf+3, FA_READ) != 0)
37+
..\Src\my_tasks.c(628): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
38+
if(f_open(&sd_file, hid_rx_buf+3, FA_CREATE_ALWAYS | FA_WRITE) != 0)
39+
..\Src\my_tasks.c(695): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
40+
f_unlink(hid_rx_buf+3);
41+
..\Src\my_tasks.c(714): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const TCHAR *"
42+
if(f_mkdir(hid_rx_buf+3) != 0)
43+
..\Src\my_tasks.c(736): warning: #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
44+
delete_node(hid_rx_buf+3, HID_RX_BUF_SIZE - 3, &fno);
45+
..\Src\my_tasks.c: 7 warnings, 0 errors
3146
linking...
3247
Program Size: Code=46716 RO-data=2848 RW-data=1420 ZI-data=14828
3348
FromELF: creating hex file...
34-
"lul\lul.axf" - 0 Error(s), 0 Warning(s).
49+
"lul\lul.axf" - 0 Error(s), 7 Warning(s).
3550

3651
<h2>Software Packages used:</h2>
3752

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

5671
* Component: ARM::CMSIS:CORE:5.3.0
57-
Build Time Elapsed: 00:00:02
72+
Build Time Elapsed: 00:00:01
5873
</pre>
5974
</body>
6075
</html>

firmware/code_duckyscript3/MDK-ARM/lul/lul.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>Static Call Graph - [lul\lul.axf]</title></head>
44
<body><HR>
55
<H1>Static Call Graph for image lul\lul.axf</H1><HR>
6-
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Tue Feb 21 16:24:30 2023
6+
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Wed Mar 01 23:44:47 2023
77
<BR><P>
88
<H3>Maximum Stack Usage = 496 bytes + Unknown(Cycles, Untraceable Function Pointers)</H3><H3>
99
Call chain for Maximum Stack Depth:</H3>

firmware/code_duckyscript3/MDK-ARM/lul/lul_lul.dep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ I (../Inc/fonts.h)(0x63BF1B78)
451451
I (../Inc/animations.h)(0x63D5A4CE)
452452
I (../Inc/usbd_desc.h)(0x63A5DA89)
453453
F (..\Inc\my_tasks.h)(0x63BF0F90)()
454-
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)
454+
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)
455455
I (C:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x5D9B429A)
456456
I (C:\Keil_v5\ARM\ARMCC\include\string.h)(0x5D9B4298)
457457
I (C:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x5D9B429A)
Binary file not shown.
Binary file not shown.

pc_software/duckyscript3/duckypad_config.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@
6565
1.2.1 2023 02 21
6666
added hid busy check
6767
68+
1.2.2 2023 03 01
69+
fixed HID busy detection bug
6870
"""
6971

70-
THIS_VERSION_NUMBER = '1.2.1'
72+
THIS_VERSION_NUMBER = '1.2.2'
7173
MIN_DUCKYPAD_FIRMWARE_VERSION = "1.1.2"
7274

7375
ENV_UI_SCALE = os.getenv("DUCKYPAD_UI_SCALE")
@@ -1201,9 +1203,10 @@ def t1_worker():
12011203
time.sleep(0.2)
12021204
if current_hid_op == HID_NOP:
12031205
continue
1204-
if hid_op.is_idle() is False:
1205-
messagebox.showerror("Error", "duckyPad is busy!")
1206-
dp_root_folder_display.set("duckyPad is busy!")
1206+
is_idle, comment = hid_op.is_idle()
1207+
if is_idle is False:
1208+
messagebox.showerror("Error", comment)
1209+
dp_root_folder_display.set("")
12071210
current_hid_op = HID_NOP
12081211
continue
12091212
if current_hid_op == HID_DUMP:
Binary file not shown.

pc_software/duckyscript3/hid_op.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ def __str__(self):
6868

6969
h = hid.device()
7070

71-
def is_idle():
72-
pc_to_duckypad_buf = [0] * PC_TO_DUCKYPAD_HID_BUF_SIZE
73-
pc_to_duckypad_buf[0] = 5 # HID Usage ID, always 5
74-
h.write(pc_to_duckypad_buf)
75-
result = _read_duckypad()
76-
return result[2] == 0
77-
7871
def _check_hid_err(result):
7972
"""
8073
Check the HID result and raise a python exception if it is one that
@@ -131,6 +124,18 @@ def duckypad_list_files(root_dir = None):
131124
duckypad_hid_resume()
132125
return ret
133126

127+
def is_idle():
128+
pc_to_duckypad_buf = [0] * PC_TO_DUCKYPAD_HID_BUF_SIZE
129+
pc_to_duckypad_buf[0] = 5 # HID Usage ID, always 5
130+
try:
131+
duckypad_hid_close()
132+
duckypad_hid_init()
133+
h.write(pc_to_duckypad_buf)
134+
result = _read_duckypad()
135+
except Exception as e:
136+
return False, str(e)
137+
return result[2] == 0, 'duckyPad is busy!'
138+
134139
def duckypad_hid_resume():
135140
pc_to_duckypad_buf = [0] * PC_TO_DUCKYPAD_HID_BUF_SIZE
136141
pc_to_duckypad_buf[0] = 5 # HID Usage ID, always 5

0 commit comments

Comments
 (0)