fixed VC++ reference

This commit is contained in:
2016-12-25 14:28:14 +08:00
parent 40dba1be58
commit 67759873a3
23 changed files with 1363 additions and 15 deletions

View File

@@ -0,0 +1,10 @@
x64/
Debug/
Release/
DecodeTestWin/Debug/
DecodeTestWin/Release/
*.sdf
*.opensdf
.vs
DecodeTestWin.VC.db
DecodeTestWin.sdf

View File

@@ -0,0 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DecodeTestWin", "DecodeTestWin\DecodeTestWin.vcxproj", "{66988DFB-7EA1-4A04-B72A-D51C4A061E57}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Debug|x64.ActiveCfg = Debug|x64
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Debug|x64.Build.0 = Debug|x64
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Debug|x86.ActiveCfg = Debug|Win32
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Debug|x86.Build.0 = Debug|Win32
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Release|x64.ActiveCfg = Release|x64
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Release|x64.Build.0 = Release|x64
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Release|x86.ActiveCfg = Release|Win32
{66988DFB-7EA1-4A04-B72A-D51C4A061E57}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,337 @@
#include "stdafx.h"
#include "DecodeTestWin.h"
#include "irda_decode.h"
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// global variable definition
long binary_length = 0;
UINT8 *binary_content = NULL;
CWinApp theApp;
HINSTANCE hInDecodeDll = NULL;
remote_ac_status_t ac_status;
UINT16 user_data[USER_DATA_SIZE] = { 0 };
typedef INT8(*lp_irda_ac_file_open) (char* file_name);
typedef INT8(*lp_irda_ac_lib_open) (UINT8 *binary, UINT16 binary_length);
typedef INT8(*lp_irda_ac_lib_close) (void);
typedef INT8(*lp_irda_ac_lib_parse) (void);
typedef UINT16(*lp_irda_ac_lib_control) (remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code, BOOL change_wind_direction);
typedef INT8(*lp_get_temperature_range) (UINT8 ac_mode, INT8* temp_min, INT8* temp_max);
typedef INT8(*lp_get_supported_mode) (UINT8* supported_mode);
typedef INT8(*lp_get_supported_wind_speed) (UINT8 ac_mode, UINT8* supported_wind_speed);
typedef INT8(*lp_get_supported_swing) (UINT8 ac_mode, UINT8* supported_swing);
typedef INT8(*lp_get_supported_wind_direction) (UINT8* supported_wind_direction);
typedef INT8(*lp_irda_tv_file_open) (char* file_name);
typedef INT8(*lp_irda_tv_lib_open) (UINT8 *binary, UINT16 binary_length);
typedef INT8(*lp_irda_tv_lib_parse) (UINT8 irda_hex_encode);
typedef UINT16(*lp_irda_tv_lib_control) (UINT8 key_code, UINT16* user_data);
typedef INT8(*lp_irda_tv_lib_close) (void);
lp_irda_ac_file_open IRDAACFileOpen;
lp_irda_ac_lib_open IRDAACLibOpen;
lp_irda_ac_lib_parse IRDAACLibParse;
lp_irda_ac_lib_control IRDAACLibControl;
lp_irda_ac_lib_close IRDAACLibClose;
lp_get_supported_mode GetSupportedMode;
lp_get_supported_swing GetSupportedSwing;
lp_get_supported_wind_speed GetSupportedWindSpeed;
lp_get_supported_wind_direction GetSupportedWindDirection;
lp_get_temperature_range GetTemperatureRange;
lp_irda_tv_file_open IRDATVFileOpen;
lp_irda_tv_lib_open IRDATVLibOpen;
lp_irda_tv_lib_parse IRDATVLibParse;
lp_irda_tv_lib_control IRDATVLibControl;
lp_irda_tv_lib_close IRDATVLibClose;
INT8 decode_as_ac(char* file_name)
{
// keyboard input
int in_char = 0;
int count = 0;
BOOL op_match = TRUE;
UINT8 function_code = AC_FUNCTION_MAX;
// get status
UINT8 supported_mode = 0x00;
INT8 min_temperature = 0;
INT8 max_temperature = 0;
UINT8 supported_speed = 0x00;
UINT8 supported_swing = 0x00;
BOOL need_control = TRUE;
// init air conditioner status
ac_status.acDisplay = 0;
ac_status.acSleep = 0;
ac_status.acTimer = 0;
ac_status.acPower = AC_POWER_OFF;
ac_status.acMode = AC_MODE_COOL;
ac_status.acTemp = AC_TEMP_20;
ac_status.acWindDir = AC_SWING_ON;
ac_status.acWindSpeed = AC_WS_AUTO;
if (IR_DECODE_FAILED == IRDAACFileOpen(file_name))
{
IRDAACLibClose();
return IR_DECODE_FAILED;
}
if (IR_DECODE_FAILED == IRDAACLibParse())
{
IR_PRINTF("\nac lib parse failed\n");
IRDAACLibClose();
return IR_DECODE_FAILED;
}
do
{
in_char = getchar();
op_match = TRUE;
need_control = TRUE;
switch (in_char)
{
case 'w':
case 'W':
// temperature plus
ac_status.acTemp = (ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1);
function_code = AC_FUNCTION_TEMPERATURE_UP;
break;
case 's':
case 'S':
ac_status.acTemp = (ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1);
function_code = AC_FUNCTION_TEMPERATURE_DOWN;
// temperature minus
break;
case 'a':
case 'A':
++ac_status.acWindSpeed;
ac_status.acWindSpeed = ac_status.acWindSpeed % AC_WS_MAX;
function_code = AC_FUNCTION_WIND_SPEED;
// wind speed loop
break;
case 'd':
case 'D':
ac_status.acWindDir = (ac_status.acWindDir == 0) ? 1 : 0;
function_code = AC_FUNCTION_WIND_SWING;
// wind swing loop
break;
case 'q':
case 'Q':
++ac_status.acMode;
ac_status.acMode = ac_status.acMode % AC_MODE_MAX;
function_code = AC_FUNCTION_MODE;
break;
case '1':
// turn on
ac_status.acPower = AC_POWER_ON;
function_code = AC_FUNCTION_POWER;
break;
case '2':
// turn off
ac_status.acPower = AC_POWER_OFF;
// FUNCTION MAX refers to power off
// function_code = AC_FUNCTION_POWER;
break;
case '3':
if (IR_DECODE_SUCCEEDED == GetSupportedMode(&supported_mode))
{
IR_PRINTF("\nsupported mode = %02X\n", supported_mode);
}
need_control = FALSE;
break;
case '4':
if (IR_DECODE_SUCCEEDED == GetSupportedSwing(ac_status.acMode, &supported_swing))
{
IR_PRINTF("\nsupported swing in %d = %02X\n", ac_status.acMode, supported_swing);
}
need_control = FALSE;
break;
case '5':
if (IR_DECODE_SUCCEEDED == GetSupportedWindSpeed(ac_status.acMode, &supported_speed))
{
IR_PRINTF("\nsupported wind speed in %d = %02X\n", ac_status.acMode, supported_speed);
}
need_control = FALSE;
break;
case '6':
if (IR_DECODE_SUCCEEDED == GetTemperatureRange(ac_status.acMode, &min_temperature, &max_temperature))
{
IR_PRINTF("\nsupported temperature range in mode %d = %d, %d\n",
ac_status.acMode, min_temperature, max_temperature);
}
need_control = FALSE;
break;
default:
op_match = FALSE;
break;
}
if (TRUE == op_match && TRUE == need_control)
{
IR_PRINTF("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d\n",
ac_status.acPower,
ac_status.acMode,
ac_status.acTemp,
ac_status.acWindSpeed,
ac_status.acWindDir
);
IRDAACLibControl(ac_status, user_data, function_code, TRUE);
}
} while ('0' != in_char);
IRDAACLibClose();
// free binary buffer
irda_free(binary_content);
binary_length = 0;
return IR_DECODE_SUCCEEDED;
}
INT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
{
// keyboard input
int in_char = 0;
int key_code = -1;
int count = 0;
if (IR_DECODE_FAILED == IRDATVFileOpen(file_name))
{
return IR_DECODE_FAILED;
}
if (IR_DECODE_FAILED == IRDATVLibParse(irda_hex_encode))
{
return IR_DECODE_FAILED;
}
do
{
in_char = getchar();
if (in_char >= '0' && in_char <= '9')
{
key_code = in_char - '0';
IRDATVLibControl(key_code, user_data);
}
else if (in_char >= 'a' && in_char <= 'f')
{
key_code = 10 + (in_char - 'a');
IRDATVLibControl(key_code, user_data);
}
else if (in_char == 'q')
{
IRDATVLibClose();
}
else
{
// do nothing
}
} while ('Q' != in_char);
// free binary buffer
irda_free(binary_content);
binary_length = 0;
return IR_DECODE_SUCCEEDED;
}
int main(int argc, char *argv[])
{
int nRetCode = 0;
HMODULE hModule = ::GetModuleHandle(nullptr);
if (hModule != nullptr)
{
if (!AfxWinInit(hModule, nullptr, ::GetCommandLine(), 0))
{
wprintf(L"error: MFC failed to initialize\n");
nRetCode = 1;
}
else
{
hInDecodeDll = LoadLibrary(_T("ir_decoder.dll"));
if (NULL != hInDecodeDll)
{
IR_PRINTF("load library successfully");
IRDAACFileOpen = (lp_irda_ac_file_open)GetProcAddress(hInDecodeDll, "irda_ac_file_open");
IRDAACLibOpen = (lp_irda_ac_lib_open)GetProcAddress(hInDecodeDll, "irda_ac_lib_open");
IRDAACLibParse = (lp_irda_ac_lib_parse)GetProcAddress(hInDecodeDll, "irda_ac_lib_parse");
IRDAACLibControl = (lp_irda_ac_lib_control)GetProcAddress(hInDecodeDll, "irda_ac_lib_control");
IRDAACLibClose = (lp_irda_ac_lib_close)GetProcAddress(hInDecodeDll, "irda_ac_lib_close");
GetSupportedMode = (lp_get_supported_mode)GetProcAddress(hInDecodeDll, "get_supported_mode");
GetSupportedSwing = (lp_get_supported_swing)GetProcAddress(hInDecodeDll, "get_supported_swing");
GetSupportedWindSpeed = (lp_get_supported_wind_speed)GetProcAddress(hInDecodeDll, "get_supported_wind_speed");
GetSupportedWindDirection = (lp_get_supported_wind_direction)GetProcAddress(hInDecodeDll, "get_supported_wind_direction");
GetTemperatureRange = (lp_get_temperature_range)GetProcAddress(hInDecodeDll, "get_temperature_range");
IRDATVFileOpen = (lp_irda_tv_file_open)GetProcAddress(hInDecodeDll, "irda_tv_file_open");
IRDATVLibOpen = (lp_irda_tv_lib_open)GetProcAddress(hInDecodeDll, "irda_tv_lib_open");
IRDATVLibParse = (lp_irda_tv_lib_parse)GetProcAddress(hInDecodeDll, "irda_tv_lib_parse");
IRDATVLibControl = (lp_irda_tv_lib_control)GetProcAddress(hInDecodeDll, "irda_tv_lib_control");
IRDATVLibClose = (lp_irda_tv_lib_close)GetProcAddress(hInDecodeDll, "irda_tv_lib_close");
char function = '0';
UINT8 irda_hex_encode = 0;
if (4 != argc)
{
IR_PRINTF("number of args error !\n");
return -1;
}
function = argv[1][0];
irda_hex_encode = (UINT8)(argv[3][0] - '0');
IR_PRINTF("decode functionality = %c\n", function);
switch (function)
{
case '0':
IR_PRINTF("decode binary file as AC\n");
decode_as_ac(argv[2]);
break;
case '1':
IR_PRINTF("decode binary file as TV : %d\n", irda_hex_encode);
decode_as_tv(argv[2], irda_hex_encode);
break;
default:
IR_PRINTF("decode functionality error !\n");
break;
}
FreeLibrary(hInDecodeDll);
}
else
{
IR_PRINTF("load library failed");
}
}
}
else
{
wprintf(L"error: GetModuleHandle failed\n");
nRetCode = 1;
}
system("pause");
return nRetCode;
}

