From d871e384845cbece8997d02c9bcd20374634043d Mon Sep 17 00:00:00 2001 From: strawmanbobi Date: Sun, 11 Jan 2026 12:44:04 +0800 Subject: [PATCH] fixed IR decode win32 example --- win32-example/DecodeTestWin.cpp | 15 +++++++++------ win32-example/IRextWin32Example.vcxproj | 7 ++++--- win32-example/ir_decoder/src/ir_decode.c | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/win32-example/DecodeTestWin.cpp b/win32-example/DecodeTestWin.cpp index 73bcc4f..0502b54 100644 --- a/win32-example/DecodeTestWin.cpp +++ b/win32-example/DecodeTestWin.cpp @@ -29,14 +29,14 @@ void input_number(int *val) char n[50]={0}; int i = 0; *val = 0; - scanf_s("%3s", n); + scanf_s("%3s", n, (unsigned)_countof(n)); getchar(); while(1) { if(n[i] < '0'||n[i] > '9') { printf("\nInvalid number format, please re-input : "); - scanf_s("%3s", n); + scanf_s("%3s", n, (unsigned)_countof(n)); i=0; } else @@ -54,7 +54,7 @@ void input_number(int *val) } } -static INT8 decode_as_ac(char *file_name) +static INT8 decode_as_ac(char *file_name, int sub_cate) { BOOL op_match = TRUE; UINT8 function_code = AC_FUNCTION_MAX; @@ -84,8 +84,9 @@ static INT8 decode_as_ac(char *file_name) ac_status.ac_wind_speed = AC_WS_AUTO; ac_status.change_wind_direction = FALSE; - if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_AC, 0, file_name)) + if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_AC, sub_cate, file_name)) { + printf("Failed to open file: %s\n", file_name); ir_close(); return IR_DECODE_FAILED; } @@ -107,6 +108,8 @@ static INT8 decode_as_ac(char *file_name) op_match = TRUE; need_control = FALSE; + printf("input key code = %d\n", key_code); + if (99 == key_code) { break; @@ -165,7 +168,7 @@ static INT8 decode_as_ac(char *file_name) switch (key_code) { case 0: - ac_status.ac_power = ((ac_status.ac_wind_dir == AC_POWER_ON) ? AC_POWER_OFF : AC_POWER_ON); + ac_status.ac_power = ((ac_status.ac_power == AC_POWER_ON) ? AC_POWER_OFF : AC_POWER_ON); need_control = TRUE; break; @@ -309,7 +312,7 @@ int main(int argc, char *argv[]) { case '0': printf("Decode %s as status-typed binary\n", argv[2]); - decode_as_ac(argv[2]); + decode_as_ac(argv[2], ir_hex_encode); break; case '1': diff --git a/win32-example/IRextWin32Example.vcxproj b/win32-example/IRextWin32Example.vcxproj index 6d48e28..cd54349 100644 --- a/win32-example/IRextWin32Example.vcxproj +++ b/win32-example/IRextWin32Example.vcxproj @@ -74,7 +74,7 @@ true - true + false D:\Project\irext\examples\win32-example\ir_decoder\src\include;$(IncludePath) @@ -103,12 +103,13 @@ Level3 true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + BOARD_PC;DEBUG;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + MultiThreaded Console - true + false diff --git a/win32-example/ir_decoder/src/ir_decode.c b/win32-example/ir_decoder/src/ir_decode.c index 2c45d0f..ff01343 100644 --- a/win32-example/ir_decoder/src/ir_decode.c +++ b/win32-example/ir_decoder/src/ir_decode.c @@ -335,6 +335,7 @@ static INT8 ir_ac_file_open(const char *file_name) if (ret <= 0) { + ir_printf("ir_ac_binary_open fread failed\n"); fclose(stream); ir_free(binary_content); binary_length = 0; @@ -345,6 +346,7 @@ static INT8 ir_ac_file_open(const char *file_name) if (IR_DECODE_FAILED == ir_ac_binary_open(binary_content, (UINT16) binary_length)) { + ir_printf("ir_ac_binary_open failed\n"); ir_free(binary_content); binary_length = 0; return IR_DECODE_FAILED;