View File

@@ -0,0 +1,3 @@
#pragma once
#include "resource.h"

View File

@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{66988DFB-7EA1-4A04-B72A-D51C4A061E57}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>DecodeTestWin</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="C:\Users\straw\Desktop\irda_defs.h" />
<ClInclude Include="DecodeTestWin.h" />
<ClInclude Include="irda_decode.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DecodeTestWin.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DecodeTestWin.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="DecodeTestWin.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="irda_decode.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="C:\Users\straw\Desktop\irda_defs.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="DecodeTestWin.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DecodeTestWin.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1,39 @@
========================================================================
控制台应用程序DecodeTestWin 项目概述
========================================================================
应用程序向导已为您创建了此 DecodeTestWin 应用程序。
本文件概要介绍组成 DecodeTestWin 应用程序的每个文件的内容。
DecodeTestWin.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
DecodeTestWin.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
DecodeTestWin.cpp
这是主应用程序源文件。
/////////////////////////////////////////////////////////////////////////////
应用程序向导创建了下列资源:
DecodeTestWin.rc
这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。
Resource.h
这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h, StdAfx.cpp
这些文件用于生成名为 DecodeTestWin.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by DecodeTestWin.rc
//
#define IDS_APP_TITLE 103
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,605 @@
/**************************************************************************************************
Filename: irda_decode.h
Revised: Date: 2016-10-01
Revision: Revision: 1.0
Description: This file provides algorithms for IR decode
Revision log:
* 2016-10-01: created by strawmanbobi
**************************************************************************************************/
#ifndef _IRDA_DECODE_H_
#define _IRDA_DECODE_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdio.h>
#include "irda_defs.h"
#define TAG_COUNT_FOR_PROTOCOL 29
#define EXPECTED_MEM_SIZE 1024
#define TAG_INVALID 0xffff
#define MAX_DELAYCODE_NUM 16
#define MAX_BITNUM 16
#define IR_DECODE_FAILED (-1)
#define IR_DECODE_SUCCEEDED (0)
#define AC_PARAMETER_TYPE_1 0
#define AC_PARAMETER_TYPE_2 1
typedef enum
{
AC_POWER_ON = 0,
AC_POWER_OFF,
AC_POWER_MAX
} ac_power;
typedef enum
{
AC_TEMP_16 = 0,
AC_TEMP_17,
AC_TEMP_18,
AC_TEMP_19,
AC_TEMP_20,
AC_TEMP_21,
AC_TEMP_22,
AC_TEMP_23,
AC_TEMP_24,
AC_TEMP_25,
AC_TEMP_26,
AC_TEMP_27,
AC_TEMP_28,
AC_TEMP_29,
AC_TEMP_30,
AC_TEMP_MAX
} ac_temperature;
typedef enum
{
AC_MODE_COOL = 0,
AC_MODE_HEAT,
AC_MODE_AUTO,
AC_MODE_FAN,
AC_MODE_DRY,
AC_MODE_MAX
} ac_mode;
typedef enum
{
AC_FUNCTION_POWER = 1,
AC_FUNCTION_MODE,
AC_FUNCTION_TEMPERATURE_UP,
AC_FUNCTION_TEMPERATURE_DOWN,
AC_FUNCTION_WIND_SPEED,
AC_FUNCTION_WIND_SWING,
AC_FUNCTION_WIND_FIX,
AC_FUNCTION_MAX,
} ac_function;
typedef enum
{
AC_WS_AUTO = 0,
AC_WS_LOW,
AC_WS_MEDIUM,
AC_WS_HIGH,
AC_WS_MAX
} ac_wind_speed;
typedef enum
{
AC_SWING_ON = 0,
AC_SWING_OFF,
AC_SWING_MAX
} ac_swing;
typedef enum
{
SWING_TYPE_SWING_ONLY = 0,
SWING_TYPE_NORMAL,
SWING_TYPE_NOT_SPECIFIED,
SWING_TYPE_MAX
} swing_type;
typedef enum
{
TEMP_TYPE_DYNAMIC = 0,
TEMP_TYPE_STATIC,
TEMP_TYPE_MAX,
} temp_type;
// enumeration for application polymorphism
typedef enum
{
AC_APPLY_POWER = 0,
AC_APPLY_MODE,
AC_APPLY_TEMPERATURE_UP,
AC_APPLY_TEMPERATURE_DOWN,
AC_APPLY_WIND_SPEED,
AC_APPLY_WIND_SWING,
AC_APPLY_WIND_FIX,
AC_APPLY_MAX
} ac_apply;
typedef struct _ac_hex
{
UINT8 len;
UINT8 *data;
} ac_hex;
typedef struct _ac_level
{
UINT16 low;
UINT16 high;
} ac_level;
typedef struct _ac_bootcode
{
UINT16 len;
UINT16 data[16];
} ac_bootcode;
typedef struct _ac_delaycode
{
INT16 pos;
UINT16 time[8];
UINT16 time_cnt;
} ac_delaycode;
/*
* the array of tag_100X application data
* seg_len : length for each segment
* byte_pos : the position of update byte
* byte_value : the value to be updated to position
*/
typedef struct _tag_comp_type_1
{
UINT8 seg_len;
UINT8 *segment;
} tag_comp;
typedef struct _tag_swing_info
{
swing_type type;
UINT8 mode_count;
UINT8 dir_index;
} swing_info;
typedef struct _tag_power_1
{
UINT8 len;
tag_comp comp_data[AC_POWER_MAX];
} power_1;
typedef struct _tag_temp_1
{
UINT8 len;
UINT8 type;
tag_comp comp_data[AC_TEMP_MAX];
} temp_1;
typedef struct tag_mode_1
{
UINT8 len;
tag_comp comp_data[AC_MODE_MAX];
} mode_1;
typedef struct tag_speed_1
{
UINT8 len;
tag_comp comp_data[AC_WS_MAX];
} speed_1;
typedef struct tag_swing_1
{
UINT8 len;
UINT16 count;
tag_comp *comp_data;
} swing_1;
typedef struct tag_temp_2
{
UINT8 len;
UINT8 type;
tag_comp comp_data[AC_TEMP_MAX];
} temp_2;
typedef struct tag_mode_2
{
UINT8 len;
tag_comp comp_data[AC_MODE_MAX];
} mode_2;
typedef struct tag_speed_2
{
UINT8 len;
tag_comp comp_data[AC_WS_MAX];
} speed_2;
typedef struct tag_swing_2
{
UINT8 len;
UINT16 count;
tag_comp *comp_data;
} swing_2;
#if defined SUPPORT_HORIZONTAL_SWING
typedef struct tag_horiswing_1
{
UINT16 len;
tag_comp comp_data[AC_HORI_SWING_MAX];
} hori_swing_1;
#endif
typedef struct _tag_checksum_data
{
UINT8 len;
UINT8 type;
UINT8 start_byte_pos;
UINT8 end_byte_pos;
UINT8 checksum_byte_pos;
UINT8 checksum_plus;
UINT8 *spec_pos;
} tag_checksum_data;
typedef struct tag_checksum
{
UINT8 len;
UINT16 count;
tag_checksum_data *checksum_data;
} tchecksum;
typedef struct tag_function_1
{
UINT8 len;
tag_comp comp_data[AC_FUNCTION_MAX - 1];
} function_1;
typedef struct tag_function_2
{
UINT8 len;
tag_comp comp_data[AC_FUNCTION_MAX - 1];
} function_2;
typedef struct tag_solo_code
{
UINT8 len;
UINT8 solo_func_count;
UINT8 solo_function_codes[AC_FUNCTION_MAX - 1];
} solo_code;
typedef struct _ac_bitnum
{
INT16 pos;
UINT16 bits;
} ac_bitnum;
typedef enum
{
N_COOL = 0,
N_HEAT,
N_AUTO,
N_FAN,
N_DRY,
N_MODE_MAX,
} ac_n_mode;
typedef enum
{
CHECKSUM_TYPE_BYTE = 1,
CHECKSUM_TYPE_BYTE_INVERSE,
CHECKSUM_TYPE_HALF_BYTE,
CHECKSUM_TYPE_HALF_BYTE_INVERSE,
CHECKSUM_TYPE_SPEC_HALF_BYTE,
CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE,
CHECKSUM_TYPE_SPEC_HALF_BYTE_ONE_BYTE,
CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE_ONE_BYTE,
CHECKSUM_TYPE_MAX,
} checksum_type;
typedef struct _ac_n_mode_info
{
UINT8 enable;
UINT8 allspeed;
UINT8 alltemp;
UINT8 temp[AC_TEMP_MAX];
UINT8 temp_cnt;
UINT8 speed[AC_WS_MAX];
UINT8 speed_cnt;
} ac_n_mode_info;
typedef struct ac_protocol
{
UINT8 endian;
// ac_hex default_code;
ac_hex default_code;
ac_level zero;
ac_level one;
ac_bootcode bootcode;
ac_delaycode dc[MAX_DELAYCODE_NUM];
power_1 power1;
temp_1 temp1;
mode_1 mode1;
speed_1 speed1;
swing_1 swing1;
tchecksum checksum;
function_1 function1;
function_2 function2;
temp_2 temp2;
mode_2 mode2;
speed_2 speed2;
swing_2 swing2;
swing_info si;
solo_code sc;
UINT8 swing_status;
BOOL change_wind_direction;
UINT16 dc_cnt;
ac_bitnum bitnum[MAX_BITNUM];
UINT16 bitnum_cnt;
UINT16 repeat_times;
UINT16 frame_length;
ac_n_mode_info n_mode[N_MODE_MAX];
UINT16 code_cnt;
UINT8 lastbit;
UINT16 *time;
UINT8 solo_function_mark;
} protocol;
typedef struct tag_head
{
UINT16 tag;
UINT16 len;
unsigned short offset;
UINT8 *pdata;
} t_tag_head;
struct ir_bin_buffer
{
UINT8 *data;
UINT16 len;
UINT16 offset;
};
typedef struct REMOTE_AC_STATUS
{
UINT8 acPower;
UINT8 acTemp;
UINT8 acMode;
UINT8 acWindDir;
UINT8 acWindSpeed;
UINT8 acDisplay;
UINT8 acSleep;
UINT8 acTimer;
} remote_ac_status_t;
// function polymorphism
typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 function_code);
#define TAG_AC_BOOT_CODE 1
#define TAG_AC_ZERO 2
#define TAG_AC_ONE 3
#define TAG_AC_DELAY_CODE 4
#define TAG_AC_FRAME_LENGTH 5
#define TAG_AC_ENDIAN 6
#define TAG_AC_LASTBIT 7
#define TAG_AC_POWER_1 21
#define TAG_AC_DEFAULT_CODE 22
#define TAG_AC_TEMP_1 23
#define TAG_AC_MODE_1 24
#define TAG_AC_SPEED_1 25
#define TAG_AC_SWING_1 26
#define TAG_AC_CHECKSUM_TYPE 27
#define TAG_AC_SOLO_FUNCTION 28
#define TAG_AC_FUNCTION_1 29
#define TAG_AC_TEMP_2 30
#define TAG_AC_MODE_2 31
#define TAG_AC_SPEED_2 32
#define TAG_AC_SWING_2 33
#define TAG_AC_FUNCTION_2 34
#define TAG_AC_BAN_FUNCTION_IN_COOL_MODE 41
#define TAG_AC_BAN_FUNCTION_IN_HEAT_MODE 42
#define TAG_AC_BAN_FUNCTION_IN_AUTO_MODE 43
#define TAG_AC_BAN_FUNCTION_IN_FAN_MODE 44
#define TAG_AC_BAN_FUNCTION_IN_DRY_MODE 45
#define TAG_AC_SWING_INFO 46
#define TAG_AC_REPEAT_TIMES 47
#define TAG_AC_BITNUM 48
// definition about size
#define PROTOCOL_SIZE (sizeof(protocol))
/* exported variables */
extern UINT8* ir_hex_code;
extern UINT8 ir_hex_len;
extern protocol* context;
extern remote_ac_status_t ac_status;
extern UINT16 user_data[];
/* exported functions */
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
/*
* function irda_context_init
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 irda_context_init();
/*
* function irda_ac_file_open
*
* parameters: file name of remote binary
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 irda_ac_file_open(const char* file_name);
/*
* function irda_ac_lib_open
*
* parameters: binary (in) binary content
* binary_length (in) length of binary content
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 irda_ac_lib_open(UINT8 *binary, UINT16 binary_length);
/*
* function irda_ac_lib_parse
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 irda_ac_lib_parse();
/*
* function irda_ac_lib_control
*
* parameters: ac_status (in) indicates the current status of air conditioner to be controlled
* user_data (out) wave code array to be transmitted
* function_code (in) indicates the AC function to be updated
* change_wind_direction (in) indicates if the wind direction need to be changed
*
* return: length of wave code array
*/
extern UINT16 irda_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
BOOL change_wind_direction);
/*
* function irda_ac_lib_close
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern void irda_ac_lib_close();
///////////////////////////////////////////////// AC End /////////////////////////////////////////////////
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
/*
* function irda_tv_file_open
*
* parameters: file name of remote binary
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
INT8 irda_tv_file_open(const char* file_name);
/*
* function irda_tv_lib_open
*
* parameters: binary (in) binary content
* binary_length (in) length of binary content
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
INT8 irda_tv_lib_open(UINT8 *binary, UINT16 binary_length);
/*
* function irda_tv_lib_parse
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 irda_tv_lib_parse(UINT8 irda_hex_encode);
/*
* function irda_tv_lib_control
*
* parameters: key_code (in) indicates the number of pressed key
* user_data (out) wave code array to be transmitted
*
* return: length of wave code array
*/
extern UINT16 irda_tv_lib_control(UINT8 key_code, UINT16* user_data);
/*
* function irda_tv_lib_close
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 irda_tv_lib_close();
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
///////////////////////////////////////////////// Utils Begin /////////////////////////////////////////////////
/*
* function get_temperature_range
*
* parameters: ac_mode (in) specify in which AC mode the application need to get temperature info
* temp_min (out) the min temperature supported in a specified AC mode
* temp_max (out) the max temperature supported in a specified AC mode
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_temperature_range(UINT8 ac_mode, INT8* temp_min, INT8* temp_max);
/*
* function get_supported_mode
*
* parameters: supported_mode (out) mode supported by the remote in lower 5 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_mode(UINT8* supported_mode);
/*
* function get_supported_wind_speed
*
* parameters: ac_mode (in) specify in which AC mode the application need to get wind speed info
* supported_wind_speed (out) wind speed supported by the remote in lower 4 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8* supported_wind_speed);
/*
* function get_supported_swing
*
* parameters: ac_mode (in) specify in which AC mode the application need to get swing info
* supported_swing (out) swing supported by the remote in lower 2 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_swing(UINT8 ac_mode, UINT8* supported_swing);
/*
* function get_supported_wind_direction
*
* parameters: supported_wind_direction (out) swing supported by the remote in lower 2 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_wind_direction(UINT8* supported_wind_direction);
///////////////////////////////////////////////// Utils End /////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif // _IRDA_DECODE_H_

View File

@@ -0,0 +1,45 @@
/**************************************************************************************************
Filename: irda_defs.h
Revised: Date: 2016-10-26
Revision: Revision: 1.0
Description: This file provides algorithms for IR decode
Revision log:
* 2016-10-01: created by strawmanbobi
**************************************************************************************************/
#ifndef PARSE_IR_DEFS_H
#define PARSE_IR_DEFS_H
#ifdef __cplusplus
extern "C"
{
#endif
#if defined BOARD_ANDROID
#include <android/log.h>
#define LOG_TAG "irda_decode"
#endif
#define TRUE 1
#define FALSE 0
typedef unsigned char UINT8;
typedef signed char INT8;
typedef unsigned short UINT16;
typedef signed short INT16;
typedef int BOOL;
#define irda_malloc(A) malloc(A)
#define irda_free(A) free(A)
#define irda_memcpy(A, B, C) memcpy(A, B, C)
#define irda_memset(A, B, C) memset(A, B, C)
#define irda_strlen(A) strlen(A)
#define IR_PRINTF printf
#define USER_DATA_SIZE 2048
#ifdef __cplusplus
}
#endif
#endif //PARSE_IR_DEFS_H

View File

@@ -0,0 +1 @@
#include "stdafx.h"

View File

@@ -0,0 +1,24 @@
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN
#endif
#include <afx.h>
#include <afxwin.h>
#include <afxext.h>
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h>
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <iostream>

View File

@@ -0,0 +1,4 @@
#pragma once
#include <SDKDDKVer.h>

View File

@@ -13,4 +13,6 @@ Release/
.DS_Store
.vs
ir_decoder.vcxproj.user
irda_decoder.exe.stackdump
irda_decoder.exe.stackdump
ir_decoder.VC.db
ir_decoder.VC.VC.opendb

View File

@@ -3,16 +3,19 @@ LIBRARY
EXPORTS
irda_context_init @1
irda_ac_lib_open @2
irda_ac_lib_parse @3
irda_ac_lib_control @4
irda_ac_lib_close @5
irda_tv_lib_open @6
irda_tv_lib_parse @7
irda_tv_lib_control @8
irda_tv_lib_close @9
get_temperature_range @10
get_supported_mode @11
get_supported_wind_speed @12
get_supported_swing @13
get_supported_wind_direction @14
irda_ac_file_open @2
irda_ac_lib_open @3
irda_ac_lib_parse @4
irda_ac_lib_control @5
irda_ac_lib_close @6
irda_tv_file_open @7
irda_tv_lib_open @8
irda_tv_lib_parse @9
irda_tv_lib_control @10
irda_tv_lib_close @11
get_temperature_range @12
get_supported_mode @13
get_supported_wind_speed @14
get_supported_swing @15
get_supported_wind_direction @16

View File

@@ -34,7 +34,7 @@ UINT16 user_data[USER_DATA_SIZE];
INT8 irda_tv_file_open(const char* file_name);
INT8 decode_as_ac(const char* file_name)
INT8 decode_as_ac(char* file_name)
{
// keyboard input
int in_char = 0;