From 109e0a8f2b788dda7246188de91a22680812d0ca Mon Sep 17 00:00:00 2001 From: tangchao0503 <735056338@qq.com> Date: Wed, 22 Jun 2022 16:48:50 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=93=8D=E4=BD=9C=E9=81=A5=E6=8E=A7?= =?UTF-8?q?=E5=99=A8=E6=8C=89=E9=92=AE=EF=BC=8Cpsdk=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E9=80=9A=E8=BF=87socket=E5=8F=91=E9=80=81=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=BB=99=E7=9B=B8=E6=9C=BA=E8=BF=9B=E7=A8=8B=20=20=E6=9D=A5?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E9=AB=98=E5=85=89=E8=B0=B1=E9=87=87=E9=9B=86?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=EF=BC=9B=202=E3=80=81=E9=80=9A=E8=BF=87FFmpe?= =?UTF-8?q?g=E9=87=87=E9=9B=86=E6=91=84=E5=83=8F=E5=A4=B4=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=B5=81=E5=B9=B6=E7=BC=96=E7=A0=81=E4=B8=BAh264?= =?UTF-8?q?=EF=BC=8C=E5=88=A9=E7=94=A8psdk=E6=8E=A8=E6=B5=81=E5=88=B0?= =?UTF-8?q?=E9=81=A5=E6=8E=A7=E5=99=A8=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 24 + EULA.txt | 53 + License.txt | 476 +++++ README.txt | 14 + .../psdk_code_style/psdk_template.c | 90 + .../psdk_code_style/psdk_template.h | 129 ++ .../camera_emu/test_payload_cam_emu.c | 1458 +++++++++++++ .../camera_emu/test_payload_cam_emu.h | 57 + .../api_sample/camera_media_emu/ffmpeg_tc.c | 176 ++ .../api_sample/camera_media_emu/ffmpeg_tc.h | 63 + .../psdk_media_file_core.c | 265 +++ .../psdk_media_file_core.h | 117 + .../psdk_media_file_jpg.c | 227 ++ .../psdk_media_file_jpg.h | 77 + .../psdk_media_file_mp4.c | 261 +++ .../psdk_media_file_mp4.h | 77 + .../camera_media_emu/test_payload_cam_media.c | 1874 +++++++++++++++++ .../camera_media_emu/test_payload_cam_media.h | 61 + .../data_channel/test_data_channel.c | 63 + .../data_channel/test_data_channel.h | 56 + .../test_data_subscription.c | 173 ++ .../test_data_subscription.h | 55 + .../test_data_transmission.c | 201 ++ .../test_data_transmission.h | 54 + .../gimbal_emu/test_payload_gimbal_emu.c | 1100 ++++++++++ .../gimbal_emu/test_payload_gimbal_emu.h | 59 + .../api_sample/mop_channel/test_mop_channel.c | 824 ++++++++ .../api_sample/mop_channel/test_mop_channel.h | 126 ++ .../test_payload_collaboration.c | 175 ++ .../test_payload_collaboration.h | 54 + .../api_sample/positioning/test_positioning.c | 151 ++ .../api_sample/positioning/test_positioning.h | 54 + .../power_management/test_power_management.c | 145 ++ .../power_management/test_power_management.h | 63 + .../time_synchronization/test_time_sync.c | 166 ++ .../time_synchronization/test_time_sync.h | 59 + sample/api_sample/upgrade/test_upgrade.c | 371 ++++ sample/api_sample/upgrade/test_upgrade.h | 52 + .../api_sample/upgrade/test_upgrade_common.h | 74 + .../test_upgrade_common_file_transfer.c | 151 ++ .../test_upgrade_common_file_transfer.h | 53 + .../upgrade/test_upgrade_platform_opt.c | 141 ++ .../upgrade/test_upgrade_platform_opt.h | 86 + sample/api_sample/utils/util_buffer.c | 129 ++ sample/api_sample/utils/util_buffer.h | 61 + sample/api_sample/utils/util_file.c | 210 ++ sample/api_sample/utils/util_file.h | 69 + sample/api_sample/utils/util_math.c | 45 + sample/api_sample/utils/util_math.h | 49 + sample/api_sample/utils/util_md5.c | 240 +++ sample/api_sample/utils/util_md5.h | 90 + sample/api_sample/utils/util_misc.c | 86 + sample/api_sample/utils/util_misc.h | 62 + sample/api_sample/utils/util_time.c | 69 + sample/api_sample/utils/util_time.h | 60 + .../widget/file_binary_array_list_en.c | 60 + .../widget/file_binary_array_list_en.h | 59 + sample/api_sample/widget/test_widget.c | 634 ++++++ sample/api_sample/widget/test_widget.h | 72 + .../cn_big_screen/widget_config.json | 119 ++ .../en_big_screen/widget_config.json | 119 ++ .../en_big_screen/icon_button1_png.h | 148 ++ .../en_big_screen/icon_button2_png.h | 147 ++ .../en_big_screen/icon_list_item1_png.h | 174 ++ .../en_big_screen/icon_list_item2_png.h | 176 ++ .../en_big_screen/icon_scale_png.h | 167 ++ .../en_big_screen/icon_switch_select_png.h | 173 ++ .../en_big_screen/icon_switch_unselect_png.h | 172 ++ .../en_big_screen/widget_config_json.h | 256 +++ sample/api_sample/xport/test_xport.c | 361 ++++ sample/api_sample/xport/test_xport.h | 56 + .../linux/common/monitor/sys_monitor.c | 484 +++++ .../linux/common/monitor/sys_monitor.h | 78 + sample/platform/linux/common/osal/osal.c | 294 +++ sample/platform/linux/common/osal/osal.h | 77 + .../upgrade_platform_opt_linux.c | 219 ++ .../upgrade_platform_opt_linux.h | 71 + sample/platform/linux/manifold2/README.txt | 38 + .../linux/manifold2/application/app_info.h | 57 + .../linux/manifold2/application/main.c | 563 +++++ .../linux/manifold2/application/psdk_config.h | 75 + .../linux/manifold2/hal/hal_network.c | 90 + .../linux/manifold2/hal/hal_network.h | 52 + .../platform/linux/manifold2/hal/hal_uart.c | 139 ++ .../platform/linux/manifold2/hal/hal_uart.h | 62 + .../linux/manifold2/project/CMakeLists.txt | 91 + .../platform/linux/manifold2/project/build.sh | 37 + .../project/cmake-build-debug/psdk_demo.cbp | 292 +++ .../manifold2/project/hahahah/psdk_demo.cbp | 292 +++ 89 files changed, 17079 insertions(+) create mode 100644 .gitignore create mode 100644 EULA.txt create mode 100644 License.txt create mode 100644 README.txt create mode 100644 doc/psdk_other_docs/psdk_code_style/psdk_template.c create mode 100644 doc/psdk_other_docs/psdk_code_style/psdk_template.h create mode 100644 sample/api_sample/camera_emu/test_payload_cam_emu.c create mode 100644 sample/api_sample/camera_emu/test_payload_cam_emu.h create mode 100644 sample/api_sample/camera_media_emu/ffmpeg_tc.c create mode 100644 sample/api_sample/camera_media_emu/ffmpeg_tc.h create mode 100644 sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.c create mode 100644 sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.h create mode 100644 sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.c create mode 100644 sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.h create mode 100644 sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.c create mode 100644 sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.h create mode 100644 sample/api_sample/camera_media_emu/test_payload_cam_media.c create mode 100644 sample/api_sample/camera_media_emu/test_payload_cam_media.h create mode 100644 sample/api_sample/data_channel/test_data_channel.c create mode 100644 sample/api_sample/data_channel/test_data_channel.h create mode 100644 sample/api_sample/data_subscription/test_data_subscription.c create mode 100644 sample/api_sample/data_subscription/test_data_subscription.h create mode 100644 sample/api_sample/data_transmission/test_data_transmission.c create mode 100644 sample/api_sample/data_transmission/test_data_transmission.h create mode 100644 sample/api_sample/gimbal_emu/test_payload_gimbal_emu.c create mode 100644 sample/api_sample/gimbal_emu/test_payload_gimbal_emu.h create mode 100644 sample/api_sample/mop_channel/test_mop_channel.c create mode 100644 sample/api_sample/mop_channel/test_mop_channel.h create mode 100644 sample/api_sample/payload_collaboration/test_payload_collaboration.c create mode 100644 sample/api_sample/payload_collaboration/test_payload_collaboration.h create mode 100644 sample/api_sample/positioning/test_positioning.c create mode 100644 sample/api_sample/positioning/test_positioning.h create mode 100644 sample/api_sample/power_management/test_power_management.c create mode 100644 sample/api_sample/power_management/test_power_management.h create mode 100644 sample/api_sample/time_synchronization/test_time_sync.c create mode 100644 sample/api_sample/time_synchronization/test_time_sync.h create mode 100644 sample/api_sample/upgrade/test_upgrade.c create mode 100644 sample/api_sample/upgrade/test_upgrade.h create mode 100644 sample/api_sample/upgrade/test_upgrade_common.h create mode 100644 sample/api_sample/upgrade/test_upgrade_common_file_transfer.c create mode 100644 sample/api_sample/upgrade/test_upgrade_common_file_transfer.h create mode 100644 sample/api_sample/upgrade/test_upgrade_platform_opt.c create mode 100644 sample/api_sample/upgrade/test_upgrade_platform_opt.h create mode 100644 sample/api_sample/utils/util_buffer.c create mode 100644 sample/api_sample/utils/util_buffer.h create mode 100644 sample/api_sample/utils/util_file.c create mode 100644 sample/api_sample/utils/util_file.h create mode 100644 sample/api_sample/utils/util_math.c create mode 100644 sample/api_sample/utils/util_math.h create mode 100644 sample/api_sample/utils/util_md5.c create mode 100644 sample/api_sample/utils/util_md5.h create mode 100644 sample/api_sample/utils/util_misc.c create mode 100644 sample/api_sample/utils/util_misc.h create mode 100644 sample/api_sample/utils/util_time.c create mode 100644 sample/api_sample/utils/util_time.h create mode 100644 sample/api_sample/widget/file_binary_array_list_en.c create mode 100644 sample/api_sample/widget/file_binary_array_list_en.h create mode 100644 sample/api_sample/widget/test_widget.c create mode 100644 sample/api_sample/widget/test_widget.h create mode 100644 sample/api_sample/widget/widget_file/cn_big_screen/widget_config.json create mode 100644 sample/api_sample/widget/widget_file/en_big_screen/widget_config.json create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_button1_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_button2_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item1_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item2_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_scale_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_select_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_unselect_png.h create mode 100644 sample/api_sample/widget/widget_file_c/en_big_screen/widget_config_json.h create mode 100644 sample/api_sample/xport/test_xport.c create mode 100644 sample/api_sample/xport/test_xport.h create mode 100644 sample/platform/linux/common/monitor/sys_monitor.c create mode 100644 sample/platform/linux/common/monitor/sys_monitor.h create mode 100644 sample/platform/linux/common/osal/osal.c create mode 100644 sample/platform/linux/common/osal/osal.h create mode 100644 sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.c create mode 100644 sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.h create mode 100644 sample/platform/linux/manifold2/README.txt create mode 100644 sample/platform/linux/manifold2/application/app_info.h create mode 100644 sample/platform/linux/manifold2/application/main.c create mode 100644 sample/platform/linux/manifold2/application/psdk_config.h create mode 100644 sample/platform/linux/manifold2/hal/hal_network.c create mode 100644 sample/platform/linux/manifold2/hal/hal_network.h create mode 100644 sample/platform/linux/manifold2/hal/hal_uart.c create mode 100644 sample/platform/linux/manifold2/hal/hal_uart.h create mode 100644 sample/platform/linux/manifold2/project/CMakeLists.txt create mode 100644 sample/platform/linux/manifold2/project/build.sh create mode 100644 sample/platform/linux/manifold2/project/cmake-build-debug/psdk_demo.cbp create mode 100644 sample/platform/linux/manifold2/project/hahahah/psdk_demo.cbp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..203b303 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +#tc +build/ +rtos_freertos/ +psdk_lib/ +/doc/simple_model +*.mp4 +*.jpg +*.h264 +*.png +/tools +/.idea +/.vscode + +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps diff --git a/EULA.txt b/EULA.txt new file mode 100644 index 0000000..0749bfa --- /dev/null +++ b/EULA.txt @@ -0,0 +1,53 @@ +END USER LICENSE AGREEMENT +YOU AGREE TO USE THE SDK SOLELY IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF THIS END USER LICENSE AGREEMENT (THE “AGREEMENT”), AND YOU AGREE THAT YOU ARE BOUND BY AND ARE A PARTY TO THIS AGREEMENT. YOU WARRANT THAT YOU ARE AT LEAST EIGHTEEN YEARS OLD AND THAT YOU HAVE THE LEGAL CAPACITY TO ENTER INTO CONTRACTS. IF YOU ARE AGREEING TO BE BOUND BY THIS AGREEMENT ON BEHALF OF A COMPANY, ORGANIZATION, OR OTHER ENTITY, THEN (i) “YOU” INCLUDES YOU AND THAT COMPANY, ORGANIZATION OR ENTITY, AND (ii) YOU REPRESENT AND WARRANT THAT YOU ARE AN AUTHORIZED REPRESENTATIVE OF SUCH COMPANY, ORGANIZATION OR ENTITY WITH THE AUTHORITY TO BIND SUCH COMPANY, ORGANIZATION OR ENTITY TO THIS AGREEMENT. +YOUR USE OF THE SDK IS EXPRESSLY CONDITIONED ON YOUR ACCEPTANCE OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT, YOU MAY NOT INSTALL OR USE THE SDK. + 1. About This Agreement. + 1.1 Generally. This Agreement applies to the SDK made available by DJI to you. + 1.2 Additional Terms. Certain additional and/or different terms may apply to certain types of users. If you are a federal, state, or local government entity (including but not limited to any agency or other sub-governmental organization thereof) utilizing the SDK in your official capacity, and to whom DJI has agreed to provide the SDK, then our Government Terms apply to you. + 2. Definitions +“Analytics Data” means information collected from a DJI Product (e.g., a DJI UAV) that is used in connection with an Application and/or devices used to operate the DJI Product (e.g., a mobile device). The Analytics Data may include Header Data and/or Event Data. Analytics Data may be used by DJI for any lawful purpose, including without limitation, for research or to improve its SDK or DJI Products. +“Application” means a software program that is developed by you using the SDK for use with DJI Products. +“Confidential Information” means the SDK and all other information disclosed to you by DJI that would reasonably be considered to be confidential, or is or was considered by DJI to be confidential, except for information which you can demonstrate: (a) is previously rightfully known to you without restriction on disclosure; (b) is or becomes, from no act or failure to act on your part, generally known in the relevant industry or public domain; (c) is disclosed to you by a third-party as a matter of right and without restriction on disclosure; or (d) is or was independently developed by you without access to, use of, or reference to the Confidential Information. +“Documentation” means any online read me, help files, technical specifications, or other related explanatory materials that are contained in the SDK or that accompany the SDK. +“DJI” means SZ DJI TECHNOLOGY CO., LTD. and its affiliates. +“DJI Products” means DJI hardware, software, and services, such as unmanned aerial vehicles (UAVs), flight controllers, sensors, cameras, gimbals, remote controllers, accessories, etc. +“Event Data” means information about time of operation or events, session identification numbers, event types, and flight operation information, including but not limited to GPS data, navigation, operation, speed, distance, modes, mission, command, altitude, takeoff and landing, payload and other component use, battery levels, etc. +“Header Data” means information about the software (including but not limited to installation identification, app key, SDK version of an Application) and hardware (including but not limited to product identifiers and names of UAVs, payloads, remote controllers, etc.). +“Licensee Disclosure” means any information that you may provide to DJI in connection with this Agreement, including, for example, feedback on errors and improvements within or relating to the SDK. +“Privacy Policy” means DJI’s privacy policy located at https://developer.dji.com/policies/privacy/. +“SDK” or “Software Development Kit” means software (source code and object code), applications, tools, sample code, templates, fonts, logos, icons, images, libraries, interfaces, Updates, Documentation, application programming interfaces (APIs), information, data, files, and other materials, whether tangible or intangible, in whatever form or medium provided to you by DJI for use by you in connection with your Application. For the purpose of this Agreement, SDK includes, without limitation, (a) the DJI “Guidance” software development kit (https://developer.dji.com/guidance-sdk/), (b) the DJI “Mobile” software development kit (https://developer.dji.com/mobile-sdk/), and/or (c) the DJI “Onboard” software development kit (https://developer.dji.com/onboard-sdk/). +“Open-Source Component” means software, interfaces and firmware subject to an open-source software license, which means any software license approved as open-source licenses by the Open Source Initiative or any substantially similar licenses, including without limitation any license that, as a condition of distribution of the software licensed under such license, requires that the distributor make the software available in source code format. +“Third-Party Component” means software, interfaces and firmware licensed by DJI from a third-party (e.g., a supplier of DJI) for incorporation into the SDK and distributed as an integral part of the SDK, as applicable. Third-Party Components may include Open-Source Components. +“Updates” means bug fixes, service packs, hot fixes, updates, upgrades, enhancements, modifications, and new releases of versions of the SDK. +“Warranty Logs” means information provided to and/or received by the SDK that is necessary for determining warranty eligibility and product reliability, including without limitation SDK function calls (including without limitation time, function name, results/feedback, etc.), protocol or commands sent from or to a mobile device, an Application, and/or a remote controller (including without limitation time, name, type, command/action, etc.). + + 3. License. + 3.1 License Grants. The SDK is licensed, not sold, to you by DJI and/or, if applicable, its suppliers and licensors. Subject to the terms and conditions of this Agreement, you are hereby granted a limited, worldwide, non-exclusive, non-sublicensable, and nontransferable right to use the SDK solely in the manner described in the Documentation and solely to develop, test, and operate Applications in connection with DJI products. + 3.2 Use Restrictions. You may not use the SDK except as permitted in this Agreement and any additional terms and conditions that DJI provides pursuant to Section 3.1. Except with DJI’s prior written consent or otherwise provided herein, you may not: (a) alter, modify or create any derivative works of the SDK, including the underlying source code, or the Documentation in any way, including without limitation customization, translation or localization; (b) port, reverse compile, reverse assemble, reverse engineer, or otherwise attempt to separate any of the components of the SDK or derive the source code for the SDK (except to the extent applicable laws specifically prohibit such restriction); (c) copy, redistribute, encumber, sell, rent, lease, sublicense, or otherwise transfer rights to the SDK; (d) remove or alter any trademark, logo, copyright or other proprietary notices, legends, symbols or labels in the SDK; (e) block, disable, or otherwise affect any advertising, advertisement banner window, links to other sites and services, or other features that constitute an integral part of the SDK; or (f) use any part of the SDK to develop applications for use with hardware devices that are not DJI Products, unless they are the devices running the applications or are devices connected (directly or indirectly) to DJI Product(s) the SDK interfaces with. You may not release the results of any performance or functional evaluation of any of the SDK to any third-party without prior written approval of DJI for each such release. You may not cause or permit any third-party to do any of the foregoing. + 3.3 Distribution of Object Code. You may distribute your Application with object code of the SDK, provided that you must: (1) distribute such object code of the SDK in execution form only; (2) distribute such code only as a part of your Applications; (3) not distribute any portion of the SDK that is not object code, including but not limited to source code, header files and Documentation; (4) not charge a separate price or fee for the object code of the SDK that is distinct from the fee you charge for your Application; (5) not distribute, link, or integrate the object code of the SDK such that any part of the object code of the SDK becomes subject to an open source license; and (6) include the following copyright notice within your Application’s source code in the same locations as your own copyright notice: “Portions copyright (c) 2014–Present DJI. All rights reserved.”. To the extent that any source code is provided to you as part of the SDK, you may use, modify and compile the source code solely for the purposes of developing your Applications. + 3.4 Third-Party Components. You acknowledge that the SDK may contain Third-Party Components. All third-party licensors and suppliers retain all right, title and interest in and to such Third-Party Components and all copies thereof, including all copyright and other intellectual property rights. Your use of any Third-Party Components shall be subject to, and you shall comply with, the terms and conditions of this Agreement, and the applicable restrictions and other terms and conditions set forth in any Third-Party Components documentation or printed materials, including without limitation an end user license agreement. + 3.5 Open-Source Components. The SDK may include Open-Source Components that are subject to open-source software licenses. The Documentation accompanying the SDK includes copies of the licenses applicable to the Open-Source Components. To the extent there is conflict between the license terms covering the Open-Source Components and this Agreement, the terms of such licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the licenses applicable to Open-Source Components prohibit any of the restrictions in this Agreement with respect to such Open-Source Component, such restrictions will not apply to such Open-Source Component. + 4. Reservation of Rights. DJI and its licensors reserve all rights, including but not limited to ownership and intellectual property rights, including in the SDK, not expressly granted to you. DJI’s licensors are the intended third-party beneficiaries of this Agreement and have the express right to rely upon and directly enforce the terms set forth herein. There are no implied licenses granted by DJI under this Agreement. Except as specified above, you shall have no rights to the SDK. You acknowledge and agree that the form and nature of the SDK that DJI provides may change without prior notice to you and that future versions of the SDK may be incompatible with Applications developed on previous versions of the SDK. You acknowledge and agree that DJI may stop providing the SDK or any features of the SDK permanently or temporarily to you or users generally at DJI’s sole discretion, without prior notice to you. If the SDK is a “beta” release, you acknowledge and agree that the SDK is a “beta” release for evaluation purposes only and may contain bugs, defects and errors and that the SDK may fail, return inaccurate results, and/or be subject to other malfunctions. + 5. Your Applications and Use of the SDK. + 5.1 Rights in Your Applications. Subject to Section 4 above, DJI agrees that it obtains no right, title, or interest from you (or your licensors) under this Agreement in or to any Applications that you develop using the SDK, including any sole and separate intellectual property rights of yours that subsist in those Applications. + 5.2 Permitted Applications. You agree to use the SDK and develop Applications solely for purposes that are permitted by: (a) this Agreement; (b) the DJI Developer Policy available at https://developer.dji.com/policies/developer/; and (c) any applicable law, rule, regulation, or generally accepted practice or guideline in the relevant jurisdiction, including but not limited to laws, rules, or regulations regarding the export of data or software to and from the United States or other relevant countries, and national, public, and personal security. + 5.3 Your Responsibilities. You agree that you are solely responsible for, and that DJI has no responsibility to you or any third-party for, or access to: (a) any data, content, or resources that you create, transmit, or display through the Applications you develop on or with the SDK (whether originating with you or a third-party), and for the consequences of your actions (including any loss or damage suffered by DJI) by doing so; and (b) any breach of your obligations under this Agreement, any applicable third-party contract or terms of service, or any applicable law, rule, or regulation, and for the consequences (including any loss or damage suffered by DJI) of any such breach. + 5.4 Compliance with Law; Safety. For the avoidance of doubt, you agree that you shall at all times strictly comply with all applicable laws, rules and regulations and shall not threaten the safety of national security, public security, or the health, privacy, or safety of any person. + 6. Privacy and Automatically Collected Information. + 6.1 SDK Use and User Information. In order to continually improve the SDK, DJI may automatically collect certain usage statistics including, but not limited to, unique identifiers, associated IP address, and other information on which tools and services in the SDK are being used and how they are being used. This data is collected in the aggregate to improve the SDK and is maintained in accordance with DJI’s Privacy Policy. We may also collect certain personal information from you, including but not limited to your legal name, mailing address, phone number, email address, and other contact or personal information. We may also collect additional information in order to verify your identity or provide certain functions. This information will be maintained in accordance with DJI’s Privacy Policy, and you hereby agree that we may share this information with our third-party business partners for purposes of verifying your identity or provide certain functions and as otherwise permitted by our Privacy Policy. + 6.2 Application User Information. The SDK may automatically collect Analytics Data, such as Header Data and/or Event Data. The Analytics Data may be provided to DJI and used by DJI for any use in research or improving its SDK or DJI Products. The Analytics Data may be used by DJI for any lawful purpose, including without limitation, for research or to improve its SDK or DJI Products. Certain SDK (e.g., Mobile SDK) may also automatically collect Warranty Log information, for example, for the purpose of determining warranty eligibility and product reliability. The Warranty Logs are stored locally on a device running the Application (e.g., mobile device) and are not automatically transmitted to DJI without prior user consent. You may be required to make the Warranty Logs available to DJI to support any warranty claims regarding the SDK. By using the SDK and creating an Application, you represent and warrant that you will provide clear and conspicuous notice to each user of the Application of the automatic collection, storage, and DJI’s use of the Analytics Data and Warranty Logs, and that you will obtain any legally-required consents for DJI to receive and use the Analytics Data and Warranty Logs for the purposes specified herein. The Application User Information is maintained in accordance with DJI’s Privacy Policy located at https://developer.dji.com/policies/privacy/. + 7. Proprietary Rights. You acknowledge and agree that the SDK belongs to DJI or its licensors. You agree that you neither own nor hereby acquire any claim or right of ownership to the SDK or to any related patents, copyrights, trademarks, or other intellectual property. DJI and its licensors retain all right, title, and interest in and to all copies of the SDK at all times, regardless of the form or media in or on which the original or other copies may subsequently exist. This license is not a sale of the original or any subsequent copy. The SDK is protected by copyright and other intellectual property laws and by international treaties. You may not make any copies of the SDK except as otherwise permitted by this Agreement. Any and all other copies of the SDK made by you are in violation of this license. All content accessed through the SDK is the property of the applicable content owner and may be protected by applicable copyright law. This license gives you no rights to such content. All trademarks used in connection with the SDK are owned by DJI, its affiliates and/or its licensors and other suppliers, and no license to use any such trademarks is provided hereunder. + 8. Information Submitted to DJI Not Deemed Confidential. DJI works with many application developers and some of their products may be similar to or compete with Your Applications. DJI may also be developing its own similar or competing applications, or may decide to do so in the future. To avoid potential misunderstandings, DJI CANNOT AGREE, AND EXPRESSLY DISCLAIMS, ANY CONFIDENTIALITY OBLIGATIONS OR USE RESTRICTIONS, EXPRESS OR IMPLIED, WITH RESPECT TO ANY LICENSEE DISCLOSURE. Such licensee disclosure may include, for example, feedback on errors and improvements within or relating to the SDK. You agree any such licensee disclosure will be non-confidential. DJI will be free to use and disclose any licensee disclosure on an unrestricted basis without notifying or compensating you. You release DJI from all liability and obligations that may arise from the receipt, review, use, or disclosure of any portion of any licensee disclosure. Any physical materials you submit to DJI will become DJI property and DJI will have no obligation to return those materials to you or to certify their destruction. + 9. No Support. This Agreement does not entitle you to receive from DJI or its licensors hard-copy documentation, support, telephone assistance, or enhancements or updates to the SDK. + 10. Term and Termination. This Agreement and your right to use the SDK may be terminated by you or by DJI at any time upon written notice. This Agreement automatically terminates if you fail to comply with its terms and conditions. Immediately upon termination, you shall return or destroy all copies of the SDK in your possession, custody, or control and, if requested by DJI, you shall certify to DJI in writing that such return or destruction has occurred. The following Sections of this Agreement survive any expiration or termination hereof: 1, 2, 3.2, 3.3, 3.4, 3.5, and 4 through 18 (inclusive). + 11. No warranty. YOU AGREE THAT THE SDK IS PROVIDED “AS IS” AND THAT DJI AND ITS LICENSORS MAKE NO OTHER WARRANTY AS TO THE SDK, INCLUDING, BUT NOT LIMITED TO, UNINTERRUPTED USE, ACCURACY, AND DATA LOSS. DJI AND ITS LICENSORS DISCLAIM ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, PRIVACY, SECURITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE (EVEN IF DJI KNOWS OR SHOULD HAVE KNOWN OF SUCH PURPOSE), RELATED TO THE SDK, ITS USE OR ANY INABILITY TO USE IT, THE RESULTS OF ITS USE AND THIS AGREEMENT. DJI AND ITS LICENSORS DO NOT WARRANT THAT THE SDK OR ANY RESULTS OF USE THEREOF WILL BE FREE OF DEFECTS, ERRORS OR VIRUSES, RELIABLE OR ABLE TO OPERATE ON AN UNINTERRUPTED BASIS OR IN A PARTICULAR ENVIRONMENT OR THAT ERRORS THEREIN, IF ANY, WILL BE CORRECTED. + 12. Limitation of Liability. TO THE FULLEST EXTENT PERMITTED BY LAW, DJI AND ITS AFFILIATES AND LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES, WHETHER IN CONTRACT OR TORT (INCLUDING NEGLIGENCE) OR ANY OTHER LEGAL OR EQUITABLE THEORY, ARISING FROM THIS AGREEMENT AND/OR YOUR USE OF THE SDK OR DEVELOPMENT OR DISTRIBUTION OF ANY APPLICATION, INCLUDING WITHOUT LIMITATION ANY INDIRECT, CONSEQUENTIAL, SPECIAL, EXEMPLARY, INCIDENTAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOU AGREE THAT YOU SHALL HAVE THE SOLE RESPONSIBILITY FOR PROTECTING YOUR DATA, BY PERIODIC BACKUP OR OTHERWISE, USED IN CONNECTION WITH THE SDK. IN ANY CASE, DJI AND ITS AFFILIATES AND LICENSORS’ SOLE LIABILITY AND YOUR EXCLUSIVE REMEDY UNDER ANY PROVISION OF THIS AGREEMENT SHALL BE TO STOP USING THE SDK, WITH THE EXCEPTION OF DEATH OR PERSONAL INJURY CAUSED BY THE SOLE NEGLIGENCE OF DJI, AND SOLELY TO THE EXTENT APPLICABLE LAW PROHIBITS THE LIMITATION OF DAMAGES IN SUCH CASES. + 13. Indemnification. TO THE MAXIMUM EXTENT PERMITTED BY LAW, YOU AGREE TO DEFEND, INDEMNIFY, AND HOLD HARMLESS DJI, ITS AFFILIATES AND THEIR RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AND AGENTS FROM AND AGAINST ANY AND ALL CLAIMS, ACTIONS, SUITS, OR PROCEEDINGS, AS WELL AS ANY AND ALL LOSSES, LIABILITIES, DAMAGES, COSTS, AND EXPENSES (INCLUDING REASONABLE ATTORNEYS’ FEES) ARISING OUT OF OR ACCRUING FROM: (A) YOUR USE OF THE SDK, INCLUDING THIRD-PARTY SOFTWARE AND/OR DOCUMENTATION; (B) ANY APPLICATION YOU DEVELOP ON OR WITH THE SDK THAT IS ALLEGED TO OR DETERMINED TO INFRINGE ANY PATENT, COPYRIGHT, TRADEMARK, OR OTHER INTELLECTUAL PROPERTY OR PROPRIETARY RIGHT OF A THIRD PARTY; AND (C) YOUR NONCOMPLIANCE WITH ANY TERM OF THIS AGREEMENT, EXCEPT FOR DEATH OR PERSONAL INJURY CAUSED BY THE SOLE NEGLIGENCE OF DJI. + 14. Confidentiality. You shall use your best efforts to preserve and protect the confidentiality of the Confidential Information at all times, both during the term hereof and for a period of at least 3 years after termination of this Agreement, provided, however, that any source code you receive shall be held in confidence in perpetuity. You shall not disclose, disseminate, or otherwise publish or communicate Confidential Information to any person, firm, corporation or other third-party without the prior written consent of DJI. You shall not use any Confidential Information other than in the course of the activities permitted hereunder. You agree to use your best efforts to prevent and protect the contents of the SDK from unauthorized disclosure or use. You shall notify DJI in writing immediately upon discovery of any unauthorized use or disclosure of Confidential Information or any other breach of this Agreement, and will cooperate with DJI in every reasonable way to regain possession of Confidential Information and prevent any further unauthorized use. +If you are legally compelled to disclose any of the Confidential Information, then, prior to such disclosure, you will (i) immediately notify DJI prior to such disclosure to allow DJI an opportunity to contest the disclosure, (ii) assert the privileged and confidential nature of the Confidential Information, and (iii) cooperate fully with DJI in protecting against any such disclosure and/or obtaining a protective order narrowing the scope of such disclosure and/or use of the Confidential Information. In the event such protection is not obtained, you shall disclose the Confidential Information only to the extent necessary to comply with the applicable legal requirements. + 15. Injunctive Relief. You acknowledge and agree that your breach or threatened breach of this Agreement shall cause DJI irreparable damage for which recovery of money damages would be inadequate and that DJI therefore may obtain timely injunctive relief to protect its rights under this Agreement in addition to any and all other remedies available at law or in equity. + 16. Export Controls. The SDK and the underlying information and technology may not be downloaded or otherwise exported or re-exported (a) into (or to a national or resident of) any country to which the U.S. has embargoed goods; or (b) to or through or involve any party on any U.S. government screening or prohibited list (including those as updated from time-to-time on the U.S. Consolidated Screening List (available at http://export.gov/ecr/eg_main_023148.asp). By downloading or using the SDK and/or Documentation, you are agreeing to the foregoing and you represent and warrant that you are not located in, under the control of, or a national or resident of any such country or on any such list and you agree to comply with all export laws and other applicable laws. + 17. Miscellaneous. (a) This Agreement, together with any amendments and any additional agreements you may enter into with DJI in connection with the use of SDK, shall constitute the entire agreement between the parties concerning the subject matter hereof, which may only be modified by a written amendment signed by an authorized executive of DJI. (b) Any dispute, controversy, difference or claim arising out of or relating to this contract, including the existence, validity, interpretation, performance, breach or termination thereof or any dispute regarding non-contractual obligations arising out of or relating to it shall be referred to and finally resolved by arbitration administered by the Hong Kong International Arbitration Centre (“HKIAC”) under the HKIAC Administered Arbitration Rules in force when the Notice of Arbitration is submitted. The law of this arbitration clause shall be Hong Kong law, excluding its conflict of law provisions. The seat of arbitration shall be Hong Kong. The number of arbitrators shall be three (3) in accordance with such rules. The arbitration proceedings shall be conducted in English. Any awards of shall be final and binding upon the applicable parties. (c) This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods. (d) If any part of this Agreement is held invalid or unenforceable, that part shall be construed to reflect the parties' original intent, and the remaining portions remain in full force and effect, or DJI may at its option terminate this Agreement. (e) The controlling language of this Agreement is English. If you have received a translation into another language, it has been provided for your convenience only. (f) A waiver by either party of any term or condition of this Agreement or any breach thereof, in any one instance, shall not waive such term or condition or any subsequent breach thereof. (g) You may not assign or otherwise transfer by operation of law or otherwise this Agreement or any rights or obligations herein. DJI may assign this Agreement to any entity at its sole discretion. (h) This Agreement shall be binding upon and shall inure to the benefit of the parties, their successors and permitted assigns. + 18. User Outside the People’s Republic of China. If you are using the SDK outside the People’s Republic of China, then the following shall apply: (a) You confirm that this Agreement and all related documentation is and will be in the English language; (b) you are responsible for complying with any local laws in your jurisdiction which might impact your right to import, export or use the SDK, and you represent that you have complied with any regulations or registration procedures required by applicable law to make this license enforceable. + +This End User License Agreement was last modified on December 11, 2017. diff --git a/License.txt b/License.txt new file mode 100644 index 0000000..6a32fe8 --- /dev/null +++ b/License.txt @@ -0,0 +1,476 @@ +The following portions of the DJI’s Payload SDK (“Software” referred to in the terms below) are made available to you under the terms of the MIT License. A copy of the MIT license is available at https://opensource.org/licenses/MIT. + +Payload-SDK +├── doc +│   ├── psdk_other_docs +│   │   └── psdk_code_style +│   │   ├── psdk_template.c +│   │   └── psdk_template.h +│   └── simple_model +│   ├── M200.STEP +│   ├── M200_V2.STEP +│   ├── M210_RTK.STEP +│   ├── M210_RTK_V2.stp +│   ├── M210.STEP +│   ├── M210_V2.stp +│   ├── M300_RTK_1.stp +│   ├── M300_RTK_2.stp +│   ├── M300_RTK_3.stp +│   ├── Skyport_Adapter_2.stp +│   └── X-Port 80mm.stp +├── EULA.txt +├── License.txt +├── psdk_lib +│   ├── api_headers +│   │   ├── psdk_aircraft_info.h +│   │   ├── psdk_core.h +│   │   ├── psdk_data_channel.h +│   │   ├── psdk_data_subscription.h +│   │   ├── psdk_data_transmission.h +│   │   ├── psdk_error.h +│   │   ├── psdk_gimbal.h +│   │   ├── psdk_logger.h +│   │   ├── psdk_mop_channel.h +│   │   ├── psdk_payload_camera.h +│   │   ├── psdk_payload_collaboration.h +│   │   ├── psdk_platform.h +│   │   ├── psdk_positioning.h +│   │   ├── psdk_power_management.h +│   │   ├── psdk_product_info.h +│   │   ├── psdk_time_sync.h +│   │   ├── psdk_typedef.h +│   │   ├── psdk_upgrade.h +│   │   ├── psdk_version.h +│   │   ├── psdk_widget.h +│   │   └── psdk_xport.h +│   └── lib +│   ├── aarch64-himix100-linux-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── aarch64-linux-gnu-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── armcc_cortex-m4 +│   │   └── payloadsdk.lib +│   ├── arm-himix100-linux-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-himix200-linux-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-hisiv300-linux-uclibcgnueabi-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-hisiv400-linux-gnueabi-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-hisiv500-linux-uclibcgnueabi-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-hisiv600-linux-gnueabi-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-linux-androideabi-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-linux-gnueabi-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   ├── arm-linux-gnueabihf-gcc +│   │   ├── libpayloadsdk.a +│   │   └── version.log +│   └── x86_64-linux-gnu-gcc +│   ├── libpayloadsdk.a +│   └── version.log +├── README.txt +├── sample +│   ├── api_sample +│   │   ├── camera_emu +│   │   │   ├── test_payload_cam_emu.c +│   │   │   └── test_payload_cam_emu.h +│   │   ├── camera_media_emu +│   │   │   ├── media_file +│   │   │   │   ├── PSDK_0001_ORG.jpg +│   │   │   │   ├── PSDK_0002_ORG.jpg +│   │   │   │   ├── PSDK_0003_ORG.jpg +│   │   │   │   ├── PSDK_0004_ORG.mp4 +│   │   │   │   └── PSDK_0006.h264 +│   │   │   ├── psdk_media_file_manage +│   │   │   │   ├── psdk_media_file_core.c +│   │   │   │   ├── psdk_media_file_core.h +│   │   │   │   ├── psdk_media_file_jpg.c +│   │   │   │   ├── psdk_media_file_jpg.h +│   │   │   │   ├── psdk_media_file_mp4.c +│   │   │   │   └── psdk_media_file_mp4.h +│   │   │   ├── test_payload_cam_media.c +│   │   │   └── test_payload_cam_media.h +│   │   ├── data_channel +│   │   │   ├── test_data_channel.c +│   │   │   └── test_data_channel.h +│   │   ├── data_subscription +│   │   │   ├── test_data_subscription.c +│   │   │   └── test_data_subscription.h +│   │   ├── data_transmission +│   │   │   ├── test_data_transmission.c +│   │   │   └── test_data_transmission.h +│   │   ├── gimbal_emu +│   │   │   ├── test_payload_gimbal_emu.c +│   │   │   └── test_payload_gimbal_emu.h +│   │   ├── mop_channel +│   │   │   ├── mop_channel_test_file +│   │   │   │   └── mop_send_test_file.mp4 +│   │   │   ├── test_mop_channel.c +│   │   │   └── test_mop_channel.h +│   │   ├── payload_collaboration +│   │   │   ├── test_payload_collaboration.c +│   │   │   └── test_payload_collaboration.h +│   │   ├── positioning +│   │   │   ├── test_positioning.c +│   │   │   └── test_positioning.h +│   │   ├── power_management +│   │   │   ├── test_power_management.c +│   │   │   └── test_power_management.h +│   │   ├── time_synchronization +│   │   │   ├── test_time_sync.c +│   │   │   └── test_time_sync.h +│   │   ├── upgrade +│   │   │   ├── test_upgrade.c +│   │   │   ├── test_upgrade_common_file_transfer.c +│   │   │   ├── test_upgrade_common_file_transfer.h +│   │   │   ├── test_upgrade_common.h +│   │   │   ├── test_upgrade.h +│   │   │   ├── test_upgrade_platform_opt.c +│   │   │   └── test_upgrade_platform_opt.h +│   │   ├── utils +│   │   │   ├── util_buffer.c +│   │   │   ├── util_buffer.h +│   │   │   ├── util_file.c +│   │   │   ├── util_file.h +│   │   │   ├── util_math.c +│   │   │   ├── util_math.h +│   │   │   ├── util_md5.c +│   │   │   ├── util_md5.h +│   │   │   ├── util_misc.c +│   │   │   ├── util_misc.h +│   │   │   ├── util_time.c +│   │   │   └── util_time.h +│   │   ├── widget +│   │   │   ├── file_binary_array_list_en.c +│   │   │   ├── file_binary_array_list_en.h +│   │   │   ├── test_widget.c +│   │   │   ├── test_widget.h +│   │   │   ├── widget_file +│   │   │   │   ├── cn_big_screen +│   │   │   │   │   ├── icon_button1.png +│   │   │   │   │   ├── icon_button2.png +│   │   │   │   │   ├── icon_list_item1.png +│   │   │   │   │   ├── icon_list_item2.png +│   │   │   │   │   ├── icon_scale.png +│   │   │   │   │   ├── icon_switch_select.png +│   │   │   │   │   ├── icon_switch_unselect.png +│   │   │   │   │   └── widget_config.json +│   │   │   │   └── en_big_screen +│   │   │   │   ├── icon_button1.png +│   │   │   │   ├── icon_button2.png +│   │   │   │   ├── icon_list_item1.png +│   │   │   │   ├── icon_list_item2.png +│   │   │   │   ├── icon_scale.png +│   │   │   │   ├── icon_switch_select.png +│   │   │   │   ├── icon_switch_unselect.png +│   │   │   │   └── widget_config.json +│   │   │   └── widget_file_c +│   │   │   └── en_big_screen +│   │   │   ├── icon_button1_png.h +│   │   │   ├── icon_button2_png.h +│   │   │   ├── icon_list_item1_png.h +│   │   │   ├── icon_list_item2_png.h +│   │   │   ├── icon_scale_png.h +│   │   │   ├── icon_switch_select_png.h +│   │   │   ├── icon_switch_unselect_png.h +│   │   │   └── widget_config_json.h +│   │   └── xport +│   │   ├── test_xport.c +│   │   └── test_xport.h +│   └── platform +│   ├── linux +│   │   ├── common +│   │   │   ├── monitor +│   │   │   │   ├── sys_monitor.c +│   │   │   │   └── sys_monitor.h +│   │   │   ├── osal +│   │   │   │   ├── osal.c +│   │   │   │   └── osal.h +│   │   │   └── upgrade_platform_opt +│   │   │   ├── upgrade_platform_opt_linux.c +│   │   │   └── upgrade_platform_opt_linux.h +│   │   └── manifold2 +│   │   ├── application +│   │   │   ├── app_info.h +│   │   │   ├── main.c +│   │   │   └── psdk_config.h +│   │   ├── hal +│   │   │   ├── hal_network.c +│   │   │   ├── hal_network.h +│   │   │   ├── hal_uart.c +│   │   │   └── hal_uart.h +│   │   ├── project +│   │   │   └── CMakeLists.txt +│   │   └── README.txt +│   └── rtos_freertos +│   ├── common +│   │   └── osal +│   │   ├── osal.c +│   │   └── osal.h +│   ├── high-speed_transmission_demo +│   │   ├── application +│   │   │   └── test_high_speed_transmission.c +│   │   ├── project +│   │   │   └── CMakeLists.txt +│   │   └── README.txt +│   ├── psdk_development_board_1.0 +│   │   ├── application +│   │   │   ├── app_info.h +│   │   │   ├── application.c +│   │   │   ├── application.h +│   │   │   ├── FreeRTOSConfig.h +│   │   │   ├── main.c +│   │   │   └── psdk_config.h +│   │   ├── bootloader +│   │   │   ├── common.c +│   │   │   ├── common.h +│   │   │   ├── main.c +│   │   │   ├── main.h +│   │   │   ├── menu.c +│   │   │   ├── menu.h +│   │   │   └── ymodem.c +│   │   ├── drivers +│   │   │   ├── BSP +│   │   │   │   ├── button.c +│   │   │   │   ├── button.h +│   │   │   │   ├── dji_ringbuffer.c +│   │   │   │   ├── dji_ringbuffer.h +│   │   │   │   ├── flash_if.c +│   │   │   │   ├── flash_if.h +│   │   │   │   ├── pps.c +│   │   │   │   ├── pps.h +│   │   │   │   ├── stm32f4xx_conf.h +│   │   │   │   ├── stm32f4xx_hal_conf.h +│   │   │   │   ├── stm32f4xx_hal_msp.c +│   │   │   │   ├── stm32f4xx_it.c +│   │   │   │   ├── stm32f4xx_it.h +│   │   │   │   ├── uart.c +│   │   │   │   ├── uart_enable.c +│   │   │   │   ├── uart_enable.h +│   │   │   │   ├── uart.h +│   │   │   │   ├── upgrade_platform_opt_stm32.c +│   │   │   │   └── upgrade_platform_opt_stm32.h +│   │   ├── hal +│   │   │   ├── hal_uart.c +│   │   │   └── hal_uart.h +│   │   ├── project +│   │   │   ├── mdk_bootloader +│   │   │   │   ├── DebugConfig +│   │   │   │   │   └── psdk_bootloader_STM32F407IGHx.dbgconf +│   │   │   │   └── psdk_demo_bootloader.uvprojx +│   │   │   └── mdk_release +│   │   │   ├── DebugConfig +│   │   │   │   └── Psdk_Demo_Release_Use_Bootloader_STM32F407IGHx.dbgconf +│   │   │   └── psdk_demo.uvprojx +│   │   └── README.txt +│   └── stm32f4_eval +│   ├── application +│   │   ├── app_info.h +│   │   ├── application.c +│   │   ├── application.h +│   │   ├── FreeRTOSConfig.h +│   │   ├── main.c +│   │   └── psdk_config.h +│   ├── bootloader +│   │   ├── common.c +│   │   ├── common.h +│   │   ├── main.c +│   │   ├── main.h +│   │   ├── menu.c +│   │   ├── menu.h +│   │   └── ymodem.c +│   ├── drivers +│   │   ├── BSP +│   │   │   ├── apply_high_power.c +│   │   │   ├── apply_high_power.h +│   │   │   ├── button.c +│   │   │   ├── button.h +│   │   │   ├── dji_ringbuffer.c +│   │   │   ├── dji_ringbuffer.h +│   │   │   ├── flash_if.c +│   │   │   ├── flash_if.h +│   │   │   ├── pps.c +│   │   │   ├── pps.h +│   │   │   ├── stm32f4xx_conf.h +│   │   │   ├── stm32f4xx_hal_conf.h +│   │   │   ├── stm32f4xx_hal_msp.c +│   │   │   ├── stm32f4xx_it.c +│   │   │   ├── stm32f4xx_it.h +│   │   │   ├── uart.c +│   │   │   ├── uart.h +│   │   │   ├── upgrade_platform_opt_stm32.c +│   │   │   └── upgrade_platform_opt_stm32.h +│   ├── hal +│   │   ├── hal_uart.c +│   │   └── hal_uart.h +│   ├── project +│   │   ├── mdk_bootloader +│   │   │   ├── DebugConfig +│   │   │   │   └── psdk_bootloader_STM32F407IGHx.dbgconf +│   │   │   └── psdk_demo_bootloader.uvprojx +│   │   └── mdk_release +│   │   ├── DebugConfig +│   │   │   └── Psdk_Demo_Release_Use_Bootloader_STM32F407IGHx.dbgconf +│   │   └── psdk_demo.uvprojx +│   └── README.txt +└── tools + └── file2c + ├── file2c.exe + └── readme.txt + +Unless otherwise agreed, all other portions of DJI’s Payload SDK are and will be made available under the SDK End User License Agreement (EULA). A copy of the SDK EULA is distributed with this software and is available at https://developer.dji.com/policies/eula/. +------------------------------------------------------------- +Copyright (c) 2018-2019 DJI. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +=============================================================== +DJI’s Payload SDK uses libraries of List and MD5, whose license is as below. + +------------------------------------------------------------- +crypto-algorithms +================= +About +--- +These are basic implementations of standard cryptography algorithms, written by Brad Conte (brad@bradconte.com) from +scratch and without any cross-licensing. They exist to provide publically accessible, restriction-free implementations +of popular cryptographic algorithms, like AES and SHA-1. These are primarily intended for educational and pragmatic +purposes (such as comparing a specification to actual implementation code, or for building an internal application +that computes test vectors for a product). The algorithms have been tested against standard test vectors. +This code is released into the public domain free of any restrictions. The author requests acknowledgement if the code +is used, but does not require it. This code is provided free of any liability and without any quality claims by the +author. +Note that these are *not* cryptographically secure implementations. They have no resistence to side-channel attacks +and should not be used in contexts that need cryptographically secure implementations. +These algorithms are not optimized for speed or space. They are primarily designed to be easy to read, although some +basic optimization techniques have been employed. +Building +The source code for each algorithm will come in a pair of a source code file and a header file. There should be no +inter-header file dependencies, no additional libraries, no platform-specific header files, or any other complicating +matters. Compiling them should be as easy as adding the relevent source code to the project. +=============================================================== +DJI’s Payload SDK uses libraries of CMSIS (https://developer.arm.com/tools-and-software/embedded/cmsis), which is licensed under the Apache License, Version 2.0. A copy of the Apache license is provided below and is also available at http://www.apache.org/licenses/LICENSE-2.0. + +------------------------------------------------------------- +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +=============================================================== +DJI’s Payload SDK uses unmodified libraries of cJSON, whose license is as below. + +------------------------------------------------------------- + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +=============================================================== +DJI’s Payload SDK uses unmodified libraries of freeRTOS (http://www.FreeRTOS.org), which is licensed under the MIT License. Full license text is available on the following link: http://www.freertos.org/a00114.html. A copy of the MIT license is provided below and is also available at https://opensource.org/licenses/MIT. + +------------------------------------------------------------- +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +=============================================================== +DJI’s Payload SDK uses unmodified libraries of STM32F4xx_HAL_Driver, BSP STM324xG_EVAL libraries and STM32 Projects libraries in STM32CubeF4 package, which is licensed by ST under BSD 3-Clause license. A copy of the license is provided below and is also available at opensource.org/licenses/BSD-3-Clause. + +------------------------------------------------------------- +Note: This license has also been called the "New BSD License" or "Modified BSD License". See also the 2-clause BSD License. + +Copyright + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..1b9e09c --- /dev/null +++ b/README.txt @@ -0,0 +1,14 @@ +Payload SDK package directory structure introduction: + +doc/psdk_other_docs/psdk_code_style: Template files described code style of Payload SDK. +doc/simple_model: Some structural models of Skyport 1/Skyport 2/X-Port and aircraft. The structure models provide convenience for users to design payload structure. +psdk_lib/api_headers: Header files of Payload SDK, describing all API of Payload SDK. Users can understand features provided by Payload SDK and its usages relying on the header files. +psdk_lib/lib: Library files of Payload SDK. Users select appropriate library file to use based on target platform. +sample/api_sample: Sample code used to demonstrate usage of Payload SDK features. +sample/platform: Sample code related to specific platform, including Linux and FreeRTOS platforms. +sample/platform/linux/common/osal: OSAL layer implementation of Linux operation system. +sample/platform/linux/manifold2: Sample project used on Manifold 2. +sample/platform/rtos_freertos/common/osal: OSAL layer implementation of FreeRTOS operation system. +sample/platform/rtos_freertos/psdk_development_board_1.0: Sample project used on Payload SDK development board 1.0. +sample/platform/rtos_freertos/stm32f4_eval: Sample project used on STM32F4XX-EVAL development board. +tools: Some tools used with Payload SDK. diff --git a/doc/psdk_other_docs/psdk_code_style/psdk_template.c b/doc/psdk_other_docs/psdk_code_style/psdk_template.c new file mode 100644 index 0000000..4b89118 --- /dev/null +++ b/doc/psdk_other_docs/psdk_code_style/psdk_template.c @@ -0,0 +1,90 @@ +/** + ****************************************************************************** + * @file psdk_template.c + * @version V0.0.0 + * @date 2017/8/10 + * @brief This file to indicate PSDK coding style and comment style. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_template.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ + +//Max PSDK data packet size +#define MAX_PACKAGE_LEN 256 + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +//A buffer used to store data to be sent +static uint8_t s_SendBuffer[PSDK_TEMPLATE_MAX_BUFFER_SIZE]; + +/* Exported variables --------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief PSDK low level send function. + * @param buffer Pointer to send data buffer. + * @param len Size of data to be sent. + * @return Size of data to be sent. + */ +static int PsdkTemplate_PrivateSend(const uint8_t *buffer, uint16_t len) +{ + /* NOTE : This function should be implemented in the user file. */ + return len; +} + +/* Exported functions --------------------------------------------------------*/ + +/** + * @brief PSDK protocol initialization. + * @param None. + * @return None. + */ +void PsdkTemplate_Init(void) +{ + /* NOTE : This function should be implemented in the user file. */ +} + +/** + * @brief Send data function. + * @param buffer : the buffer point send data + * @param len : send data length + * @return if >= 0, indicate the real send data length; if < 0, indicate the -ErrorCode for send failure reason. + */ +int PsdkTemplate_Send(const uint8_t *buffer, uint16_t len) +{ + uint16_t realLen; + + if (len > MAX_PACKAGE_LEN) { + realLen = MAX_PACKAGE_LEN; + } else { + realLen = len; + } + + PsdkTemplate_PrivateSend(buffer, len); + return realLen; +} + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/doc/psdk_other_docs/psdk_code_style/psdk_template.h b/doc/psdk_other_docs/psdk_code_style/psdk_template.h new file mode 100644 index 0000000..b6caaf5 --- /dev/null +++ b/doc/psdk_other_docs/psdk_code_style/psdk_template.h @@ -0,0 +1,129 @@ +/** + ******************************************************************** + * @file psdk_template.h + * @version V0.0.0 + * @date 2017/8/10 + * @brief This file to indicate PSDK coding style and comment style. + * @attention Code file rules: + * rule: file encoding use UTF8; + * rule: max line length 120 characters; + * rule: line separator \r\n; + * rule: use clion auto code format tool. + * + * If not want to format some code, use @formatter:off & @formatter:on to disable code format, for example: + * //@formatter:off + * extern int g_testCodeFormatOFF; + * //@formatter:on + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PSDK_TEMPLATE_H +#define PSDK_TEMPLATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include + +/* Exported constants --------------------------------------------------------*/ +#define PSDK_TEMPLATE_MAX_BUFFER_SIZE 256 + +/** + * @defgroup psdk_some_flag + * @{ + */ +#define PSDK_TEMPLATE_SUCCESS 0 +#define PSDK_TEMPLATE_FAILURE -1 + +#define PSDK_SOME_FLAG_AAA 1 /*!< Define line comment. */ +#define PSDK_SOME_FLAG_BBB 2 /*!< Define line comment, + if comment is too long, split line. */ +#define PSDK_SOME_FLAG_CCC 3 + +/* Exported macros -----------------------------------------------------------*/ + +#define IS_PSDK_SOME_FLAG(FLAG) (((FLAG) == PSDK_SOME_FLAG_AAA) || \ + ((FLAG) == PSDK_SOME_FLAG_BBB) || \ + ((FLAG) == PSDK_SOME_FLAG_CCC)) + +/** + * @} + */ + +#define PSDK_TEMPLATE_MIN(a, b) (((a)<(b))?(a):(b)) + +/* Exported types ------------------------------------------------------------*/ + +/** + * @brief Enum brief comment. + */ +typedef enum { + TEMPLATE_COLOR_RED = 0, + TEMPLATE_COLOR_GREED = 1, + TEMPLATE_COLOR_BLUE = 2, +} E_TemplateColor; + +/** + * @brief Struct brief comment. + */ +typedef struct { + uint8_t structMember1; /*!< structure member comment. */ + uint8_t longStructMember2; /*!< structure member comment. */ + + uint8_t someFlag; /*!< if this value use marco define ,must use defgroup to indicate, and comment here + use ref. for example: + someFlag of PSDK template. This parameter can be a value of @ref psdk_some_flag */ +} T_StructDefine; + +typedef void (*PsdkTemplateFunc)(void); + +typedef int Inttype; + +/* Use pack(1) to transfer structure. */ +#pragma pack(1) + +typedef struct { + uint8_t structMember1; + uint32_t structMember2; +} T_StructProtocolCommunication; + +#pragma pack() + +/* Exported variables --------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +void PsdkTemplate_Init(void); +int PsdkTemplate_Send(const uint8_t *buffer, uint16_t len); + +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif //PSDK_TEMPLATE_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/camera_emu/test_payload_cam_emu.c b/sample/api_sample/camera_emu/test_payload_cam_emu.c new file mode 100644 index 0000000..52500e3 --- /dev/null +++ b/sample/api_sample/camera_emu/test_payload_cam_emu.c @@ -0,0 +1,1458 @@ +/** + ******************************************************************** + * @file test_payload_cam_emu.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "math.h" +#include "test_payload_cam_emu.h" +#include +#include +#include +#include "psdk_payload_camera.h" +#include "psdk_platform.h" +#include "utils/util_misc.h" +#include "psdk_aircraft_info.h" +#include "psdk_xport.h" +#include "gimbal_emu/test_payload_gimbal_emu.h" +#include "camera_media_emu/test_payload_cam_media.h" + +/* Private constants ---------------------------------------------------------*/ +#define PAYLOAD_CAMERA_EMU_TASK_FREQ (100) +#define PAYLOAD_CAMERA_EMU_TASK_STACK_SIZE (2048) +#define SDCARD_TOTAL_SPACE_IN_MB (32 * 1024) +#define SDCARD_PER_PHOTO_SPACE_IN_MB (4) +#define SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB (2) +#define ZOOM_OPTICAL_FOCAL_MAX_LENGTH (300) +#define ZOOM_OPTICAL_FOCAL_MIN_LENGTH (10) +#define ZOOM_OPTICAL_FOCAL_LENGTH_STEP (10) +#define ZOOM_OPTICAL_FOCAL_LENGTH_CTRL_STEP (5) +#define ZOOM_DIGITAL_BASE_FACTOR (1.0) +#define ZOOM_DIGITAL_STEP_FACTOR (0.1) +#define ZOOM_DIGITAL_MAX_FACTOR (6.0) +#define FOCUS_MAX_RINGVALUE (1000) +#define FOCUS_MID_RINGVALUE (500) +#define IMAGE_SENSOR_X_SIZE (88.0f) // unit: 0.1mm +#define IMAGE_SENSOR_Y_SIZE (66.0f) // unit: 0.1mm +#define CENTER_POINT_IN_SCREEN_X_VALUE (0.5f) +#define CENTER_POINT_IN_SCREEN_Y_VALUE (0.5f) +#define TAP_ZOOM_DURATION (2000) // unit: ms +#define INTERVAL_PHOTOGRAPH_ALWAYS_COUNT (255) +#define INTERVAL_PHOTOGRAPH_INTERVAL_INIT_VALUE (1) // unit: s +#define TAKING_PHOTO_SPENT_TIME_MS_EMU (500) +#define PHOTO_FILE_PATH "../../../../../api_sample/camera_media_emu/media_file/PSDK_0001_ORG.jpg" + +/* Private types -------------------------------------------------------------*/ +typedef struct { + E_PsdkGimbalRotationMode rotationMode; + T_PsdkGimbalRotationProperty rotationProperty; + T_PsdkAttitude3d rotationValue; +} T_TestCameraGimbalRotationArgument; + +/* Private variables ---------------------------------------------------------*/ +static bool s_isCamInited = false; + +static T_PsdkCameraCommonHandler s_commonHandler;//注册相机类基础功能 +static T_PsdkCameraExposureMeteringHandler s_exposureMeteringHandler;//用于测光 +static T_PsdkCameraFocusHandler s_focusHandler;//设置对焦 +static T_PsdkCameraDigitalZoomHandler s_digitalZoomHandler;//数字变焦 +static T_PsdkCameraOpticalZoomHandler s_opticalZoomHandler;//光学变焦 +static T_PsdkCameraTapZoomHandler s_tapZoomHandler;//指点变焦功能 + +static T_PsdkTaskHandle s_userCameraThread; + +static T_PsdkCameraSystemState s_cameraState = {0}; +static E_PsdkCameraShootPhotoMode s_cameraShootPhotoMode = PSDK_CAMERA_SHOOT_PHOTO_MODE_SINGLE; +static E_PsdkCameraBurstCount s_cameraBurstCount = PSDK_CAMERA_BURST_COUNT_2; +static T_PsdkCameraPhotoTimeIntervalSettings s_cameraPhotoTimeIntervalSettings = {INTERVAL_PHOTOGRAPH_ALWAYS_COUNT, + INTERVAL_PHOTOGRAPH_INTERVAL_INIT_VALUE}; +static T_PsdkCameraSDCardState s_cameraSDCardState = {0}; +static T_PsdkMutexHandle s_commonMutex = {0}; + +static E_PsdkCameraMeteringMode s_cameraMeteringMode = PSDK_CAMERA_METERING_MODE_CENTER; +static T_PsdkCameraSpotMeteringTarget s_cameraSpotMeteringTarget = {0}; + +static E_PsdkCameraFocusMode s_cameraFocusMode = PSDK_CAMERA_FOCUS_MODE_AUTO; +static T_PsdkCameraPointInScreen s_cameraFocusTarget = {0};//对焦点 +static uint32_t s_cameraFocusRingValue = FOCUS_MID_RINGVALUE;//对焦环 +static T_PsdkCameraFocusAssistantSettings s_cameraFocusAssistantSettings = {0}; + +static E_PsdkCameraZoomDirection s_cameraZoomDirection = PSDK_CAMERA_ZOOM_DIRECTION_OUT; +static E_PsdkCameraZoomSpeed s_cameraZoomSpeed = PSDK_CAMERA_ZOOM_SPEED_NORMAL; +static uint32_t s_cameraOpticalZoomFocalLength = ZOOM_OPTICAL_FOCAL_MIN_LENGTH; +static psdk_f32_t s_cameraDigitalZoomFactor = ZOOM_DIGITAL_BASE_FACTOR; +static bool s_isStartContinuousOpticalZoom = false; +static bool s_isOpticalZoomReachLimit = false; +static T_PsdkMutexHandle s_zoomMutex = {0}; + +static bool s_isTapZoomEnabled = false; +static T_PsdkCameraTapZoomState s_cameraTapZoomState = {0}; +static uint8_t s_tapZoomMultiplier = 1; +static uint32_t s_tapZoomStartTime = 0; +static bool s_isStartTapZoom = false; +static bool s_isTapZooming = false; +static T_TestCameraGimbalRotationArgument s_tapZoomNewestGimbalRotationArgument = {0}; +static uint32_t s_tapZoomNewestTargetHybridFocalLength = 0; // unit: 0.1mm +static T_PsdkMutexHandle s_tapZoomMutex = NULL; +static E_PsdkCameraVideoStreamType s_cameraVideoStreamType; + +/* Private functions declaration ---------------------------------------------*/ +//用于s_commonHandler中的回调函数:相机类基础功能 +static T_PsdkReturnCode GetSystemState(T_PsdkCameraSystemState *systemState); +static T_PsdkReturnCode SetMode(E_PsdkCameraMode mode); +static T_PsdkReturnCode StartRecordVideo(void); +static T_PsdkReturnCode StopRecordVideo(void); +static T_PsdkReturnCode StartShootPhoto(void); +static T_PsdkReturnCode StopShootPhoto(void); +static T_PsdkReturnCode SetShootPhotoMode(E_PsdkCameraShootPhotoMode mode); +static T_PsdkReturnCode GetShootPhotoMode(E_PsdkCameraShootPhotoMode *mode); +static T_PsdkReturnCode SetPhotoBurstCount(E_PsdkCameraBurstCount burstCount); +static T_PsdkReturnCode GetPhotoBurstCount(E_PsdkCameraBurstCount *burstCount); +static T_PsdkReturnCode SetPhotoTimeIntervalSettings(T_PsdkCameraPhotoTimeIntervalSettings settings); +static T_PsdkReturnCode GetPhotoTimeIntervalSettings(T_PsdkCameraPhotoTimeIntervalSettings *settings); +static T_PsdkReturnCode GetSDCardState(T_PsdkCameraSDCardState *sdCardState); +static T_PsdkReturnCode FormatSDCard(void); + +////用于s_exposureMeteringHandler中的回调函数:测光 +static T_PsdkReturnCode SetMeteringMode(E_PsdkCameraMeteringMode mode); +static T_PsdkReturnCode GetMeteringMode(E_PsdkCameraMeteringMode *mode); +static T_PsdkReturnCode SetSpotMeteringTarget(T_PsdkCameraSpotMeteringTarget target); +static T_PsdkReturnCode GetSpotMeteringTarget(T_PsdkCameraSpotMeteringTarget *target); + +//用于s_focusHandler中的回调函数:设置对焦功能 +static T_PsdkReturnCode SetFocusMode(E_PsdkCameraFocusMode mode); +static T_PsdkReturnCode GetFocusMode(E_PsdkCameraFocusMode *mode); +static T_PsdkReturnCode SetFocusTarget(T_PsdkCameraPointInScreen target); +static T_PsdkReturnCode GetFocusTarget(T_PsdkCameraPointInScreen *target); +static T_PsdkReturnCode SetFocusAssistantSettings(T_PsdkCameraFocusAssistantSettings settings); +static T_PsdkReturnCode GetFocusAssistantSettings(T_PsdkCameraFocusAssistantSettings *settings); +static T_PsdkReturnCode SetFocusRingValue(uint32_t value); +static T_PsdkReturnCode GetFocusRingValue(uint32_t *value); +static T_PsdkReturnCode GetFocusRingValueUpperBound(uint32_t *value); + +//用于s_digitalZoomHandler的回调函数中:数字变焦功能 +static T_PsdkReturnCode SetDigitalZoomFactor(psdk_f32_t factor); + +//用于s_opticalZoomHandler的回调函数中:光学变焦功能 +static T_PsdkReturnCode SetOpticalZoomFocalLength(uint32_t focalLength); +static T_PsdkReturnCode GetOpticalZoomFocalLength(uint32_t *focalLength); +static T_PsdkReturnCode GetOpticalZoomSpec(T_PsdkCameraOpticalZoomSpec *spec); +static T_PsdkReturnCode StartContinuousOpticalZoom(E_PsdkCameraZoomDirection direction, E_PsdkCameraZoomSpeed speed); +static T_PsdkReturnCode StopContinuousOpticalZoom(void); + +//用于s_tapZoomHandler中的回调函数:指点变焦功能 +static T_PsdkReturnCode GetTapZoomState(T_PsdkCameraTapZoomState *state); +static T_PsdkReturnCode SetTapZoomEnabled(bool enabledFlag); +static T_PsdkReturnCode GetTapZoomEnabled(bool *enabledFlag); +static T_PsdkReturnCode SetTapZoomMultiplier(uint8_t multiplier); +static T_PsdkReturnCode GetTapZoomMultiplier(uint8_t *multiplier); +static T_PsdkReturnCode TapZoomAtTarget(T_PsdkCameraPointInScreen target); + +// +static T_PsdkReturnCode PsdkTest_CameraHybridZoom(uint32_t focalLength); +static T_PsdkReturnCode PsdkTest_CameraRotationGimbal(T_TestCameraGimbalRotationArgument gimbalRotationArgument); + +static void *UserCamera_Task(void *arg); + +/* Exported functions definition ---------------------------------------------*/ + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode GetSystemState(T_PsdkCameraSystemState *systemState) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + *systemState = s_cameraState; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetMode(E_PsdkCameraMode mode) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_cameraState.cameraMode = mode; + PsdkLogger_UserLogInfo("set camera mode:%d", mode); + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StartRecordVideo(void) +{ + T_PsdkReturnCode psdkStat; + T_PsdkReturnCode returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + if (s_cameraState.isRecording != false) { + PsdkLogger_UserLogError("camera is already in recording state"); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE; + goto out; + } + + s_cameraState.isRecording = true; + PsdkLogger_UserLogInfo("start record video"); + +out: + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return returnCode; +} + +static T_PsdkReturnCode StopRecordVideo(void) +{ + T_PsdkReturnCode psdkStat; + T_PsdkReturnCode returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + if (s_cameraState.isRecording != true) { + PsdkLogger_UserLogError("camera is not in recording state"); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE; + goto out; + } + + s_cameraState.isRecording = false; + s_cameraState.currentVideoRecordingTimeInSeconds = 0; + PsdkLogger_UserLogInfo("stop record video"); + +out: + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return returnCode; +} + +static T_PsdkReturnCode StartShootPhoto(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("start shoot photo"); +// PsdkLogger_UserLogInfo("使用电源模块--------------------------------------------------------------------------------------------------------------------------"); + printf("tangchantdddddddd/n"); + s_cameraState.isStoring = true; + + if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_SINGLE) { + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_SINGLE_PHOTO; + } else if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_BURST) { + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_BURST_PHOTO; + } else if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_INTERVAL) { + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_INTERVAL_PHOTO; + s_cameraState.isShootingIntervalStart = true; + s_cameraState.currentPhotoShootingIntervalTimeInSeconds = s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds; + } + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StopShootPhoto(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("stop shoot photo"); + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_PHOTO_IDLE; + s_cameraState.isStoring = false; + s_cameraState.isShootingIntervalStart = false; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetShootPhotoMode(E_PsdkCameraShootPhotoMode mode) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_cameraShootPhotoMode = mode; + PsdkLogger_UserLogInfo("set shoot photo mode:%d", mode); + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetShootPhotoMode(E_PsdkCameraShootPhotoMode *mode) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + *mode = s_cameraShootPhotoMode; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat);\ + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetPhotoBurstCount(E_PsdkCameraBurstCount burstCount) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_cameraBurstCount = burstCount; + PsdkLogger_UserLogInfo("set photo burst count:%d", burstCount); + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetPhotoBurstCount(E_PsdkCameraBurstCount *burstCount) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + *burstCount = s_cameraBurstCount; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetPhotoTimeIntervalSettings(T_PsdkCameraPhotoTimeIntervalSettings settings) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_cameraPhotoTimeIntervalSettings.captureCount = settings.captureCount; + s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds = settings.timeIntervalSeconds; + PsdkLogger_UserLogInfo("set photo interval settings count:%d seconds:%d", settings.captureCount, + settings.timeIntervalSeconds); + s_cameraState.currentPhotoShootingIntervalCount = settings.captureCount; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetPhotoTimeIntervalSettings(T_PsdkCameraPhotoTimeIntervalSettings *settings) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + memcpy(settings, &s_cameraPhotoTimeIntervalSettings, sizeof(T_PsdkCameraPhotoTimeIntervalSettings)); + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetSDCardState(T_PsdkCameraSDCardState *sdCardState) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + memcpy(sdCardState, &s_cameraSDCardState, sizeof(T_PsdkCameraSDCardState)); + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode FormatSDCard(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("format sdcard"); + + memset(&s_cameraSDCardState, 0, sizeof(T_PsdkCameraSDCardState)); + s_cameraSDCardState.isInserted = true; + s_cameraSDCardState.totalSpaceInMB = SDCARD_TOTAL_SPACE_IN_MB; + s_cameraSDCardState.remainSpaceInMB = SDCARD_TOTAL_SPACE_IN_MB; + s_cameraSDCardState.availableCaptureCount = SDCARD_TOTAL_SPACE_IN_MB / SDCARD_PER_PHOTO_SPACE_IN_MB; + s_cameraSDCardState.availableRecordingTimeInSeconds = + SDCARD_TOTAL_SPACE_IN_MB / SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetMeteringMode(E_PsdkCameraMeteringMode mode) +{ + PsdkLogger_UserLogInfo("set metering mode:%d", mode); + s_cameraMeteringMode = mode; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetMeteringMode(E_PsdkCameraMeteringMode *mode) +{ + *mode = s_cameraMeteringMode; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetSpotMeteringTarget(T_PsdkCameraSpotMeteringTarget target) +{ + PsdkLogger_UserLogInfo("set spot metering area col:%d row:%d", target.col, target.row); + memcpy(&s_cameraSpotMeteringTarget, &target, sizeof(T_PsdkCameraSpotMeteringTarget)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetSpotMeteringTarget(T_PsdkCameraSpotMeteringTarget *target) +{ + memcpy(target, &s_cameraSpotMeteringTarget, sizeof(T_PsdkCameraSpotMeteringTarget)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetFocusMode(E_PsdkCameraFocusMode mode) +{ + PsdkLogger_UserLogInfo("set focus mode:%d", mode); + s_cameraFocusMode = mode; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetFocusMode(E_PsdkCameraFocusMode *mode) +{ + *mode = s_cameraFocusMode; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetFocusTarget(T_PsdkCameraPointInScreen target) +{ + PsdkLogger_UserLogInfo("set focus target x:%.2f y:%.2f", target.focusX, target.focusY); + memcpy(&s_cameraFocusTarget, &target, sizeof(T_PsdkCameraPointInScreen)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetFocusTarget(T_PsdkCameraPointInScreen *target) +{ + memcpy(target, &s_cameraFocusTarget, sizeof(T_PsdkCameraPointInScreen)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetFocusAssistantSettings(T_PsdkCameraFocusAssistantSettings settings) +{ + PsdkLogger_UserLogInfo("set focus assistant setting MF:%d AF:%d", settings.isEnabledMF, settings.isEnabledAF); + memcpy(&s_cameraFocusAssistantSettings, &settings, sizeof(T_PsdkCameraFocusAssistantSettings)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetFocusAssistantSettings(T_PsdkCameraFocusAssistantSettings *settings) +{ + memcpy(settings, &s_cameraFocusAssistantSettings, sizeof(T_PsdkCameraFocusAssistantSettings)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetFocusRingValue(uint32_t value) +{ + PsdkLogger_UserLogInfo("set focus ring value:%d", value); + s_cameraFocusRingValue = value; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetFocusRingValue(uint32_t *value) +{ + *value = s_cameraFocusRingValue; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetFocusRingValueUpperBound(uint32_t *value) +{ + *value = FOCUS_MAX_RINGVALUE; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetDigitalZoomFactor(psdk_f32_t factor) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("set digital zoom factor:%.2f", factor); + s_cameraDigitalZoomFactor = factor; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetOpticalZoomFocalLength(uint32_t focalLength) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("set optical zoom focal length:%d", focalLength); + s_isOpticalZoomReachLimit = false; + s_cameraDigitalZoomFactor = ZOOM_DIGITAL_BASE_FACTOR; + s_cameraOpticalZoomFocalLength = ZOOM_OPTICAL_FOCAL_MIN_LENGTH; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetOpticalZoomFocalLength(uint32_t *focalLength) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + *focalLength = s_cameraOpticalZoomFocalLength; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetOpticalZoomSpec(T_PsdkCameraOpticalZoomSpec *spec) +{ + spec->maxFocalLength = ZOOM_OPTICAL_FOCAL_MAX_LENGTH; + spec->minFocalLength = ZOOM_OPTICAL_FOCAL_MIN_LENGTH; + spec->focalLengthStep = ZOOM_OPTICAL_FOCAL_LENGTH_STEP; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StartContinuousOpticalZoom(E_PsdkCameraZoomDirection direction, E_PsdkCameraZoomSpeed speed) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("start continuous optical zoom direction:%d speed:%d", direction, speed); + s_isStartContinuousOpticalZoom = true; + s_cameraZoomDirection = direction; + s_cameraZoomSpeed = speed; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StopContinuousOpticalZoom(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + PsdkLogger_UserLogInfo("stop continuous optical zoom"); + s_isStartContinuousOpticalZoom = false; + s_cameraZoomDirection = PSDK_CAMERA_ZOOM_DIRECTION_OUT; + s_cameraZoomSpeed = PSDK_CAMERA_ZOOM_SPEED_NORMAL; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetTapZoomState(T_PsdkCameraTapZoomState *state) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_tapZoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + memcpy(state, &s_cameraTapZoomState, sizeof(T_PsdkCameraTapZoomState)); + + psdkStat = PsdkOsal_MutexUnlock(s_tapZoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetTapZoomEnabled(bool enabledFlag) +{ + PsdkLogger_UserLogInfo("set tap zoom enabled flag: %d.", enabledFlag); + s_isTapZoomEnabled = enabledFlag; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetTapZoomEnabled(bool *enabledFlag) +{ + *enabledFlag = s_isTapZoomEnabled; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetTapZoomMultiplier(uint8_t multiplier) +{ + PsdkLogger_UserLogInfo("set tap zoom multiplier: %d.", multiplier); + s_tapZoomMultiplier = multiplier; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetTapZoomMultiplier(uint8_t *multiplier) +{ + *multiplier = s_tapZoomMultiplier; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode TapZoomAtTarget(T_PsdkCameraPointInScreen target) +{ + T_PsdkReturnCode psdkStat; + E_PsdkGimbalRotationMode rotationMode; + T_PsdkGimbalRotationProperty rotationProperty = {0}; + T_PsdkAttitude3d rotationValue = {0}; + float hybridFocalLength = 0; // unit: 0.1mm + + PsdkLogger_UserLogInfo("tap zoom at target: x %f, y %f.", target.focusX, target.focusY); + + if (s_isTapZoomEnabled != true) { + PsdkLogger_UserLogWarn("tap zoom is not enabled."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + if (s_isTapZooming || s_isStartTapZoom) { + PsdkLogger_UserLogWarn("The last tap zoom process is not over."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE; + } + + //设置云台相机指点变焦的模式 + rotationMode = PSDK_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE; + rotationProperty.relativeAngleRotation.actionTime = TAP_ZOOM_DURATION / 10; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + /* Calculation formula: rotation angle = arctan((coordinate of target in sensor - coordinate of center point in + * sensor) / hybrid focal length). Here, suppose that images of all pixels of sensor are displayed in screen, + * and that center of the image sensor coincides with center of rotation of the gimbal, and that optical axis of + * camera coincides with x-axis of gimbal. */ + hybridFocalLength = s_cameraOpticalZoomFocalLength * s_cameraDigitalZoomFactor; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + rotationValue.pitch = (int32_t) ( + atan2f((target.focusY - CENTER_POINT_IN_SCREEN_Y_VALUE) * IMAGE_SENSOR_Y_SIZE, hybridFocalLength) * 1800 / + PI); + rotationValue.yaw = (int32_t) ( + atan2f((target.focusX - CENTER_POINT_IN_SCREEN_X_VALUE) * IMAGE_SENSOR_X_SIZE, hybridFocalLength) * 1800 / + PI); + + psdkStat = PsdkOsal_MutexLock(s_tapZoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_tapZoomNewestGimbalRotationArgument.rotationMode = rotationMode; + s_tapZoomNewestGimbalRotationArgument.rotationProperty = rotationProperty; + s_tapZoomNewestGimbalRotationArgument.rotationValue = rotationValue; + s_tapZoomNewestTargetHybridFocalLength = (uint32_t) (hybridFocalLength * (float) s_tapZoomMultiplier); + + psdkStat = PsdkOsal_MutexUnlock(s_tapZoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_isStartTapZoom = true; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTest_CameraHybridZoom(uint32_t focalLength) +{ + if (focalLength >= ZOOM_OPTICAL_FOCAL_MIN_LENGTH && focalLength <= ZOOM_OPTICAL_FOCAL_MAX_LENGTH) { + s_cameraOpticalZoomFocalLength = focalLength; + s_cameraDigitalZoomFactor = ZOOM_DIGITAL_BASE_FACTOR; + } else if (focalLength < ZOOM_OPTICAL_FOCAL_MIN_LENGTH) { + s_cameraOpticalZoomFocalLength = ZOOM_OPTICAL_FOCAL_MIN_LENGTH; + s_cameraDigitalZoomFactor = ZOOM_DIGITAL_BASE_FACTOR; + + PsdkLogger_UserLogError("focal length %d is smaller than min optical focal length %d.", focalLength, + ZOOM_OPTICAL_FOCAL_MIN_LENGTH); + return PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + } else { + s_cameraOpticalZoomFocalLength = ZOOM_OPTICAL_FOCAL_MAX_LENGTH; + s_cameraDigitalZoomFactor = (float) focalLength / ZOOM_OPTICAL_FOCAL_MAX_LENGTH; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTest_CameraRotationGimbal(T_TestCameraGimbalRotationArgument gimbalRotationArgument) +{ + T_PsdkReturnCode psdkStat; + T_PsdkAircraftInfoBaseInfo aircraftBaseInfo = {0}; + + psdkStat = PsdkAircraftInfo_GetBaseInfo(&aircraftBaseInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get aircraft information error: 0x%08llX.", psdkStat); + return psdkStat; + } + + if (aircraftBaseInfo.psdkAdapterType == PSDK_AIRCRAFT_INFO_PSDK_ADAPTER_TYPE_SKYPORT_V2) { + psdkStat = PsdkTest_GimbalRotate(gimbalRotationArgument.rotationMode, gimbalRotationArgument.rotationProperty, + gimbalRotationArgument.rotationValue); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("rotate gimbal error: 0x%08llX.", psdkStat); + return psdkStat; + } + } else if (aircraftBaseInfo.psdkAdapterType == PSDK_AIRCRAFT_INFO_PSDK_ADAPTER_TYPE_XPORT) { + psdkStat = PsdkXPort_RotateSync(gimbalRotationArgument.rotationMode, gimbalRotationArgument.rotationProperty, + gimbalRotationArgument.rotationValue); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("rotate XPort error: 0x%08llX.", psdkStat); + return psdkStat; + } + } else { + PsdkLogger_UserLogError("PSDK adapter type is invalid: %d.", aircraftBaseInfo.psdkAdapterType); + return PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *UserCamera_Task(void *arg) +{ + static uint32_t photoCnt = 0;//???????? + static uint32_t step = 0;//控制任务的执行时间间隔 + T_PsdkReturnCode psdkStat; + int32_t tempFocalLength = 0; + psdk_f64_t tempDigitalFactor = 0.0f; + uint32_t currentTime = 0; + bool isStartIntervalPhotoAction = false; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / PAYLOAD_CAMERA_EMU_TASK_FREQ);//睡眠10ms + step++; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + continue; + } + + s_cameraSDCardState.availableRecordingTimeInSeconds = + s_cameraSDCardState.remainSpaceInMB / SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB; + s_cameraSDCardState.availableCaptureCount = s_cameraSDCardState.remainSpaceInMB / SDCARD_PER_PHOTO_SPACE_IN_MB; + + //realize your photo shoot and storage logic here + //1. 确认拍照状态:使用PSDK 开发的相机类负载设备在执行完拍照动作后,需要获取负载设备的拍照状态。 + if (s_cameraState.shootingState != PSDK_CAMERA_SHOOTING_PHOTO_IDLE && + photoCnt++ > TAKING_PHOTO_SPENT_TIME_MS_EMU / (1000 / PAYLOAD_CAMERA_EMU_TASK_FREQ)) {//?????????????????????????????????????????????? + photoCnt = 0; + + //store the photo after shooting finished + //2. 存储照片:相机类负载设备在执行完拍照后,使用PSDK 开发的相机类负载设备将相机拍摄的照片存储在相机类负载设备上的内存卡中。 + if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_SINGLE) { + s_cameraSDCardState.remainSpaceInMB = + s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_PHOTO_SPACE_IN_MB; + s_cameraState.isStoring = false; + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_PHOTO_IDLE; + } else if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_BURST) { + s_cameraSDCardState.remainSpaceInMB = + s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_PHOTO_SPACE_IN_MB * s_cameraBurstCount; + s_cameraState.isStoring = false; + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_PHOTO_IDLE; + } else if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_INTERVAL) { + if (isStartIntervalPhotoAction == true) { + s_cameraState.isStoring = false; + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_PHOTO_IDLE; + s_cameraSDCardState.remainSpaceInMB = + s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_PHOTO_SPACE_IN_MB; + } + } + + //check the remain space of sdcard + //3. 检查存储空间: + if (s_cameraSDCardState.remainSpaceInMB > SDCARD_TOTAL_SPACE_IN_MB) { + s_cameraSDCardState.remainSpaceInMB = 0; + s_cameraSDCardState.isFull = true; + } + +#if PSDK_ARCH_SYS_LINUX + T_PsdkCameraMediaFileInfo mediaFileInfo = {0}; + + // push added media file information + if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_SINGLE) { + if (UtilFile_IsFileExist(PHOTO_FILE_PATH) == true) { + psdkStat = PsdkTest_CameraMediaGetFileInfo(PHOTO_FILE_PATH, &mediaFileInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get media file info error 0x%08llX", psdkStat); + } + + psdkStat = PsdkPayloadCamera_PushAddedMediaFileInfo(PHOTO_FILE_PATH, mediaFileInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Push added media file info error 0x%08llX", psdkStat); + } + } else { + PsdkLogger_UserLogWarn("Can't found the media file by path. " + "Probably because media file has not existed. " + "Please check media file if exists. "); + } + } +#endif + } + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + continue; + } + + // ! step%10:相当于10毫秒执行一次,tc → Add logic here for zoom camera + //没看关于这个if + if (USER_UTIL_IS_WORK_TURN(step, 10, PAYLOAD_CAMERA_EMU_TASK_FREQ)) { + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + continue; + } + + //Add logic here for zoom camera + // + if (s_isStartContinuousOpticalZoom == true) { + tempDigitalFactor = s_cameraDigitalZoomFactor; + tempFocalLength = s_cameraOpticalZoomFocalLength; + if (s_isOpticalZoomReachLimit == false) { + if (s_cameraZoomDirection == PSDK_CAMERA_ZOOM_DIRECTION_IN) { + tempFocalLength += ((int) s_cameraZoomSpeed - PSDK_CAMERA_ZOOM_SPEED_SLOWEST + 1) * + ZOOM_OPTICAL_FOCAL_LENGTH_CTRL_STEP; + } else if (s_cameraZoomDirection == PSDK_CAMERA_ZOOM_DIRECTION_OUT) { + tempFocalLength -= ((int) s_cameraZoomSpeed - PSDK_CAMERA_ZOOM_SPEED_SLOWEST + 1) * + ZOOM_OPTICAL_FOCAL_LENGTH_CTRL_STEP; + } + + if (tempFocalLength > ZOOM_OPTICAL_FOCAL_MAX_LENGTH) { + s_isOpticalZoomReachLimit = true; + tempFocalLength = ZOOM_OPTICAL_FOCAL_MAX_LENGTH; + } + + if (tempFocalLength < ZOOM_OPTICAL_FOCAL_MIN_LENGTH) { + tempFocalLength = ZOOM_OPTICAL_FOCAL_MIN_LENGTH; + } + } else { + if (s_cameraZoomDirection == PSDK_CAMERA_ZOOM_DIRECTION_IN) { + tempDigitalFactor += ZOOM_DIGITAL_STEP_FACTOR; + } else if (s_cameraZoomDirection == PSDK_CAMERA_ZOOM_DIRECTION_OUT) { + tempDigitalFactor -= ZOOM_DIGITAL_STEP_FACTOR; + } + + if (tempDigitalFactor > ZOOM_DIGITAL_MAX_FACTOR) { + tempDigitalFactor = ZOOM_DIGITAL_MAX_FACTOR; + } + + if (tempDigitalFactor < ZOOM_DIGITAL_BASE_FACTOR) { + s_isOpticalZoomReachLimit = false; + tempDigitalFactor = ZOOM_DIGITAL_BASE_FACTOR; + } + } + + s_cameraOpticalZoomFocalLength = (uint16_t) tempFocalLength; + s_cameraDigitalZoomFactor = tempDigitalFactor; + } + + psdkStat = PsdkOsal_MutexLock(s_tapZoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + goto out; + } + + if (s_isStartTapZoom) { + s_isStartTapZoom = false; + s_isTapZooming = true; + + psdkStat = PsdkOsal_GetTimeMs(&s_tapZoomStartTime); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get start time error: 0x%08llX.", psdkStat); + } + + psdkStat = PsdkTest_CameraRotationGimbal(s_tapZoomNewestGimbalRotationArgument); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) + PsdkLogger_UserLogError("rotate gimbal error: 0x%08llX.", psdkStat); + else + s_cameraTapZoomState.isGimbalMoving = true; + + psdkStat = PsdkTest_CameraHybridZoom(s_tapZoomNewestTargetHybridFocalLength); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + s_cameraTapZoomState.zoomState = s_tapZoomNewestTargetHybridFocalLength > + (s_cameraOpticalZoomFocalLength * s_cameraDigitalZoomFactor) + ? PSDK_CAMERA_TAP_ZOOM_STATE_ZOOM_IN + : PSDK_CAMERA_TAP_ZOOM_STATE_ZOOM_OUT; + } else if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE) { + PsdkLogger_UserLogError("hybrid zoom focal length beyond limit."); + s_cameraTapZoomState.zoomState = PSDK_CAMERA_TAP_ZOOM_STATE_ZOOM_LIMITED; + } else { + PsdkLogger_UserLogError("hybrid zoom error: 0x%08llX.", psdkStat); + } + } else if (s_isTapZooming) { + psdkStat = PsdkOsal_GetTimeMs(¤tTime); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get start time error: 0x%08llX.", psdkStat); + } + + if ((currentTime - s_tapZoomStartTime) >= TAP_ZOOM_DURATION) { + s_cameraTapZoomState.zoomState = PSDK_CAMERA_TAP_ZOOM_STATE_IDLE; + s_cameraTapZoomState.isGimbalMoving = false; + s_isTapZooming = false; + } + } + + psdkStat = PsdkOsal_MutexUnlock(s_tapZoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + goto out; + } + +out: + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + continue; + } + } + + // ! step%100:相当于100毫秒执行一次, + if (USER_UTIL_IS_WORK_TURN(step, 1, PAYLOAD_CAMERA_EMU_TASK_FREQ)) { + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + continue; + } + + // 预估可拍照张数和可录像时长的功能。 + if (s_cameraState.isRecording) { + s_cameraState.currentVideoRecordingTimeInSeconds++; + s_cameraSDCardState.remainSpaceInMB = + s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB; + if (s_cameraSDCardState.remainSpaceInMB > SDCARD_TOTAL_SPACE_IN_MB) {//????????难道是因为小于0后就是无穷大了? + s_cameraSDCardState.remainSpaceInMB = 0; + s_cameraSDCardState.isFull = true; + } + } + + if (s_cameraState.isShootingIntervalStart == false) { + isStartIntervalPhotoAction = false; + } + + if (s_cameraShootPhotoMode == PSDK_CAMERA_SHOOT_PHOTO_MODE_INTERVAL + && s_cameraState.isShootingIntervalStart == true && s_cameraPhotoTimeIntervalSettings.captureCount > 0 + && s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds > 0) { + s_cameraState.currentPhotoShootingIntervalTimeInSeconds--; + + if ((s_cameraState.currentPhotoShootingIntervalTimeInSeconds == 0 && + s_cameraState.currentPhotoShootingIntervalCount > 0) || + (s_cameraState.isShootingIntervalStart == true && isStartIntervalPhotoAction == false)) { + + isStartIntervalPhotoAction = true; + + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_INTERVAL_PHOTO; + s_cameraState.isStoring = true; + s_cameraState.currentPhotoShootingIntervalTimeInSeconds + = s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds; + if (s_cameraState.currentPhotoShootingIntervalCount < INTERVAL_PHOTOGRAPH_ALWAYS_COUNT) { + PsdkLogger_UserLogInfo("interval taking photograph count:%d interval_time:%ds", + (s_cameraPhotoTimeIntervalSettings.captureCount - + s_cameraState.currentPhotoShootingIntervalCount + 1), + s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds); + s_cameraState.currentPhotoShootingIntervalCount--; + if (s_cameraState.currentPhotoShootingIntervalCount == 0) { + s_cameraState.shootingState = PSDK_CAMERA_SHOOTING_PHOTO_IDLE; + s_cameraState.isStoring = false; + s_cameraState.isShootingIntervalStart = false; + } + } else { + PsdkLogger_UserLogInfo("interval taking photograph always, interval_time:%ds", + s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds); + s_cameraState.currentPhotoShootingIntervalCount--; + } + } + } + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + continue; + } + } + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +/* Private functions definition-----------------------------------------------*/ +T_PsdkReturnCode PsdkTest_CameraInit(void) +{ + T_PsdkReturnCode returnCode; + char ipAddr[PSDK_IP_ADDR_STR_SIZE_MAX] = {0}; + uint16_t port = 0; + T_PsdkAircraftInfoBaseInfo aircraftBaseInfo = {0}; + + returnCode = PsdkOsal_MutexCreate(&s_commonMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("create mutex used to lock tap zoom arguments error: 0x%08llX", returnCode); + return returnCode; + } + + returnCode = PsdkOsal_MutexCreate(&s_zoomMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("create mutex used to lock tap zoom arguments error: 0x%08llX", returnCode); + return returnCode; + } + + returnCode = PsdkOsal_MutexCreate(&s_tapZoomMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("create mutex used to lock tap zoom arguments error: 0x%08llX", returnCode); + return returnCode; + } + + returnCode = PsdkPayloadCamera_Init();//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("payload camera init error:0x%08llX", returnCode); + } + + /* Init the SDcard parameters */ + s_cameraSDCardState.isInserted = true; + s_cameraSDCardState.totalSpaceInMB = SDCARD_TOTAL_SPACE_IN_MB; + s_cameraSDCardState.remainSpaceInMB = SDCARD_TOTAL_SPACE_IN_MB; + s_cameraSDCardState.availableCaptureCount = SDCARD_TOTAL_SPACE_IN_MB / SDCARD_PER_PHOTO_SPACE_IN_MB; + s_cameraSDCardState.availableRecordingTimeInSeconds = + SDCARD_TOTAL_SPACE_IN_MB / SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB; + + /* Register the camera common handler */ + //注册相机类基础功能,(1)SetMode:设置相机工作模式(照片/视频/回放);(2)如果是photo模式,使用SetShootPhotoMode设置照片拍照模式;(3)StartShootPhoto开始拍摄照片 + s_commonHandler.GetSystemState = GetSystemState; + s_commonHandler.SetMode = SetMode;//设置相机模式:照片/视频/回放 + s_commonHandler.GetMode = PsdkTest_CameraGetMode; + s_commonHandler.StartRecordVideo = StartRecordVideo;//控制相机录像:s_cameraState.isRecording = true; + s_commonHandler.StopRecordVideo = StopRecordVideo; + s_commonHandler.StartShootPhoto = StartShootPhoto;//控制相机拍摄照片:单拍/连拍/等时间间隔;只是改变了s_cameraState的状态 + s_commonHandler.StopShootPhoto = StopShootPhoto; + s_commonHandler.SetShootPhotoMode = SetShootPhotoMode;//写入变量s_cameraShootPhotoMode,设置相机类负载的拍照模式:单拍/连拍/等时间间隔 + s_commonHandler.GetShootPhotoMode = GetShootPhotoMode;//读取变量s_cameraShootPhotoMode + s_commonHandler.SetPhotoBurstCount = SetPhotoBurstCount;//控制相机连拍,写入变量s_cameraBurstCount + s_commonHandler.GetPhotoBurstCount = GetPhotoBurstCount;// 读取变量s_cameraBurstCount + s_commonHandler.SetPhotoTimeIntervalSettings = SetPhotoTimeIntervalSettings;//控制相机定时拍照,变量s_cameraPhotoTimeIntervalSettings有啥用, + s_commonHandler.GetPhotoTimeIntervalSettings = GetPhotoTimeIntervalSettings;// 读取变量s_cameraPhotoTimeIntervalSettings + s_commonHandler.GetSDCardState = GetSDCardState;//获取SD 卡的当前状态 + s_commonHandler.FormatSDCard = FormatSDCard;//SD卡格式化 + + returnCode = PsdkPayloadCamera_RegCommonHandler(&s_commonHandler);//注册相机类基础功能 + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("camera register common handler error:0x%08llX", returnCode); + } + + /* Register the camera metering handler */ + //注册相机测光功能 + s_exposureMeteringHandler.SetMeteringMode = SetMeteringMode; + s_exposureMeteringHandler.GetMeteringMode = GetMeteringMode; + s_exposureMeteringHandler.SetSpotMeteringTarget = SetSpotMeteringTarget; + s_exposureMeteringHandler.GetSpotMeteringTarget = GetSpotMeteringTarget; + + returnCode = PsdkPayloadCamera_RegExposureMeteringHandler(&s_exposureMeteringHandler); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("camera register exposure metering handler error:0x%08llX", returnCode); + return returnCode; + } + + /* Register the camera focus handler */ + //注册相机设置对焦功能 + s_focusHandler.SetFocusMode = SetFocusMode; + s_focusHandler.GetFocusMode = GetFocusMode; + s_focusHandler.SetFocusTarget = SetFocusTarget;//设置对焦点 + s_focusHandler.GetFocusTarget = GetFocusTarget; + s_focusHandler.SetFocusAssistantSettings = SetFocusAssistantSettings; + s_focusHandler.GetFocusAssistantSettings = GetFocusAssistantSettings; + s_focusHandler.SetFocusRingValue = SetFocusRingValue;//设置对焦环 + s_focusHandler.GetFocusRingValue = GetFocusRingValue; + s_focusHandler.GetFocusRingValueUpperBound = GetFocusRingValueUpperBound; + + returnCode = PsdkPayloadCamera_RegFocusHandler(&s_focusHandler); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("camera register adjustable focal point handler error:0x%08llX", returnCode); + return returnCode; + } + + /* Register the camera digital zoom handler */ + //注册相机数字变焦功能 + s_digitalZoomHandler.SetDigitalZoomFactor = SetDigitalZoomFactor;//设置数字变焦因子 + s_digitalZoomHandler.GetDigitalZoomFactor = PsdkTest_CameraGetDigitalZoomFactor; + + returnCode = PsdkPayloadCamera_RegDigitalZoomHandler(&s_digitalZoomHandler); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("camera register digital zoom handler error:0x%08llX", returnCode); + return returnCode; + } + + /* Register the camera optical zoom handler */ + //注册相机光学变焦功能 + s_opticalZoomHandler.SetOpticalZoomFocalLength = SetOpticalZoomFocalLength;//设置光学变焦相机的焦距 + s_opticalZoomHandler.GetOpticalZoomFocalLength = GetOpticalZoomFocalLength; + s_opticalZoomHandler.GetOpticalZoomFactor = PsdkTest_CameraGetOpticalZoomFactor;//获取相机类负载设备的变焦系数 + s_opticalZoomHandler.GetOpticalZoomSpec = GetOpticalZoomSpec;//获取光学变焦的范围 + s_opticalZoomHandler.StartContinuousOpticalZoom = StartContinuousOpticalZoom;//控制相机类负载设备开始变焦 + s_opticalZoomHandler.StopContinuousOpticalZoom = StopContinuousOpticalZoom; + + returnCode = PsdkPayloadCamera_RegOpticalZoomHandler(&s_opticalZoomHandler); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("camera register optical zoom handler error:0x%08llX", returnCode); + return returnCode; + } + + /* Register the camera tap zoom handler */ + //注册指点变焦功能 + s_tapZoomHandler.GetTapZoomState = GetTapZoomState; + s_tapZoomHandler.SetTapZoomEnabled = SetTapZoomEnabled; + s_tapZoomHandler.GetTapZoomEnabled = GetTapZoomEnabled; + s_tapZoomHandler.SetTapZoomMultiplier = SetTapZoomMultiplier; + s_tapZoomHandler.GetTapZoomMultiplier = GetTapZoomMultiplier; + s_tapZoomHandler.TapZoomAtTarget = TapZoomAtTarget; + + returnCode = PsdkPayloadCamera_RegTapZoomHandler(&s_tapZoomHandler); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("camera register tap zoom handler error:0x%08llX", returnCode); + return returnCode; + } + + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /* Create the camera emu task */ + if (PsdkOsal_TaskCreate(&s_userCameraThread, UserCamera_Task, "user_camera_task", + PAYLOAD_CAMERA_EMU_TASK_STACK_SIZE, NULL) + != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user camera task create error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkAircraftInfo_GetBaseInfo(&aircraftBaseInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get aircraft information error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M300_RTK) { + returnCode = PsdkPayloadCamera_SetVideoStreamType(PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_CUSTOM_FORMAT);//本来用的是:PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk camera set video stream error."); + return PSDK_RETURN_CODE_ERR_UNKNOWN; + } + s_cameraVideoStreamType = PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT; + } else { + returnCode = PsdkPayloadCamera_SetVideoStreamType(PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_CUSTOM_FORMAT); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk camera set video stream error."); + return PSDK_RETURN_CODE_ERR_UNKNOWN; + } + s_cameraVideoStreamType = PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_CUSTOM_FORMAT; + } + + returnCode = PsdkPayloadCamera_GetVideoStreamRemoteAddress(ipAddr, &port); + if (returnCode == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogInfo("get video stream remote address:%s_%d", ipAddr, port); + } else { + PsdkLogger_UserLogError("get video stream remote address error."); + return PSDK_RETURN_CODE_ERR_UNKNOWN; + } + + s_isCamInited = true; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_CameraGetDigitalZoomFactor(psdk_f32_t *factor) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + *factor = s_cameraDigitalZoomFactor; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_CameraGetOpticalZoomFactor(psdk_f32_t *factor) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + //Formula:factor = currentFocalLength / minFocalLength + *factor = (psdk_f32_t) s_cameraOpticalZoomFocalLength / ZOOM_OPTICAL_FOCAL_MIN_LENGTH; + + psdkStat = PsdkOsal_MutexUnlock(s_zoomMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_CameraGetMode(E_PsdkCameraMode *mode) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_MutexLock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("lock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + *mode = s_cameraState.cameraMode; + + psdkStat = PsdkOsal_MutexUnlock(s_commonMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("unlock mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_CameraGetVideoStreamType(E_PsdkCameraVideoStreamType *type) +{ + T_PsdkReturnCode psdkStat; + + if (s_isCamInited == false) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE; + } + + *type = s_cameraVideoStreamType; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +bool PsdkTest_CameraIsInited(void) +{ + return s_isCamInited; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/camera_emu/test_payload_cam_emu.h b/sample/api_sample/camera_emu/test_payload_cam_emu.h new file mode 100644 index 0000000..6b1d5b5 --- /dev/null +++ b/sample/api_sample/camera_emu/test_payload_cam_emu.h @@ -0,0 +1,57 @@ +/** + ******************************************************************** + * @file test_payload_cam_emu.h + * @version V2.0.0 + * @date 2019/07/01 + * @brief This is the header file for "test_payload_cam_emu.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_PAYLOAD_CAM_EMU_H +#define TEST_PAYLOAD_CAM_EMU_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_CameraInit(void); +T_PsdkReturnCode PsdkTest_CameraGetDigitalZoomFactor(psdk_f32_t *factor); +T_PsdkReturnCode PsdkTest_CameraGetOpticalZoomFactor(psdk_f32_t *factor); +T_PsdkReturnCode PsdkTest_CameraGetMode(E_PsdkCameraMode *mode); +T_PsdkReturnCode PsdkTest_CameraGetVideoStreamType(E_PsdkCameraVideoStreamType *type); +bool PsdkTest_CameraIsInited(void); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_PAYLOAD_CAM_EMU_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/camera_media_emu/ffmpeg_tc.c b/sample/api_sample/camera_media_emu/ffmpeg_tc.c new file mode 100644 index 0000000..df02b8f --- /dev/null +++ b/sample/api_sample/camera_media_emu/ffmpeg_tc.c @@ -0,0 +1,176 @@ +// +// Created by tangchao on 2021/11/16. +// + + +#include "ffmpeg_tc.h" + +char *getsystemtime() +{ + //获取系统时间 + time_t timer;//time_t就是long int 类型 + struct tm *tblock; + timer = time(NULL);//返回秒数(精度为秒),从1970-1-1,00:00:00 可以当成整型输出或用于其它函数 + tblock = localtime(&timer); + //printf("Local time is: %s\n", asctime(tblock)); + + //格式化时间为需要的格式 + char fileNameTmp[256] = { 0 }; + char dirNameTmp[256] = { 0 }; + strftime(fileNameTmp, sizeof(fileNameTmp), "%Y%m%d_%H%M%S", tblock); + return fileNameTmp; +} + +AVFrame *get_video_frame(IntputDev* input)//tc改动 +{ + clock_t start,finish; + start = clock(); // 设置开始clock + + int ret; + AVFrame * ret_frame=NULL; + + if(av_read_frame(input->v_ifmtCtx, input->in_packet)>=0) + { + if(input->in_packet->stream_index==input->videoindex) + { + ret = avcodec_send_packet(input->pCodecCtx, input->in_packet); + if (ret < 0) { + fprintf(stderr, "Error sending a packet for decoding\n"); + exit(1); + } + + ret = avcodec_receive_frame(input->pCodecCtx, input->pFrame); + if(ret<0) + { + printf("Decode Error.\n"); + av_packet_unref(input->in_packet); + return NULL; + } + sws_scale(input->img_convert_ctx, (const unsigned char* const*)input->pFrame->data, input->pFrame->linesize, 0, input->pCodecCtx->height, input->pFrameYUV->data, input->pFrameYUV->linesize); + input->pFrameYUV->pts=input->next_pts++; + ret_frame= input->pFrameYUV; + } + av_packet_unref(input->in_packet); + } + + finish = clock();// 设置结束clock + double duration = (double)(finish - start) / CLOCKS_PER_SEC;//转换浮点型 +// printf( "采集视频帧时间:%lf seconds\n", duration ); + + return ret_frame; +} +// +//static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt) +//{ +// int ret; +// +// /* send the frame to the encoder */ +// if (frame) +// printf("Send frame %3"PRId64"\n", frame->pts); +// +// ret = avcodec_send_frame(enc_ctx, frame);//返回-21????????????????????????????????????????????? +// if (ret < 0) { +// fprintf(stderr, "Error sending a frame for encoding\n"); +// exit(1); +// } +// +// while (ret >= 0) { +// ret = avcodec_receive_packet(enc_ctx, pkt); +// if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) +// return; +// else if (ret < 0) { +// fprintf(stderr, "Error during encoding\n"); +// exit(1); +// } +// +//// printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size); +//// fwrite(pkt->data, 1, pkt->size, outfile); +// av_packet_unref(pkt); +// } +//} + +void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, char **data, int *datasize) +{ + int ret; + + /* send the frame to the encoder */ +// if (frame) +// printf("Send frame %3"PRId64"\n", frame->pts); + + ret = avcodec_send_frame(enc_ctx, frame);//返回-21????????????????????????????????????????????? + if (ret < 0) { + fprintf(stderr, "Error sending a frame for encoding\n"); + exit(1); + } + + while (ret >= 0) { + ret = avcodec_receive_packet(enc_ctx, pkt); + if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) + { + printf("11111111111111111111\n"); + return; + } + else if (ret < 0) { + fprintf(stderr, "Error during encoding\n"); + exit(1); + } + +// printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size); +// fwrite(pkt->data, 1, pkt->size, outfile); + + //tc + char *dataBuffer = calloc(pkt->size, 1); + memcpy(dataBuffer,pkt->data,pkt->size); + + *data = dataBuffer; + *datasize = pkt->size; + + av_packet_unref(pkt); + } + printf("22222222222222222\n"); +} + +char * encode2(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, int *datasize) +{ + clock_t start,finish; + start = clock(); // 设置开始clock + + int ret; + char *dataBuffer; + + ret = avcodec_send_frame(enc_ctx, frame); + if (ret < 0) { + fprintf(stderr, "Error sending a frame for encoding\n"); + exit(1); + } + + while (ret >= 0) { + ret = avcodec_receive_packet(enc_ctx, pkt); + if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) + { + printf("11111111111111111111\n"); + return NULL; + } + else if (ret < 0) { + fprintf(stderr, "Error during encoding\n"); + exit(1); + } + +// printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size); +// fwrite(pkt->data, 1, pkt->size, outfile); + + //tc + dataBuffer = calloc(pkt->size, 1); + memcpy(dataBuffer,pkt->data,pkt->size); + + *datasize = pkt->size; + + av_packet_unref(pkt); + + finish = clock();// 设置结束clock + double duration = (double)(finish - start) / CLOCKS_PER_SEC;//转换浮点型 +// printf( "编码视频帧时间:%lf seconds\n", duration ); + + return dataBuffer; + } +} \ No newline at end of file diff --git a/sample/api_sample/camera_media_emu/ffmpeg_tc.h b/sample/api_sample/camera_media_emu/ffmpeg_tc.h new file mode 100644 index 0000000..b47742b --- /dev/null +++ b/sample/api_sample/camera_media_emu/ffmpeg_tc.h @@ -0,0 +1,63 @@ +// +// Created by tangchao on 2021/11/16. +// + +#ifndef PSDK_DEMO_FFMPEG_TC_H +#define PSDK_DEMO_FFMPEG_TC_H + + +//tc开始 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "libavdevice/avdevice.h" + +#include + +#include //usleep + + +#define STREAM_DURATION 50.0 /*录制视频的持续时间 秒*/ +#define STREAM_FRAME_RATE 15 /* images/s 这里可以根据摄像头的采集速度来设置帧率 */ +#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */ +#define SCALE_FLAGS SWS_BICUBIC +//tc结束 + + +//存放视频的宽度和高度 +int video_width; +int video_height; + + +typedef struct IntputDev +{ + AVCodecContext *pCodecCtx; + AVCodec *pCodec; + AVFormatContext *v_ifmtCtx; + int videoindex; + struct SwsContext *img_convert_ctx; + AVPacket *in_packet; + AVFrame *pFrame,*pFrameYUV; + + /*下一帧的点数*/ + int64_t next_pts; +}IntputDev; + +char *getsystemtime(); +AVFrame *get_video_frame(IntputDev* input); +//static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt); +void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, char **data, int *datasize); +char * encode2(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, int *datasize); + +#endif //PSDK_DEMO_FFMPEG_TC_H diff --git a/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.c b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.c new file mode 100644 index 0000000..ed6d724 --- /dev/null +++ b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.c @@ -0,0 +1,265 @@ +/** + ******************************************************************** + * @file psdk_media_file_core.c + * @version V1.0.0 + * @date 2019/01/01 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include +#include + +#include "psdk_media_file_core.h" +#include "psdk_media_file_jpg.h" +#include "psdk_media_file_mp4.h" +#include "psdk_platform.h" + +/* Private constants ---------------------------------------------------------*/ + + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ + +/* Private values ------------------------------------------------------------*/ +//@formatter:off +static const T_PsdkMediaFileOptItem s_mediaFileOpt[] = +{ + //JPEG File Operation Item + { + PSDK_CAMERA_FILE_TYPE_JPEG , + PsdkMediaFile_IsSupported_JPG, + PsdkMediaFile_GetAttrFunc_JPG, + PsdkMediaFile_GetDataOrigin_JPG, + PsdkMediaFile_GetFileSizeOrigin_JPG, + PsdkMediaFile_CreateThumbNail_JPG, + PsdkMediaFile_GetFileSizeThumbNail_JPG, + PsdkMediaFile_GetDataThumbNail_JPG, + PsdkMediaFile_DestroyThumbNail_JPG, + PsdkMediaFile_CreateScreenNail_JPG, + PsdkMediaFile_GetFileSizeScreenNail_JPG, + PsdkMediaFile_GetDataScreenNail_JPG, + PsdkMediaFile_DestroyScreenNail_JPG, + }, + //MP4 File Operation Item + { + PSDK_CAMERA_FILE_TYPE_MP4 , + PsdkMediaFile_IsSupported_MP4, + PsdkMediaFile_GetAttrFunc_MP4, + PsdkMediaFile_GetDataOrigin_MP4, + PsdkMediaFile_GetFileSizeOrigin_MP4, + PsdkMediaFile_CreateThumbNail_MP4, + PsdkMediaFile_GetFileSizeThumbNail_MP4, + PsdkMediaFile_GetDataThumbNail_MP4, + PsdkMediaFile_DestroyThumbNail_MP4, + PsdkMediaFile_CreateScreenNail_MP4, + PsdkMediaFile_GetFileSizeScreenNail_MP4, + PsdkMediaFile_GetDataScreenNail_MP4, + PsdkMediaFile_DestroyScreenNail_MP4, + }, +}; +static const uint32_t s_mediaFileOptCount = sizeof (s_mediaFileOpt) / sizeof(T_PsdkMediaFileOptItem); +//@formatter:on + +/* Exported functions definition ---------------------------------------------*/ +bool PsdkMediaFile_IsSupported(const char *filePath) +{ + int i; + + for (i = 0; i < s_mediaFileOptCount; i++) { + if (s_mediaFileOpt[i].isSupportedFunc(filePath) == true) { + return true; + } + } + + return false; +} + +T_PsdkReturnCode PsdkMediaFile_CreateHandle(const char *filePath, T_PsdkMediaFileHandle *pMediaFileHandle) +{ + int optIndex;//这个指数 指明了 filePath中的文件格式 处于数组s_mediaFileOpt中的哪一个元素 + + for (optIndex = 0; optIndex < s_mediaFileOptCount; optIndex++) { + if (s_mediaFileOpt[optIndex].isSupportedFunc(filePath) == true) {//查看filePath的格式是否 存在于 所有支持的格式中 + break; + } + } + + if (optIndex == s_mediaFileOptCount) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + *pMediaFileHandle = PsdkOsal_Malloc(sizeof(T_PsdkMediaFile)); + if (*pMediaFileHandle == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + (*pMediaFileHandle)->filePath = PsdkOsal_Malloc(strlen(filePath) + 1); + if ((*pMediaFileHandle)->filePath == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + (*pMediaFileHandle)->mediaFileOptItem = s_mediaFileOpt[optIndex];//为pMediaFileHandle(媒体文件句柄)添加处理函数 + (*pMediaFileHandle)->mediaFileThm.privThm = NULL; + (*pMediaFileHandle)->mediaFileScr.privScr = NULL; + + strcpy((*pMediaFileHandle)->filePath, filePath); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkMediaFile_DestroyHandle(T_PsdkMediaFileHandle mediaFileHandle) +{ + PsdkOsal_Free(mediaFileHandle->filePath); + + PsdkOsal_Free(mediaFileHandle); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkMediaFile_GetMediaFileType(T_PsdkMediaFileHandle mediaFileHandle, + E_PsdkCameraMediaFileType *mediaFileType) +{ + *mediaFileType = mediaFileHandle->mediaFileOptItem.mediaFileType; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkMediaFile_GetMediaFileAttr(T_PsdkMediaFileHandle mediaFileHandle, + T_PsdkCameraMediaFileAttr *mediaFileAttr) +{ + if (mediaFileHandle->mediaFileOptItem.getAttrFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getAttrFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getAttrFunc(mediaFileHandle, mediaFileAttr); +} + +T_PsdkReturnCode PsdkMediaFile_GetDataOrg(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + if (mediaFileHandle->mediaFileOptItem.getDataOrgFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getDataOrgFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getDataOrgFunc(mediaFileHandle, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeOrg(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + if (mediaFileHandle->mediaFileOptItem.getFileSizeOrgFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getFileSizeOrgFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getFileSizeOrgFunc(mediaFileHandle, fileSize); +} + +T_PsdkReturnCode PsdkMediaFile_CreateThm(T_PsdkMediaFileHandle mediaFileHandle) +{ + if (mediaFileHandle->mediaFileOptItem.createThmFunc == NULL) { + PsdkLogger_UserLogError("Media file handle createThmFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.createThmFunc(mediaFileHandle); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeThm(T_PsdkMediaFileHandle mediaFileHandle, uint32_t *fileSize) +{ + if (mediaFileHandle->mediaFileOptItem.getFileSizeThmFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getFileSizeThmFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getFileSizeThmFunc(mediaFileHandle, fileSize); +} + +T_PsdkReturnCode PsdkMediaFile_GetDataThm(T_PsdkMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + if (mediaFileHandle->mediaFileOptItem.getDataThmFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getDataThmFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getDataThmFunc(mediaFileHandle, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_DestoryThm(T_PsdkMediaFileHandle mediaFileHandle) +{ + if (mediaFileHandle->mediaFileOptItem.destroyThmFunc == NULL) { + PsdkLogger_UserLogError("Media file handle destroyThmFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.destroyThmFunc(mediaFileHandle); +} + +T_PsdkReturnCode PsdkMediaFile_CreateScr(T_PsdkMediaFileHandle mediaFileHandle) +{ + if (mediaFileHandle->mediaFileOptItem.creatScrFunc == NULL) { + PsdkLogger_UserLogError("Media file handle creatScrFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.creatScrFunc(mediaFileHandle); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeScr(T_PsdkMediaFileHandle mediaFileHandle, uint32_t *fileSize) +{ + if (mediaFileHandle->mediaFileOptItem.getFileSizeScrFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getFileSizeScrFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getFileSizeScrFunc(mediaFileHandle, fileSize); +} + +T_PsdkReturnCode PsdkMediaFile_GetDataScr(T_PsdkMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + if (mediaFileHandle->mediaFileOptItem.getDataScrFunc == NULL) { + PsdkLogger_UserLogError("Media file handle getDataScrFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.getDataScrFunc(mediaFileHandle, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_DestroyScr(T_PsdkMediaFileHandle mediaFileHandle) +{ + if (mediaFileHandle->mediaFileOptItem.destroyScrFunc == NULL) { + PsdkLogger_UserLogError("Media file handle destroyScrFunc null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return mediaFileHandle->mediaFileOptItem.destroyScrFunc(mediaFileHandle); +} + +/* Private functions definition-----------------------------------------------*/ + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.h b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.h new file mode 100644 index 0000000..9a66c45 --- /dev/null +++ b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_core.h @@ -0,0 +1,117 @@ +/** + ******************************************************************** + * @file psdk_media_file_core.h + * @version V0.0.0 + * @date 2019/01/01 + * @brief This is the header file for "psdk_media_file_core.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PSDK_MEDIA_FILE_CORE_H +#define PSDK_MEDIA_FILE_CORE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include + +/* Exported constants --------------------------------------------------------*/ +#define PSDK_MEDIA_FILE_PATH_LEN_MAX 512 /*max file path len */ +#define PSDK_MEDIA_DIR_PATH_LEN_MAX 256 /*max dir path len */ + +/* Exported types ------------------------------------------------------------*/ +typedef struct { + void *privThm; +} T_PsdkMediaFileThm; + +typedef struct { + void *privScr; +} T_PsdkMediaFileScr; + +struct _PsdkMediaFile; + +typedef struct { + E_PsdkCameraMediaFileType mediaFileType; + bool (*isSupportedFunc)(const char *filePath); + + T_PsdkReturnCode (*getAttrFunc)(struct _PsdkMediaFile *mediaFileHandle, T_PsdkCameraMediaFileAttr *mediaFileAttr); + + T_PsdkReturnCode (*getDataOrgFunc)(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); + T_PsdkReturnCode (*getFileSizeOrgFunc)(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); + + T_PsdkReturnCode (*createThmFunc)(struct _PsdkMediaFile *mediaFileHandle); + T_PsdkReturnCode (*getFileSizeThmFunc)(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); + T_PsdkReturnCode (*getDataThmFunc)(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); + T_PsdkReturnCode (*destroyThmFunc)(struct _PsdkMediaFile *mediaFileHandle); + + T_PsdkReturnCode (*creatScrFunc)(struct _PsdkMediaFile *mediaFileHandle); + T_PsdkReturnCode (*getFileSizeScrFunc)(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); + T_PsdkReturnCode (*getDataScrFunc)(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); + T_PsdkReturnCode (*destroyScrFunc)(struct _PsdkMediaFile *mediaFileHandle); +} T_PsdkMediaFileOptItem; + +typedef struct _PsdkMediaFile { + char *filePath; + T_PsdkMediaFileOptItem mediaFileOptItem; + T_PsdkMediaFileThm mediaFileThm; + T_PsdkMediaFileScr mediaFileScr; +} T_PsdkMediaFile, *T_PsdkMediaFileHandle; + +/* Exported functions --------------------------------------------------------*/ +bool PsdkMediaFile_IsSupported(const char *filePath); +T_PsdkReturnCode PsdkMediaFile_CreateHandle(const char *filePath, T_PsdkMediaFileHandle *pMediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_DestroyHandle(T_PsdkMediaFileHandle mediaFileHandle); + +T_PsdkReturnCode PsdkMediaFile_GetMediaFileType(T_PsdkMediaFileHandle mediaFileHandle, + E_PsdkCameraMediaFileType *mediaFileType); +T_PsdkReturnCode PsdkMediaFile_GetMediaFileAttr(T_PsdkMediaFileHandle mediaFileHandle, + T_PsdkCameraMediaFileAttr *mediaFileAttr); + +T_PsdkReturnCode PsdkMediaFile_GetDataOrg(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeOrg(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); + +T_PsdkReturnCode PsdkMediaFile_CreateThm(T_PsdkMediaFileHandle mediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeThm(T_PsdkMediaFileHandle mediaFileHandle, uint32_t *fileSize); +T_PsdkReturnCode PsdkMediaFile_GetDataThm(T_PsdkMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_DestoryThm(T_PsdkMediaFileHandle mediaFileHandle); + +T_PsdkReturnCode PsdkMediaFile_CreateScr(T_PsdkMediaFileHandle mediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeScr(T_PsdkMediaFileHandle mediaFileHandle, uint32_t *fileSize); +T_PsdkReturnCode PsdkMediaFile_GetDataScr(T_PsdkMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_DestroyScr(T_PsdkMediaFileHandle mediaFileHandle); + +#ifdef __cplusplus +} +#endif + +#endif // PSDK_MEDIA_FILE_CORE_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.c b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.c new file mode 100644 index 0000000..b11d30a --- /dev/null +++ b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.c @@ -0,0 +1,227 @@ +/** + ******************************************************************** + * @file psdk_media_file_JPG.c + * @version V1.0.0 + * @date 2019/01/01 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_media_file_jpg.h" +#include "psdk_media_file_core.h" +#include +#include +#include +#include +#include +#include +#include "psdk_platform.h" +#include "utils/util_time.h" +#include "utils/util_file.h" + +/* Private constants ---------------------------------------------------------*/ +#define JPG_FILE_SUFFIX ".jpg" +#define JPG_TEMP_FILE_TEMPLATE_STR "JPG_TEMP_XXXXXX.jpg" +#define JPG_TEMP_FILE_PATH_MAX_LEN 50 +#define FFMPEG_CMD_BUF_SIZE 1024 + +#define JPG_THM_SCALE_CFG_STR "scale=100:-1" +#define JPG_SCR_SCALE_CFG_STR "scale=600:-1" + +/* Private types -------------------------------------------------------------*/ +typedef struct { + FILE *tempFile; + char tempfilePath[JPG_TEMP_FILE_PATH_MAX_LEN]; +} T_PsdkJPGTempFilePriv; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkMediaFile_CreateTempFilePriv_JPG(const char *srcFilePath, const char *scaleCfgStr, + T_PsdkJPGTempFilePriv **pTempFilePrivHandle); +static T_PsdkReturnCode PsdkMediaFile_DestroyTempFilePriv_JPG(T_PsdkJPGTempFilePriv *tempFilePrivHandle); + +/* Exported functions definition ---------------------------------------------*/ +bool PsdkMediaFile_IsSupported_JPG(const char *filePath) +{ + if (filePath == NULL) { + PsdkLogger_UserLogError("input parameter is null error"); + return false; + } + + if (strcmp(&filePath[strlen(filePath) - 4], JPG_FILE_SUFFIX) == 0) { + return true; + } + + return false; +} + +T_PsdkReturnCode PsdkMediaFile_GetAttrFunc_JPG(struct _PsdkMediaFile *mediaFileHandle, + T_PsdkCameraMediaFileAttr *mediaFileAttr) +{ + USER_UTIL_UNUSED(mediaFileHandle); + + mediaFileAttr->attrVideoDuration = 0; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkMediaFile_GetDataOrigin_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeOrigin_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + return UtilFile_GetFileSizeByPath(mediaFileHandle->filePath, fileSize); +} + +T_PsdkReturnCode PsdkMediaFile_CreateThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle) +{ + return PsdkMediaFile_CreateTempFilePriv_JPG(mediaFileHandle->filePath, JPG_THM_SCALE_CFG_STR, + (T_PsdkJPGTempFilePriv **) &mediaFileHandle->mediaFileThm.privThm); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + T_PsdkJPGTempFilePriv *jpgFileThmPriv = (T_PsdkJPGTempFilePriv *) mediaFileHandle->mediaFileThm.privThm; + + return UtilFile_GetFileSize(jpgFileThmPriv->tempFile, fileSize); +} + +T_PsdkReturnCode +PsdkMediaFile_GetDataThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + T_PsdkJPGTempFilePriv *jpgFileThmPriv = (T_PsdkJPGTempFilePriv *) mediaFileHandle->mediaFileThm.privThm; + + return UtilFile_GetFileData(jpgFileThmPriv->tempFile, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_DestroyThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle) +{ + return PsdkMediaFile_DestroyTempFilePriv_JPG(mediaFileHandle->mediaFileThm.privThm); +} + +T_PsdkReturnCode PsdkMediaFile_CreateScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle) +{ + return PsdkMediaFile_CreateTempFilePriv_JPG(mediaFileHandle->filePath, JPG_SCR_SCALE_CFG_STR, + (T_PsdkJPGTempFilePriv **) &mediaFileHandle->mediaFileScr.privScr); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + T_PsdkJPGTempFilePriv *jpgFileScrPriv = (T_PsdkJPGTempFilePriv *) mediaFileHandle->mediaFileScr.privScr; + + return UtilFile_GetFileSize(jpgFileScrPriv->tempFile, fileSize); +} + +T_PsdkReturnCode +PsdkMediaFile_GetDataScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + T_PsdkJPGTempFilePriv *jpgFileScrPriv = (T_PsdkJPGTempFilePriv *) mediaFileHandle->mediaFileScr.privScr; + + return UtilFile_GetFileData(jpgFileScrPriv->tempFile, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_DestroyScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle) +{ + return PsdkMediaFile_DestroyTempFilePriv_JPG(mediaFileHandle->mediaFileScr.privScr); +} + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkMediaFile_CreateTempFilePriv_JPG(const char *srcFilePath, const char *scaleCfgStr, + T_PsdkJPGTempFilePriv **pTempFilePrivHandle) +{ + char ffmpeg_cmd[FFMPEG_CMD_BUF_SIZE]; + int cmdRet; + T_PsdkRunTimeStamps tiStart, tiEnd; + T_PsdkJPGTempFilePriv *jpgTempFilePriv; + T_PsdkReturnCode psdkStat; + int tempFd; + + tiStart = PsdkUtilTime_GetRunTimeStamps(); + + *pTempFilePrivHandle = PsdkOsal_Malloc(sizeof(T_PsdkJPGTempFilePriv)); + if (*pTempFilePrivHandle == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + jpgTempFilePriv = *pTempFilePrivHandle; + + //get temp file name + strcpy(jpgTempFilePriv->tempfilePath, JPG_TEMP_FILE_TEMPLATE_STR); + tempFd = mkstemps(jpgTempFilePriv->tempfilePath, strlen(JPG_FILE_SUFFIX)); + if (tempFd < 0) { + PsdkLogger_UserLogError("JPG Create Temp File Error, tempFd = %d\n", tempFd); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto err_create_temp; + } + close(tempFd); + unlink(jpgTempFilePriv->tempfilePath); + + //ffmpeg cmd send + snprintf(ffmpeg_cmd, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" -vf %s %s 1>/dev/null 2>&1", + srcFilePath, scaleCfgStr, jpgTempFilePriv->tempfilePath); + + cmdRet = system(ffmpeg_cmd); + + tiEnd = PsdkUtilTime_GetRunTimeStamps(); + + PsdkLogger_UserLogDebug("JPG Create TempFile, RealTime = %ld us\n", tiEnd.realUsec - tiStart.realUsec); + + if (cmdRet != 0) { + PsdkLogger_UserLogError("JPG ffmpeg cmd call error, ret = %d\n", cmdRet); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto err_system_cmd; + } + + //open temp file + jpgTempFilePriv->tempFile = fopen(jpgTempFilePriv->tempfilePath, "rb+"); + if (jpgTempFilePriv->tempFile == NULL) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto err_file_open; + } + + //unlink temp file + unlink(jpgTempFilePriv->tempfilePath); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + +err_file_open: + unlink(jpgTempFilePriv->tempfilePath); +err_system_cmd: +err_create_temp: + PsdkOsal_Free(*pTempFilePrivHandle); + + return psdkStat; +} + +static T_PsdkReturnCode PsdkMediaFile_DestroyTempFilePriv_JPG(T_PsdkJPGTempFilePriv *tempFilePrivHandle) +{ + fclose(tempFilePrivHandle->tempFile); + PsdkOsal_Free(tempFilePrivHandle); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.h b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.h new file mode 100644 index 0000000..bae7830 --- /dev/null +++ b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_jpg.h @@ -0,0 +1,77 @@ +/** + ******************************************************************** + * @file psdk_media_file_JPG.h + * @version V0.0.0 + * @date 2019/01/01 + * @brief This is the header file for "psdk_media_file_JPG.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PSDK_MEDIA_FILE_JPG_H +#define PSDK_MEDIA_FILE_JPG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include "psdk_media_file_core.h" + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +bool PsdkMediaFile_IsSupported_JPG(const char *filePath); + +T_PsdkReturnCode PsdkMediaFile_GetAttrFunc_JPG(struct _PsdkMediaFile *mediaFileHandle, + T_PsdkCameraMediaFileAttr *mediaFileAttr); + +T_PsdkReturnCode PsdkMediaFile_GetDataOrigin_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeOrigin_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); + +T_PsdkReturnCode PsdkMediaFile_CreateThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); +T_PsdkReturnCode +PsdkMediaFile_GetDataThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_DestroyThumbNail_JPG(struct _PsdkMediaFile *mediaFileHandle); + +T_PsdkReturnCode PsdkMediaFile_CreateScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); +T_PsdkReturnCode +PsdkMediaFile_GetDataScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_DestroyScreenNail_JPG(struct _PsdkMediaFile *mediaFileHandle); + +#ifdef __cplusplus +} +#endif + +#endif // PSDK_MEIDA_FILE_JPG_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.c b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.c new file mode 100644 index 0000000..515a712 --- /dev/null +++ b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.c @@ -0,0 +1,261 @@ +/** + ******************************************************************** + * @file psdk_media_file_MP4.c + * @version V1.0.0 + * @date 2019/01/01 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_media_file_mp4.h" +#include "psdk_media_file_core.h" +#include +#include +#include +#include +#include +#include "psdk_platform.h" +#include "utils/util_time.h" +#include "utils/util_file.h" + +/* Private constants ---------------------------------------------------------*/ + +#define MP4_FILE_SUFFIX ".mp4" +#define MP4_TEMP_FILE_TEMPLATE_STR "MP4_TEMP_XXXXXX.jpg" +#define MP4_TEMP_FILE_PATH_MAX_LEN 50 +#define FFMPEG_CMD_BUF_SIZE (PSDK_MEDIA_FILE_PATH_LEN_MAX + 256) + +#define MP4_THM_SCALE_CFG_STR "scale=100:-1" +#define MP4_SCR_SCALE_CFG_STR "scale=600:-1" + +/* Private types -------------------------------------------------------------*/ +typedef struct { + FILE *tempFile; + char tempfilePath[MP4_TEMP_FILE_PATH_MAX_LEN]; +} T_PsdkMP4TempPicPriv; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkMediaFile_CreateTempPicPriv_MP4(const char *srcFilePath, const char *scaleCfgStr, + T_PsdkMP4TempPicPriv **pTempPicPrivHandle); +static T_PsdkReturnCode PsdkMediaFile_DestroyTempPicPriv_MP4(T_PsdkMP4TempPicPriv *tempPicPrivHandle); + +/* Private values ------------------------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ +bool PsdkMediaFile_IsSupported_MP4(const char *filePath) +{ + if (filePath == NULL) { + PsdkLogger_UserLogError("input parameter is null error"); + return false; + } + + if (strcmp(&filePath[strlen(filePath) - 4], MP4_FILE_SUFFIX) == 0) { + return true; + } + + return false; +} + +T_PsdkReturnCode PsdkMediaFile_GetAttrFunc_MP4(struct _PsdkMediaFile *mediaFileHandle, + T_PsdkCameraMediaFileAttr *mediaFileAttr) +{ + FILE *fp; + char ffmpegCmdStr[FFMPEG_CMD_BUF_SIZE]; + float hour, minute, second; + char tempTailStr[128]; + int ret; + T_PsdkReturnCode psdkStat; + + snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" 2>&1 | grep \"Duration\"", mediaFileHandle->filePath); + fp = popen(ffmpegCmdStr, "r"); + + if (fp == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + ret = fscanf(fp, " Duration: %f:%f:%f,%127s", &hour, &minute, &second, tempTailStr); + if (ret <= 0) { + PsdkLogger_UserLogError("MP4 File Get Duration Error\n"); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + + mediaFileAttr->attrVideoDuration = (uint32_t) (hour * 3600 + minute * 60 + second + 0.5); + + /*! The user needs to obtain the frame rate and resolution of the video file by ffmpeg tools. + * Also the frame rate and resolution of video need convert to enum E_PsdkCameraVideoFrameRate or + * E_PsdkCameraVideoResolution. + */ + mediaFileAttr->attrVideoFrameRate = PSDK_CAMERA_VIDEO_FRAME_RATE_30_FPS; + mediaFileAttr->attrVideoResolution = PSDK_CAMERA_VIDEO_RESOLUTION_1920x1080; + + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + +out: + pclose(fp); + + return psdkStat; +} + +T_PsdkReturnCode PsdkMediaFile_GetDataOrigin_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeOrigin_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + return UtilFile_GetFileSizeByPath(mediaFileHandle->filePath, fileSize); +} + +T_PsdkReturnCode PsdkMediaFile_CreateThumbNail_MP4(struct _PsdkMediaFile *mediaFileHandle) +{ + + return PsdkMediaFile_CreateTempPicPriv_MP4(mediaFileHandle->filePath, MP4_THM_SCALE_CFG_STR, + (T_PsdkMP4TempPicPriv **) &mediaFileHandle->mediaFileThm.privThm); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeThumbNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + T_PsdkMP4TempPicPriv *jpgFileThmPriv = (T_PsdkMP4TempPicPriv *) mediaFileHandle->mediaFileThm.privThm; + + return UtilFile_GetFileSize(jpgFileThmPriv->tempFile, fileSize); +} + +T_PsdkReturnCode +PsdkMediaFile_GetDataThumbNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + T_PsdkMP4TempPicPriv *jpgFileThmPriv = (T_PsdkMP4TempPicPriv *) mediaFileHandle->mediaFileThm.privThm; + + return UtilFile_GetFileData(jpgFileThmPriv->tempFile, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_DestroyThumbNail_MP4(struct _PsdkMediaFile *MediaFileHandle) +{ + return PsdkMediaFile_DestroyTempPicPriv_MP4(MediaFileHandle->mediaFileThm.privThm); +} + +T_PsdkReturnCode PsdkMediaFile_CreateScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle) +{ + return PsdkMediaFile_CreateTempPicPriv_MP4(mediaFileHandle->filePath, MP4_SCR_SCALE_CFG_STR, + (T_PsdkMP4TempPicPriv **) &mediaFileHandle->mediaFileScr.privScr); +} + +T_PsdkReturnCode PsdkMediaFile_GetFileSizeScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize) +{ + T_PsdkMP4TempPicPriv *jpgFileScrPriv = (T_PsdkMP4TempPicPriv *) mediaFileHandle->mediaFileScr.privScr; + + return UtilFile_GetFileSize(jpgFileScrPriv->tempFile, fileSize); +} + +T_PsdkReturnCode +PsdkMediaFile_GetDataScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + T_PsdkMP4TempPicPriv *jpgFileScrPriv = (T_PsdkMP4TempPicPriv *) mediaFileHandle->mediaFileScr.privScr; + + return UtilFile_GetFileData(jpgFileScrPriv->tempFile, offset, len, data, realLen); +} + +T_PsdkReturnCode PsdkMediaFile_DestroyScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle) +{ + return PsdkMediaFile_DestroyTempPicPriv_MP4(mediaFileHandle->mediaFileScr.privScr); +} + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkMediaFile_CreateTempPicPriv_MP4(const char *srcFilePath, const char *scaleCfgStr, + T_PsdkMP4TempPicPriv **pTempPicPrivHandle) +{ + char ffmpeg_cmd[FFMPEG_CMD_BUF_SIZE]; + int cmdRet; + T_PsdkRunTimeStamps tiStart, tiEnd; + T_PsdkMP4TempPicPriv *mp4TempPicFile; + T_PsdkReturnCode psdkStat; + int tempFd; + + tiStart = PsdkUtilTime_GetRunTimeStamps(); + + *pTempPicPrivHandle = PsdkOsal_Malloc(sizeof(T_PsdkMP4TempPicPriv)); + if (*pTempPicPrivHandle == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + mp4TempPicFile = *pTempPicPrivHandle; + + //get temp file name + strcpy(mp4TempPicFile->tempfilePath, MP4_TEMP_FILE_TEMPLATE_STR); + tempFd = mkstemps(mp4TempPicFile->tempfilePath, strlen(MP4_FILE_SUFFIX)); + if (tempFd < 0) { + PsdkLogger_UserLogError("JPG Create Temp File Error, tempFd = %d\n", tempFd); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto err_create_temp; + } + close(tempFd); + unlink(mp4TempPicFile->tempfilePath); + + //ffmpeg cmd send + snprintf(ffmpeg_cmd, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" -vf %s -ss 00:00:00 -vframes 1 %s 1>/dev/null 2>&1", + srcFilePath, scaleCfgStr, mp4TempPicFile->tempfilePath); + + cmdRet = system(ffmpeg_cmd); + + tiEnd = PsdkUtilTime_GetRunTimeStamps(); + + PsdkLogger_UserLogDebug("JPG Create TempFile, RealTime = %ld us\n", tiEnd.realUsec - tiStart.realUsec); + + if (cmdRet != 0) { + PsdkLogger_UserLogError("JPG ffmpeg cmd call error, ret = %d\n", cmdRet); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto err_system_cmd; + } + + //open temp file + mp4TempPicFile->tempFile = fopen(mp4TempPicFile->tempfilePath, "rb+"); + if (mp4TempPicFile->tempFile == NULL) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto err_file_open; + } + + //unlink temp file + unlink(mp4TempPicFile->tempfilePath); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + +err_file_open: + unlink(mp4TempPicFile->tempfilePath); +err_system_cmd: +err_create_temp: + PsdkOsal_Free(*pTempPicPrivHandle); + + return psdkStat; +} + +static T_PsdkReturnCode PsdkMediaFile_DestroyTempPicPriv_MP4(T_PsdkMP4TempPicPriv *tempPicPrivHandle) +{ + fclose(tempPicPrivHandle->tempFile); + PsdkOsal_Free(tempPicPrivHandle); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.h b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.h new file mode 100644 index 0000000..c5d1790 --- /dev/null +++ b/sample/api_sample/camera_media_emu/psdk_media_file_manage/psdk_media_file_mp4.h @@ -0,0 +1,77 @@ +/** + ******************************************************************** + * @file psdk_media_file_MP4.h + * @version V0.0.0 + * @date 2019/01/01 + * @brief This is the header file for "psdk_media_file_MP4.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PSDK_MEDIA_FILE_MP4_H +#define PSDK_MEDIA_FILE_MP4_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include "psdk_media_file_core.h" + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +bool PsdkMediaFile_IsSupported_MP4(const char *filePath); + +T_PsdkReturnCode PsdkMediaFile_GetAttrFunc_MP4(struct _PsdkMediaFile *mediaFileHandle, + T_PsdkCameraMediaFileAttr *mediaFileAttr); + +T_PsdkReturnCode PsdkMediaFile_GetDataOrigin_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeOrigin_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); + +T_PsdkReturnCode PsdkMediaFile_CreateThumbNail_MP4(struct _PsdkMediaFile *mediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeThumbNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); +T_PsdkReturnCode +PsdkMediaFile_GetDataThumbNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_DestroyThumbNail_MP4(struct _PsdkMediaFile *MediaFileHandle); + +T_PsdkReturnCode PsdkMediaFile_CreateScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle); +T_PsdkReturnCode PsdkMediaFile_GetFileSizeScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t *fileSize); +T_PsdkReturnCode +PsdkMediaFile_GetDataScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkMediaFile_DestroyScreenNail_MP4(struct _PsdkMediaFile *mediaFileHandle); + +#ifdef __cplusplus +} +#endif + +#endif // PSDK_MEDIA_FILE_MP4_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/camera_media_emu/test_payload_cam_media.c b/sample/api_sample/camera_media_emu/test_payload_cam_media.c new file mode 100644 index 0000000..740ff75 --- /dev/null +++ b/sample/api_sample/camera_media_emu/test_payload_cam_media.c @@ -0,0 +1,1874 @@ +/** + ******************************************************************** + * @file test_payload_cam_media.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "test_payload_cam_media.h" + +#if PSDK_ARCH_SYS_LINUX + +#include +#include +#include +#include +#include "psdk_logger.h" +#include "camera_media_emu/psdk_media_file_manage/psdk_media_file_core.h" +#include "utils/util_time.h" +#include "utils/util_file.h" +#include "utils/util_misc.h" +#include "utils/util_buffer.h" + + + +/* Private constants ---------------------------------------------------------*/ +#define PLAYBACK_TIME_STR_BUF_SIZE 50 +#define FFMPEG_CMD_BUF_SIZE (PSDK_MEDIA_FILE_PATH_LEN_MAX + 256) + +#define PSDK_MEDIA_FILE_PATH "../../../../../api_sample/camera_media_emu/media_file/" + +#define SEND_VIDEO_TASK_FREQ 120 +#define VIDEO_FRAME_MAX_COUNT 18000 // max video duration 10 minutes +#define VIDEO_FRAME_AUD_LEN 6 +#define VIDEO_FILE_PATH "../../../../../api_sample/camera_media_emu/media_file/PSDK_0006.h264" + +#define DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN 65000 + +/* Private types -------------------------------------------------------------*/ +typedef enum { + TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_STOP = 0, + TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_PAUSE = 1, + TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_START = 2, +} E_TestPayloadCameraPlaybackCommand; + +typedef struct { + uint8_t isInPlayProcess; + uint16_t videoIndex; + char filePath[PSDK_MEDIA_FILE_PATH_LEN_MAX]; + uint32_t videoLengthMs; + uint64_t startPlayTimestampsUs; + uint64_t playPosMs; +} T_PsdkPlaybackInfo; + +typedef struct { + E_TestPayloadCameraPlaybackCommand command; + uint32_t timeMs; + char path[PSDK_MEDIA_FILE_PATH_LEN_MAX]; +} T_TestPayloadCameraPlaybackCommand; + +typedef struct { + float durationS; + uint32_t positionInFile; + uint32_t size; +} T_TestPayloadCameraVideoFrameInfo; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkPlayback_StopPlay(T_PsdkPlaybackInfo *playbackInfo); +static T_PsdkReturnCode PsdkPlayback_PausePlay(T_PsdkPlaybackInfo *playbackInfo); +static T_PsdkReturnCode PsdkPlayback_SetPlayFile(T_PsdkPlaybackInfo *playbackInfo, const char *filePath, + uint16_t index); +static T_PsdkReturnCode PsdkPlayback_SeekPlay(T_PsdkPlaybackInfo *playbackInfo, uint32_t seekPos); +static T_PsdkReturnCode PsdkPlayback_StartPlay(T_PsdkPlaybackInfo *playbackInfo); +static T_PsdkReturnCode PsdkPlayback_GetPlaybackStatus(T_PsdkPlaybackInfo *playbackInfo, + T_PsdkCameraPlaybackStatus *playbackStatus); +static T_PsdkReturnCode PsdkPlayback_GetVideoLengthMs(const char *filePath, uint32_t *videoLengthMs); +static T_PsdkReturnCode PsdkPlayback_StartPlayProcess(const char *filePath, uint32_t playPosMs); +static T_PsdkReturnCode PsdkPlayback_StopPlayProcess(void); +static T_PsdkReturnCode +PsdkPlayback_VideoFileTranscode(const char *inPath, const char *outFormat, char *outPath, uint16_t outPathBufferSize); +static T_PsdkReturnCode +PsdkPlayback_GetFrameInfoOfVideoFile(const char *path, T_TestPayloadCameraVideoFrameInfo *frameInfo, + uint32_t frameInfoBufferCount, uint32_t *frameCount); +static T_PsdkReturnCode PsdkPlayback_GetFrameRateOfVideoFile(const char *path, float *frameRate); +static T_PsdkReturnCode +PsdkPlayback_GetFrameNumberByTime(T_TestPayloadCameraVideoFrameInfo *frameInfo, uint32_t frameCount, + uint32_t *frameNumber, uint32_t timeMs); + + +//用于s_psdkCameraMedia中的回调函数:相机类负载设备的下载回放功能 +static T_PsdkReturnCode GetMediaFileDir(char *dirPath); +static T_PsdkReturnCode GetMediaFileOriginData(const char *filePath, uint32_t offset, uint32_t length, + uint8_t *data); + +static T_PsdkReturnCode CreateMediaFileThumbNail(const char *filePath); +static T_PsdkReturnCode GetMediaFileThumbNailInfo(const char *filePath, T_PsdkCameraMediaFileInfo *fileInfo); +static T_PsdkReturnCode GetMediaFileThumbNailData(const char *filePath, uint32_t offset, uint32_t length, + uint8_t *data); +static T_PsdkReturnCode DestroyMediaFileThumbNail(const char *filePath); + +static T_PsdkReturnCode CreateMediaFileScreenNail(const char *filePath); +static T_PsdkReturnCode GetMediaFileScreenNailInfo(const char *filePath, T_PsdkCameraMediaFileInfo *fileInfo); +static T_PsdkReturnCode GetMediaFileScreenNailData(const char *filePath, uint32_t offset, uint32_t length, + uint8_t *data); +static T_PsdkReturnCode DestroyMediaFileScreenNail(const char *filePath); + +static T_PsdkReturnCode DeleteMediaFile(char *filePath); +static T_PsdkReturnCode SetMediaPlaybackFile(const char *filePath); +static T_PsdkReturnCode StartMediaPlayback(void); +static T_PsdkReturnCode StopMediaPlayback(void); +static T_PsdkReturnCode PauseMediaPlayback(void); +static T_PsdkReturnCode SeekMediaPlayback(uint32_t playbackPosition); +static T_PsdkReturnCode GetMediaPlaybackStatus(T_PsdkCameraPlaybackStatus *status); + +static T_PsdkReturnCode StartDownloadNotification(void); +static T_PsdkReturnCode StopDownloadNotification(void); + +static void *UserCameraMedia_SendVideoTask(void *arg); +static void *UserCameraMedia_SendVideoTask_tc(void *arg); + +/* Private variables -------------------------------------------------------------*/ +static T_PsdkCameraMediaDownloadPlaybackHandler s_psdkCameraMedia = {0};//控制相机类负载设备执行媒体文件下载回放功能 +static T_PsdkPlaybackInfo s_playbackInfo = {0};//非常重要的变量!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +static T_PsdkTaskHandle s_userSendVideoThread; +static T_UtilBuffer s_mediaPlayCommandBufferHandler = {0};//非常重要的变量,用户自定义功能读取此变量中的命令执行相应的操作!!!!!!!!!!!!!!!!!!! +static T_PsdkMutexHandle s_mediaPlayCommandBufferMutex = {0}; +static uint8_t s_mediaPlayCommandBuffer[sizeof(T_TestPayloadCameraPlaybackCommand) * 32] = {0}; +static const char *s_frameKeyChar = "[PACKET]"; +static const char *s_frameDurationTimeKeyChar = "duration_time"; +static const char *s_framePositionKeyChar = "pos"; +static const char *s_frameSizeKeyChar = "size"; +static T_PsdkMediaFileHandle s_mediaFileThumbNailHandle; +static T_PsdkMediaFileHandle s_mediaFileScreenNailHandle; +static const uint8_t s_frameAudInfo[VIDEO_FRAME_AUD_LEN] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10}; + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_CameraMediaInit(void) +{ + T_PsdkReturnCode psdkStat; + + //s_psdkCameraMedia(类型为T_PsdkCameraMediaDownloadPlaybackHandler)是下载回放功能 + + // 实现获取媒体文件信息的功能 + s_psdkCameraMedia.GetMediaFileDir = GetMediaFileDir; + s_psdkCameraMedia.GetMediaFileOriginInfo = PsdkTest_CameraMediaGetFileInfo;//非常重要!!!!!获取视频文件信息(类型、帧率、分辨率等) + s_psdkCameraMedia.GetMediaFileOriginData = GetMediaFileOriginData;//获取视频文件数据 + // 实现获取媒体文件缩略图的功能 + s_psdkCameraMedia.CreateMediaFileThumbNail = CreateMediaFileThumbNail; + s_psdkCameraMedia.GetMediaFileThumbNailInfo = GetMediaFileThumbNailInfo; + s_psdkCameraMedia.GetMediaFileThumbNailData = GetMediaFileThumbNailData; + s_psdkCameraMedia.DestroyMediaFileThumbNail = DestroyMediaFileThumbNail; + // 实现获取媒体文件截屏图的功能 + s_psdkCameraMedia.CreateMediaFileScreenNail = CreateMediaFileScreenNail; + s_psdkCameraMedia.GetMediaFileScreenNailInfo = GetMediaFileScreenNailInfo; + s_psdkCameraMedia.GetMediaFileScreenNailData = GetMediaFileScreenNailData; + s_psdkCameraMedia.DestroyMediaFileScreenNail = DestroyMediaFileScreenNail; + // 实现删除媒体文件的功能 + s_psdkCameraMedia.DeleteMediaFile = DeleteMediaFile; + // 实现控制媒体文件回放的功能 + s_psdkCameraMedia.SetMediaPlaybackFile = SetMediaPlaybackFile; + s_psdkCameraMedia.StartMediaPlayback = StartMediaPlayback;//主要作用是将命令写入到s_mediaPlayCommandBufferHandler + s_psdkCameraMedia.StopMediaPlayback = StopMediaPlayback;//主要作用是将命令写入到s_mediaPlayCommandBufferHandler + s_psdkCameraMedia.PauseMediaPlayback = PauseMediaPlayback;//主要作用是将命令写入到s_mediaPlayCommandBufferHandler + s_psdkCameraMedia.SeekMediaPlayback = SeekMediaPlayback; + s_psdkCameraMedia.GetMediaPlaybackStatus = GetMediaPlaybackStatus; + // 实现下载媒体文件的功能 + s_psdkCameraMedia.StartDownloadNotification = StartDownloadNotification; + s_psdkCameraMedia.StopDownloadNotification = StopDownloadNotification; + + if (PsdkOsal_MutexCreate(&s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex create error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + UtilBuffer_Init(&s_mediaPlayCommandBufferHandler, s_mediaPlayCommandBuffer, sizeof(s_mediaPlayCommandBuffer));//!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + //注册相机类负载设备的下载回放功能 + psdkStat = PsdkPayloadCamera_RegMediaDownloadPlaybackHandler(&s_psdkCameraMedia); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk camera media function init error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //创建线程执行用户自定义函数!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + if (PsdkOsal_TaskCreate(&s_userSendVideoThread, UserCameraMedia_SendVideoTask_tc, "user_camera_media_task", 2048, + NULL) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user send video task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_CameraMediaGetFileInfo(const char *filePath, T_PsdkCameraMediaFileInfo *fileInfo) +{ + T_PsdkReturnCode psdkStat; + T_PsdkMediaFileHandle mediaFileHandle; + + psdkStat = PsdkMediaFile_CreateHandle(filePath, &mediaFileHandle);//mediaFileHandle是重点!!!!其中注册了很多处理媒体文件的函数 + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file create handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_GetMediaFileType(mediaFileHandle, &fileInfo->type); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get type error stat:0x%08llX", psdkStat); + goto out; + } + + psdkStat = PsdkMediaFile_GetMediaFileAttr(mediaFileHandle, &fileInfo->mediaFileAttr); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get attr error stat:0x%08llX", psdkStat); + goto out; + } + + psdkStat = PsdkMediaFile_GetFileSizeOrg(mediaFileHandle, &fileInfo->fileSize); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get size error stat:0x%08llX", psdkStat); + goto out; + } + + out: + psdkStat = PsdkMediaFile_DestroyHandle(mediaFileHandle);//通过PsdkOsal_Free释放内存空间 + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file destroy handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return psdkStat; +} + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkPlayback_StopPlay(T_PsdkPlaybackInfo *playbackInfo) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkPlayback_StopPlayProcess(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("stop play error "); + } + + playbackInfo->isInPlayProcess = 0; + playbackInfo->playPosMs = 0; + + return psdkStat; +} + +static T_PsdkReturnCode PsdkPlayback_PausePlay(T_PsdkPlaybackInfo *playbackInfo) +{ + T_PsdkReturnCode psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + T_TestPayloadCameraPlaybackCommand playbackCommand = {0}; + if (playbackInfo->isInPlayProcess) { + playbackCommand.command = TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_PAUSE; + + if (PsdkOsal_MutexLock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (UtilBuffer_GetUnusedSize(&s_mediaPlayCommandBufferHandler) >= sizeof(T_TestPayloadCameraPlaybackCommand)) {//内存空间>=一个命令??????????????????????????????????????????????????????????????????????????? + UtilBuffer_Put(&s_mediaPlayCommandBufferHandler, (const uint8_t *) &playbackCommand, + sizeof(T_TestPayloadCameraPlaybackCommand)); + } else { + PsdkLogger_UserLogError("Media playback command buffer is full."); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + } + + if (PsdkOsal_MutexUnlock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + } + + playbackInfo->isInPlayProcess = 0; + + return psdkStat; +} + +static T_PsdkReturnCode PsdkPlayback_SetPlayFile(T_PsdkPlaybackInfo *playbackInfo, const char *filePath, uint16_t index) +{ + T_PsdkReturnCode psdkStat; + + if (strlen(filePath) > PSDK_MEDIA_FILE_PATH_LEN_MAX) { + PsdkLogger_UserLogError("Psdk playback file path out of length range error\n"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + strcpy(playbackInfo->filePath, filePath); + playbackInfo->videoIndex = index; + + psdkStat = PsdkPlayback_GetVideoLengthMs(filePath, &playbackInfo->videoLengthMs); + + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkPlayback_SeekPlay(T_PsdkPlaybackInfo *playbackInfo, uint32_t seekPos) +{ + T_PsdkRunTimeStamps ti; + T_PsdkReturnCode psdkStat; + + //先暂停播放 + psdkStat = PsdkPlayback_PausePlay(playbackInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("pause play error \n"); + return psdkStat; + } + + //将需要播放的位置写入到变量playbackInfo中 + playbackInfo->playPosMs = seekPos; + psdkStat = PsdkPlayback_StartPlayProcess(playbackInfo->filePath, playbackInfo->playPosMs); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("start playback process error \n"); + return psdkStat; + } + + playbackInfo->isInPlayProcess = 1; + ti = PsdkUtilTime_GetRunTimeStamps(); + playbackInfo->startPlayTimestampsUs = ti.realUsec - playbackInfo->playPosMs * 1000; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkPlayback_StartPlay(T_PsdkPlaybackInfo *playbackInfo) +{ + T_PsdkRunTimeStamps ti; + T_PsdkReturnCode psdkStat; + + if (playbackInfo->isInPlayProcess == 1) { + //already in playing, return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } + + psdkStat = PsdkPlayback_StartPlayProcess(playbackInfo->filePath, playbackInfo->playPosMs); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("start play process error \n"); + return psdkStat; + } + + playbackInfo->isInPlayProcess = 1; + + ti = PsdkUtilTime_GetRunTimeStamps(); + playbackInfo->startPlayTimestampsUs = ti.realUsec - playbackInfo->playPosMs * 1000; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkPlayback_GetPlaybackStatus(T_PsdkPlaybackInfo *playbackInfo, + T_PsdkCameraPlaybackStatus *playbackStatus) +{ + T_PsdkRunTimeStamps timeStamps; + + memset(playbackStatus, 0, sizeof(T_PsdkCameraPlaybackStatus)); + + //update playback pos info + if (playbackInfo->isInPlayProcess) { + timeStamps = PsdkUtilTime_GetRunTimeStamps(); + playbackInfo->playPosMs = (timeStamps.realUsec - playbackInfo->startPlayTimestampsUs) / 1000; + + if (playbackInfo->playPosMs >= playbackInfo->videoLengthMs) { + if (PsdkPlayback_PausePlay(playbackInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + } + } + + //set playback status + if (playbackInfo->isInPlayProcess == 0 && playbackInfo->playPosMs != 0) { + playbackStatus->playbackMode = PSDK_CAMERA_PLAYBACK_MODE_PAUSE; + } else if (playbackInfo->isInPlayProcess) { + playbackStatus->playbackMode = PSDK_CAMERA_PLAYBACK_MODE_PLAY; + } else { + playbackStatus->playbackMode = PSDK_CAMERA_PLAYBACK_MODE_STOP; + } + + playbackStatus->playPosMs = playbackInfo->playPosMs; + playbackStatus->videoLengthMs = playbackInfo->videoLengthMs; + + if (playbackInfo->videoLengthMs != 0) { + playbackStatus->videoPlayProcess = + (playbackInfo->videoLengthMs - playbackInfo->playPosMs) / playbackInfo->videoLengthMs; + } else { + playbackStatus->videoPlayProcess = 0; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkPlayback_GetVideoLengthMs(const char *filePath, uint32_t *videoLengthMs) +{ + FILE *fp; + T_PsdkReturnCode psdkStat; + char ffmpegCmdStr[FFMPEG_CMD_BUF_SIZE]; + float hour, minute, second; + char tempTailStr[128]; + int ret; + + snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" 2>&1 | grep \"Duration\"", filePath); + fp = popen(ffmpegCmdStr, "r"); + + if (fp == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + ret = fscanf(fp, " Duration: %f:%f:%f,%127s", &hour, &minute, &second, tempTailStr); + if (ret <= 0) { + PsdkLogger_UserLogError("MP4 File Get Duration Error\n"); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + + *videoLengthMs = (uint32_t) ((hour * 3600 + minute * 60 + second) * 1000); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + + out: + pclose(fp); + + return psdkStat; +} + +static T_PsdkReturnCode PsdkPlayback_StartPlayProcess(const char *filePath, uint32_t playPosMs) +{ + T_PsdkReturnCode psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + T_TestPayloadCameraPlaybackCommand mediaPlayCommand = {0}; + + mediaPlayCommand.command = TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_START; + mediaPlayCommand.timeMs = playPosMs; + + if (strlen(filePath) >= sizeof(mediaPlayCommand.path)) { + PsdkLogger_UserLogError("File path is too long."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + } + memcpy(mediaPlayCommand.path, filePath, strlen(filePath)); + + if (PsdkOsal_MutexLock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (UtilBuffer_GetUnusedSize(&s_mediaPlayCommandBufferHandler) >= sizeof(T_TestPayloadCameraPlaybackCommand)) { + UtilBuffer_Put(&s_mediaPlayCommandBufferHandler, (const uint8_t *) &mediaPlayCommand, + sizeof(T_TestPayloadCameraPlaybackCommand)); + } else { + PsdkLogger_UserLogError("Media playback command buffer is full."); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + } + + if (PsdkOsal_MutexUnlock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return psdkStat; +} + +static T_PsdkReturnCode PsdkPlayback_StopPlayProcess(void) +{ + T_PsdkReturnCode psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + T_TestPayloadCameraPlaybackCommand playbackCommand = {0}; + + playbackCommand.command = TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_STOP; + + if (PsdkOsal_MutexLock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (UtilBuffer_GetUnusedSize(&s_mediaPlayCommandBufferHandler) >= sizeof(T_TestPayloadCameraPlaybackCommand)) { + UtilBuffer_Put(&s_mediaPlayCommandBufferHandler, (const uint8_t *) &playbackCommand, + sizeof(T_TestPayloadCameraPlaybackCommand)); + } else { + PsdkLogger_UserLogError("Media playback command buffer is full."); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + } + + if (PsdkOsal_MutexUnlock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return psdkStat; +} + +static T_PsdkReturnCode +PsdkPlayback_VideoFileTranscode(const char *inPath, const char *outFormat, char *outPath, uint16_t outPathBufferSize) +{ + T_PsdkReturnCode psdkStat; + T_PsdkReturnCode returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + FILE *fpCommand = NULL; + char ffmpegCmdStr[FFMPEG_CMD_BUF_SIZE]; + char *directory = NULL; + + directory = PsdkOsal_Malloc(PSDK_MEDIA_FILE_PATH_LEN_MAX); + if (directory == NULL) { + PsdkLogger_UserLogError("malloc memory for directory fail."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + psdkStat = PsdkUserUtil_GetCurrentFileDirPath(inPath, PSDK_MEDIA_FILE_PATH_LEN_MAX, directory); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get directory of file error: 0x%08llX.", psdkStat); + returnCode = psdkStat; + goto out; + } + + snprintf(outPath, outPathBufferSize, "%sout.%s", directory, outFormat); + snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE, + "echo \"y\" | ffmpeg -i \"%s\" -codec copy -f \"%s\" \"%s\" 1>/dev/null 2>&1", inPath, + outFormat, outPath); +// printf(ffmpegCmdStr); + fpCommand = popen(ffmpegCmdStr, "r"); + + if (fpCommand == NULL) { + PsdkLogger_UserLogError("execute transcode command fail."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out; + } + + pclose(fpCommand); + + out: + PsdkOsal_Free(directory); + + return returnCode; +} + +static T_PsdkReturnCode +PsdkPlayback_GetFrameInfoOfVideoFile(const char *path, T_TestPayloadCameraVideoFrameInfo *frameInfo, + uint32_t frameInfoBufferCount, uint32_t *frameCount) +{ + long ret; + T_PsdkReturnCode returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + FILE *fpCommand = NULL; + char ffmpegCmdStr[FFMPEG_CMD_BUF_SIZE]; + char *frameInfoString = NULL; + char *frameLocation = NULL; + char frameParameterFormat[50] = {0}; + char *frameDurationTimeLocation = NULL; + float frameDurationTimeS = 0; + uint32_t frameNumber = 0; + char *framePositionLocation = NULL; + uint32_t framePosition = 0; + char *frameSizeLocation = NULL; + uint32_t frameSize = 0; + + frameInfoString = PsdkOsal_Malloc(VIDEO_FRAME_MAX_COUNT * 1024); + if (frameInfoString == NULL) { + PsdkLogger_UserLogError("malloc memory for frame info fail."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + memset(frameInfoString, 0, VIDEO_FRAME_MAX_COUNT * 1024); + + snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE, "ffprobe -show_packets \"%s\" 2>/dev/null", path); + fpCommand = popen(ffmpegCmdStr, "r"); + if (fpCommand == NULL) { + PsdkLogger_UserLogError("execute show frames commands fail."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out2; + } + + ret = (long) fread(frameInfoString, 1, VIDEO_FRAME_MAX_COUNT * 1024, fpCommand); + if (ret < 0) { + PsdkLogger_UserLogError("read show frames commands result error."); + goto out1; + } + frameInfoString[ret] = '\0'; + + frameLocation = frameInfoString; + *frameCount = 0; + while (1) { + // find frame + frameLocation = strstr(frameLocation, s_frameKeyChar); + if (frameLocation == NULL) { + PsdkLogger_UserLogDebug("reach file tail."); + break; + } + + // find frame duration + frameDurationTimeLocation = strstr(frameLocation, s_frameDurationTimeKeyChar); + if (frameDurationTimeLocation == NULL) { + PsdkLogger_UserLogError("can not find pkt_duration_time."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out1; + } + + ret = snprintf(frameParameterFormat, sizeof(frameParameterFormat), "%s=%%f", s_frameDurationTimeKeyChar);//%%表示这里就是一个“%”符,让程序不要理解成格式符 + if (ret < 0) { + PsdkLogger_UserLogError("snprintf frameParameterFormat fail."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out1; + } + + ret = sscanf(frameDurationTimeLocation, frameParameterFormat, &frameDurationTimeS);//将DurationTime从frameDurationTimeLocation读入到frameDurationTimeS + if (ret <= 0) { + PsdkLogger_UserLogError("can not find pkt_duration_time."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out1; + } + frameInfo[frameNumber].durationS = frameDurationTimeS; + + // find frame position + framePositionLocation = strstr(frameLocation, s_framePositionKeyChar); + if (framePositionLocation == NULL) { + PsdkLogger_UserLogError("can not found pkt_pos."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out1; + } + + ret = snprintf(frameParameterFormat, sizeof(frameParameterFormat), "%s=%%d", s_framePositionKeyChar); + if (ret < 0) { + PsdkLogger_UserLogError("snprintf frameParameterFormat fail."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out1; + } + + ret = sscanf(framePositionLocation, frameParameterFormat, &framePosition); + if (ret <= 0) { + PsdkLogger_UserLogError("can not found pkt_pos."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out1; + } + frameInfo[frameNumber].positionInFile = framePosition; + + // find frame size + frameSizeLocation = strstr(frameLocation, s_frameSizeKeyChar); + if (frameSizeLocation == NULL) { + PsdkLogger_UserLogError("can not found pkt_size."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out1; + } + + ret = snprintf(frameParameterFormat, sizeof(frameParameterFormat), "%s=%%d", s_frameSizeKeyChar); + if (ret < 0) { + PsdkLogger_UserLogError("snprintf frameParameterFormat fail."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out1; + } + + ret = sscanf(frameSizeLocation, frameParameterFormat, &frameSize); + if (ret <= 0) { + PsdkLogger_UserLogError("can not find pkt_size."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out1; + } + frameInfo[frameNumber].size = frameSize; + + frameLocation += strlen(s_frameKeyChar);//排除已经找到的帧 + frameNumber++; + (*frameCount)++; + + if (frameNumber >= frameInfoBufferCount) { + PsdkLogger_UserLogError("frame buffer is full."); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + goto out1; + } + } + + out1: + pclose(fpCommand); + + out2: + PsdkOsal_Free(frameInfoString); + + return returnCode; +} + +static T_PsdkReturnCode PsdkPlayback_GetFrameRateOfVideoFile(const char *path, float *frameRate) +{ + int ret; + T_PsdkReturnCode psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + FILE *fpCommand = NULL; + char ffmpegCmdStr[FFMPEG_CMD_BUF_SIZE] = {0}; + int frameRateMolecule = 0; + int frameRateDenominator = 0; + + snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE, "ffprobe -show_streams \"%s\" 2>/dev/null | grep r_frame_rate", path); + fpCommand = popen(ffmpegCmdStr, "r"); + if (fpCommand == NULL) { + PsdkLogger_UserLogError("execute show frame rate command fail."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + ret = fscanf(fpCommand, "r_frame_rate=%d/%d", &frameRateMolecule, &frameRateDenominator); + if (ret <= 0) { + PsdkLogger_UserLogError("can not find frame rate."); + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; + goto out; + } + *frameRate = (float) frameRateMolecule / (float) frameRateDenominator; + + out: + pclose(fpCommand); + + return psdkStat; +} + +static T_PsdkReturnCode +PsdkPlayback_GetFrameNumberByTime(T_TestPayloadCameraVideoFrameInfo *frameInfo, uint32_t frameCount, + uint32_t *frameNumber, uint32_t timeMs) +{ + uint32_t i = 0; + double camulativeTimeS = 0; + double timeS = (double) timeMs / 1000.0; + + for (i = 0; i < frameCount; ++i) { + camulativeTimeS += frameInfo[i].durationS; + + if (camulativeTimeS >= timeS) { + *frameNumber = i; + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND; +} + +static T_PsdkReturnCode GetMediaFileDir(char *dirPath) +{ + strcpy(dirPath, PSDK_MEDIA_FILE_PATH); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetMediaFileOriginData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data) +{ + T_PsdkReturnCode psdkStat; + uint16_t realLen = 0; + T_PsdkMediaFileHandle mediaFileHandle; + + psdkStat = PsdkMediaFile_CreateHandle(filePath, &mediaFileHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file create handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_GetDataOrg(mediaFileHandle, offset, length, data, &realLen); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get data error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_DestroyHandle(mediaFileHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file destroy handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode CreateMediaFileThumbNail(const char *filePath) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkMediaFile_CreateHandle(filePath, &s_mediaFileThumbNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file create handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_CreateThm(s_mediaFileThumbNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file create thumb nail error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetMediaFileThumbNailInfo(const char *filePath, T_PsdkCameraMediaFileInfo *fileInfo) +{ + T_PsdkReturnCode psdkStat; + + USER_UTIL_UNUSED(filePath); + + if (s_mediaFileThumbNailHandle == NULL) { + PsdkLogger_UserLogError("Media file thumb nail handle null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + psdkStat = PsdkMediaFile_GetMediaFileType(s_mediaFileThumbNailHandle, &fileInfo->type); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get type error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_GetMediaFileAttr(s_mediaFileThumbNailHandle, &fileInfo->mediaFileAttr); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get attr error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_GetFileSizeThm(s_mediaFileThumbNailHandle, &fileInfo->fileSize); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get size error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetMediaFileThumbNailData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data) +{ + T_PsdkReturnCode psdkStat; + uint16_t realLen = 0; + + USER_UTIL_UNUSED(filePath); + + if (s_mediaFileThumbNailHandle == NULL) { + PsdkLogger_UserLogError("Media file thumb nail handle null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + psdkStat = PsdkMediaFile_GetDataThm(s_mediaFileThumbNailHandle, offset, length, data, &realLen); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get data error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode DestroyMediaFileThumbNail(const char *filePath) +{ + T_PsdkReturnCode psdkStat; + + USER_UTIL_UNUSED(filePath); + + if (s_mediaFileThumbNailHandle == NULL) { + PsdkLogger_UserLogError("Media file thumb nail handle null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + psdkStat = PsdkMediaFile_DestoryThm(s_mediaFileThumbNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file destroy thumb nail error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_DestroyHandle(s_mediaFileThumbNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file destroy handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode CreateMediaFileScreenNail(const char *filePath) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkMediaFile_CreateHandle(filePath, &s_mediaFileScreenNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file create handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_CreateScr(s_mediaFileScreenNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file create screen nail error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetMediaFileScreenNailInfo(const char *filePath, T_PsdkCameraMediaFileInfo *fileInfo) +{ + T_PsdkReturnCode psdkStat; + + USER_UTIL_UNUSED(filePath); + + if (s_mediaFileScreenNailHandle == NULL) { + PsdkLogger_UserLogError("Media file screen nail handle null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + psdkStat = PsdkMediaFile_GetMediaFileType(s_mediaFileScreenNailHandle, &fileInfo->type); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get type error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_GetMediaFileAttr(s_mediaFileScreenNailHandle, &fileInfo->mediaFileAttr); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get attr error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_GetFileSizeScr(s_mediaFileScreenNailHandle, &fileInfo->fileSize); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get size error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode +GetMediaFileScreenNailData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data) +{ + T_PsdkReturnCode psdkStat; + uint16_t realLen = 0; + + USER_UTIL_UNUSED(filePath); + + if (s_mediaFileScreenNailHandle == NULL) { + PsdkLogger_UserLogError("Media file screen nail handle null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + psdkStat = PsdkMediaFile_GetDataScr(s_mediaFileScreenNailHandle, offset, length, data, &realLen); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file get size error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode DestroyMediaFileScreenNail(const char *filePath) +{ + T_PsdkReturnCode psdkStat; + + USER_UTIL_UNUSED(filePath); + + if (s_mediaFileScreenNailHandle == NULL) { + PsdkLogger_UserLogError("Media file screen nail handle null error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + psdkStat = PsdkMediaFile_DestroyScr(s_mediaFileScreenNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file destroy screen nail error stat:0x%08llX", psdkStat); + return psdkStat; + } + + psdkStat = PsdkMediaFile_DestroyHandle(s_mediaFileScreenNailHandle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file destroy handle error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode DeleteMediaFile(char *filePath) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkFile_Delete(filePath); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Media file delete error stat:0x%08llX", psdkStat); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetMediaPlaybackFile(const char *filePath) +{ + PsdkLogger_UserLogDebug("set media playback file:%s", filePath); + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkPlayback_StopPlay(&s_playbackInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + return psdkStat; + } + + psdkStat = PsdkPlayback_SetPlayFile(&s_playbackInfo, filePath, 0); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + return psdkStat; + } + + psdkStat = PsdkPlayback_StartPlay(&s_playbackInfo);//设置完成回放文件后,就开始回放(播放回放文件) + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StartMediaPlayback(void) +{ + T_PsdkReturnCode psdkStat; + + PsdkLogger_UserLogDebug("start media playback"); + psdkStat = PsdkPlayback_StartPlay(&s_playbackInfo);//s_playbackInfo是哪里设置的???????????????????? + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("start media playback status error, stat:0x%08llX", psdkStat); + return psdkStat; + } + + return psdkStat; +} + +static T_PsdkReturnCode StopMediaPlayback(void) +{ + T_PsdkReturnCode psdkStat; + + PsdkLogger_UserLogDebug("stop media playback"); + psdkStat = PsdkPlayback_StopPlay(&s_playbackInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("stop media playback error, stat:0x%08llX", psdkStat); + return psdkStat; + } + + return psdkStat; +} + +static T_PsdkReturnCode PauseMediaPlayback(void) +{ + T_PsdkReturnCode psdkStat; + + PsdkLogger_UserLogDebug("pause media playback"); + psdkStat = PsdkPlayback_PausePlay(&s_playbackInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("pause media playback error, stat:0x%08llX", psdkStat); + return psdkStat; + } + + return psdkStat; +} + +static T_PsdkReturnCode SeekMediaPlayback(uint32_t playbackPosition) +{ + T_PsdkReturnCode psdkStat; + + PsdkLogger_UserLogDebug("seek media playback:%d", playbackPosition); + psdkStat = PsdkPlayback_SeekPlay(&s_playbackInfo, playbackPosition); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("seek media playback error, stat:0x%08llX", psdkStat); + return psdkStat; + } + + return psdkStat; +} + +static T_PsdkReturnCode GetMediaPlaybackStatus(T_PsdkCameraPlaybackStatus *status) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkPlayback_GetPlaybackStatus(&s_playbackInfo, status); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get playback status error, stat:0x%08llX", psdkStat); + return psdkStat; + } + + status->videoPlayProcess = (uint8_t) (((float) s_playbackInfo.playPosMs / (float) s_playbackInfo.videoLengthMs) * + 100); + + PsdkLogger_UserLogDebug("get media playback status %d %d %d %d", status->videoPlayProcess, status->playPosMs, + status->videoLengthMs, status->playbackMode); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StartDownloadNotification(void) +{ + T_PsdkReturnCode returnCode; + T_PsdkDataChannelBandwidthProportionOfHighspeedChannel channel = {0}; + + PsdkLogger_UserLogDebug("media download start notification."); + + channel.dataStream = 0; + channel.videoStream = 0; + channel.downloadStream = 100; + + returnCode = PsdkDataChannel_SetBandwidthProportionForHighspeedChannel(channel); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set bandwidth proportion for high speed channel error, stat:0x%08llX.", returnCode); + return returnCode; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StopDownloadNotification(void) +{ + T_PsdkReturnCode returnCode; + T_PsdkDataChannelBandwidthProportionOfHighspeedChannel channel = {0}; + + PsdkLogger_UserLogDebug("media download stop notification."); + + channel.dataStream = 10; + channel.videoStream = 60; + channel.downloadStream = 30; + + returnCode = PsdkDataChannel_SetBandwidthProportionForHighspeedChannel(channel); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set bandwidth proportion for high speed channel error, stat:0x%08llX.", returnCode); + return returnCode; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *UserCameraMedia_SendVideoTask(void *arg) +{ + int ret; + T_PsdkReturnCode psdkStat; + static uint32_t sendVideoStep = 0; + FILE *fpFile = NULL; + unsigned long dataLength = 0; + uint16_t lengthOfDataToBeSent = 0; + int lengthOfDataHaveBeenSent = 0; + char *dataBuffer = NULL; + T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//?????????????????????? + uint16_t bufferReadSize = 0; + char *videoFilePath = NULL; + char *transcodedFilePath = NULL;//转换视频编码后的文件路径 + float frameRate = 1.0f; + T_TestPayloadCameraVideoFrameInfo *frameInfo = NULL;//时长,大小,此帧在文件中的位置 + uint32_t frameNumber = 0; + uint32_t frameCount = 0; + uint32_t startTimeMs = 0; + bool sendVideoFlag = true; + bool sendOneTimeFlag = false; + T_PsdkDataChannelState videoStreamState = {0}; + E_PsdkCameraMode mode = PSDK_CAMERA_MODE_SHOOT_PHOTO; + uint32_t frameBufSize = 0; + E_PsdkCameraVideoStreamType videoStreamType; + + USER_UTIL_UNUSED(arg); + + //1. 视频流处理线程初始化: + //https://developer.dji.com/cn/payload-sdk/documentation/camera/video-stream-transmission.html + //使用PSDK 开发的相机类负载设备在创建视频流处理线程后,需要先初始化线程状态并向相机类负载设备申请用于缓存视频流文件的内存空间。 + videoFilePath = PsdkOsal_Malloc(PSDK_MEDIA_FILE_PATH_LEN_MAX); + if (videoFilePath == NULL) { + PsdkLogger_UserLogError("malloc memory for video file path fail."); + exit(1); + } + + transcodedFilePath = PsdkOsal_Malloc(PSDK_MEDIA_FILE_PATH_LEN_MAX); + if (transcodedFilePath == NULL) { + PsdkLogger_UserLogError("malloc memory for transcoded file path fail."); + exit(1); + } + + frameInfo = PsdkOsal_Malloc(VIDEO_FRAME_MAX_COUNT * sizeof(T_TestPayloadCameraVideoFrameInfo)); + if (frameInfo == NULL) { + PsdkLogger_UserLogError("malloc memory for frame info fail."); + exit(1); + } + memset(frameInfo, 0, VIDEO_FRAME_MAX_COUNT * sizeof(T_TestPayloadCameraVideoFrameInfo)); + + psdkStat = PsdkPlayback_StopPlayProcess();//??????????????????????????????????????????????????????????????? + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("stop playback and start liveview error: 0x%08llX.", psdkStat); + exit(1); + } + + while (1) { + PsdkOsal_TaskSleepMs(1000 / SEND_VIDEO_TASK_FREQ); +// PsdkOsal_TaskSleepMs(1000 / 15); + + // response playback command + if (PsdkOsal_MutexLock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + continue; + } + + bufferReadSize = UtilBuffer_Get(&s_mediaPlayCommandBufferHandler, (uint8_t *) &playbackCommand, + sizeof(T_TestPayloadCameraPlaybackCommand));//将参数从s_mediaPlayCommandBufferHandler拷贝到playbackCommand + + if (PsdkOsal_MutexUnlock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + continue; + } + + if (bufferReadSize != sizeof(T_TestPayloadCameraPlaybackCommand))//????????????????????????????? + goto send; + + switch (playbackCommand.command) {//测试开机后不做任何操作的情况下,这个command是什么类型 + case TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_STOP: + snprintf(videoFilePath, PSDK_MEDIA_FILE_PATH_LEN_MAX, "%s", VIDEO_FILE_PATH); + startTimeMs = 0; + sendVideoFlag = true; + sendOneTimeFlag = false; + break; + case TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_PAUSE: + sendVideoFlag = false; + goto send; + case TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_START: + snprintf(videoFilePath, PSDK_MEDIA_FILE_PATH_LEN_MAX, "%s", playbackCommand.path); + startTimeMs = playbackCommand.timeMs; + sendVideoFlag = true; + sendOneTimeFlag = true; + break; + default: + PsdkLogger_UserLogError("playback command invalid: %d.", playbackCommand.command); + sendVideoFlag = false; + goto send; + } + + // video send preprocess + //2. 获取视频流文件信息 + //获取H.264 文件的信息 + psdkStat = PsdkPlayback_VideoFileTranscode(videoFilePath, "h264", transcodedFilePath, + PSDK_MEDIA_FILE_PATH_LEN_MAX);//??????????????????????????????????????????????????????? + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("transcode video file error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkPlayback_GetFrameRateOfVideoFile(transcodedFilePath, &frameRate); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get frame rate of video error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkPlayback_GetFrameInfoOfVideoFile(transcodedFilePath, frameInfo, VIDEO_FRAME_MAX_COUNT, + &frameCount);//???????????????????????????????????????????????????????????????????? + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get frame info of video error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkPlayback_GetFrameNumberByTime(frameInfo, frameCount, &frameNumber, + startTimeMs);//获取指定时间所在帧的位置(帧号) + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get start frame number error: 0x%08llX.", psdkStat); + continue; + } + + if (fpFile != NULL) + fclose(fpFile); + + fpFile = fopen(transcodedFilePath, "rb+");//打开编码后的文件 + if (fpFile == NULL) { + PsdkLogger_UserLogError("open video file fail-1111111111111111111111111111."); + continue; + } + +send: + if (fpFile == NULL) { + PsdkLogger_UserLogError("open video file fail-2222222222222222222222222222."); + continue; + } + + if (sendVideoFlag != true) + continue; + + psdkStat = PsdkTest_CameraGetMode(&mode); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + continue; + } + + psdkStat = PsdkTest_CameraGetVideoStreamType(&videoStreamType); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + continue; + } + + if (mode == PSDK_CAMERA_MODE_PLAYBACK && s_playbackInfo.isInPlayProcess == false) {//???????????????????????????????? + continue; + } + + if (!USER_UTIL_IS_WORK_TURN(sendVideoStep++, frameRate, SEND_VIDEO_TASK_FREQ))//????????????????????????????????? + continue; + + + //3. 解析视频流文件 + //基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。 + frameBufSize = frameInfo[frameNumber].size;//这行几行代码的意思:每一帧的大小不一样 + if (videoStreamType == PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) { + frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN; + } + + dataBuffer = calloc(frameBufSize, 1); + if (dataBuffer == NULL) { + PsdkLogger_UserLogError("malloc fail."); + goto free; + } + + ret = fseek(fpFile, frameInfo[frameNumber].positionInFile, SEEK_SET); + if (ret != 0) { + PsdkLogger_UserLogError("fseek fail."); + goto free; + } + + dataLength = fread(dataBuffer, 1, frameInfo[frameNumber].size, fpFile); + if (dataLength != frameInfo[frameNumber].size) { + PsdkLogger_UserLogError("read data from video file error."); + } else { + PsdkLogger_UserLogDebug("read data from video file success, len = %d B\r\n", dataLength); + } + + + //4. 发送视频流数据 + //基于PSDK 开发的相机类负载设备在解析视频流文件并识别视频流文件的帧头后,调用视频流发送接口PsdkPayloadCamera_SendVideoStream, + //以逐帧的方式发送视频流数据。若视频流格式为DJI H264格式,需要在每一帧的最后增加AUD信息,用于标识一帧的结束。 + if (videoStreamType == PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) { + memcpy(&dataBuffer[frameInfo[frameNumber].size], s_frameAudInfo, VIDEO_FRAME_AUD_LEN); + dataLength = dataLength + VIDEO_FRAME_AUD_LEN; + } + +// for(int i=0;i= frameCount) { + PsdkLogger_UserLogDebug("reach file tail."); + frameNumber = 0; + + if (sendOneTimeFlag == true) + sendVideoFlag = false; + } + + + //5. 获取视频流状态 + //使用PSDK 开发的相机类负载设备能够获取视频流发送的实时状态,方便用户调整视频流的码率,确保图传画面的稳定显示。 + psdkStat = PsdkPayloadCamera_GetVideoStreamState(&videoStreamState); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogDebug( + "video stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController:%d busyState: %d.", + videoStreamState.realtimeBandwidthLimit, videoStreamState.realtimeBandwidthBeforeFlowController, + videoStreamState.realtimeBandwidthAfterFlowController, + videoStreamState.busyState); + } else { + PsdkLogger_UserLogError("get video stream state error."); + } + +free: + free(dataBuffer); + } +} + +//tc改动 +static void *UserCameraMedia_SendVideoTask_tc(void *arg) +{ + int ret; + T_PsdkReturnCode psdkStat; + static uint32_t sendVideoStep = 0; + FILE *fpFile = NULL; + unsigned long dataLength = 0; + uint16_t lengthOfDataToBeSent = 0; + int lengthOfDataHaveBeenSent = 0; + char *dataBuffer = NULL; + T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//?????????????????????? + uint16_t bufferReadSize = 0; + char *videoFilePath = NULL; + char *transcodedFilePath = NULL;//转换视频编码后的文件路径 + float frameRate = 1.0f; + T_TestPayloadCameraVideoFrameInfo *frameInfo = NULL;//时长,大小,此帧在文件中的位置 + uint32_t frameNumber = 0; + uint32_t frameCount = 0; + uint32_t startTimeMs = 0; + bool sendVideoFlag = true; + bool sendOneTimeFlag = false; + T_PsdkDataChannelState videoStreamState = {0}; + E_PsdkCameraMode mode = PSDK_CAMERA_MODE_SHOOT_PHOTO; + uint32_t frameBufSize = 0; + E_PsdkCameraVideoStreamType videoStreamType; + + USER_UTIL_UNUSED(arg); + + //1. 视频流处理线程初始化: + //https://developer.dji.com/cn/payload-sdk/documentation/camera/video-stream-transmission.html + //使用PSDK 开发的相机类负载设备在创建视频流处理线程后,需要先初始化线程状态并向相机类负载设备申请用于缓存视频流文件的内存空间。 + videoFilePath = PsdkOsal_Malloc(PSDK_MEDIA_FILE_PATH_LEN_MAX); + if (videoFilePath == NULL) { + PsdkLogger_UserLogError("malloc memory for video file path fail."); + exit(1); + } + + transcodedFilePath = PsdkOsal_Malloc(PSDK_MEDIA_FILE_PATH_LEN_MAX); + if (transcodedFilePath == NULL) { + PsdkLogger_UserLogError("malloc memory for transcoded file path fail."); + exit(1); + } + + frameInfo = PsdkOsal_Malloc(VIDEO_FRAME_MAX_COUNT * sizeof(T_TestPayloadCameraVideoFrameInfo)); + if (frameInfo == NULL) { + PsdkLogger_UserLogError("malloc memory for frame info fail."); + exit(1); + } + memset(frameInfo, 0, VIDEO_FRAME_MAX_COUNT * sizeof(T_TestPayloadCameraVideoFrameInfo)); + + psdkStat = PsdkPlayback_StopPlayProcess();//??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("stop playback and start liveview error: 0x%08llX.", psdkStat); + exit(1); + } + + /*tc111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111*/ +// int ret; + int have_video = 0, have_audio = 0; + int encode_video = 0, encode_audio = 0; + AVDictionary *opt = NULL; + int i; + + /*添加摄像头******************************************************************************************************************************/ + + char *dev_name = "/dev/video4"; + + //输入文件格式 + AVFormatContext *v_ifmtCtx; + v_ifmtCtx = avformat_alloc_context(); + + AVInputFormat *ifmt=av_find_input_format("video4linux2"); + + avdevice_register_all(); + + ret = avformat_open_input(&v_ifmtCtx, dev_name, ifmt, NULL);//根据摄像头名字(dev_name)和格式(ifmt) 打开流(摄像头,v_ifmtCtx) + if(ret!=0) + { + printf("无法打开摄像头输入流:%d\n",ret); + return -1; + } +// printf("摄像头输入流的封装格式为:%s\n",ifmt->name);//因为ifmt=null,所以此行代码出现段错误 + + //input video initialize + if(avformat_find_stream_info(v_ifmtCtx,NULL)<0)//获取流(摄像头)的信息 + { + printf("找不到流信息.\n"); + return -1; + } + + + int videoindex = -1; + for (i = 0; i < v_ifmtCtx->nb_streams; i++) + { + if (v_ifmtCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) + { + videoindex = i; + break; + } + } + if(videoindex==-1) + { + printf("找不到视频流。\n"); + return -1; + } + + //获取帧率信息 + int aa = v_ifmtCtx->streams[videoindex]->r_frame_rate.num; + int bb = v_ifmtCtx->streams[videoindex]->r_frame_rate.den; + double dInputFps = v_ifmtCtx->streams[videoindex]->r_frame_rate.num*1.0 / v_ifmtCtx->streams[videoindex]->r_frame_rate.den; + printf("摄像头的帧率%d\n",(int)dInputFps); + + + //视频流的编解码器 + AVCodecContext *pCodecCtx; + AVCodec *pCodec; + + pCodec=avcodec_find_decoder(v_ifmtCtx->streams[videoindex]->codecpar->codec_id); + printf("编码器名字:%%s\n",pCodec->name); + + if(pCodec==NULL) + { + printf("找不到编解码器。\n"); + return -1; + } + + // pCodecCtx=v_ifmtCtx->streams[videoindex]->codecpar;//老版api方式,新版放弃 +// pCodecCtx=avcodec_alloc_context3(NULL); + pCodecCtx=avcodec_alloc_context3(pCodec);//tc + if (pCodecCtx == NULL) + { + printf("Could not allocate AVCodecContext\n"); + return -1; + } + avcodec_parameters_to_context(pCodecCtx, v_ifmtCtx->streams[videoindex]->codecpar); + + if(avcodec_open2(pCodecCtx, pCodec,NULL)<0) + { + printf("无法打开编解码器。\n"); + return -1; + } + + + AVFrame *pFrame,*pFrameYUV; + pFrame=av_frame_alloc(); + pFrameYUV=av_frame_alloc(); + + + + unsigned char *out_buffer=(unsigned char *)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height,16)); +// av_image_fill_arrays((AVPicture *)pFrameYUV->data,(AVPicture *)pFrameYUV->linesize, out_buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height,16); + av_image_fill_arrays(pFrameYUV->data,pFrameYUV->linesize, out_buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height,16); + + video_width=pCodecCtx->width; + video_height=pCodecCtx->height; + printf("摄像头尺寸(WxH): %d x %d \n",pCodecCtx->width, pCodecCtx->height); + + //tc: + pFrameYUV->format = AV_PIX_FMT_YUV420P; + pFrameYUV->width = video_width; + pFrameYUV->height = video_height; + + struct SwsContext *img_convert_ctx; + img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL); + + IntputDev video_input={0}; + + AVPacket *in_packet=(AVPacket *)av_malloc(sizeof(AVPacket)); + video_input.img_convert_ctx=img_convert_ctx; + video_input.in_packet=in_packet; + video_input.pCodecCtx=pCodecCtx; + video_input.pCodec=pCodec; + video_input.v_ifmtCtx=v_ifmtCtx; + video_input.videoindex=videoindex; + video_input.pFrame=pFrame; + video_input.pFrameYUV=pFrameYUV; + + /*添加摄像头结束*******************************************************************************************************************************************/ + + /*添加输出信息*******************************************************************************************************************************************/ +// if (argc <= 2) { +// fprintf(stderr, "Usage: %s \n", argv[0]);//libx264 +// exit(0); +// } + const char *filename, *codec_name; + const AVCodec *codec; + AVCodecContext *c= NULL; +// int i, ret, x, y; + FILE *f; + AVFrame *frame; + AVPacket *pkt; + +// filename = argv[1]; +// codec_name = argv[2]; + + filename = "delete.h264"; + codec_name = "libx264"; + + + + /* find the mpeg1video encoder */ + codec = avcodec_find_encoder_by_name(codec_name); + if (!codec) { + fprintf(stderr, "Codec '%s' not found\n", codec_name); + exit(1); + } + + c = avcodec_alloc_context3(codec); + if (!c) { + fprintf(stderr, "Could not allocate video codec context\n"); + exit(1); + } + + pkt = av_packet_alloc(); + if (!pkt) + exit(1); + + c->codec_id = codec->id; + c->bit_rate = 400000; //平均比特率,例子代码默认值是400000 + /* 分辨率必须是2的倍数。*/ + c->width=video_width; + c->height=video_height; + + + /*时基:这是基本的时间单位(以秒为单位) + *表示其中的帧时间戳。 对于固定fps内容, + *时基应为1 /framerate,时间戳增量应为 + *等于1。*/ + c->time_base = (AVRational){1, 15}; + c->framerate = (AVRational){15, 1}; + c->gop_size = 15; /* emit one intra frame every twelve frames at most */ + c->pix_fmt = AV_PIX_FMT_YUV420P; + + c->max_b_frames = 0; + av_opt_set(c->priv_data, "tune", "zerolatency", 0);//解决编码延时 + av_opt_set(c->priv_data, "preset", "superfast", 0); + + + if(c->codec_id == AV_CODEC_ID_MPEG2VIDEO) + { + /* 只是为了测试,我们还添加了B帧 */ + c->max_b_frames = 2; + } + if(c->codec_id == AV_CODEC_ID_MPEG1VIDEO) + { + /*需要避免使用其中一些系数溢出的宏块。 + *普通视频不会发生这种情况,因为 + *色度平面的运动与亮度平面不匹配。 */ + c->mb_decision = 2; + } + + /* open it */ + ret = avcodec_open2(c, codec, NULL); + if (ret < 0) { + fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret)); + exit(1); + } + + AVFrame *frame_tmp; + char *data; + int datasize; + clock_t start,finish; + /*tc222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222*/ + + while (1) { + // response playback command + if (PsdkOsal_MutexLock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + continue; + } + + bufferReadSize = UtilBuffer_Get(&s_mediaPlayCommandBufferHandler, (uint8_t *) &playbackCommand, + sizeof(T_TestPayloadCameraPlaybackCommand));//将参数从s_mediaPlayCommandBufferHandler拷贝到playbackCommand + + if (PsdkOsal_MutexUnlock(s_mediaPlayCommandBufferMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + continue; + } + + if (bufferReadSize != sizeof(T_TestPayloadCameraPlaybackCommand))//????????????????????????????? + goto send; + + switch (playbackCommand.command) {//(1)测试开机后不做任何操作的情况下,这个command是什么类型;(2)这个switch有啥用???????????????????????????????????????? + case TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_STOP: + snprintf(videoFilePath, PSDK_MEDIA_FILE_PATH_LEN_MAX, "%s", VIDEO_FILE_PATH); + startTimeMs = 0; + sendVideoFlag = true; + sendOneTimeFlag = false; + break; + case TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_PAUSE: + sendVideoFlag = false; + goto send; + case TEST_PAYLOAD_CAMERA_MEDIA_PLAY_COMMAND_START: + snprintf(videoFilePath, PSDK_MEDIA_FILE_PATH_LEN_MAX, "%s", playbackCommand.path); + startTimeMs = playbackCommand.timeMs; + sendVideoFlag = true; + sendOneTimeFlag = true; + break; + default: + PsdkLogger_UserLogError("playback command invalid: %d.", playbackCommand.command); + sendVideoFlag = false; + goto send; + } + + // video send preprocess + //2. 获取视频流文件信息 + //获取H.264 文件的信息 + psdkStat = PsdkPlayback_VideoFileTranscode(videoFilePath, "h264", transcodedFilePath, + PSDK_MEDIA_FILE_PATH_LEN_MAX);//将输入视频文件(videoFilePath)编码为h264,并写到视频文件中(transcodedFilePath) + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("transcode video file error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkPlayback_GetFrameRateOfVideoFile(transcodedFilePath, &frameRate); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get frame rate of video error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkPlayback_GetFrameInfoOfVideoFile(transcodedFilePath, frameInfo, VIDEO_FRAME_MAX_COUNT, + &frameCount);//获取每一帧的信息并存入frameInfo,frameCount代表此文件共有多少帧 + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get frame info of video error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkPlayback_GetFrameNumberByTime(frameInfo, frameCount, &frameNumber, + startTimeMs);//获取指定时间所在帧的位置(帧号) + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get start frame number error: 0x%08llX.", psdkStat); + continue; + } + + if (fpFile != NULL) + fclose(fpFile); + + fpFile = fopen(transcodedFilePath, "rb+");//打开编码后的文件 + if (fpFile == NULL) { + PsdkLogger_UserLogError("11111open video file fail."); + continue; + } + + + send: + //tc11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 + + frame_tmp=get_video_frame(&video_input); + +// encode(c, frame_tmp, pkt, &data, &datasize); + data = encode2(c, frame_tmp, pkt, &datasize); + + if(data == NULL) + { +// printf("编码后数据为空!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + continue; + } + + //tc22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 + +// if (fpFile == NULL) { +// +// PsdkLogger_UserLogError("22222open video file fail."); +// continue; +// } + +// if (sendVideoFlag != true) +// continue; +// +// psdkStat = PsdkTest_CameraGetMode(&mode); +// if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { +// continue; +// } +// +// psdkStat = PsdkTest_CameraGetVideoStreamType(&videoStreamType); +// if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { +// continue; +// } +// +// if (mode == PSDK_CAMERA_MODE_PLAYBACK && s_playbackInfo.isInPlayProcess == false) {//当处于回放模式下,才会向下执行 +// continue; +// } +// +// if (!USER_UTIL_IS_WORK_TURN(sendVideoStep++, frameRate, SEND_VIDEO_TASK_FREQ))//???????????????????????????????????????????????????????????????????????????????????????????? +// continue; + + + //3. 解析视频流文件 + //基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。 +// frameBufSize = frameInfo[frameNumber].size;//这行几行代码的意思:每一帧的大小不一样 + + frameBufSize = datasize; + if (videoStreamType == PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) { + frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN; + } + + dataBuffer = calloc(frameBufSize, 1); + if (dataBuffer == NULL) { + PsdkLogger_UserLogError("malloc fail."); + goto free; + } + +// ret = fseek(fpFile, frameInfo[frameNumber].positionInFile, SEEK_SET); +// if (ret != 0) { +// PsdkLogger_UserLogError("fseek fail."); +// goto free; +// } + +// dataLength = fread(dataBuffer, 1, frameInfo[frameNumber].size, fpFile); +// if (dataLength != frameInfo[frameNumber].size) { +// PsdkLogger_UserLogError("read data from video file error."); +// } else { +// PsdkLogger_UserLogDebug("read data from video file success, len = %d B\r\n", dataLength); +// } + + memcpy(dataBuffer,data,datasize); + dataLength = datasize; + + + //4. 发送视频流数据 + //基于PSDK 开发的相机类负载设备在解析视频流文件并识别视频流文件的帧头后,调用视频流发送接口PsdkPayloadCamera_SendVideoStream, + //以逐帧的方式发送视频流数据。若视频流格式为DJI H264格式,需要在每一帧的最后增加AUD信息,用于标识一帧的结束。 + if (videoStreamType == PSDK_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) { +// memcpy(&dataBuffer[frameInfo[frameNumber].size], s_frameAudInfo, VIDEO_FRAME_AUD_LEN); + + memcpy(&dataBuffer[datasize], s_frameAudInfo, VIDEO_FRAME_AUD_LEN); + + dataLength = dataLength + VIDEO_FRAME_AUD_LEN; + } + + //tc:将视频帧打印出来 +// char *deletestr = calloc(dataLength+5,1); +// memcpy(deletestr, data, datasize); +// printf("正在显示的视频帧:%s\n", deletestr); +// free(deletestr); + +// for(i=0;i= frameCount) { +// PsdkLogger_UserLogDebug("reach file tail."); +// frameNumber = 0; +// +// if (sendOneTimeFlag == true) +// sendVideoFlag = false; +// } + + + //5. 获取视频流状态 + //使用PSDK 开发的相机类负载设备能够获取视频流发送的实时状态,方便用户调整视频流的码率,确保图传画面的稳定显示。 + psdkStat = PsdkPayloadCamera_GetVideoStreamState(&videoStreamState); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogDebug( + "video stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController:%d busyState: %d.", + videoStreamState.realtimeBandwidthLimit, videoStreamState.realtimeBandwidthBeforeFlowController, + videoStreamState.realtimeBandwidthAfterFlowController, + videoStreamState.busyState); + } else { + PsdkLogger_UserLogError("get video stream state error."); + } + + free: + free(dataBuffer); + free(data); + + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +#endif + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/camera_media_emu/test_payload_cam_media.h b/sample/api_sample/camera_media_emu/test_payload_cam_media.h new file mode 100644 index 0000000..21b1661 --- /dev/null +++ b/sample/api_sample/camera_media_emu/test_payload_cam_media.h @@ -0,0 +1,61 @@ +/** + ******************************************************************** + * @file test_payload_cam_media.h + * @version V2.0.0 + * @date 2019/07/01 + * @brief This is the header file for "test_payload_cam_media.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_PAYLOAD_CAM_MEDIA_H +#define TEST_PAYLOAD_CAM_MEDIA_H + +/* Includes ------------------------------------------------------------------*/ +#if PSDK_ARCH_SYS_LINUX + +#include "psdk_typedef.h" +#include "psdk_payload_camera.h" + +//tc开始 +#include "ffmpeg_tc.h" +//tc结束 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_CameraMediaInit(void); +T_PsdkReturnCode PsdkTest_CameraMediaGetFileInfo(const char *filePath, T_PsdkCameraMediaFileInfo *fileInfo); + +#ifdef __cplusplus +} +#endif + +#endif + +#endif // TEST_PAYLOAD_CAM_MEDIA_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/data_channel/test_data_channel.c b/sample/api_sample/data_channel/test_data_channel.c new file mode 100644 index 0000000..7460a42 --- /dev/null +++ b/sample/api_sample/data_channel/test_data_channel.c @@ -0,0 +1,63 @@ +/** + ******************************************************************** + * @file test_data_channel.c + * @version V2.0.0 + * @date 2019/9/30 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_data_channel.h" +#include "psdk_data_channel.h" +#include "psdk_logger.h" + +/* Private constants ---------------------------------------------------------*/ + + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ + + +/* Private variables ---------------------------------------------------------*/ + + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_DataChannelSetBandwidthProportionForHighspeedChannel( + T_PsdkDataChannelBandwidthProportionOfHighspeedChannel bandwidthProportion) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkDataChannel_SetBandwidthProportionForHighspeedChannel(bandwidthProportion); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set bandwidth proportion for high-speed channel error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ + + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/data_channel/test_data_channel.h b/sample/api_sample/data_channel/test_data_channel.h new file mode 100644 index 0000000..db6c5bf --- /dev/null +++ b/sample/api_sample/data_channel/test_data_channel.h @@ -0,0 +1,56 @@ +/** + ******************************************************************** + * @file test_data_channel.h + * @version V2.0.0 + * @date 2019/9/30 + * @brief This is the header file for "test_data_channel.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_DATA_CHANNEL_H +#define TEST_DATA_CHANNEL_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" +#include "psdk_data_channel.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_DataChannelSetBandwidthProportionForHighspeedChannel( + T_PsdkDataChannelBandwidthProportionOfHighspeedChannel bandwidthProportion); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_DATA_CHANNEL_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/data_subscription/test_data_subscription.c b/sample/api_sample/data_subscription/test_data_subscription.c new file mode 100644 index 0000000..9d7b4d3 --- /dev/null +++ b/sample/api_sample/data_subscription/test_data_subscription.c @@ -0,0 +1,173 @@ +/** + ******************************************************************** + * @file test_data_subscription.c + * @version V2.0.0 + * @date 2019/8/15 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include +#include "test_data_subscription.h" +#include "psdk_logger.h" +#include "psdk_platform.h" + +/* Private constants ---------------------------------------------------------*/ +#define DATA_SUBSCRIPTION_TASK_FREQ (1) +#define DATA_SUBSCRIPTION_TASK_STACK_SIZE (2048) + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static void *UserDataSubscription_Task(void *arg); +static T_PsdkReturnCode PsdkTest_DataSubscriptionReceiveQuaternionCallback(const uint8_t *data, uint16_t dataSize, + const T_PsdkDataSubscriptiontTimestamp *timestamp); + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTaskHandle s_userDataSubscriptionThread; + +/* Exported functions definition ---------------------------------------------*/ +//要先订阅消息(PsdkDataSubscription_RegTopicSync),才能获取消息(PsdkDataSubscription_GetValueOfTopicWithTimestamp) +T_PsdkReturnCode PsdkTest_DataSubscriptionInit(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkDataSubscription_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("init data subscription module error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //订阅姿态四元数 + //要先订阅消息(PsdkDataSubscription_RegTopicSync),才能获取消息(PsdkDataSubscription_GetValueOfTopicWithTimestamp) + psdkStat = PsdkDataSubscription_RegTopicSync(PSDK_DATA_SUBSCRIPTION_TOPIC_QUATERNION, 10, + PsdkTest_DataSubscriptionReceiveQuaternionCallback); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Subscribe topic QUATERNION error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //订阅无人机速度 + //要先订阅消息(PsdkDataSubscription_RegTopicSync),才能获取消息(PsdkDataSubscription_GetValueOfTopicWithTimestamp) + psdkStat = PsdkDataSubscription_RegTopicSync(PSDK_DATA_SUBSCRIPTION_TOPIC_VELOCITY, 1, NULL); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Subscribe topic VELOCITY error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + psdkStat = PsdkDataSubscription_RegTopicSync(PSDK_DATA_SUBSCRIPTION_TOPIC_GPS_POSITION, 1, NULL); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Subscribe topic GPS_POSITION error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //创建用户任务 + //要先订阅消息(PsdkDataSubscription_RegTopicSync),才能获取消息(PsdkDataSubscription_GetValueOfTopicWithTimestamp) + if (PsdkOsal_TaskCreate(&s_userDataSubscriptionThread, UserDataSubscription_Task, "user_subscription_task", + DATA_SUBSCRIPTION_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user data subscription task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *UserDataSubscription_Task(void *arg) +{ + T_PsdkReturnCode psdkStat; + T_PsdkDataSubscriptionQuaternion quaternion = {0}; + T_PsdkDataSubscriptionVelocity velocity = {0}; + T_PsdkDataSubscriptiontTimestamp timestamp = {0}; + T_PsdkDataSubscriptionGpsPosition gpsPosition = {0}; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / DATA_SUBSCRIPTION_TASK_FREQ); + + //要先订阅消息(PsdkDataSubscription_RegTopicSync),才能获取消息(PsdkDataSubscription_GetValueOfTopicWithTimestamp) + psdkStat = PsdkDataSubscription_GetValueOfTopicWithTimestamp(PSDK_DATA_SUBSCRIPTION_TOPIC_QUATERNION, + (uint8_t *) &quaternion, + sizeof(T_PsdkDataSubscriptionQuaternion), + ×tamp); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get value of topic quaternion error."); + } else { + PsdkLogger_UserLogDebug("timestamp: millisecond %u microsecond %u.", timestamp.millisecond, + timestamp.microsecond); + PsdkLogger_UserLogDebug("quaternion: %f %f %f %f.", quaternion.q0, quaternion.q1, quaternion.q2, + quaternion.q3); + } + + psdkStat = PsdkDataSubscription_GetValueOfTopicWithTimestamp(PSDK_DATA_SUBSCRIPTION_TOPIC_VELOCITY, + (uint8_t *) &velocity, + sizeof(T_PsdkDataSubscriptionVelocity), + ×tamp); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get value of topic velocity error."); + } else { + PsdkLogger_UserLogDebug("velocity: x %f y %f z %f, healthFlag %d.", velocity.data.x, velocity.data.y, + velocity.data.z, velocity.health); + } + + psdkStat = PsdkDataSubscription_GetValueOfTopicWithTimestamp(PSDK_DATA_SUBSCRIPTION_TOPIC_GPS_POSITION, + (uint8_t *) &gpsPosition, + sizeof(T_PsdkDataSubscriptionGpsPosition), + ×tamp); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get value of topic gps position error."); + } else { + PsdkLogger_UserLogDebug("gps position: x %d y %d z %d.", gpsPosition.x, gpsPosition.y, gpsPosition.z); + }//PsdkLogger_UserLogInfo + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +static T_PsdkReturnCode PsdkTest_DataSubscriptionReceiveQuaternionCallback(const uint8_t *data, uint16_t dataSize, + const T_PsdkDataSubscriptiontTimestamp *timestamp) +{ + T_PsdkDataSubscriptionQuaternion *quaternion = (T_PsdkDataSubscriptionQuaternion *) data; + + USER_UTIL_UNUSED(dataSize); + + PsdkLogger_UserLogDebug("receive quaternion data.");// + + PsdkLogger_UserLogDebug("timestamp: millisecond %u microsecond %u.", timestamp->millisecond, + timestamp->microsecond); + PsdkLogger_UserLogDebug("quaternion: %f %f %f %f.", quaternion->q0, quaternion->q1, quaternion->q2, quaternion->q3); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/data_subscription/test_data_subscription.h b/sample/api_sample/data_subscription/test_data_subscription.h new file mode 100644 index 0000000..8228c1e --- /dev/null +++ b/sample/api_sample/data_subscription/test_data_subscription.h @@ -0,0 +1,55 @@ +/** + ******************************************************************** + * @file test_data_subscription.h + * @version V2.0.0 + * @date 2019/8/15 + * @brief This is the header file for "test_data_subscription.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_DATA_SUBSCRIPTION_H +#define TEST_DATA_SUBSCRIPTION_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" +#include "psdk_data_subscription.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_DataSubscriptionInit(void); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_DATA_SUBSCRIPTION_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/data_transmission/test_data_transmission.c b/sample/api_sample/data_transmission/test_data_transmission.c new file mode 100644 index 0000000..36206a2 --- /dev/null +++ b/sample/api_sample/data_transmission/test_data_transmission.c @@ -0,0 +1,201 @@ +/** + ******************************************************************** + * @file test_data_transmission.c + * @version V2.0.0 + * @date 2019/8/3 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_data_transmission.h" +#include "psdk_data_transmission.h" +#include "psdk_logger.h" +#include "psdk_platform.h" +#include "utils/util_misc.h" + +/* Private constants ---------------------------------------------------------*/ +#define DATA_TRANSMISSION_TASK_FREQ (1) +#define DATA_TRANSMISSION_TASK_STACK_SIZE (2048) + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static void *UserDataTransmission_Task(void *arg); +static T_PsdkReturnCode ReceiveDataFromMobile(const uint8_t *data, uint16_t len); +static T_PsdkReturnCode ReceiveDataFromOnboardComputer(const uint8_t *data, uint16_t len); + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTaskHandle s_userDataTransmissionThread;//线程句柄 + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_DataTransmissionInit(void) +{ + T_PsdkReturnCode psdkStat; + char ipAddr[PSDK_IP_ADDR_STR_SIZE_MAX] = {0}; + uint16_t port = 0; + + psdkStat = PsdkDataTransmission_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("init data transmission module error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //函数能够获取用户在DJI Pilot "文本输入框控件" 中向负载设备发送的信息(编码格式为UTF-8)。 + psdkStat = PsdkDataTransmission_RegReceiveDataFromMobileCallback(ReceiveDataFromMobile); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register receive data from mobile error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + psdkStat = PsdkDataTransmission_RegReceiveDataFromOsdkCallback(ReceiveDataFromOnboardComputer); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register receive data from onboard coputer error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //调用osal层中注册的创建任务的函数来 创建一个任务(在新线程中运行) + if (PsdkOsal_TaskCreate(&s_userDataTransmissionThread, UserDataTransmission_Task, "user_transmission_task", + DATA_TRANSMISSION_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user data transmission task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + psdkStat = PsdkDataTransmission_GetDataStreamRemoteAddress(ipAddr, &port); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogInfo("get data stream remote address: %s_%d", ipAddr, port); + } else { + PsdkLogger_UserLogError("get data stream remote address error."); + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *UserDataTransmission_Task(void *arg) +{ + T_PsdkReturnCode psdkStat; + const uint8_t dataToBeSent[] = "PSDK Data Transmission Test Data.\r\n"; + T_PsdkDataChannelState state = {0}; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / DATA_TRANSMISSION_TASK_FREQ); + + psdkStat = PsdkDataTransmission_SendDataToMobile(dataToBeSent, sizeof(dataToBeSent)); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) + PsdkLogger_UserLogError("send data to mobile error."); + + psdkStat = PsdkDataTransmission_SendDataToOsdk(dataToBeSent, sizeof(dataToBeSent)); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) + PsdkLogger_UserLogError("send data to onboard computer error."); + +#if PSDK_ARCH_SYS_LINUX + psdkStat = PsdkDataTransmission_SendDataStream(dataToBeSent, sizeof(dataToBeSent)); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) + PsdkLogger_UserLogError("send data to data stream error."); +#endif + + psdkStat = PsdkDataTransmission_GetSendToMobileState(&state); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogDebug( + "send to mobile state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.", + state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController, + state.busyState); + } else { + PsdkLogger_UserLogError("get send to mobile channel state error."); + } + + psdkStat = PsdkDataTransmission_GetSendToOsdkState(&state); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogDebug( + "send to onboard computer state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.", + state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController, + state.busyState); + } else { + PsdkLogger_UserLogError("get send to onboard computer channel state error."); + } + +#if PSDK_ARCH_SYS_LINUX + psdkStat = PsdkDataTransmission_GetDataStreamState(&state); + if (psdkStat == PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogDebug( + "data stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, busyState: %d.", + state.realtimeBandwidthLimit, state.realtimeBandwidthBeforeFlowController, state.busyState); + } else { + PsdkLogger_UserLogError("get data stream state error."); + } +#endif + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +static T_PsdkReturnCode ReceiveDataFromMobile(const uint8_t *data, uint16_t len) +{ + char *printData = NULL; + + printData = PsdkOsal_Malloc(len + 1); + if (printData == NULL) { + PsdkLogger_UserLogError("malloc memory for printData fail."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + strncpy(printData, (const char *) data, len); + printData[len] = '\0'; + PsdkLogger_UserLogInfo("receive data from mobile: %s, len:%d.", printData, len); + + PsdkOsal_Free(printData); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode ReceiveDataFromOnboardComputer(const uint8_t *data, uint16_t len) +{ + char *printData = NULL; + + printData = PsdkOsal_Malloc(len + 1); + if (printData == NULL) { + PsdkLogger_UserLogError("malloc memory for printData fail."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + strncpy(printData, (const char *) data, len); + printData[len] = '\0'; + PsdkLogger_UserLogInfo("receive data from onboard computer: %s, len:%d.", printData, len); + + PsdkOsal_Free(printData); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/data_transmission/test_data_transmission.h b/sample/api_sample/data_transmission/test_data_transmission.h new file mode 100644 index 0000000..ccac4d5 --- /dev/null +++ b/sample/api_sample/data_transmission/test_data_transmission.h @@ -0,0 +1,54 @@ +/** + ******************************************************************** + * @file test_data_transmission.h + * @version V2.0.0 + * @date 2019/8/3 + * @brief This is the header file for "test_data_transmission.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_DATA_TRANSMISSION_H +#define TEST_DATA_TRANSMISSION_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_DataTransmissionInit(void); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_DATA_TRANSMISSION_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/gimbal_emu/test_payload_gimbal_emu.c b/sample/api_sample/gimbal_emu/test_payload_gimbal_emu.c new file mode 100644 index 0000000..2cf4ad8 --- /dev/null +++ b/sample/api_sample/gimbal_emu/test_payload_gimbal_emu.c @@ -0,0 +1,1100 @@ +/** + ******************************************************************** + * @file test_payload_gimbal_emu.c + * @version V2.0.0 + * @date 2019/9/19 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "math.h" +#include +#include "test_payload_gimbal_emu.h" +#include "psdk_data_subscription.h" +#include "psdk_logger.h" +#include "psdk_platform.h" +#include "utils/util_misc.h" + +/* Private constants ---------------------------------------------------------*/ +#define PAYLOAD_GIMBAL_EMU_TASK_STACK_SIZE (2048) +#define PAYLOAD_GIMBAL_TASK_FREQ 1000 +#define PAYLOAD_GIMBAL_CALIBRATION_TIME_MS 2000 + +/* Private types -------------------------------------------------------------*/ +typedef enum { + TEST_GIMBAL_CONTROL_TYPE_UNKNOWN = 0, + TEST_GIMBAL_CONTROL_TYPE_SPEED = 1, + TEST_GIMBAL_CONTROL_TYPE_ANGLE = 2, +} E_TestGimbalControlType; + +/* Private functions declaration ---------------------------------------------*/ +static void *UserGimbal_Task(void *arg); +static T_PsdkReturnCode GetSystemState(T_PsdkGimbalSystemState *systemState); +static T_PsdkReturnCode GetAttitudeInformation(T_PsdkGimbalAttitudeInformation *attitudeInformation); +static T_PsdkReturnCode GetCalibrationState(T_PsdkGimbalCalibrationState *calibrationState); +static T_PsdkReturnCode GetRotationSpeed(T_PsdkAttitude3d *rotationSpeed); +static T_PsdkReturnCode GetJointAngle(T_PsdkAttitude3d *jointAngle); +static T_PsdkReturnCode StartCalibrate(void); +static T_PsdkReturnCode SetControllerSmoothFactor(uint8_t smoothingFactor, E_PsdkGimbalAxis axis); +static T_PsdkReturnCode SetPitchRangeExtensionEnabled(bool enabledFlag); +static T_PsdkReturnCode SetControllerMaxSpeedPercentage(uint8_t maxSpeedPercentage, E_PsdkGimbalAxis axis); +static T_PsdkReturnCode RestoreFactorySettings(void); +static T_PsdkReturnCode SetMode(E_PsdkGimbalMode mode); +static T_PsdkReturnCode Reset(E_PsdkGimbalResetMode mode); +static T_PsdkReturnCode FineTuneAngle(T_PsdkAttitude3d fineTuneAngle); +static T_PsdkReturnCode PsdkTest_GimbalAngleLegalization(T_PsdkAttitude3f *attitude, T_PsdkAttitude3d aircraftAttitude, + T_PsdkGimbalReachLimitFlag *reachLimitFlag); +static T_PsdkReturnCode +PsdkTest_GimbalCalculateSpeed(T_PsdkAttitude3d originalAttitude, T_PsdkAttitude3d targetAttitude, uint16_t actionTime, + T_PsdkAttitude3d *speed); +static void PsdkTest_GimbalSpeedLegalization(T_PsdkAttitude3d *speed); +static T_PsdkReturnCode +PsdkTest_GimbalCalculateGroundAttitudeBaseQuaternion(T_PsdkDataSubscriptionQuaternion quaternion, + T_PsdkAttitude3d *attitude); + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTaskHandle s_userGimbalThread; +static T_PsdkGimbalCommonHandler s_commonHandler = {0}; +static T_PsdkGimbalSystemState s_systemState = {0}; +static bool s_rotatingFlag = false; +static T_PsdkMutexHandle s_commonMutex = {0}; + +static T_PsdkGimbalAttitudeInformation s_attitudeInformation = {0}; // unit: 0.1 degree, ground coordination +static T_PsdkAttitude3f s_attitudeHighPrecision = {0}; // unit: 0.1 degree, ground coordination +static T_PsdkGimbalCalibrationState s_calibrationState = {0}; +static T_PsdkAttitude3d s_targetAttitude = {0}; // unit: 0.1 degree, ground coordination +static T_PsdkAttitude3d s_speed = {0}; // unit: 0.1 degree/s, ground coordination +static T_PsdkAttitude3d s_aircraftAttitude = {0}; // unit: 0.1 degree, ground coordination +static T_PsdkAttitude3d s_lastAircraftAttitude = {0}; // unit: 0.1 degree, ground coordination +static E_TestGimbalControlType s_controlType = TEST_GIMBAL_CONTROL_TYPE_UNKNOWN; +static const T_PsdkAttitude3d s_jointAngleLimitMin = {-900, -100, -1800}; // unit: 0.1 degree +static const T_PsdkAttitude3d s_jointAngleLimitMax = {100, 100, 1800}; // unit: 0.1 degree +static const T_PsdkAttitude3d s_eulerAngleLimitMin = {-900, -100, -1800}; // unit: 0.1 degree +static const T_PsdkAttitude3d s_eulerAngleLimitMax = {100, 100, 1800}; // unit: 0.1 degree +static const int32_t s_pitchEulerAngleExtensionMin = -1200; // unit: 0.1 degree +static const int32_t s_pitchEulerAngleExtensionMax = 300; // unit: 0.1 degree +static const T_PsdkAttitude3d s_speedLimit = {1800, 1800, 1800}; // unit: 0.1 degree/s +static uint32_t s_calibrationStartTime = 0; // unit: ms +static T_PsdkMutexHandle s_attitudeMutex = NULL; +static T_PsdkMutexHandle s_calibrationMutex = NULL; + +/* Exported functions definition ---------------------------------------------*/ +/** + * @brief + * @note Gimbal sample rely on aircraft quaternion. + * @return + */ +T_PsdkReturnCode PsdkTest_GimbalInit(void) +{ + T_PsdkReturnCode psdkStat; + + s_systemState.resettingFlag = false; + s_systemState.mountedUpward = false; + s_systemState.blockingFlag = false; + s_systemState.pitchRangeExtensionEnabledFlag = false; + + s_calibrationState.calibratingFlag = false; + s_calibrationState.lastCalibrationResult = true; + + s_commonHandler.GetSystemState = GetSystemState; + s_commonHandler.GetAttitudeInformation = GetAttitudeInformation; + s_commonHandler.GetCalibrationState = GetCalibrationState; + s_commonHandler.GetRotationSpeed = GetRotationSpeed; + s_commonHandler.GetJointAngle = GetJointAngle; + s_commonHandler.Rotate = PsdkTest_GimbalRotate; + s_commonHandler.StartCalibrate = StartCalibrate; + s_commonHandler.SetControllerSmoothFactor = SetControllerSmoothFactor; + s_commonHandler.SetPitchRangeExtensionEnabled = SetPitchRangeExtensionEnabled; + s_commonHandler.SetControllerMaxSpeedPercentage = SetControllerMaxSpeedPercentage; + s_commonHandler.RestoreFactorySettings = RestoreFactorySettings; + s_commonHandler.SetMode = SetMode; + s_commonHandler.Reset = Reset; + s_commonHandler.FineTuneAngle = FineTuneAngle; + + if (PsdkOsal_MutexCreate(&s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex create error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_MutexCreate(&s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex create error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_MutexCreate(&s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex create error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + psdkStat = PsdkGimbal_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("init gimbal module error: 0x%08llX", psdkStat); + } + + psdkStat = PsdkGimbal_RegCommonHandler(&s_commonHandler); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("gimbal register common handler error: 0x%08llX", psdkStat); + } + + if (PsdkOsal_TaskCreate(&s_userGimbalThread, UserGimbal_Task, "user_gimbal_task", + PAYLOAD_GIMBAL_EMU_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user gimbal task create error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_GimbalDeInit(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_TaskDestroy(s_userGimbalThread); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Destroy test gimbal thread error: 0x%08llX.", psdkStat); + return psdkStat; + } + + psdkStat = PsdkGimbal_DeInit(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Deinit gimbal module error: 0x%08llX.", psdkStat); + return psdkStat; + } + + if (PsdkOsal_MutexDestroy(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex destroy error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_MutexDestroy(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex destroy error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_MutexDestroy(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex destroy error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_GimbalRotate(E_PsdkGimbalRotationMode rotationMode, + T_PsdkGimbalRotationProperty rotationProperty, + T_PsdkAttitude3d rotationValue) +{ + T_PsdkReturnCode psdkStat; + T_PsdkReturnCode returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + T_PsdkAttitude3d targetAttitudeDTemp = {0}; + T_PsdkAttitude3f targetAttitudeFTemp = {0}; + T_PsdkAttitude3d speedTemp = {0}; + + PsdkLogger_UserLogDebug("gimbal rotation value invalid flag: pitch %d, roll %d, yaw %d.", + rotationProperty.rotationValueInvalidFlag.pitch, + rotationProperty.rotationValueInvalidFlag.roll, + rotationProperty.rotationValueInvalidFlag.yaw); + + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out2; + } + + switch (rotationMode) { + case PSDK_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE: + PsdkLogger_UserLogDebug("gimbal relative rotate angle: pitch %d, roll %d, yaw %d.", rotationValue.pitch, + rotationValue.roll, rotationValue.yaw); + PsdkLogger_UserLogDebug("gimbal relative rotate action time: %d.", + rotationProperty.relativeAngleRotation.actionTime); + + if (s_rotatingFlag == true) { + PsdkLogger_UserLogWarn("gimbal is rotating."); + goto out1; + } + + targetAttitudeDTemp.pitch = + rotationProperty.rotationValueInvalidFlag.pitch == true ? s_attitudeInformation.attitude.pitch : ( + s_attitudeInformation.attitude.pitch + rotationValue.pitch); + targetAttitudeDTemp.roll = + rotationProperty.rotationValueInvalidFlag.roll == true ? s_attitudeInformation.attitude.roll : ( + s_attitudeInformation.attitude.roll + rotationValue.roll); + targetAttitudeDTemp.yaw = + rotationProperty.rotationValueInvalidFlag.yaw == true ? s_attitudeInformation.attitude.yaw : ( + s_attitudeInformation.attitude.yaw + rotationValue.yaw); + + targetAttitudeFTemp.pitch = targetAttitudeDTemp.pitch; + targetAttitudeFTemp.roll = targetAttitudeDTemp.roll; + targetAttitudeFTemp.yaw = targetAttitudeDTemp.yaw; + PsdkTest_GimbalAngleLegalization(&targetAttitudeFTemp, s_aircraftAttitude, NULL); + targetAttitudeDTemp.pitch = targetAttitudeFTemp.pitch; + targetAttitudeDTemp.roll = targetAttitudeFTemp.roll; + targetAttitudeDTemp.yaw = targetAttitudeFTemp.yaw; + + s_targetAttitude = targetAttitudeDTemp; + s_rotatingFlag = true; + s_controlType = TEST_GIMBAL_CONTROL_TYPE_ANGLE; + + psdkStat = PsdkTest_GimbalCalculateSpeed(s_attitudeInformation.attitude, s_targetAttitude, + rotationProperty.relativeAngleRotation.actionTime, &s_speed); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("calculate gimbal rotation speed error: 0x%08llX.", psdkStat); + returnCode = psdkStat; + goto out1; + } + + break; + case PSDK_GIMBAL_ROTATION_MODE_ABSOLUTE_ANGLE: + PsdkLogger_UserLogDebug("gimbal absolute rotate angle: pitch %d, roll %d, yaw %d.", rotationValue.pitch, + rotationValue.roll, rotationValue.yaw); + PsdkLogger_UserLogDebug("gimbal absolute rotate action time: %d.", + rotationProperty.absoluteAngleRotation.actionTime); + if (rotationProperty.absoluteAngleRotation.jointAngleValid) { + PsdkLogger_UserLogDebug("gimbal joint angles: pitch %d, roll %d, yaw %d.", + rotationProperty.absoluteAngleRotation.jointAngle.pitch, + rotationProperty.absoluteAngleRotation.jointAngle.roll, + rotationProperty.absoluteAngleRotation.jointAngle.yaw); + } + + if (s_rotatingFlag == true) { + PsdkLogger_UserLogWarn("gimbal is rotating."); + goto out1; + } + + targetAttitudeDTemp.pitch = + rotationProperty.rotationValueInvalidFlag.pitch == true ? s_attitudeInformation.attitude.pitch + : rotationValue.pitch; + targetAttitudeDTemp.roll = + rotationProperty.rotationValueInvalidFlag.roll == true ? s_attitudeInformation.attitude.roll + : rotationValue.roll; + targetAttitudeDTemp.yaw = + rotationProperty.rotationValueInvalidFlag.yaw == true ? s_attitudeInformation.attitude.yaw + : rotationValue.yaw; + + targetAttitudeFTemp.pitch = targetAttitudeDTemp.pitch; + targetAttitudeFTemp.roll = targetAttitudeDTemp.roll; + targetAttitudeFTemp.yaw = targetAttitudeDTemp.yaw; + PsdkTest_GimbalAngleLegalization(&targetAttitudeFTemp, s_aircraftAttitude, NULL); + targetAttitudeDTemp.pitch = targetAttitudeFTemp.pitch; + targetAttitudeDTemp.roll = targetAttitudeFTemp.roll; + targetAttitudeDTemp.yaw = targetAttitudeFTemp.yaw; + + s_targetAttitude = targetAttitudeDTemp; + s_rotatingFlag = true; + s_controlType = TEST_GIMBAL_CONTROL_TYPE_ANGLE; + + psdkStat = PsdkTest_GimbalCalculateSpeed(s_attitudeInformation.attitude, s_targetAttitude, + rotationProperty.absoluteAngleRotation.actionTime, &s_speed); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("calculate gimbal rotation speed error: 0x%08llX.", psdkStat); + returnCode = psdkStat; + goto out1; + } + + break; + case PSDK_GIMBAL_ROTATION_MODE_SPEED: + PsdkLogger_UserLogDebug("gimbal rotate speed: pitch %d, roll %d, yaw %d.", rotationValue.pitch, + rotationValue.roll, rotationValue.yaw); + + if (s_rotatingFlag == true && s_controlType == TEST_GIMBAL_CONTROL_TYPE_ANGLE) { + PsdkLogger_UserLogWarn("gimbal is rotating."); + goto out1; + } + + memcpy(&speedTemp, &rotationValue, sizeof(T_PsdkAttitude3d)); + PsdkTest_GimbalSpeedLegalization(&speedTemp); + s_speed = speedTemp; + + if (rotationValue.pitch != 0 || rotationValue.roll != 0 || rotationValue.yaw != 0) { + s_rotatingFlag = true; + s_controlType = TEST_GIMBAL_CONTROL_TYPE_SPEED; + } else { + s_rotatingFlag = false; + } + + break; + default: + PsdkLogger_UserLogError("gimbal rotation mode invalid: %d.", rotationMode); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT; + goto out1; + } + +out1: + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto out2; + } + +out2: + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return returnCode; +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *UserGimbal_Task(void *arg) +{ + T_PsdkReturnCode psdkStat; + static uint32_t step = 0; + T_PsdkDataSubscriptionQuaternion quaternion = {0}; + T_PsdkDataSubscriptiontTimestamp timestamp = {0}; + T_PsdkAttitude3f nextAttitude = {0}; + T_PsdkAttitude3f attitudeFTemp = {0}; + uint32_t currentTime = 0; + uint32_t progressTemp = 0; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / PAYLOAD_GIMBAL_TASK_FREQ); + step++; + + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + continue; + } + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + goto out2; + } + + if (USER_UTIL_IS_WORK_TURN(step, 1, PAYLOAD_GIMBAL_TASK_FREQ)) { + PsdkLogger_UserLogDebug("gimbal attitude: pitch %d, roll %d, yaw %d.", s_attitudeInformation.attitude.pitch, + s_attitudeInformation.attitude.roll, s_attitudeInformation.attitude.yaw); + + PsdkLogger_UserLogDebug("gimbal fine tune: pitch %d, roll %d, yaw %d.", s_systemState.fineTuneAngle.pitch, + s_systemState.fineTuneAngle.roll, s_systemState.fineTuneAngle.yaw); + } + + // update aircraft attitude + if (USER_UTIL_IS_WORK_TURN(step, 50, PAYLOAD_GIMBAL_TASK_FREQ)) { + psdkStat = PsdkDataSubscription_GetValueOfTopicWithTimestamp(PSDK_DATA_SUBSCRIPTION_TOPIC_QUATERNION, + (uint8_t *) &quaternion, + sizeof(T_PsdkDataSubscriptionQuaternion), + ×tamp); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get topic quaternion value error."); + } + + psdkStat = PsdkTest_GimbalCalculateGroundAttitudeBaseQuaternion(quaternion, &s_aircraftAttitude); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("calculate and update aircraft attitude error."); + } + } + + // stable control + switch (s_systemState.gimbalMode) { + case PSDK_GIMBAL_MODE_FREE: + break; + case PSDK_GIMBAL_MODE_FPV: + s_attitudeInformation.attitude.roll += (s_aircraftAttitude.roll - s_lastAircraftAttitude.roll); + s_attitudeInformation.attitude.yaw += (s_aircraftAttitude.yaw - s_lastAircraftAttitude.yaw); + + s_attitudeHighPrecision.roll += (float) (s_aircraftAttitude.roll - s_lastAircraftAttitude.roll); + s_attitudeHighPrecision.yaw += (float) (s_aircraftAttitude.yaw - s_lastAircraftAttitude.yaw); + + if (s_rotatingFlag == true && s_controlType == TEST_GIMBAL_CONTROL_TYPE_ANGLE) { + s_targetAttitude.roll += (s_aircraftAttitude.roll - s_lastAircraftAttitude.roll); + s_targetAttitude.yaw += (s_aircraftAttitude.yaw - s_lastAircraftAttitude.yaw); + } + break; + case PSDK_GIMBAL_MODE_YAW_FOLLOW: + s_attitudeInformation.attitude.yaw += (s_aircraftAttitude.yaw - s_lastAircraftAttitude.yaw); + + s_attitudeHighPrecision.yaw += (float) (s_aircraftAttitude.yaw - s_lastAircraftAttitude.yaw); + + if (s_rotatingFlag == true && s_controlType == TEST_GIMBAL_CONTROL_TYPE_ANGLE) { + s_targetAttitude.yaw += (s_aircraftAttitude.yaw - s_lastAircraftAttitude.yaw); + } + break; + default: + PsdkLogger_UserLogError("gimbal mode invalid: %d.", s_systemState.gimbalMode); + } + s_lastAircraftAttitude = s_aircraftAttitude; + + attitudeFTemp.pitch = s_attitudeInformation.attitude.pitch; + attitudeFTemp.roll = s_attitudeInformation.attitude.roll; + attitudeFTemp.yaw = s_attitudeInformation.attitude.yaw; + PsdkTest_GimbalAngleLegalization(&attitudeFTemp, s_aircraftAttitude, &s_attitudeInformation.reachLimitFlag); + s_attitudeInformation.attitude.pitch = attitudeFTemp.pitch; + s_attitudeInformation.attitude.roll = attitudeFTemp.roll; + s_attitudeInformation.attitude.yaw = attitudeFTemp.yaw; + + PsdkTest_GimbalAngleLegalization(&s_attitudeHighPrecision, s_aircraftAttitude, NULL); + + attitudeFTemp.pitch = s_targetAttitude.pitch; + attitudeFTemp.roll = s_targetAttitude.roll; + attitudeFTemp.yaw = s_targetAttitude.yaw; + PsdkTest_GimbalAngleLegalization(&attitudeFTemp, s_aircraftAttitude, NULL); + s_targetAttitude.pitch = attitudeFTemp.pitch; + s_targetAttitude.roll = attitudeFTemp.roll; + s_targetAttitude.yaw = attitudeFTemp.yaw; + + // rotation + if (s_rotatingFlag != true) + goto out1; + + nextAttitude.pitch = + (float) s_attitudeHighPrecision.pitch + (float) s_speed.pitch / (float) PAYLOAD_GIMBAL_TASK_FREQ; + nextAttitude.roll = + (float) s_attitudeHighPrecision.roll + (float) s_speed.roll / (float) PAYLOAD_GIMBAL_TASK_FREQ; + nextAttitude.yaw = (float) s_attitudeHighPrecision.yaw + (float) s_speed.yaw / (float) PAYLOAD_GIMBAL_TASK_FREQ; + + if (s_controlType == TEST_GIMBAL_CONTROL_TYPE_ANGLE) { + nextAttitude.pitch = + (nextAttitude.pitch - s_targetAttitude.pitch) * s_speed.pitch >= 0 ? s_targetAttitude.pitch + : nextAttitude.pitch; + nextAttitude.roll = (nextAttitude.roll - s_targetAttitude.roll) * s_speed.roll >= 0 ? s_targetAttitude.roll + : nextAttitude.roll; + nextAttitude.yaw = + (nextAttitude.yaw - s_targetAttitude.yaw) * s_speed.yaw >= 0 ? s_targetAttitude.yaw : nextAttitude.yaw; + } + + PsdkTest_GimbalAngleLegalization(&nextAttitude, s_aircraftAttitude, &s_attitudeInformation.reachLimitFlag); + s_attitudeInformation.attitude.pitch = nextAttitude.pitch; + s_attitudeInformation.attitude.roll = nextAttitude.roll; + s_attitudeInformation.attitude.yaw = nextAttitude.yaw; + + s_attitudeHighPrecision.pitch = nextAttitude.pitch; + s_attitudeHighPrecision.roll = nextAttitude.roll; + s_attitudeHighPrecision.yaw = nextAttitude.yaw; + + if (s_controlType == TEST_GIMBAL_CONTROL_TYPE_ANGLE) { + if (memcmp(&s_attitudeInformation.attitude, &s_targetAttitude, sizeof(T_PsdkAttitude3d)) == 0) { + s_rotatingFlag = false; + } + } else if (s_controlType == TEST_GIMBAL_CONTROL_TYPE_SPEED) { + if ((s_attitudeInformation.reachLimitFlag.pitch == true || s_speed.pitch == 0) && + (s_attitudeInformation.reachLimitFlag.roll == true || s_speed.roll == 0) && + (s_attitudeInformation.reachLimitFlag.yaw == true || s_speed.yaw == 0)) { + s_rotatingFlag = false; + } + } + +out1: + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + goto out2; + } + +out2: + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + continue; + } + + psdkStat = PsdkOsal_GetTimeMs(¤tTime); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get current time error: 0x%08llX.", psdkStat); + continue; + } + + if (PsdkOsal_MutexLock(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + continue; + } + + // calibration + if (s_calibrationState.calibratingFlag != true) + goto unlockCalibrationMutex; + + progressTemp = (currentTime - s_calibrationStartTime) * 100 / PAYLOAD_GIMBAL_CALIBRATION_TIME_MS; + if (progressTemp >= 100) { + s_calibrationState.calibratingFlag = false; + s_calibrationState.currentCalibrationProgress = 100; + s_calibrationState.currentCalibrationStage = PSDK_GIMBAL_CALIBRATION_STAGE_COMPLETE; + } + +unlockCalibrationMutex: + if (PsdkOsal_MutexUnlock(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + continue; + } + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +static T_PsdkReturnCode GetSystemState(T_PsdkGimbalSystemState *systemState) +{ + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + *systemState = s_systemState; + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetAttitudeInformation(T_PsdkGimbalAttitudeInformation *attitudeInformation) +{ + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + *attitudeInformation = s_attitudeInformation; + + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetCalibrationState(T_PsdkGimbalCalibrationState *calibrationState) +{ + if (PsdkOsal_MutexLock(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + *calibrationState = s_calibrationState; + + if (PsdkOsal_MutexUnlock(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetRotationSpeed(T_PsdkAttitude3d *rotationSpeed) +{ + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + *rotationSpeed = s_speed; + + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode GetJointAngle(T_PsdkAttitude3d *jointAngle) +{ + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + jointAngle->pitch = s_attitudeInformation.attitude.pitch - s_aircraftAttitude.pitch; + jointAngle->roll = s_attitudeInformation.attitude.roll - s_aircraftAttitude.roll; + jointAngle->yaw = s_attitudeInformation.attitude.yaw - s_aircraftAttitude.yaw; + + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode StartCalibrate(void) +{ + T_PsdkReturnCode psdkStat; + + PsdkLogger_UserLogDebug("start calibrate gimbal."); + + psdkStat = PsdkOsal_GetTimeMs(&s_calibrationStartTime); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get start time error: 0x%08llX.", psdkStat); + } + + if (PsdkOsal_MutexLock(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + s_calibrationState.calibratingFlag = true; + s_calibrationState.currentCalibrationProgress = 0; + s_calibrationState.currentCalibrationStage = PSDK_GIMBAL_CALIBRATION_STAGE_PROCRESSING; + + if (PsdkOsal_MutexUnlock(s_calibrationMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetControllerSmoothFactor(uint8_t smoothingFactor, E_PsdkGimbalAxis axis) +{ + PsdkLogger_UserLogDebug("set gimbal controller smooth factor: factor %d, axis %d.", smoothingFactor, axis); + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (axis == PSDK_GIMBAL_AXIS_PITCH) + s_systemState.smoothFactor.pitch = smoothingFactor; + else if (axis == PSDK_GIMBAL_AXIS_YAW) + s_systemState.smoothFactor.yaw = smoothingFactor; + else + PsdkLogger_UserLogError("axis is not supported."); + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetPitchRangeExtensionEnabled(bool enabledFlag) +{ + PsdkLogger_UserLogDebug("set gimbal pitch range extension enable flag: %d.", enabledFlag); + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + s_systemState.pitchRangeExtensionEnabledFlag = enabledFlag; + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetControllerMaxSpeedPercentage(uint8_t maxSpeedPercentage, E_PsdkGimbalAxis axis) +{ + PsdkLogger_UserLogDebug("set gimbal controller max speed: max speed %d, axis %d.", maxSpeedPercentage, axis); + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (axis == PSDK_GIMBAL_AXIS_PITCH) + s_systemState.maxSpeedPercentage.pitch = maxSpeedPercentage; + else if (axis == PSDK_GIMBAL_AXIS_YAW) + s_systemState.maxSpeedPercentage.yaw = maxSpeedPercentage; + else + PsdkLogger_UserLogError("axis is not supported."); + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode RestoreFactorySettings(void) +{ + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + s_systemState.pitchRangeExtensionEnabledFlag = false; + s_systemState.gimbalMode = PSDK_GIMBAL_MODE_FREE; + memset(&s_systemState.fineTuneAngle, 0, sizeof(s_systemState.fineTuneAngle)); + memset(&s_systemState.smoothFactor, 0, sizeof(s_systemState.smoothFactor)); + s_systemState.maxSpeedPercentage.pitch = 1; + s_systemState.maxSpeedPercentage.yaw = 1; + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode SetMode(E_PsdkGimbalMode mode) +{ + PsdkLogger_UserLogDebug("set gimbal mode: %d.", mode); + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + s_systemState.gimbalMode = mode; + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode Reset(E_PsdkGimbalResetMode mode) +{ + T_PsdkReturnCode psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + T_PsdkAttitude3f attitudeFTemp = {0}; + + PsdkLogger_UserLogDebug("reset gimbal: %d.", mode); + + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto unlock2; + } + + switch (mode) { + case PSDK_GIMBAL_RESET_MODE_YAW: + s_attitudeInformation.attitude.yaw = s_aircraftAttitude.yaw + s_systemState.fineTuneAngle.yaw; + + s_attitudeHighPrecision.yaw = s_aircraftAttitude.yaw + s_systemState.fineTuneAngle.yaw; + break; + case PSDK_GIMBAL_RESET_MODE_PITCH_AND_YAW: + s_attitudeInformation.attitude.pitch = s_systemState.fineTuneAngle.pitch; + s_attitudeInformation.attitude.yaw = s_aircraftAttitude.yaw + s_systemState.fineTuneAngle.yaw; + + s_attitudeHighPrecision.pitch = s_systemState.fineTuneAngle.pitch; + s_attitudeHighPrecision.yaw = s_aircraftAttitude.yaw + s_systemState.fineTuneAngle.yaw; + break; + case PSDK_GIMBAL_RESET_MODE_PITCH_DOWNWARD_UPWARD_AND_YAW: + s_attitudeInformation.attitude.pitch = + s_systemState.fineTuneAngle.pitch + (s_systemState.mountedUpward ? 900 : -900); + s_attitudeInformation.attitude.yaw = s_aircraftAttitude.yaw + s_systemState.fineTuneAngle.yaw; + + s_attitudeHighPrecision.pitch = + s_systemState.fineTuneAngle.pitch + (s_systemState.mountedUpward ? 900 : -900); + s_attitudeHighPrecision.yaw = s_aircraftAttitude.yaw + s_systemState.fineTuneAngle.yaw; + break; + case PSDK_GIMBAL_RESET_MODE_PITCH_DOWNWARD_UPWARD: + s_attitudeInformation.attitude.pitch = + s_systemState.fineTuneAngle.pitch + (s_systemState.mountedUpward ? 900 : -900); + + s_attitudeHighPrecision.pitch = + s_systemState.fineTuneAngle.pitch + (s_systemState.mountedUpward ? 900 : -900); + break; + default: + PsdkLogger_UserLogError("reset mode is invalid: %d.", mode); + psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + goto unlock1; + } + + attitudeFTemp.pitch = s_attitudeInformation.attitude.pitch; + attitudeFTemp.roll = s_attitudeInformation.attitude.roll; + attitudeFTemp.yaw = s_attitudeInformation.attitude.yaw; + PsdkTest_GimbalAngleLegalization(&attitudeFTemp, s_aircraftAttitude, &s_attitudeInformation.reachLimitFlag); + s_attitudeInformation.attitude.pitch = attitudeFTemp.pitch; + s_attitudeInformation.attitude.roll = attitudeFTemp.roll; + s_attitudeInformation.attitude.yaw = attitudeFTemp.yaw; + PsdkTest_GimbalAngleLegalization(&s_attitudeHighPrecision, s_aircraftAttitude, NULL); + + s_rotatingFlag = false; + +unlock1: + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto unlock2; + } + +unlock2: + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return psdkReturnCode; +} + +static T_PsdkReturnCode FineTuneAngle(T_PsdkAttitude3d fineTuneAngle) +{ + T_PsdkReturnCode psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + T_PsdkGimbalReachLimitFlag attitudeReachLimitFlag = {0}; + T_PsdkGimbalReachLimitFlag fineTuneAngleReachLimitFlag = {0}; + T_PsdkAttitude3d aircraftAttitudeResetted = {0}; + T_PsdkAttitude3f attitudeFTemp = {0}; + + PsdkLogger_UserLogDebug("gimbal fine tune angle: pitch %d, roll %d, yaw %d.", fineTuneAngle.pitch, + fineTuneAngle.roll, fineTuneAngle.yaw); + + if (PsdkOsal_MutexLock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + s_attitudeInformation.attitude.pitch += fineTuneAngle.pitch; + s_attitudeInformation.attitude.roll += fineTuneAngle.roll; + s_attitudeInformation.attitude.yaw += fineTuneAngle.yaw; + attitudeFTemp.pitch = s_attitudeInformation.attitude.pitch; + attitudeFTemp.roll = s_attitudeInformation.attitude.roll; + attitudeFTemp.yaw = s_attitudeInformation.attitude.yaw; + PsdkTest_GimbalAngleLegalization(&attitudeFTemp, s_aircraftAttitude, &attitudeReachLimitFlag); + s_attitudeInformation.attitude.pitch = attitudeFTemp.pitch; + s_attitudeInformation.attitude.roll = attitudeFTemp.roll; + s_attitudeInformation.attitude.yaw = attitudeFTemp.yaw; + + s_attitudeHighPrecision.pitch += fineTuneAngle.pitch; + s_attitudeHighPrecision.roll += fineTuneAngle.roll; + s_attitudeHighPrecision.yaw += fineTuneAngle.yaw; + PsdkTest_GimbalAngleLegalization(&s_attitudeHighPrecision, s_aircraftAttitude, NULL); + + if (PsdkOsal_MutexLock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex lock error"); + psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto unlock; + } + + s_systemState.fineTuneAngle.pitch += fineTuneAngle.pitch; + s_systemState.fineTuneAngle.roll += fineTuneAngle.roll; + s_systemState.fineTuneAngle.yaw += fineTuneAngle.yaw; + attitudeFTemp.pitch = s_systemState.fineTuneAngle.pitch; + attitudeFTemp.roll = s_systemState.fineTuneAngle.roll; + attitudeFTemp.yaw = s_systemState.fineTuneAngle.yaw; + PsdkTest_GimbalAngleLegalization(&attitudeFTemp, aircraftAttitudeResetted, &fineTuneAngleReachLimitFlag); + s_systemState.fineTuneAngle.pitch = attitudeFTemp.pitch; + s_systemState.fineTuneAngle.roll = attitudeFTemp.roll; + s_systemState.fineTuneAngle.yaw = attitudeFTemp.yaw; + + if (PsdkOsal_MutexUnlock(s_commonMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + psdkReturnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + goto unlock; + } + +unlock: + if (PsdkOsal_MutexUnlock(s_attitudeMutex) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mutex unlock error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (((attitudeReachLimitFlag.pitch == true || fineTuneAngleReachLimitFlag.pitch == true) && + fineTuneAngle.pitch != 0) || + ((attitudeReachLimitFlag.roll == true || fineTuneAngleReachLimitFlag.roll == true) && + fineTuneAngle.roll != 0) || + ((attitudeReachLimitFlag.yaw == true || fineTuneAngleReachLimitFlag.yaw == true) && fineTuneAngle.yaw != 0)) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE; + } + + return psdkReturnCode; +} + +/** + * @brief + * @param attitude: in ground coordinate + * @param aircraftAttitude: in ground coordinate + * @param reachLimitFlag + * @return + */ +static T_PsdkReturnCode PsdkTest_GimbalAngleLegalization(T_PsdkAttitude3f *attitude, T_PsdkAttitude3d aircraftAttitude, + T_PsdkGimbalReachLimitFlag *reachLimitFlag) +{ + T_PsdkAttitude3d eulerAngleLimitMin; + T_PsdkAttitude3d eulerAngleLimitMax; + T_PsdkAttitude3d angleLimitInBodyCoordinateFromEulerLimitMin = {0}; + T_PsdkAttitude3d angleLimitInBodyCoordinateFromEulerLimitMax = {0}; + T_PsdkAttitude3d finalAngleLimitInBodyCoordinateMin = {0}; + T_PsdkAttitude3d finalAngleLimitInBodyCoordinateMax = {0}; + T_PsdkAttitude3f attitudeInBodyCoordinate = {0}; + + if (attitude == NULL) { + PsdkLogger_UserLogError("input pointer is null."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + // calculate euler angle limit + eulerAngleLimitMin = s_eulerAngleLimitMin; + eulerAngleLimitMax = s_eulerAngleLimitMax; + if (s_systemState.pitchRangeExtensionEnabledFlag == true) { + eulerAngleLimitMin.pitch = s_pitchEulerAngleExtensionMin; + eulerAngleLimitMax.pitch = s_pitchEulerAngleExtensionMax; + } + + // transfer euler angle limit to angle limit in body coordinate + angleLimitInBodyCoordinateFromEulerLimitMin.pitch = eulerAngleLimitMin.pitch - aircraftAttitude.pitch; + angleLimitInBodyCoordinateFromEulerLimitMin.roll = eulerAngleLimitMin.roll - aircraftAttitude.roll; + angleLimitInBodyCoordinateFromEulerLimitMin.yaw = eulerAngleLimitMin.yaw - aircraftAttitude.yaw; + angleLimitInBodyCoordinateFromEulerLimitMax.pitch = eulerAngleLimitMax.pitch - aircraftAttitude.pitch; + angleLimitInBodyCoordinateFromEulerLimitMax.roll = eulerAngleLimitMax.roll - aircraftAttitude.roll; + angleLimitInBodyCoordinateFromEulerLimitMax.yaw = eulerAngleLimitMax.yaw - aircraftAttitude.yaw; + + // calculate final angle limit in body coordinate based on euler angle limit and joint angle limit + finalAngleLimitInBodyCoordinateMin.pitch = USER_UTIL_MAX(angleLimitInBodyCoordinateFromEulerLimitMin.pitch, + s_jointAngleLimitMin.pitch); + finalAngleLimitInBodyCoordinateMin.roll = USER_UTIL_MAX(angleLimitInBodyCoordinateFromEulerLimitMin.roll, + s_jointAngleLimitMin.roll); + finalAngleLimitInBodyCoordinateMin.yaw = USER_UTIL_MAX(angleLimitInBodyCoordinateFromEulerLimitMin.yaw, + s_jointAngleLimitMin.yaw); + finalAngleLimitInBodyCoordinateMax.pitch = USER_UTIL_MIN(angleLimitInBodyCoordinateFromEulerLimitMax.pitch, + s_jointAngleLimitMax.pitch); + finalAngleLimitInBodyCoordinateMax.roll = USER_UTIL_MIN(angleLimitInBodyCoordinateFromEulerLimitMax.roll, + s_jointAngleLimitMax.roll); + finalAngleLimitInBodyCoordinateMax.yaw = USER_UTIL_MIN(angleLimitInBodyCoordinateFromEulerLimitMax.yaw, + s_jointAngleLimitMax.yaw); + + // calculate gimbal attitude in body coordinate + attitudeInBodyCoordinate.pitch = attitude->pitch - (float) aircraftAttitude.pitch; + attitudeInBodyCoordinate.roll = attitude->roll - (float) aircraftAttitude.roll; + attitudeInBodyCoordinate.yaw = attitude->yaw - (float) aircraftAttitude.yaw; + + // modify attitude based on final angle limit + attitudeInBodyCoordinate.pitch = USER_UTIL_MIN(attitudeInBodyCoordinate.pitch, + (float) finalAngleLimitInBodyCoordinateMax.pitch); + attitudeInBodyCoordinate.pitch = USER_UTIL_MAX(attitudeInBodyCoordinate.pitch, + (float) finalAngleLimitInBodyCoordinateMin.pitch); + attitudeInBodyCoordinate.roll = USER_UTIL_MIN(attitudeInBodyCoordinate.roll, + (float) finalAngleLimitInBodyCoordinateMax.roll); + attitudeInBodyCoordinate.roll = USER_UTIL_MAX(attitudeInBodyCoordinate.roll, + (float) finalAngleLimitInBodyCoordinateMin.roll); + attitudeInBodyCoordinate.yaw = USER_UTIL_MIN(attitudeInBodyCoordinate.yaw, + (float) finalAngleLimitInBodyCoordinateMax.yaw); + attitudeInBodyCoordinate.yaw = USER_UTIL_MAX(attitudeInBodyCoordinate.yaw, + (float) finalAngleLimitInBodyCoordinateMin.yaw); + + // calculate gimbal attitude in ground coordinate + attitude->pitch = attitudeInBodyCoordinate.pitch + (float) aircraftAttitude.pitch; + attitude->roll = attitudeInBodyCoordinate.roll + (float) aircraftAttitude.roll; + attitude->yaw = attitudeInBodyCoordinate.yaw + (float) aircraftAttitude.yaw; + + // calculate reach limit flag, please note reach limit flag only specifies whether gimbal attitude reach joint angle limit + if (reachLimitFlag != NULL) { + reachLimitFlag->pitch = (attitudeInBodyCoordinate.pitch >= s_jointAngleLimitMax.pitch || + attitudeInBodyCoordinate.pitch <= s_jointAngleLimitMin.pitch) ? true : false; + reachLimitFlag->roll = (attitudeInBodyCoordinate.roll >= s_jointAngleLimitMax.roll || + attitudeInBodyCoordinate.roll <= s_jointAngleLimitMin.roll) ? true : false; + reachLimitFlag->yaw = (attitudeInBodyCoordinate.yaw >= s_jointAngleLimitMax.yaw || + attitudeInBodyCoordinate.yaw <= s_jointAngleLimitMin.yaw) ? true : false; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief + * @param originalAttitude: unit: 0.1degree. + * @param targetAttitude: unit: 0.1degree. + * @param actionTime: unit: 0.01s. + * @param speed: unit: 0.1degree/s. + * @return + */ +static T_PsdkReturnCode +PsdkTest_GimbalCalculateSpeed(T_PsdkAttitude3d originalAttitude, T_PsdkAttitude3d targetAttitude, uint16_t actionTime, + T_PsdkAttitude3d *speed) +{ + float pitchSpeedTemp = 0; + float rollSpeedTemp = 0; + float yawSpeedTemp = 0; + + if (speed == NULL) { + PsdkLogger_UserLogError("input pointer is null."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + pitchSpeedTemp = (float) (targetAttitude.pitch - originalAttitude.pitch) / (float) actionTime * 100; + rollSpeedTemp = (float) (targetAttitude.roll - originalAttitude.roll) / (float) actionTime * 100; + yawSpeedTemp = (float) (targetAttitude.yaw - originalAttitude.yaw) / (float) actionTime * 100; + + speed->pitch = pitchSpeedTemp >= 0.0f ? (int32_t) (pitchSpeedTemp + 1) : (int32_t) (pitchSpeedTemp - 1); + speed->roll = rollSpeedTemp >= 0.0f ? (int32_t) (rollSpeedTemp + 1) : (int32_t) (rollSpeedTemp - 1); + speed->yaw = yawSpeedTemp >= 0.0f ? (int32_t) (yawSpeedTemp + 1) : (int32_t) (yawSpeedTemp - 1); + + PsdkTest_GimbalSpeedLegalization(speed); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static void PsdkTest_GimbalSpeedLegalization(T_PsdkAttitude3d *speed) +{ + speed->pitch = speed->pitch > s_speedLimit.pitch ? s_speedLimit.pitch : speed->pitch; + speed->roll = speed->roll > s_speedLimit.roll ? s_speedLimit.roll : speed->roll; + speed->yaw = speed->yaw > s_speedLimit.yaw ? s_speedLimit.yaw : speed->yaw; + + speed->pitch = speed->pitch < (0 - s_speedLimit.pitch) ? (0 - s_speedLimit.pitch) : speed->pitch; + speed->roll = speed->roll < (0 - s_speedLimit.roll) ? (0 - s_speedLimit.roll) : speed->roll; + speed->yaw = speed->yaw < (0 - s_speedLimit.yaw) ? (0 - s_speedLimit.yaw) : speed->yaw; +} + +/** + * @brief + * @param quaternion + * @param attitude Unit: 0.1 degree. + * @return + */ +static T_PsdkReturnCode +PsdkTest_GimbalCalculateGroundAttitudeBaseQuaternion(T_PsdkDataSubscriptionQuaternion quaternion, + T_PsdkAttitude3d *attitude) +{ + double aircraftPitchInRad; + double aircraftRollInRad; + double aircraftYawInRad; + + if (attitude == NULL) { + PsdkLogger_UserLogError("Input argument is null."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + aircraftPitchInRad = asin(2 * ((double) quaternion.q0 * quaternion.q2 - (double) quaternion.q3 * quaternion.q1)); + attitude->pitch = aircraftPitchInRad * 180 / PI * 10; + + aircraftRollInRad = atan2(2 * ((double) quaternion.q0 * quaternion.q1 + (double) quaternion.q2 * quaternion.q3), + (double) 1 - + 2 * ((double) quaternion.q1 * quaternion.q1 + (double) quaternion.q2 * quaternion.q2)); + attitude->roll = aircraftRollInRad * 180 / PI * 10; + + aircraftYawInRad = atan2(2 * ((double) quaternion.q0 * quaternion.q3 + (double) quaternion.q1 * quaternion.q2), + (double) 1 - + 2 * ((double) quaternion.q2 * quaternion.q2 + (double) quaternion.q3 * quaternion.q3)); + attitude->yaw = aircraftYawInRad * 180 / PI * 10; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/gimbal_emu/test_payload_gimbal_emu.h b/sample/api_sample/gimbal_emu/test_payload_gimbal_emu.h new file mode 100644 index 0000000..649c991 --- /dev/null +++ b/sample/api_sample/gimbal_emu/test_payload_gimbal_emu.h @@ -0,0 +1,59 @@ +/** + ******************************************************************** + * @file test_payload_gimbal_emu.h + * @version V2.0.0 + * @date 2019/9/19 + * @brief This is the header file for "test_payload_gimbal_emu.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_PAYLOAD_GIMBAL_EMU_H +#define TEST_PAYLOAD_GIMBAL_EMU_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" +#include "psdk_gimbal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_GimbalInit(void); +T_PsdkReturnCode PsdkTest_GimbalDeInit(void); +T_PsdkReturnCode +PsdkTest_GimbalRotate(E_PsdkGimbalRotationMode rotationMode, T_PsdkGimbalRotationProperty rotationProperty, + T_PsdkAttitude3d rotationValue); // unit if angle control: 0.1 degree, unit if speed control: 0.1 degree/s + +#ifdef __cplusplus +} +#endif + +#endif // TEST_PAYLOAD_GIMBAL_EMU_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/mop_channel/test_mop_channel.c b/sample/api_sample/mop_channel/test_mop_channel.c new file mode 100644 index 0000000..10ea2b9 --- /dev/null +++ b/sample/api_sample/mop_channel/test_mop_channel.c @@ -0,0 +1,824 @@ +/** + ******************************************************************** + * @file test_mop_channel.c + * @version V2.0.0 + * @date 1/14/20 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#if PSDK_ARCH_SYS_LINUX + +#include +#include +#include +#include "psdk_mop_channel.h" +#include "psdk_logger.h" +#include "psdk_platform.h" +#include "test_mop_channel.h" + +/* Private constants ---------------------------------------------------------*/ +#define PSDK_MOP_CHANNEL_TASK_STACK_SIZE 2048 +#define TEST_MOP_CHANNEL_INIT_TIMEMS (3 * 1000) +#define TEST_MOP_CHANNEL_RETRY_TIMEMS (3 * 1000) + +#define TEST_MOP_CHANNEL_NORMAL_TRANSFOR_CHANNEL_ID 49152 +#define TEST_MOP_CHANNEL_NORMAL_TRANSFOR_USING_RELIABLE_TRANS 0 +#define TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_TASK_FREQ 1 +#define TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER (64 * 1024) +#define TEST_MOP_CHANNEL_NORMAL_TRANSFOR_RECV_BUFFER (100 * 1024) + +#define TEST_MOP_CHANNEL_FILE_SERVICE_CHANNEL_ID 49153 +#define TEST_MOP_CHANNEL_FILE_SERVICE_SEND_BUFFER (3 * 1024 * 1024) +#define TEST_MOP_CHANNEL_FILE_SERVICE_RECV_BUFFER (100 * 1024) +#define TEST_MOP_CHANNEL_FILE_SERVICE_CLIENT_MAX_SUPPORT_NUM 10 +#define TEST_MOP_CHANNEL_FILE_SERVICE_FILE_PATH "../../../../../api_sample/mop_channel/mop_channel_test_file/mop_send_test_file.mp4" + +/* Private types -------------------------------------------------------------*/ +typedef enum { + MOP_FILE_SERVICE_DOWNLOAD_IDEL = 0, + MOP_FILE_SERVICE_DOWNLOAD_REQUEST_START, + MOP_FILE_SERVICE_DOWNLOAD_FILE_INFO_SUCCESS, + MOP_FILE_SERVICE_DOWNLOAD_FILE_INFO_FAILED, + MOP_FILE_SERVICE_DOWNLOAD_DATA_SENDING, + MOP_FILE_SERVICE_DOWNLOAD_FINISHED_SUCCESS, + MOP_FILE_SERVICE_DOWNLOAD_FINISHED_FAILED, + MOP_FILE_SERVICE_DOWNLOAD_STOP, +} E_MopFileServiceDownloadState; + +typedef enum { + MOP_FILE_SERVICE_UPLOAD_IDEL = 0, + MOP_FILE_SERVICE_UPLOAD_REQUEST_START, + MOP_FILE_SERVICE_UPLOAD_FILE_INFO_SUCCESS, + MOP_FILE_SERVICE_UPLOAD_FILE_INFO_FAILED, + MOP_FILE_SERVICE_UPLOAD_DATA_SENDING, + MOP_FILE_SERVICE_UPLOAD_FINISHED_SUCCESS, + MOP_FILE_SERVICE_UPLOAD_FINISHED_FAILED, + MOP_FILE_SERVICE_UPLOAD_STOP, +} E_MopFileServiceUploadState; + +typedef struct { + uint8_t index; + T_PsdkTaskHandle clientRecvTask; + T_PsdkTaskHandle clientSendTask; + T_PsdkMopChannelHandle clientHandle; + E_MopFileServiceDownloadState downloadState; + uint16_t downloadSeqNum; + E_MopFileServiceUploadState uploadState; + uint16_t uploadSeqNum; +} T_MopFileServiceClientContent; + +/* Private values -------------------------------------------------------------*/ +static T_PsdkMopChannelHandle s_testMopChannelNormalHandle; +static T_PsdkMopChannelHandle s_testMopChannelNormalOutHandle; +static T_PsdkTaskHandle s_testMopChannelNormalSendTask; +static T_PsdkTaskHandle s_testMopChannelNormalRecvTask; +static T_PsdkSemHandle s_testMopChannelReadySema; +static bool s_testMopChannelConnected = false; + +static T_PsdkTaskHandle s_fileServiceMopChannelAcceptTask; +static T_PsdkMopChannelHandle s_fileServiceMopChannelHandle; +static T_MopFileServiceClientContent s_fileServiceContent[TEST_MOP_CHANNEL_FILE_SERVICE_CLIENT_MAX_SUPPORT_NUM]; + +/* Private functions declaration ---------------------------------------------*/ +static void *PsdkTest_MopChannelSendNormalTask(void *arg); +static void *PsdkTest_MopChannelRecvNormalTask(void *arg); +static void *PsdkTest_MopChannelFileServiceAcceptTask(void *arg); +static void *PsdkTest_MopChannelFileServiceRecvTask(void *arg); +static void *PsdkTest_MopChannelFileServiceSendTask(void *arg); + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_MopChannelInit(void) +{ + T_PsdkReturnCode returnCode; + + returnCode = PsdkOsal_SemaphoreCreate(&s_testMopChannelReadySema, 0); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel create msdk sema error, stat:0x%08llX.", returnCode); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + returnCode = PsdkMopChannel_Init(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel init error, stat:0x%08llX.", returnCode); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + returnCode = PsdkOsal_TaskCreate(&s_testMopChannelNormalSendTask, PsdkTest_MopChannelSendNormalTask, + "mop_msdk_send_task", + PSDK_MOP_CHANNEL_TASK_STACK_SIZE, NULL); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel msdk send task create error, stat:0x%08llX.", returnCode); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + returnCode = PsdkOsal_TaskCreate(&s_testMopChannelNormalRecvTask, PsdkTest_MopChannelRecvNormalTask, + "mop_msdk_recv_task", PSDK_MOP_CHANNEL_TASK_STACK_SIZE, NULL); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel msdk recv task create error, stat:0x%08llX.", returnCode); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + returnCode = PsdkOsal_TaskCreate(&s_fileServiceMopChannelAcceptTask, PsdkTest_MopChannelFileServiceAcceptTask, + "mop_msdk_accept_task", PSDK_MOP_CHANNEL_TASK_STACK_SIZE, NULL); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel osdk recv task create error, stat:0x%08llX.", returnCode); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +static void *PsdkTest_MopChannelSendNormalTask(void *arg) +{ + uint8_t *sendBuf = NULL; + uint32_t realLen = 0; + T_PsdkReturnCode returnCode; + uint32_t sendDataCount = 0; + + USER_UTIL_UNUSED(arg); + + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_INIT_TIMEMS); + + sendBuf = PsdkOsal_Malloc(TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER); + if (sendBuf == NULL) { + PsdkLogger_UserLogError("malloc send buffer error"); + return NULL; + } + +REWAIT: + returnCode = PsdkOsal_SemaphoreWait(s_testMopChannelReadySema); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel wait sema error, stat:0x%08llX.", returnCode); + return NULL; + } + + while (1) { + if (s_testMopChannelConnected == false) { + sendDataCount = 0; + goto REWAIT; + } + + sendDataCount++; + memset(sendBuf, sendDataCount, TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER); + returnCode = PsdkMopChannel_SendData(s_testMopChannelNormalOutHandle, sendBuf, + TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER, &realLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel send data to channel error,stat:0x%08llX", returnCode); + } else { + PsdkLogger_UserLogInfo("mop channel send data to channel length:%d count:%d", realLen, sendDataCount); + } + + PsdkOsal_TaskSleepMs(1000 / TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_TASK_FREQ); + } +} + +#pragma GCC diagnostic pop + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +static void *PsdkTest_MopChannelRecvNormalTask(void *arg) +{ + USER_UTIL_UNUSED(arg); + uint8_t *recvBuf = NULL; + uint32_t realLen; + T_PsdkReturnCode returnCode; + uint32_t recvDataCount = 0; + + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_INIT_TIMEMS); + +#if TEST_MOP_CHANNEL_NORMAL_TRANSFOR_USING_RELIABLE_TRANS + returnCode = PsdkMopChannel_Create(&s_testMopChannelNormalHandle, PSDK_MOP_CHANNEL_TRANS_RELIABLE); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel create send handle error, stat:0x%08llX.", returnCode); + return NULL; + } +#else + returnCode = PsdkMopChannel_Create(&s_testMopChannelNormalHandle, PSDK_MOP_CHANNEL_TRANS_UNRELIABLE); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel create send handle error, stat:0x%08llX.", returnCode); + return NULL; + } +#endif + +REBIND: + returnCode = PsdkMopChannel_Bind(s_testMopChannelNormalHandle, TEST_MOP_CHANNEL_NORMAL_TRANSFOR_CHANNEL_ID); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop bind channel error :0x%08llX", returnCode); + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_RETRY_TIMEMS); + goto REBIND; + } + +REACCEPT: + returnCode = PsdkMopChannel_Accept(s_testMopChannelNormalHandle, &s_testMopChannelNormalOutHandle); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogWarn("mop accept channel error :0x%08llX", returnCode); + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_RETRY_TIMEMS); + goto REACCEPT; + } + + PsdkLogger_UserLogInfo("mop channel is connected"); + + recvBuf = PsdkOsal_Malloc(TEST_MOP_CHANNEL_NORMAL_TRANSFOR_RECV_BUFFER); + if (recvBuf == NULL) { + PsdkLogger_UserLogError("malloc recv buffer error"); + return NULL; + } + + s_testMopChannelConnected = true; + + returnCode = PsdkOsal_SemaphorePost(s_testMopChannelReadySema); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel post sema error, stat:0x%08llX.", returnCode); + return NULL; + } + + while (1) { + memset(recvBuf, 0, TEST_MOP_CHANNEL_NORMAL_TRANSFOR_RECV_BUFFER); + + returnCode = PsdkMopChannel_RecvData(s_testMopChannelNormalOutHandle, recvBuf, + TEST_MOP_CHANNEL_NORMAL_TRANSFOR_RECV_BUFFER, &realLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + if (returnCode == PSDK_ERROR_MOP_CHANNEL_MODULE_CODE_CONNECTION_CLOSE) { + PsdkLogger_UserLogInfo("mop channel is disconnected"); + s_testMopChannelConnected = false; + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_RETRY_TIMEMS); + PsdkMopChannel_Close(s_testMopChannelNormalOutHandle); + PsdkMopChannel_Destroy(s_testMopChannelNormalOutHandle); + goto REACCEPT; + } + } else { + PsdkLogger_UserLogInfo("mop channel recv data from channel length:%d count:%d", realLen, recvDataCount++); + } + } +} + +#pragma GCC diagnostic pop + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +static void *PsdkTest_MopChannelFileServiceAcceptTask(void *arg) +{ + T_PsdkReturnCode returnCode; + uint8_t currentClientNum = 0; + + USER_UTIL_UNUSED(arg); + + PsdkLogger_UserLogDebug("[File-Service] Start the file service."); + + returnCode = PsdkMopChannel_Create(&s_fileServiceMopChannelHandle, PSDK_MOP_CHANNEL_TRANS_RELIABLE); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("[File-Service] mop channel create send handle error, stat:0x%08llX.", returnCode); + return NULL; + } + +REBIND: + returnCode = PsdkMopChannel_Bind(s_fileServiceMopChannelHandle, TEST_MOP_CHANNEL_FILE_SERVICE_CHANNEL_ID); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("[File-Service] mop bind channel error :0x%08llX", returnCode); + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_RETRY_TIMEMS); + goto REBIND; + } + + while (1) { +REACCEPT: + returnCode = PsdkMopChannel_Accept(s_fileServiceMopChannelHandle, + &s_fileServiceContent[currentClientNum].clientHandle); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogWarn("[File-Service] mop accept channel error :0x%08llX", returnCode); + PsdkOsal_TaskSleepMs(TEST_MOP_CHANNEL_RETRY_TIMEMS); + goto REACCEPT; + } + + PsdkLogger_UserLogInfo("[File-Service] [Client:%d] mop channel is connected", currentClientNum); + + s_fileServiceContent[currentClientNum].index = currentClientNum; + returnCode = PsdkOsal_TaskCreate(&s_fileServiceContent[currentClientNum].clientRecvTask, + PsdkTest_MopChannelFileServiceRecvTask, + "mop_file_service_recv_task", + PSDK_MOP_CHANNEL_TASK_STACK_SIZE, + &s_fileServiceContent[currentClientNum].index); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel recv task create error, stat:0x%08llX.", returnCode); + return NULL; + } + + returnCode = PsdkOsal_TaskCreate(&s_fileServiceContent[currentClientNum].clientSendTask, + PsdkTest_MopChannelFileServiceSendTask, + "mop_file_service_send_task", + PSDK_MOP_CHANNEL_TASK_STACK_SIZE, + &s_fileServiceContent[currentClientNum].index); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("mop channel send task create error, stat:0x%08llX.", returnCode); + return NULL; + } + + currentClientNum++; + if (currentClientNum > TEST_MOP_CHANNEL_FILE_SERVICE_CLIENT_MAX_SUPPORT_NUM) { + currentClientNum = 0; + } + } +} + +#pragma GCC diagnostic pop + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +static void *PsdkTest_MopChannelFileServiceSendTask(void *arg) +{ + T_PsdkReturnCode returnCode; + uint8_t clientNum = *(uint8_t *) arg; + uint32_t sendRealLen = 0; + uint8_t *sendBuf; + MD5_CTX downloadFileMd5Ctx; + FILE *downloadFile = NULL; + uint8_t downloadFileMd5[PSDK_MD5_BUFFER_LEN] = {0}; + uint64_t downloadFileTotalSize = 0; + uint64_t downloadWriteLen; + uint16_t downloadPackCount = 0; + T_PsdkMopChannel_FileInfo downloadFileInfo = {0}; + T_PsdkMopChannel_FileTransfor transforAck = {0}; + T_PsdkMopChannel_FileTransfor fileData = {0}; + T_PsdkMopChannel_FileTransfor fileInfo = {0}; + uint32_t downloadStartMs = 0; + uint32_t downloadEndMs = 0; + uint32_t downloadDurationMs; + psdk_f32_t downloadRate; + + sendBuf = PsdkOsal_Malloc(TEST_MOP_CHANNEL_FILE_SERVICE_SEND_BUFFER); + if (sendBuf == NULL) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] malloc send buffer error", clientNum); + return NULL; + } + + while (1) { + switch (s_fileServiceContent[clientNum].uploadState) { + case MOP_FILE_SERVICE_UPLOAD_REQUEST_START: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_ACK; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_ACK_OK; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] upload request ack", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + break; + case MOP_FILE_SERVICE_UPLOAD_FILE_INFO_SUCCESS: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_ACK; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_ACK_OK; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] upload file info success", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + break; + case MOP_FILE_SERVICE_UPLOAD_FILE_INFO_FAILED: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_ACK; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_ACK_REJECTED; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + PsdkLogger_UserLogError("[File-Service] [Client:%d] upload file info failed", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + break; + case MOP_FILE_SERVICE_UPLOAD_FINISHED_SUCCESS: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_RESULT; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_RESULT_OK; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum++; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, + (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] upload finished success", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + + break; + case MOP_FILE_SERVICE_UPLOAD_FINISHED_FAILED: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_RESULT; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_RESULT_FAILED; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum++; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, + (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + PsdkLogger_UserLogError("[File-Service] [Client:%d] upload finished failed", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + break; + case MOP_FILE_SERVICE_UPLOAD_STOP: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_STOP_ACK; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_STOP_UPLOAD; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum++; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, + (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + break; + default: + break; + } + + switch (s_fileServiceContent[clientNum].downloadState) { + case MOP_FILE_SERVICE_DOWNLOAD_REQUEST_START: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_ACK; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_ACK_OK; + transforAck.seqNum = s_fileServiceContent[clientNum].downloadSeqNum; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] download request ack", clientNum); + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_IDEL; + + break; + case MOP_FILE_SERVICE_DOWNLOAD_STOP: + transforAck.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_STOP_ACK; + transforAck.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_STOP_DOWNLOAD; + transforAck.seqNum = s_fileServiceContent[clientNum].uploadSeqNum++; + transforAck.dataLen = 0; + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, + (uint8_t *) &transforAck, + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data), + &sendRealLen); + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_IDEL; + break; + case MOP_FILE_SERVICE_DOWNLOAD_FILE_INFO_SUCCESS: + UtilMd5_Init(&downloadFileMd5Ctx); + PsdkOsal_GetTimeMs(&downloadStartMs); + if (downloadFile != NULL) { + fclose(downloadFile); + } + downloadFile = fopen(TEST_MOP_CHANNEL_FILE_SERVICE_FILE_PATH, "rb"); + if (downloadFile == NULL) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] download open file error", + clientNum); + return NULL; + } + + downloadFileTotalSize = 0; + while (1) { + returnCode = fseek(downloadFile, downloadFileTotalSize, SEEK_SET); + if (returnCode != 0) { + PsdkLogger_UserLogError( + "[File-Service] [Client:%d] mop channel fseek file data fail.", clientNum); + } + downloadWriteLen = fread(sendBuf, 1, TEST_MOP_CHANNEL_FILE_SERVICE_SEND_BUFFER, + downloadFile); + if (downloadWriteLen > 0) { + downloadFileTotalSize += downloadWriteLen; + UtilMd5_Update(&downloadFileMd5Ctx, sendBuf, downloadWriteLen); + if (downloadWriteLen < TEST_MOP_CHANNEL_FILE_SERVICE_SEND_BUFFER) { + break; + } + } + } + UtilMd5_Final(&downloadFileMd5Ctx, downloadFileMd5); + + fileInfo.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_INFO; + fileInfo.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_DOWNLOAD_REQUEST; + fileInfo.seqNum = s_fileServiceContent[clientNum].downloadSeqNum; + fileInfo.dataLen = sizeof(fileInfo) - UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data); + + fileInfo.data.fileInfo.isExist = true; + downloadFileInfo.fileLength = downloadFileTotalSize; + fileInfo.data.fileInfo.fileLength = downloadFileTotalSize; + strcpy(fileInfo.data.fileInfo.fileName, "test.mp4"); + memcpy(&fileInfo.data.fileInfo.md5Buf, &downloadFileMd5, sizeof(downloadFileMd5)); + PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, (uint8_t *) &fileInfo, + sizeof(T_PsdkMopChannel_FileTransfor), + &sendRealLen); + PsdkLogger_UserLogDebug( + "[File-Service] [Client:%d] download ack file info exist:%d length:%d name:%s", + clientNum, fileInfo.data.fileInfo.isExist, + fileInfo.data.fileInfo.fileLength, fileInfo.data.fileInfo.fileName); + + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_DATA_SENDING; + downloadFileTotalSize = 0; + downloadPackCount = 0; + break; + case MOP_FILE_SERVICE_DOWNLOAD_DATA_SENDING: + if (downloadFile == NULL) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] download file object is NULL."); + break; + } + + returnCode = fseek(downloadFile, downloadFileTotalSize, SEEK_SET); + if (returnCode != 0) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] download fseek file data fail.", + clientNum); + break; + } + downloadWriteLen = fread(&sendBuf[UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)], + 1, + (TEST_MOP_CHANNEL_FILE_SERVICE_SEND_BUFFER - + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)), + downloadFile); + + if (downloadWriteLen > 0) { + downloadFileTotalSize += downloadWriteLen; + downloadPackCount++; + + fileData.cmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_DATA; + fileData.dataLen = downloadWriteLen; + fileData.seqNum++; + if (downloadWriteLen == + (TEST_MOP_CHANNEL_FILE_SERVICE_SEND_BUFFER - + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data))) { + fileData.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_NORMAL; + } else { + fileData.subcmd = PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_END; + } + + memcpy(sendBuf, &fileData, UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)); + returnCode = PsdkMopChannel_SendData(s_fileServiceContent[clientNum].clientHandle, sendBuf, + (downloadWriteLen + + UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)), + &sendRealLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError( + "[File-Service] [Client:%d] download send file data error,stat:0x%08llX", + clientNum, returnCode); + if (returnCode == PSDK_ERROR_MOP_CHANNEL_MODULE_CODE_CONNECTION_CLOSE) { + break; + } + } else { + PsdkLogger_UserLogInfo( + "[File-Service] [Client:%d] download send file data length:%d count:%d total:%d percent: %.1f %%", + clientNum, sendRealLen, downloadPackCount, downloadFileTotalSize, + (psdk_f32_t) (downloadFileTotalSize) * 100 / (psdk_f32_t) downloadFileInfo.fileLength); + } + + if (fileData.subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_END) { + PsdkOsal_GetTimeMs(&downloadEndMs); + downloadDurationMs = downloadEndMs - downloadStartMs; + if (downloadDurationMs != 0) { + downloadRate = (psdk_f32_t) downloadFileInfo.fileLength * 1000 / + (psdk_f32_t) (downloadDurationMs); + PsdkLogger_UserLogInfo( + "[File-Service] [Client:%d] download finished totalTime:%d, rate:%.2f Byte/s", + clientNum, downloadDurationMs, downloadRate); + } + } + break; + default: + break; + } + } + } +} + +#pragma GCC diagnostic pop + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +static void *PsdkTest_MopChannelFileServiceRecvTask(void *arg) +{ + T_PsdkReturnCode returnCode; + uint8_t clientNum = *(uint8_t *) arg; + uint32_t recvRealLen; + uint8_t *recvBuf; + MD5_CTX uploadFileMd5Ctx; + FILE *uploadFile = NULL; + uint8_t uploadFileMd5[PSDK_MD5_BUFFER_LEN] = {0}; + uint32_t uploadFileTotalSize = 0; + int32_t uploadWriteLen; + T_PsdkMopChannel_FileInfo uploadFileInfo = {0}; + uint32_t uploadStartMs = 0; + uint32_t uploadEndMs = 0; + psdk_f32_t uploadRate; + + recvBuf = PsdkOsal_Malloc(TEST_MOP_CHANNEL_FILE_SERVICE_RECV_BUFFER); + if (recvBuf == NULL) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] malloc recv buffer error", clientNum); + return NULL; + } + + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_IDEL; + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_IDEL; + + while (1) { + returnCode = PsdkMopChannel_RecvData(s_fileServiceContent[clientNum].clientHandle, recvBuf, + TEST_MOP_CHANNEL_FILE_SERVICE_RECV_BUFFER, &recvRealLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkOsal_TaskSleepMs(1000); + if (returnCode == PSDK_ERROR_MOP_CHANNEL_MODULE_CODE_CONNECTION_CLOSE) { + PsdkLogger_UserLogInfo("[File-Service] [Client:%d] mop channel is disconnected", clientNum); + PsdkOsal_TaskDestroy(s_fileServiceContent[clientNum].clientRecvTask); + PsdkMopChannel_Close(s_fileServiceContent[clientNum].clientHandle); + PsdkMopChannel_Destroy(s_fileServiceContent[clientNum].clientHandle); + } + } else { + if (&recvRealLen > 0) { + T_PsdkMopChannel_FileTransfor *fileTransfor = (T_PsdkMopChannel_FileTransfor *) recvBuf; + + switch (fileTransfor->cmd) { + case PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_REQUEST: + if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_REQUEST_UPLOAD) { + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_REQUEST_START; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] upload request is ok", clientNum); + UtilMd5_Init(&uploadFileMd5Ctx); + uploadFileTotalSize = 0; + PsdkOsal_GetTimeMs(&uploadStartMs); + } else if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_REQUEST_DOWNLOAD) { + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_REQUEST_START; + s_fileServiceContent[clientNum].downloadSeqNum = fileTransfor->seqNum; + + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] download request is ok", clientNum); + } + break; + case PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_DOWNLOAD_REQ: + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] download request file name:%s", clientNum, + fileTransfor->data.dwonloadReq.fileName); + + if (strcmp(fileTransfor->data.dwonloadReq.fileName, "test.mp4") == 0) { + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_FILE_INFO_SUCCESS; + s_fileServiceContent[clientNum].downloadSeqNum = fileTransfor->seqNum; + } else { + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_FILE_INFO_FAILED; + s_fileServiceContent[clientNum].downloadSeqNum = fileTransfor->seqNum; + } + break; + case PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_INFO: + PsdkLogger_UserLogDebug( + "[File-Service] [Client:%d] upload file info length:%d exist:%d name:%s seq:%d", clientNum, + fileTransfor->data.fileInfo.fileLength, + fileTransfor->data.fileInfo.isExist, + fileTransfor->data.fileInfo.fileName, fileTransfor->seqNum); + + uploadFileInfo.fileLength = fileTransfor->data.fileInfo.fileLength; + memcpy(uploadFileInfo.md5Buf, fileTransfor->data.fileInfo.md5Buf, + sizeof(uploadFileInfo.md5Buf)); + if (uploadFile != NULL) { + fclose(uploadFile); + } + uploadFile = fopen(fileTransfor->data.fileInfo.fileName, "wb"); + if (uploadFile == NULL) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] open file error", clientNum); + return NULL; + } + + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_FILE_INFO_SUCCESS; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + + break; + case PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_DATA: + if (uploadFile == NULL) { + PsdkLogger_UserLogError("[File-Service] [Client:%d] open file error", clientNum); + return NULL; + } + + if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_NORMAL) { + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_DATA_SENDING; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + + uploadWriteLen = fwrite(&recvBuf[UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)], 1, + fileTransfor->dataLen, uploadFile); + if (uploadWriteLen < 0) { + PsdkLogger_UserLogError( + "[File-Service] [Client:%d] upload write normal data to file error, stat:%d.", + clientNum, + uploadWriteLen); + } else { + uploadFileTotalSize += uploadWriteLen; + UtilMd5_Update(&uploadFileMd5Ctx, + &recvBuf[UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)], + fileTransfor->dataLen); + + if (uploadFileInfo.fileLength != 0) { + PsdkLogger_UserLogInfo( + "[File-Service] [Client:%d] upload write data to file success, len:%d percent:%.1f %%", + clientNum, uploadWriteLen, + (psdk_f32_t) (uploadFileTotalSize * 100) / + (psdk_f32_t) uploadFileInfo.fileLength); + } + } + } else if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_END) { + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_DATA_SENDING; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + uploadWriteLen = fwrite(&recvBuf[UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)], 1, + fileTransfor->dataLen, uploadFile); + if (uploadWriteLen < 0) { + PsdkLogger_UserLogError( + "[File-Service] [Client:%d] upload write end data to file error, stat:%d.", + clientNum, + uploadWriteLen); + } else { + uploadFileTotalSize += uploadWriteLen; + UtilMd5_Update(&uploadFileMd5Ctx, + &recvBuf[UTIL_OFFSETOF(T_PsdkMopChannel_FileTransfor, data)], + fileTransfor->dataLen); + UtilMd5_Final(&uploadFileMd5Ctx, uploadFileMd5); + PsdkOsal_GetTimeMs(&uploadEndMs); + + if (uploadEndMs - uploadStartMs > 0) { + uploadRate = (psdk_f32_t) uploadFileTotalSize * 1000 / + (psdk_f32_t) (uploadEndMs - uploadStartMs); + PsdkLogger_UserLogInfo( + "[File-Service] [Client:%d] upload write data to file success, len:%d percent:%.1f %%", + clientNum, uploadWriteLen, + (psdk_f32_t) (uploadFileTotalSize * 100) / + (psdk_f32_t) uploadFileInfo.fileLength); + PsdkLogger_UserLogInfo( + "[File-Service] [Client:%d] upload file finished, totalTime:%d ms rate:%.2f Byte/s", + clientNum, (uploadEndMs - uploadStartMs), uploadRate); + } + + fclose(uploadFile); + uploadFile = NULL; + if (uploadFileInfo.fileLength == uploadFileTotalSize) { + if (memcmp(uploadFileInfo.md5Buf, uploadFileMd5, sizeof(uploadFileMd5)) == 0) { + PsdkLogger_UserLogDebug( + "[File-Service] [Client:%d] upload file md5 check success", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_FINISHED_SUCCESS; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + } else { + PsdkLogger_UserLogError( + "[File-Service] [Client:%d] upload file md5 check failed", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_FINISHED_FAILED; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + } + } else { + PsdkLogger_UserLogError( + "[File-Service] [Client:%d] upload file check file length error", clientNum); + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_FINISHED_FAILED; + s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum; + } + } + } + break; + case PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_RESULT: + if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_RESULT_OK) { + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_FINISHED_SUCCESS; + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] download file result notify success", + clientNum); + } else { + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_FINISHED_FAILED; + PsdkLogger_UserLogError("[File-Service] [Client:%d] download file result notify failed", + clientNum); + } + break; + case PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_STOP_REQUEST: + if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_STOP_UPLOAD) { + s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_STOP; + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] upload file stop", clientNum); + } else if (fileTransfor->subcmd == PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_STOP_DOWNLOAD) { + s_fileServiceContent[clientNum].downloadState = MOP_FILE_SERVICE_DOWNLOAD_STOP; + PsdkLogger_UserLogDebug("[File-Service] [Client:%d] download file stop", clientNum); + } + break; + default: + PsdkLogger_UserLogWarn("[File-Service] [Client:%d] recv the unknown command:0x%02X", + clientNum, fileTransfor->cmd); + break; + } + } + } + } +} + +#pragma GCC diagnostic pop + +#endif + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/mop_channel/test_mop_channel.h b/sample/api_sample/mop_channel/test_mop_channel.h new file mode 100644 index 0000000..f13f0d2 --- /dev/null +++ b/sample/api_sample/mop_channel/test_mop_channel.h @@ -0,0 +1,126 @@ +/** + ******************************************************************** + * @file test_mop_channel.h + * @version V2.0.0 + * @date 1/14/20 + * @brief This is the header file for "test_mop_channel.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_MOP_CHANNEL_H +#define TEST_MOP_CHANNEL_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#if PSDK_ARCH_SYS_LINUX + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_REQUEST = 0x50, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_ACK = 0x51, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_RESULT = 0x52, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_INFO = 0x60, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_DOWNLOAD_REQ = 0x61, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_FILE_DATA = 0x62, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_STOP_REQUEST = 0x63, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_CMD_STOP_ACK = 0x64, +} E_PsdkMopChannel_FileTransforCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_REQUEST_UPLOAD = 0x00, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_REQUEST_DOWNLOAD = 0x01, +} E_PsdkMopChannel_FileTransforRequestSubCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_ACK_OK = 0x00, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_ACK_REJECTED = 0x01, +} E_PsdkMopChannel_FileTransforAckSubCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_RESULT_OK = 0x00, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_RESULT_FAILED = 0x01, +} E_PsdkMopChannel_FileTransforResultSubCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_INFO_DEFAULT = 0xFF, +} E_PsdkMopChannel_FileTransforFileInfoSubCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_DOWNLOAD_REQUEST = 0xFF, +} E_PsdkMopChannel_FileTransforFileDownloadRequestSubCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_NORMAL = 0x00, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_FILE_DATA_END = 0x01, +} E_PsdkMopChannel_FileTransforFileDataSubCmd; + +typedef enum { + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_STOP_UPLOAD = 0x00, + PSDK_MOP_CHANNEL_FILE_TRANSFOR_SUBCMD_STOP_DOWNLOAD = 0x01, +} E_PsdkMopChannel_FileTransforStopSubCmd; + +#pragma pack(1) + +typedef struct { + bool isExist; + uint32_t fileLength; + char fileName[32]; + uint8_t md5Buf[16]; +} T_PsdkMopChannel_FileInfo; + +typedef struct { + char fileName[32]; +} T_PsdkMopChannel_DwonloadReq; + +typedef struct { + uint8_t cmd; + uint8_t subcmd; + uint16_t seqNum; + uint32_t dataLen; + union dataType { + T_PsdkMopChannel_FileInfo fileInfo; + T_PsdkMopChannel_DwonloadReq dwonloadReq; + uint8_t fileData[0]; + } data; +} T_PsdkMopChannel_FileTransfor; + +#pragma pack() + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_MopChannelInit(void); + + +#ifdef __cplusplus +} +#endif + +#endif + +#endif // TEST_MOP_CHANNEL_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/payload_collaboration/test_payload_collaboration.c b/sample/api_sample/payload_collaboration/test_payload_collaboration.c new file mode 100644 index 0000000..ae89a27 --- /dev/null +++ b/sample/api_sample/payload_collaboration/test_payload_collaboration.c @@ -0,0 +1,175 @@ +/** + ******************************************************************** + * @file test_payload_collaboration.c + * @version V2.0.0 + * @date 2019/9/3 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_payload_collaboration.h" +#include "psdk_payload_collaboration.h" +#include "psdk_logger.h" +#include "psdk_platform.h" +#include "utils/util_misc.h" + +/* Private constants ---------------------------------------------------------*/ +#define PSDK_TEST_PAYLOAD_COLLABORATION_TASK_FREQ (1) +#define PSDK_TEST_PAYLOAD_COLLABORATION_TASK_STACK_SIZE (2048) +#define PSDK_TEST_PAYLOAD_COLLABORATION_PAYLOADS_IN_DRONE_MAX_COUNT (3) + +/* Private types -------------------------------------------------------------*/ +typedef struct { + E_PsdkPayloadCollaborationCameraType cameraType; + bool hasOpticalZoomSpec; + bool hasHybridZoomFocalLength; +} T_PsdkTestPayloadPara; + +/* Private functions declaration ---------------------------------------------*/ +static void *PsdkTest_PayloadCollaborationTask(void *arg); + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTaskHandle s_payloadCollaborationThread; + +static const T_PsdkTestPayloadPara s_payloadPara[] = { + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_XT, false, false}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_X4S, true, true}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_X5S, true, true}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_X7, true, true}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_Z30, true, true}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_XT2, true, true}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_XTS, false, false}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_H20, true, true}, + {PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_H20T, true, true}, +}; + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_PayloadCollaborationInit(void) +{ + if (PsdkPayloadCollaboration_Init() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("payload collaboration module init error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_TaskCreate(&s_payloadCollaborationThread, PsdkTest_PayloadCollaborationTask, + "user_payload_collaboration_task", PSDK_TEST_PAYLOAD_COLLABORATION_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user payload collaboration task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *PsdkTest_PayloadCollaborationTask(void *arg) +{ + int i = 0; + unsigned int payloadParaIndex = 0; + T_PsdkReturnCode psdkStat; + E_PsdkPayloadCollaborationCameraType cameraType = PSDK_PAYLOAD_COLLABORATION_CAMERA_TYPE_UNKNOWN; + T_PsdkCameraOpticalZoomSpec cameraOpticalZoomSpec = {0}; + uint16_t cameraHybridZoomFocalLength = 0; + T_PsdkAircraftInfoBaseInfo aircraftBaseInfo = {0}; + E_PsdkAircraftInfoPayloadMountPosition requestedPayloadMountPosition; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / PSDK_TEST_PAYLOAD_COLLABORATION_TASK_FREQ); + + psdkStat = PsdkAircraftInfo_GetBaseInfo(&aircraftBaseInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get aircraft information error: 0x%08llX.", psdkStat); + continue; + } + + for (i = 0; i < PSDK_TEST_PAYLOAD_COLLABORATION_PAYLOADS_IN_DRONE_MAX_COUNT; ++i) { + requestedPayloadMountPosition = + (E_PsdkAircraftInfoPayloadMountPosition) (i + PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO1); + if (requestedPayloadMountPosition == aircraftBaseInfo.payloadMountPosition) + continue; + + if (aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M200_V2 || + aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210_V2 || + aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210RTK_V2) { + if (requestedPayloadMountPosition == PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO3) { + continue; + } + } + + psdkStat = PsdkPayloadCollaboration_GetCameraTypeOfPayload(requestedPayloadMountPosition, &cameraType); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + continue; + } + PsdkLogger_UserLogDebug("camera type of payload mounted on NO.%d gimbal connector is %d.", + requestedPayloadMountPosition, cameraType); + + for (payloadParaIndex = 0; payloadParaIndex < UTIL_ARRAY_SIZE(s_payloadPara); ++payloadParaIndex) { + if (s_payloadPara[payloadParaIndex].cameraType == cameraType) + break; + } + if (payloadParaIndex == UTIL_ARRAY_SIZE(s_payloadPara)) { + PsdkLogger_UserLogError("Not find payload parameters."); + continue; + } + + if (s_payloadPara[payloadParaIndex].hasOpticalZoomSpec) { + psdkStat = PsdkPayloadCollaboration_GetCameraOpticalZoomSpecOfPayload(requestedPayloadMountPosition, + &cameraOpticalZoomSpec); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get optical zoom specification error."); + } else { + PsdkLogger_UserLogDebug( + "camera optical zoom specification of payload mounted on NO.%d gimbal connector, maxFocalLength: %d, minFocalLength: %d, focalLengthStep: %d.", + requestedPayloadMountPosition, cameraOpticalZoomSpec.maxFocalLength, + cameraOpticalZoomSpec.minFocalLength, cameraOpticalZoomSpec.focalLengthStep); + } + } + + if (s_payloadPara[payloadParaIndex].hasHybridZoomFocalLength) { + psdkStat = PsdkPayloadCollaboration_GetCameraHybridZoomFocalLengthOfPayload( + requestedPayloadMountPosition, + &cameraHybridZoomFocalLength); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get hybrid zoom focal length error."); + } else { + PsdkLogger_UserLogDebug( + "camera hybrid zoom focal length of payload mounted on NO.%d gimbal connector, focalLength: %d.", + requestedPayloadMountPosition, cameraHybridZoomFocalLength); + } + } + } + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/payload_collaboration/test_payload_collaboration.h b/sample/api_sample/payload_collaboration/test_payload_collaboration.h new file mode 100644 index 0000000..f3aa167 --- /dev/null +++ b/sample/api_sample/payload_collaboration/test_payload_collaboration.h @@ -0,0 +1,54 @@ +/** + ******************************************************************** + * @file test_payload_collaboration.h + * @version V2.0.0 + * @date 2019/9/3 + * @brief This is the header file for "test_payload_collaboration.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_PAYLOAD_COLLABORATION_H +#define TEST_PAYLOAD_COLLABORATION_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_PayloadCollaborationInit(void); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_PAYLOAD_COLLABORATION_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/positioning/test_positioning.c b/sample/api_sample/positioning/test_positioning.c new file mode 100644 index 0000000..06f386a --- /dev/null +++ b/sample/api_sample/positioning/test_positioning.c @@ -0,0 +1,151 @@ +/** + ******************************************************************** + * @file test_positioning.c + * @version V2.0.0 + * @date 2019/8/22 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_positioning.h" +#include "psdk_positioning.h" +#include "psdk_logger.h" +#include "utils/util_misc.h" +#include "psdk_platform.h" +#include "time_synchronization/test_time_sync.h" + +/* Private constants ---------------------------------------------------------*/ +#define POSITIONING_TASK_FREQ (1) +#define POSITIONING_TASK_STACK_SIZE (2048) +#define TEST_EVENT_COUNT (2) +#define TEST_TIME_INTERVAL_AMONG_EVENTS_US (200000) + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static void *PsdkTest_PositioningTask(void *arg); + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTaskHandle s_userPositioningThread; +static int32_t s_eventIndex = 0; + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_PositioningInit(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkPositioning_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("positioning module init error."); + return psdkStat; + } + + PsdkPositioning_SetTaskIndex(0); + + if (PsdkOsal_TaskCreate(&s_userPositioningThread, PsdkTest_PositioningTask, "user_positioning_task", + POSITIONING_TASK_STACK_SIZE, NULL) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user positioning task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *PsdkTest_PositioningTask(void *arg) +{ + int32_t i = 0; + T_PsdkReturnCode psdkStat; + uint64_t ppsNewestTriggerTimeUs = 0; + T_PsdkPositioningEventInfo eventInfo[TEST_EVENT_COUNT] = {0}; + T_PsdkPositioningPositionInfo positionInfo[TEST_EVENT_COUNT] = {0}; + T_PsdkTimeSyncAircraftTime aircraftTime = {0}; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / POSITIONING_TASK_FREQ); + + psdkStat = PsdkTest_TimeSyncGetNewestPpsTriggerLocalTimeUs(&ppsNewestTriggerTimeUs); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get newest pps trigger time error: 0x%08llX.", psdkStat); + continue; + } + + for (i = 0; i < TEST_EVENT_COUNT; ++i) { + eventInfo[i].eventSetIndex = s_eventIndex; + eventInfo[i].targetPointIndex = i; + + psdkStat = PsdkTimeSync_TransferToAircraftTime( + ppsNewestTriggerTimeUs - 1000000 - i * TEST_TIME_INTERVAL_AMONG_EVENTS_US, &aircraftTime); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("transfer to aircraft time error: 0x%08llX.", psdkStat); + continue; + } + + eventInfo[i].eventTime = aircraftTime; + } + + psdkStat = PsdkPositioning_GetPositionInformationSync(TEST_EVENT_COUNT, eventInfo, positionInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get position information error."); + continue; + } + + PsdkLogger_UserLogDebug("request position of target points success."); + PsdkLogger_UserLogDebug("detail position information:"); + for (i = 0; i < TEST_EVENT_COUNT; ++i) { + PsdkLogger_UserLogDebug("position solution property: %d.", positionInfo[i].positionSolutionProperty); + PsdkLogger_UserLogDebug("pitchAttitudeAngle: %d\trollAttitudeAngle: %d\tyawAttitudeAngle: %d", + positionInfo[i].uavAttitude.pitch, positionInfo[i].uavAttitude.roll, + positionInfo[i].uavAttitude.yaw); + PsdkLogger_UserLogDebug("northPositionOffset: %d\tearthPositionOffset: %d\tdownPositionOffset: %d", + positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.x, + positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.y, + positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.z); + PsdkLogger_UserLogDebug("longitude: %.8f\tlatitude: %.8f\theight: %.8f", + positionInfo[i].targetPointPosition.longitude, + positionInfo[i].targetPointPosition.latitude, + positionInfo[i].targetPointPosition.height); + PsdkLogger_UserLogDebug( + "longStandardDeviation: %.8f\tlatStandardDeviation: %.8f\thgtStandardDeviation: %.8f", + positionInfo[i].targetPointPositionStandardDeviation.longitude, + positionInfo[i].targetPointPositionStandardDeviation.latitude, + positionInfo[i].targetPointPositionStandardDeviation.height); + } + + s_eventIndex++; + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/positioning/test_positioning.h b/sample/api_sample/positioning/test_positioning.h new file mode 100644 index 0000000..820dd87 --- /dev/null +++ b/sample/api_sample/positioning/test_positioning.h @@ -0,0 +1,54 @@ +/** + ******************************************************************** + * @file test_positioning.h + * @version V2.0.0 + * @date 2019/8/22 + * @brief This is the header file for "test_positioning.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_POSITIONING_H +#define TEST_POSITIONING_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_PositioningInit(void); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_POSITIONING_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/power_management/test_power_management.c b/sample/api_sample/power_management/test_power_management.c new file mode 100644 index 0000000..f7ca6b9 --- /dev/null +++ b/sample/api_sample/power_management/test_power_management.c @@ -0,0 +1,145 @@ +/** + ******************************************************************** + * @file test_power_management.c + * @version V2.0.0 + * @date 2019/8/29 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_power_management.h" +#include "psdk_logger.h" + +/* Private constants ---------------------------------------------------------*/ + +/* Private types -------------------------------------------------------------*/ + +/* Private functions declaration ---------------------------------------------*/ +//需要自己写的函数:功能是负载设备关机前需要执行的命令 +//详细说明见网页:https://developer.dji.com/cn/payload-sdk/documentation/basicfunction/power-manage.html +static T_PsdkReturnCode PsdkTest_PowerOffNotificationCallback(bool *powerOffPreparationFlag); + +/* Private variables ---------------------------------------------------------*/ +//此变量是函数PsdkTest_RegApplyHighPowerHandler先判断然后内存拷贝过来的 +static T_PsdkTestApplyHighPowerHandler s_applyHighPowerHandler; + +/* Exported functions definition ---------------------------------------------*/ +/** + * @brief Register handler function for applying high power. This function have to be called before calling + * PsdkTest_PowerManagementInit(), except for in Linux, because PsdkTest_PowerManagementInit() do not apply high power + * in Linux OS. + * @param applyHighPowerHandler: pointer to handler function for applying high power. + * @return Execution result. + */ +T_PsdkReturnCode PsdkTest_RegApplyHighPowerHandler(T_PsdkTestApplyHighPowerHandler *applyHighPowerHandler) +{ + //此函数的功能:验证这两个函数指针指向的函数是否可用 → 结构体T_PsdkTestApplyHighPowerHandler中有两个函数指针,分别为pinInit和pinWrite + + //1、先判断两个函数指针是否为空,如果为空就报错 + if (applyHighPowerHandler->pinInit == NULL) { + PsdkLogger_UserLogError("reg apply high power handler pinInit error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (applyHighPowerHandler->pinWrite == NULL) { + PsdkLogger_UserLogError("reg apply high power handler pinWrite error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + //2、如果不为空就内存拷贝到本文件的静态变量中 + memcpy(&s_applyHighPowerHandler, applyHighPowerHandler, sizeof(T_PsdkTestApplyHighPowerHandler)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Initialise power management module, including apply high power (only RTOS) and register power off notification + * callback function. + * @note PSDK development board 1.0 can not accept high power, so do not call this function in PSDK development board + * 1.0 project. + * @return Execution result. + */ +T_PsdkReturnCode PsdkTest_PowerManagementInit(void) +{ + //此函数的功能: + //1、申请高功率。如果要申请高功率,需要在执行本函数前,先执行PsdkTest_RegApplyHighPowerHandler函数 + //2、负载设备关机前需要执行的操作 + + + T_PsdkReturnCode psdkStat; + + // apply high power +#if !PSDK_ARCH_SYS_LINUX + //如果函数指针pinInit为空(没有指向函数),就返回错误代码:PSDK_RETURN_CODE_ERR_UNKNOWN + if (s_applyHighPowerHandler.pinInit == NULL) { + PsdkLogger_UserLogError("apply high power pin init interface is NULL error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (s_applyHighPowerHandler.pinWrite == NULL) { + PsdkLogger_UserLogError("apply high power pin write interface is NULL error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //如果函数指针pinInit不为空(指向了一个函数),就执行函数,并根据返回值判断是否成功 + psdkStat = s_applyHighPowerHandler.pinInit(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("apply high power pin init error"); + return psdkStat; + } + //注册高电压返回函数 + psdkStat = PsdkPowerManagement_RegWriteHighPowerApplyPinCallback(s_applyHighPowerHandler.pinWrite); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register WriteHighPowerApplyPinCallback error."); + return psdkStat; + } + //执行高电压请求 + psdkStat = PsdkPowerManagement_ApplyHighPowerSync(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("apply high power error"); + return psdkStat; + } +#endif + + // register power off notification callback function + //负载设备关机前需要执行的操作 + psdkStat = PsdkPowerManagement_RegPowerOffNotificationCallback(PsdkTest_PowerOffNotificationCallback); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register power off notification callback function error"); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +//详细说明见函数申明处 +static T_PsdkReturnCode PsdkTest_PowerOffNotificationCallback(bool *powerOffPreparationFlag) +{ + PsdkLogger_UserLogDebug("aircraft will power off soon."); + + *powerOffPreparationFlag = true; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/power_management/test_power_management.h b/sample/api_sample/power_management/test_power_management.h new file mode 100644 index 0000000..96d7264 --- /dev/null +++ b/sample/api_sample/power_management/test_power_management.h @@ -0,0 +1,63 @@ +/** + ******************************************************************** + * @file test_power_management.h + * @version V2.0.0 + * @date 2019/8/29 + * @brief This is the header file for "test_power_management.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_POWER_MANAGEMENT_H +#define TEST_POWER_MANAGEMENT_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" +#include "psdk_power_management.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ +//E_PsdkPowerManagementPinState定义在中psdk_power_management.h +//里面的两个函数指针例子见下行网页中:PsdkTest_HighPowerApplyPinInit + PsdkTest_WriteHighPowerApplyPin +//https://developer.dji.com/cn/payload-sdk/documentation/basicfunction/power-manage.html +typedef struct { + T_PsdkReturnCode (*pinInit)(void); + T_PsdkReturnCode (*pinWrite)(E_PsdkPowerManagementPinState pinState); +} T_PsdkTestApplyHighPowerHandler; + +/* Exported functions --------------------------------------------------------*/ +//如果要申请高功率,需要在执行PsdkTest_PowerManagementInit函数前,先执行PsdkTest_RegApplyHighPowerHandler函数 +T_PsdkReturnCode PsdkTest_PowerManagementInit(void); +T_PsdkReturnCode PsdkTest_RegApplyHighPowerHandler(T_PsdkTestApplyHighPowerHandler *applyHighPowerHandler); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_POWER_MANAGEMENT_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/time_synchronization/test_time_sync.c b/sample/api_sample/time_synchronization/test_time_sync.c new file mode 100644 index 0000000..625c400 --- /dev/null +++ b/sample/api_sample/time_synchronization/test_time_sync.c @@ -0,0 +1,166 @@ +/** + ******************************************************************** + * @file test_time_sync.c + * @version V1.0.0 + * @date 11/26/19 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_time_sync.h" +#include "psdk_time_sync.h" +#include "psdk_logger.h" +#include "utils/util_misc.h" +#include "psdk_platform.h" + +/* Private constants ---------------------------------------------------------*/ +#define PSDK_TEST_TIME_SYNC_TASK_FREQ (1) +#define PSDK_TEST_TIME_SYNC_TASK_STACK_SIZE (2048) + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static void *PsdkTest_TimeSyncTask(void *arg); + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTestTimeSyncHandler s_timeSyncHandler; +static T_PsdkTaskHandle s_timeSyncThread; + +/* Exported functions definition ---------------------------------------------*/ +/** + * @brief Register handler function for initialising PPS pin configure and reporting the latest local time when PPS is + * triggered. This function have to be called before calling PsdkTest_TimeSyncInit(). + * @param timeSyncHandler: pointer to handler function for time synchronization. + * @return Execution result. + */ +T_PsdkReturnCode PsdkTest_TimeSyncRegHandler(T_PsdkTestTimeSyncHandler *timeSyncHandler) +{ + if (timeSyncHandler->PpsSignalResponseInit == NULL) { + PsdkLogger_UserLogError("reg time sync handler PpsSignalResponseInit error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (timeSyncHandler->GetNewestPpsTriggerLocalTimeUs == NULL) { + PsdkLogger_UserLogError("reg time sync handler GetNewestPpsTriggerLocalTimeUs error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + memcpy(&s_timeSyncHandler, timeSyncHandler, sizeof(T_PsdkTestTimeSyncHandler)); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_TimeSyncInit(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkTimeSync_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("time synchronization module init error."); + return psdkStat; + } + + if (s_timeSyncHandler.PpsSignalResponseInit == NULL) { + PsdkLogger_UserLogError("time sync handler PpsSignalResponseInit interface is NULL error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (s_timeSyncHandler.GetNewestPpsTriggerLocalTimeUs == NULL) { + PsdkLogger_UserLogError("time sync handler GetNewestPpsTriggerLocalTimeUs interface is NULL error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + // users must register getNewestPpsTriggerTime callback function + psdkStat = PsdkTimeSync_RegGetNewestPpsTriggerTimeCallback(s_timeSyncHandler.GetNewestPpsTriggerLocalTimeUs); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register GetNewestPpsTriggerLocalTimeUsCallback error."); + return psdkStat; + } + + if (PsdkOsal_TaskCreate(&s_timeSyncThread, PsdkTest_TimeSyncTask, "user_time_sync_task", + PSDK_TEST_TIME_SYNC_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user time sync task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + psdkStat = s_timeSyncHandler.PpsSignalResponseInit(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("pps signal response init error"); + return psdkStat; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_TimeSyncGetNewestPpsTriggerLocalTimeUs(uint64_t *localTimeUs) +{ + if (s_timeSyncHandler.GetNewestPpsTriggerLocalTimeUs == NULL) { + PsdkLogger_UserLogError("GetNewestPpsTriggerLocalTimeUs null error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + return s_timeSyncHandler.GetNewestPpsTriggerLocalTimeUs(localTimeUs); +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *PsdkTest_TimeSyncTask(void *arg) +{ + T_PsdkReturnCode psdkStat; + uint32_t currentTimeMs = 0; + T_PsdkTimeSyncAircraftTime aircraftTime = {0}; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / PSDK_TEST_TIME_SYNC_TASK_FREQ); + + psdkStat = PsdkOsal_GetTimeMs(¤tTimeMs); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get current time error: 0x%08llX.", psdkStat); + continue; + } + + psdkStat = PsdkTimeSync_TransferToAircraftTime(currentTimeMs * 1000, &aircraftTime); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("transfer to aircraft time error: 0x%08llX.", psdkStat); + continue; + } + + PsdkLogger_UserLogDebug("current aircraft time is %d.%d.%d %d:%d %d %d.", aircraftTime.year, aircraftTime.month, + aircraftTime.day, aircraftTime.hour, aircraftTime.minute, aircraftTime.second, + aircraftTime.microsecond); + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/time_synchronization/test_time_sync.h b/sample/api_sample/time_synchronization/test_time_sync.h new file mode 100644 index 0000000..00dc302 --- /dev/null +++ b/sample/api_sample/time_synchronization/test_time_sync.h @@ -0,0 +1,59 @@ +/** + ******************************************************************** + * @file test_time_sync.h + * @version V0.0.0 + * @date 11/26/19 + * @brief This is the header file for "test_time_sync.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_TIME_SYNC_H +#define TEST_TIME_SYNC_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ +typedef struct { + T_PsdkReturnCode (*PpsSignalResponseInit)(void); + T_PsdkReturnCode (*GetNewestPpsTriggerLocalTimeUs)(uint64_t *localTimeUs); +} T_PsdkTestTimeSyncHandler; + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_TimeSyncRegHandler(T_PsdkTestTimeSyncHandler *timeSyncHandler); +T_PsdkReturnCode PsdkTest_TimeSyncInit(void); +T_PsdkReturnCode PsdkTest_TimeSyncGetNewestPpsTriggerLocalTimeUs(uint64_t *localTimeUs); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_TIME_SYNC_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/upgrade/test_upgrade.c b/sample/api_sample/upgrade/test_upgrade.c new file mode 100644 index 0000000..dc11050 --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade.c @@ -0,0 +1,371 @@ +/** + ******************************************************************** + * @file test_upgrade.c + * @version V2.0.0 + * @date 3/4/20 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "test_upgrade_common.h" +#include +#include +#include +#include "test_upgrade_common_file_transfer.h" +#include "test_upgrade_platform_opt.h" + +/* Private constants ---------------------------------------------------------*/ +#define UPGRADE_TASK_STACK_SIZE (2048) +#define PSDK_TEST_UPGRADE_TASK_FREQ 50 +#define PSDK_TEST_ENTER_UPGRADE_WAIT_TIME 10 //wait 10s for enter upgrade process +#define PSDK_TEST_UPGRADE_REBOOT_TIMEOUT 30 //reboot timeout 30s + +/* Private types -------------------------------------------------------------*/ + +/* Private values -------------------------------------------------------------*/ +static T_PsdkUpgradeState s_upgradeState = {0}; +static T_PsdkMutexHandle s_upgradeStateMutex = {0}; +static T_PsdkTaskHandle s_upgradeProcessThread; +static T_PsdkTaskHandle s_enterUpgradeModeProcessThread; +static bool s_isNeedEnterUpgradeModeProcess = false; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkTest_EnterUpgradeMode(uint16_t *waitTime); +static T_PsdkReturnCode PsdkTest_CheckFirmware(void); +static T_PsdkReturnCode PsdkTest_StartUpgrade(void); +static T_PsdkReturnCode PsdkTest_FinishUpgrade(void); +static void *PsdkTest_UpgradeProcessTask(void *arg); +static void *PsdkTest_EnterUpgradeModeProcessTask(void *arg); + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_UpgradeInit(const T_PsdkTestUpgradePlatformOpt *upgradePlatformOpt) +{ + T_PsdkReturnCode returnCode; + bool isUpgradeReboot = false; + T_PsdkUpgradeEndInfo upgradeEndInfo = {0}; + T_PsdkUpgradeConfig upgradeConfig = { + .currentFirmwareVersion = {PSDK_TEST_FIRMWARE_VERSION_MAJOR, PSDK_TEST_FIRMWARE_VERSION_MINOR, + PSDK_TEST_FIRMWARE_VERSION_MODIFY, PSDK_TEST_FIRMWARE_VERSION_DEBUG}, +#if PSDK_TEST_UPGRADE_USE_FTP_TRANSFER + .firmwareTransferInfo = { + .transferType = PSDK_PAYLOAD_FIRMWARE_TRANSFER_TYPE_FTP, + .ftpTransferInfo.port = 21, // use default ftp port + } +#else + .firmwareTransferInfo = { + .transferType = PSDK_PAYLOAD_FIRMWARE_TRANSFER_TYPE_DCFTP, + .dcftpFileTransferOpt = { + .start = PsdkTestCommonFileTransfer_Start, + .transfer = PsdkTestCommonFileTransfer_Transfer, + .finish = PsdkTestCommonFileTransfer_Finish, + } + } +#endif + }; + + T_PsdkUpgradeHandler s_upgradeHandler = { + .EnterUpgradeMode = PsdkTest_EnterUpgradeMode, + .CheckFirmware = PsdkTest_CheckFirmware, + .StartUpgrade = PsdkTest_StartUpgrade, + .FinishUpgrade = PsdkTest_FinishUpgrade + }; + + returnCode = PsdkTest_RegUpgradePlatformOpt(upgradePlatformOpt); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Reg upgrade platform opt error, return code = 0x%08llX", returnCode); + return returnCode; + } + + returnCode = PsdkOsal_MutexCreate(&s_upgradeStateMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Create mutex error"); + return returnCode; + } + + returnCode = PsdkTest_GetUpgradeRebootState(&isUpgradeReboot, &upgradeEndInfo); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get upgrade reboot state error"); + isUpgradeReboot = false; + } + + returnCode = PsdkTest_CleanUpgradeRebootState(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Clean upgrade reboot state error"); + } + + PsdkOsal_MutexLock(s_upgradeStateMutex); + if (isUpgradeReboot == true) { + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo = upgradeEndInfo; + } else { + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_IDLE; + } + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + + returnCode = PsdkUpgrade_Init(&upgradeConfig); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("PsdkUpgrade_Init error, return code = %d", returnCode); + return returnCode; + } + + returnCode = PsdkUpgrade_RegHandler(&s_upgradeHandler); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("PsdkUpgrade_RegHandler error, return code = %d", returnCode); + return returnCode; + } + + returnCode = PsdkUpgrade_EnableLocalUpgrade(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("PsdkUpgrade_EnableLocalUpgrade error, return code = %d", returnCode); + return returnCode; + } + + if (PsdkOsal_TaskCreate(&s_upgradeProcessThread, PsdkTest_UpgradeProcessTask, "upgrade_task", + UPGRADE_TASK_STACK_SIZE, NULL) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Psdk upgrade test task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + if (PsdkOsal_TaskCreate(&s_enterUpgradeModeProcessThread, PsdkTest_EnterUpgradeModeProcessTask, + "enter_upgrade_mode_task", UPGRADE_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Psdk upgrade test task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkTest_EnterUpgradeMode(uint16_t *waitTime) +{ + // need 10s for upgrade preprocess work. + *waitTime = PSDK_TEST_ENTER_UPGRADE_WAIT_TIME; + // enable is need enter upgrade mode process, the process is in PsdkTest_EnterUpgradeModeProcessTask + s_isNeedEnterUpgradeModeProcess = true; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTest_CheckFirmware(void) +{ + // you can do decrypt and check firmware in this stage + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTest_StartUpgrade(void) +{ + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeOngoingInfo.upgradeProgress = 0; + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_ONGOING; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTest_FinishUpgrade(void) +{ + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_IDLE; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *PsdkTest_EnterUpgradeModeProcessTask(void *arg) +{ + T_PsdkReturnCode returnCode; + + USER_UTIL_UNUSED(arg); + + while (1) { + if (s_isNeedEnterUpgradeModeProcess) { + // prepare enter upgrade mode + // you can do some thing before enter upgrade mode. + // clear upgrade program file store area + returnCode = PsdkTest_CleanUpgradeProgramFileStoreArea(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Clean upgrade file dir error, please check dir permission"); + } + + s_isNeedEnterUpgradeModeProcess = false; + } + PsdkOsal_TaskSleepMs(1000 / PSDK_TEST_UPGRADE_TASK_FREQ); + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +static void *PsdkTest_UpgradeProcessTask(void *arg) +{ + T_PsdkUpgradeState tempUpgradeState; + T_PsdkUpgradeEndInfo upgradeEndInfo; + T_PsdkReturnCode returnCode; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_MutexLock(s_upgradeStateMutex); + tempUpgradeState = s_upgradeState; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + + if (tempUpgradeState.upgradeStage == PSDK_UPGRADE_STAGE_ONGOING) { +#if PSDK_TEST_REPLACE_PROGRAM_BEFORE_REBOOT + // Step 1 : Replace old program + returnCode = PsdkTest_ReplaceOldProgram(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Replace firmware error, return code = 0x%08llX", returnCode); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_UNKNOWN_ERROR; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; + } + + PsdkOsal_TaskSleepMs(1000); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_ONGOING; + s_upgradeState.upgradeOngoingInfo.upgradeProgress = 20; + PsdkUpgrade_PushUpgradeState(&s_upgradeState); + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + + // Step 2 : Clean upgrade program file store area + returnCode = PsdkTest_CleanUpgradeProgramFileStoreArea(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Clean upgrade file dir error, please check dir permission"); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_UNKNOWN_ERROR; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; + } + + PsdkOsal_TaskSleepMs(1000); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_ONGOING; + s_upgradeState.upgradeOngoingInfo.upgradeProgress = 30; + PsdkUpgrade_PushUpgradeState(&s_upgradeState); + PsdkOsal_MutexUnlock(s_upgradeStateMutex); +#endif + //attention emulation upgrade progress, user don't need this process + do { + PsdkOsal_TaskSleepMs(1000); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_ONGOING; + s_upgradeState.upgradeOngoingInfo.upgradeProgress += 10; + tempUpgradeState = s_upgradeState; + PsdkUpgrade_PushUpgradeState(&s_upgradeState); + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + } while (tempUpgradeState.upgradeOngoingInfo.upgradeProgress < 100); + + // Step 3 : Reboot device + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_DEVICE_REBOOT; + s_upgradeState.upgradeRebootInfo.rebootTimeout = PSDK_TEST_UPGRADE_REBOOT_TIMEOUT; + PsdkUpgrade_PushUpgradeState(&s_upgradeState); + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + PsdkOsal_TaskSleepMs(1000); // sleep 1000ms to ensure push send terminal. + + upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_SUCCESS; + returnCode = PsdkTest_SetUpgradeRebootState(&upgradeEndInfo); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Set Upgrade reboot state error"); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_UNKNOWN_ERROR; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; + } + +#if PSDK_TEST_UPGRADE_NO_REBOOT_EMU + bool isUpgradeReboot; + returnCode = PsdkTest_GetUpgradeRebootState(&isUpgradeReboot, &upgradeEndInfo); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get upgrade reboot state error"); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_UNKNOWN_ERROR; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; + } + + returnCode = PsdkTest_CleanUpgradeRebootState(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Clean upgrade reboot state error"); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_UNKNOWN_ERROR; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; + } + + PsdkOsal_MutexLock(s_upgradeStateMutex); + if (isUpgradeReboot == true) { + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo = upgradeEndInfo; + } else { + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_IDLE; + } + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; +#else + returnCode = PsdkTest_RebootSystem(); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Reboot system error"); + PsdkOsal_MutexLock(s_upgradeStateMutex); + s_upgradeState.upgradeStage = PSDK_UPGRADE_STAGE_END; + s_upgradeState.upgradeEndInfo.upgradeEndState = PSDK_UPGRADE_END_STATE_UNKNOWN_ERROR; + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + continue; + } + while (1) { + PsdkOsal_TaskSleepMs(500); + } +#endif + } else if (s_upgradeState.upgradeStage == PSDK_UPGRADE_STAGE_END) { + PsdkOsal_MutexLock(s_upgradeStateMutex); + PsdkUpgrade_PushUpgradeState(&s_upgradeState); + PsdkOsal_MutexUnlock(s_upgradeStateMutex); + } + + PsdkOsal_TaskSleepMs(500); + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/upgrade/test_upgrade.h b/sample/api_sample/upgrade/test_upgrade.h new file mode 100644 index 0000000..4390c2e --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade.h @@ -0,0 +1,52 @@ +/** + ******************************************************************** + * @file test_upgrade.h + * @version V2.0.0 + * @date 3/4/20 + * @brief This is the header file for "test_upgrade.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_UPGRADE_H +#define TEST_UPGRADE_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include "test_upgrade_platform_opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_UpgradeInit(const T_PsdkTestUpgradePlatformOpt *upgradePlatformOpt); + +#ifdef __cplusplus +} +#endif + +#endif +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/upgrade/test_upgrade_common.h b/sample/api_sample/upgrade/test_upgrade_common.h new file mode 100644 index 0000000..e018314 --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade_common.h @@ -0,0 +1,74 @@ +/** + ******************************************************************** + * @file test_upgrade_common.h + * @version V2.0.0 + * @date 3/12/20 + * @brief This is the header file for "test_upgrade_linux_common.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_UPGRADE_COMMON_H +#define TEST_UPGRADE_COMMON_H + +/* Includes ------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ +// firmware version +#define PSDK_TEST_FIRMWARE_VERSION_MAJOR 2 +#define PSDK_TEST_FIRMWARE_VERSION_MINOR 1 +#define PSDK_TEST_FIRMWARE_VERSION_MODIFY 0 +#define PSDK_TEST_FIRMWARE_VERSION_DEBUG 3 + +// define if only emulate upgrade, no system reboot +#define PSDK_TEST_UPGRADE_NO_REBOOT_EMU 0 + +#if PSDK_ARCH_SYS_LINUX + +// define if replace program before reboot +#define PSDK_TEST_REPLACE_PROGRAM_BEFORE_REBOOT 1 +// define if use ftp transfer, only support linux +#define PSDK_TEST_UPGRADE_USE_FTP_TRANSFER 1 + +#else + +// for mcu, program is on flash , need replace program in loader, not before reboot +#define PSDK_TEST_REPLACE_PROGRAM_BEFORE_REBOOT 0 +// define if use ftp transfer +#define PSDK_TEST_UPGRADE_USE_FTP_TRANSFER 0 + +#endif + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif // TEST_UPGRADE_LINUX_COMMON_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/upgrade/test_upgrade_common_file_transfer.c b/sample/api_sample/upgrade/test_upgrade_common_file_transfer.c new file mode 100644 index 0000000..7592846 --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade_common_file_transfer.c @@ -0,0 +1,151 @@ +/** + ******************************************************************** + * @file test_upgrade_common_file_transfer.c + * @version V2.0.0 + * @date 3/12/20 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "test_upgrade_common_file_transfer.h" +#include "psdk_logger.h" +#include +#include "test_upgrade_platform_opt.h" + +/* Private constants ---------------------------------------------------------*/ +#define PSDK_TEST_FILE_MD5_BUFFER_SIZE 256 + +/* Private types -------------------------------------------------------------*/ + +/* Private values -------------------------------------------------------------*/ +static T_PsdkUpgradeFileInfo s_upgradeFileInfo = {0}; +static uint32_t s_alreadyTransferFileSize = 0; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkTestFile_GetUpgradeFileMd5(uint8_t md5[PSDK_MD5_BUFFER_LEN]); + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTestCommonFileTransfer_Start(const T_PsdkUpgradeFileInfo *fileInfo) +{ + T_PsdkReturnCode returnCode; + + s_upgradeFileInfo.fileSize = 0; + memset(s_upgradeFileInfo.fileName, 0, sizeof(s_upgradeFileInfo.fileName)); + s_alreadyTransferFileSize = 0; + + returnCode = PsdkTest_CreateUpgradeProgramFile(fileInfo); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Create upgrade program file error"); + return returnCode; + } + + s_upgradeFileInfo = *fileInfo; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTestCommonFileTransfer_Transfer(const uint8_t *data, uint16_t dataLen) +{ + T_PsdkReturnCode returnCode; + + if (s_alreadyTransferFileSize >= s_upgradeFileInfo.fileSize) { + PsdkLogger_UserLogError("Already transfer file size is more than file real size"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + returnCode = PsdkTest_WriteUpgradeProgramFile(s_alreadyTransferFileSize, data, dataLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Write upgrade program file error, return code = 0x%08llX", returnCode); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + s_alreadyTransferFileSize += dataLen; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTestCommonFileTransfer_Finish(const uint8_t md5[PSDK_MD5_BUFFER_LEN]) +{ + uint8_t localFileMd5[PSDK_MD5_BUFFER_LEN] = {0}; + T_PsdkReturnCode returnCode; + + if (s_alreadyTransferFileSize != s_upgradeFileInfo.fileSize) { + PsdkLogger_UserLogError("Transfer finish error, transfer file size is not equal"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + returnCode = PsdkTestFile_GetUpgradeFileMd5(localFileMd5); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get file md5 error, return code = 0x%08llX", returnCode); + goto out; + } + + if (memcmp(md5, localFileMd5, PSDK_MD5_BUFFER_LEN) == 0) { + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } else { + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + +out: + PsdkTest_CloseUpgradeProgramFile(); + s_upgradeFileInfo.fileSize = 0; + memset(s_upgradeFileInfo.fileName, 0, sizeof(s_upgradeFileInfo.fileName)); + s_alreadyTransferFileSize = 0; + return returnCode; +} + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkTestFile_GetUpgradeFileMd5(uint8_t md5[PSDK_MD5_BUFFER_LEN]) +{ + uint8_t fileBuffer[PSDK_TEST_FILE_MD5_BUFFER_SIZE] = {0}; + T_PsdkReturnCode returnCode; + uint32_t offset; + MD5_CTX fileMd5Ctx; + uint16_t realLen = 0; + + offset = 0; + UtilMd5_Init(&fileMd5Ctx); + while (s_upgradeFileInfo.fileSize - offset > PSDK_TEST_FILE_MD5_BUFFER_SIZE) { + returnCode = PsdkTest_ReadUpgradeProgramFile(offset, PSDK_TEST_FILE_MD5_BUFFER_SIZE, + fileBuffer, &realLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS || realLen != PSDK_TEST_FILE_MD5_BUFFER_SIZE) { + PsdkLogger_UserLogError("Get file data error, return code = 0x%08llX", returnCode); + return returnCode; + } + + UtilMd5_Update(&fileMd5Ctx, fileBuffer, PSDK_TEST_FILE_MD5_BUFFER_SIZE); + + offset += PSDK_TEST_FILE_MD5_BUFFER_SIZE; + } + + returnCode = PsdkTest_ReadUpgradeProgramFile(offset, s_upgradeFileInfo.fileSize - offset, fileBuffer, &realLen); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS || realLen != s_upgradeFileInfo.fileSize - offset) { + PsdkLogger_UserLogError("Get file data error, return code = 0x%08llX", returnCode); + return returnCode; + } + + UtilMd5_Update(&fileMd5Ctx, fileBuffer, s_upgradeFileInfo.fileSize - offset); + UtilMd5_Final(&fileMd5Ctx, md5); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/upgrade/test_upgrade_common_file_transfer.h b/sample/api_sample/upgrade/test_upgrade_common_file_transfer.h new file mode 100644 index 0000000..f01d35d --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade_common_file_transfer.h @@ -0,0 +1,53 @@ +/** + ******************************************************************** + * @file test_upgrade_common_file_transfer.h + * @version V2.0.0 + * @date 3/12/20 + * @brief This is the header file for "test_upgrade_common_file_transfer.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_UPGRADE_COMMON_FILE_TRANSFER_H +#define TEST_UPGRADE_COMMON_FILE_TRANSFER_H + +/* Includes ------------------------------------------------------------------*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTestCommonFileTransfer_Start(const T_PsdkUpgradeFileInfo *fileInfo); +T_PsdkReturnCode PsdkTestCommonFileTransfer_Transfer(const uint8_t *data, uint16_t dataLen); +T_PsdkReturnCode PsdkTestCommonFileTransfer_Finish(const uint8_t md5[PSDK_MD5_BUFFER_LEN]); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_UPGRADE_COMMON_FILE_TRANSFER_LINUX_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/upgrade/test_upgrade_platform_opt.c b/sample/api_sample/upgrade/test_upgrade_platform_opt.c new file mode 100644 index 0000000..aa0063d --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade_platform_opt.c @@ -0,0 +1,141 @@ +/** + ******************************************************************** + * @file test_upgrade_platform_opt.c + * @version V1.0.0 + * @date 2019/01/01 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "test_upgrade_platform_opt.h" +#include + +/* Private constants ---------------------------------------------------------*/ + +/* Private types -------------------------------------------------------------*/ + +/* Private values -------------------------------------------------------------*/ +static T_PsdkTestUpgradePlatformOpt s_upgradePlatformOpt = {0}; + +/* Private functions declaration ---------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_RegUpgradePlatformOpt(const T_PsdkTestUpgradePlatformOpt *upgradePlatformOpt) +{ + if (upgradePlatformOpt->rebootSystem == NULL) { + PsdkLogger_UserLogError("rebootSystem callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->cleanUpgradeProgramFileStoreArea == NULL) { + PsdkLogger_UserLogError("cleanUpgradeProgramFileStoreArea callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->createUpgradeProgramFile == NULL) { + PsdkLogger_UserLogError("createUpgradeProgramFile callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->readUpgradeProgramFile == NULL) { + PsdkLogger_UserLogError("readUpgradeProgramFile callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->writeUpgradeProgramFile == NULL) { + PsdkLogger_UserLogError("writeUpgradeProgramFile callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->closeUpgradeProgramFile == NULL) { + PsdkLogger_UserLogError("closeUpgradeProgramFile callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->replaceOldProgram == NULL) { + PsdkLogger_UserLogError("replaceOldProgram callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->setUpgradeRebootState == NULL) { + PsdkLogger_UserLogError("setUpgradeRebootState callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->getUpgradeRebootState == NULL) { + PsdkLogger_UserLogError("getUpgradeRebootState callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + if (upgradePlatformOpt->cleanUpgradeRebootState == NULL) { + PsdkLogger_UserLogError("cleanUpgradeRebootState callback can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + s_upgradePlatformOpt = *upgradePlatformOpt; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_RebootSystem(void) +{ + return s_upgradePlatformOpt.rebootSystem(); +} + +T_PsdkReturnCode PsdkTest_CleanUpgradeProgramFileStoreArea(void) +{ + return s_upgradePlatformOpt.cleanUpgradeProgramFileStoreArea(); +} + +T_PsdkReturnCode PsdkTest_CreateUpgradeProgramFile(const T_PsdkUpgradeFileInfo *fileInfo) +{ + return s_upgradePlatformOpt.createUpgradeProgramFile(fileInfo); +} + +T_PsdkReturnCode PsdkTest_WriteUpgradeProgramFile(uint32_t offset, const uint8_t *data, uint16_t dataLen) +{ + return s_upgradePlatformOpt.writeUpgradeProgramFile(offset, data, dataLen); +} + +T_PsdkReturnCode PsdkTest_ReadUpgradeProgramFile(uint32_t offset, uint16_t readDataLen, uint8_t *data, + uint16_t *realLen) +{ + return s_upgradePlatformOpt.readUpgradeProgramFile(offset, readDataLen, data, realLen); +} + +T_PsdkReturnCode PsdkTest_CloseUpgradeProgramFile(void) +{ + return s_upgradePlatformOpt.closeUpgradeProgramFile(); +} + +T_PsdkReturnCode PsdkTest_ReplaceOldProgram(void) +{ + return s_upgradePlatformOpt.replaceOldProgram(); +} + +T_PsdkReturnCode PsdkTest_SetUpgradeRebootState(const T_PsdkUpgradeEndInfo *upgradeEndInfo) +{ + return s_upgradePlatformOpt.setUpgradeRebootState(upgradeEndInfo); +} + +T_PsdkReturnCode PsdkTest_GetUpgradeRebootState(bool *isUpgradeReboot, T_PsdkUpgradeEndInfo *upgradeEndInfo) +{ + return s_upgradePlatformOpt.getUpgradeRebootState(isUpgradeReboot, upgradeEndInfo); +} + +T_PsdkReturnCode PsdkTest_CleanUpgradeRebootState(void) +{ + return s_upgradePlatformOpt.cleanUpgradeRebootState(); +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/upgrade/test_upgrade_platform_opt.h b/sample/api_sample/upgrade/test_upgrade_platform_opt.h new file mode 100644 index 0000000..b27abc4 --- /dev/null +++ b/sample/api_sample/upgrade/test_upgrade_platform_opt.h @@ -0,0 +1,86 @@ +/** + ******************************************************************** + * @file test_upgrade_platform_opt.h + * @version V0.0.0 + * @date 2019/01/01 + * @brief This is the header file for "test_upgrade_platform_opt.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_UPGRADE_PLATFORM_OPT_H +#define TEST_UPGRADE_PLATFORM_OPT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ +typedef struct { + T_PsdkReturnCode (*rebootSystem)(void); + + T_PsdkReturnCode (*cleanUpgradeProgramFileStoreArea)(void); + T_PsdkReturnCode (*createUpgradeProgramFile)(const T_PsdkUpgradeFileInfo *fileInfo); + T_PsdkReturnCode (*writeUpgradeProgramFile)(uint32_t offset, const uint8_t *data, uint16_t dataLen); + T_PsdkReturnCode (*readUpgradeProgramFile)(uint32_t offset, uint16_t readDataLen, uint8_t *data, + uint16_t *realLen); + T_PsdkReturnCode (*closeUpgradeProgramFile)(void); + + T_PsdkReturnCode (*replaceOldProgram)(void); + + T_PsdkReturnCode (*setUpgradeRebootState)(const T_PsdkUpgradeEndInfo *upgradeEndInfo); + T_PsdkReturnCode (*getUpgradeRebootState)(bool *isUpgradeReboot, T_PsdkUpgradeEndInfo *upgradeEndInfo); + T_PsdkReturnCode (*cleanUpgradeRebootState)(void); +} T_PsdkTestUpgradePlatformOpt; + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_RegUpgradePlatformOpt(const T_PsdkTestUpgradePlatformOpt *upgradePlatformOpt); + +T_PsdkReturnCode PsdkTest_RebootSystem(void); + +T_PsdkReturnCode PsdkTest_CleanUpgradeProgramFileStoreArea(void); +T_PsdkReturnCode PsdkTest_CreateUpgradeProgramFile(const T_PsdkUpgradeFileInfo *fileInfo); +T_PsdkReturnCode PsdkTest_WriteUpgradeProgramFile(uint32_t offset, const uint8_t *data, uint16_t dataLen); +T_PsdkReturnCode PsdkTest_ReadUpgradeProgramFile(uint32_t offset, uint16_t readDataLen, uint8_t *data, + uint16_t *realLen); +T_PsdkReturnCode PsdkTest_CloseUpgradeProgramFile(void); + +T_PsdkReturnCode PsdkTest_ReplaceOldProgram(void); + +T_PsdkReturnCode PsdkTest_SetUpgradeRebootState(const T_PsdkUpgradeEndInfo *upgradeEndInfo); +T_PsdkReturnCode PsdkTest_GetUpgradeRebootState(bool *isUpgradeReboot, T_PsdkUpgradeEndInfo *upgradeEndInfo); +T_PsdkReturnCode PsdkTest_CleanUpgradeRebootState(void); + +#ifdef __cplusplus +} +#endif + +#endif // TEST_UPGRADE_PLATFORM_OPT_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/utils/util_buffer.c b/sample/api_sample/utils/util_buffer.c new file mode 100644 index 0000000..e6e1485 --- /dev/null +++ b/sample/api_sample/utils/util_buffer.c @@ -0,0 +1,129 @@ +/** + ****************************************************************************** + * @file util_buffer.c + * @version V1.0.0 + * @date 2017/11/10 + * @brief The file defines buffer related functions, including initialize, put data to buffer, + * get data from buffer and get unused count of bytes of buffer. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "util_buffer.h" +#include +#include "util_misc.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Exported variables --------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Cut buffer size to power of 2, in order to increase the convenience of get and put operating of buffer. + * @param bufSize Original buffer size. + * @return Buffer size after handling. + */ +static uint16_t UtilBuffer_CutBufSizeToPowOfTwo(uint16_t bufSize) +{ + uint16_t i = 0; + + while ((1 << (++i)) <= bufSize); + return (uint16_t) (1 << (--i)); +} + +/* Exported functions --------------------------------------------------------*/ + +/** + * @brief Buffer initialization. + * @param pthis Pointer to buffer structure. + * @param pBuf Pointer to data buffer. + * @param bufSize Size of data buffer. + * @return None. + */ +void UtilBuffer_Init(T_UtilBuffer *pthis, uint8_t *pBuf, uint16_t bufSize) +{ + pthis->readIndex = 0; + pthis->writeIndex = 0; + pthis->bufferPtr = pBuf; + pthis->bufferSize = UtilBuffer_CutBufSizeToPowOfTwo(bufSize); +} + +/** + * @brief Put a block of data into buffer. + * @param pthis Pointer to buffer structure. + * @param pData Pointer to data to be stored. + * @param dataLen Length of data to be stored. + * @return Length of data to be stored. + */ +uint16_t UtilBuffer_Put(T_UtilBuffer *pthis, const uint8_t *pData, uint16_t dataLen) +{ + uint16_t writeUpLen; + + dataLen = USER_UTIL_MIN(dataLen, (uint16_t) (pthis->bufferSize - pthis->writeIndex + pthis->readIndex)); + + //fill up data + writeUpLen = USER_UTIL_MIN(dataLen, (uint16_t) (pthis->bufferSize - (pthis->writeIndex & (pthis->bufferSize - 1)))); + memcpy(pthis->bufferPtr + (pthis->writeIndex & (pthis->bufferSize - 1)), pData, writeUpLen); + + //fill begin data + memcpy(pthis->bufferPtr, pData + writeUpLen, dataLen - writeUpLen); + + pthis->writeIndex += dataLen; + + return dataLen; +} + +/** + * @brief Get a block of data from buffer. +* @param pthis Pointer to buffer structure. +* @param pData Pointer to data to be read. +* @param dataLen Length of data to be read. +* @return Length of data to be read. + */ +uint16_t UtilBuffer_Get(T_UtilBuffer *pthis, uint8_t *pData, uint16_t dataLen) +{ + uint16_t readUpLen; + + dataLen = USER_UTIL_MIN(dataLen, (uint16_t) (pthis->writeIndex - pthis->readIndex)); + + //get up data + readUpLen = USER_UTIL_MIN(dataLen, (uint16_t) (pthis->bufferSize - (pthis->readIndex & (pthis->bufferSize - 1)))); + memcpy(pData, pthis->bufferPtr + (pthis->readIndex & (pthis->bufferSize - 1)), readUpLen); + + //get begin data + memcpy(pData + readUpLen, pthis->bufferPtr, dataLen - readUpLen); + + pthis->readIndex += dataLen; + + return dataLen; +} + +/** + * @brief Get unused size of buffer. + * @param pthis Pointer to buffer structure. + * @return Unused size of buffer. + */ +uint16_t UtilBuffer_GetUnusedSize(T_UtilBuffer *pthis) +{ + return (uint16_t) (pthis->bufferSize - pthis->writeIndex + pthis->readIndex); +} diff --git a/sample/api_sample/utils/util_buffer.h b/sample/api_sample/utils/util_buffer.h new file mode 100644 index 0000000..0a83313 --- /dev/null +++ b/sample/api_sample/utils/util_buffer.h @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * @file util_buffer.h + * @version V1.0.0 + * @date 2017/11/10 + * @brief This is the header file for "util_buffer.c". + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _DJI_UTIL_BUFFER_H_ +#define _DJI_UTIL_BUFFER_H_ + +/* Includes ------------------------------------------------------------------*/ +#include + +/* Exported constants --------------------------------------------------------*/ +/* Exported macros -----------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ + +//Note: not need lock for just one producer / one consumer +//need mutex to protect for multi-producer / multi-consumer +typedef struct { + uint8_t *bufferPtr; + uint16_t bufferSize; + uint16_t readIndex; + uint16_t writeIndex; +} T_UtilBuffer; + +/* Exported variables --------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ + +void UtilBuffer_Init(T_UtilBuffer *pthis, uint8_t *pBuf, uint16_t bufSize); +uint16_t UtilBuffer_Put(T_UtilBuffer *pthis, const uint8_t *pData, uint16_t dataLen); +uint16_t UtilBuffer_Get(T_UtilBuffer *pthis, uint8_t *pData, uint16_t dataLen); +uint16_t UtilBuffer_GetUnusedSize(T_UtilBuffer *pthis); + +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +#endif diff --git a/sample/api_sample/utils/util_file.c b/sample/api_sample/utils/util_file.c new file mode 100644 index 0000000..34d10ca --- /dev/null +++ b/sample/api_sample/utils/util_file.c @@ -0,0 +1,210 @@ +/** + ******************************************************************** + * @file util_file.c + * @version V2.0.0 + * @date 2019/08/30 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "util_file.h" +#include +#include +#include + +/* Private constants ---------------------------------------------------------*/ + + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ + + +/* Private values ------------------------------------------------------------*/ + + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode UtilFile_GetCreateTime(const char *filePath, T_UtilFileCreateTime *createTime) +{ + struct stat st; + struct tm *fileTm; + + if (filePath == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (stat(filePath, &st) != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + fileTm = localtime(&(st.st_ctime)); + if (fileTm == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + createTime->year = fileTm->tm_year + 1900 - 1980; + createTime->month = fileTm->tm_mon; + createTime->day = fileTm->tm_mday; + createTime->hour = fileTm->tm_hour; + createTime->minute = fileTm->tm_min; + createTime->second = fileTm->tm_sec; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode UtilFile_GetFileSizeByPath(const char *filePath, uint32_t *fileSize) +{ + struct stat st; + + if (filePath == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (stat(filePath, &st) != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + *fileSize = st.st_size; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen) +{ + FILE *pF; + T_PsdkReturnCode psdkStat; + uint32_t readRtn; + + if (filePath == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + pF = fopen(filePath, "rb+"); + if (pF == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (fseek(pF, offset, SEEK_SET) != 0) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + + readRtn = fread(data, 1, len, pF); + if (readRtn == 0 || readRtn > len) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + + *realLen = readRtn; + + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + +out: + fclose(pF); + + return psdkStat; +} + +T_PsdkReturnCode UtilFile_Delete(const char *filePath) +{ + int ret; + + if (filePath == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + ret = unlink(filePath); + + if (ret != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } else { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } +} + +T_PsdkReturnCode UtilFile_GetFileSize(FILE *file, uint32_t *fileSize) +{ + int result; + + if (file == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + long int curSeek = ftell(file); + + result = fseek(file, 0L, SEEK_END); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + *fileSize = ftell(file); + + if (curSeek < 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + result = fseek(file, curSeek, SEEK_SET); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode UtilFile_GetFileData(FILE *file, uint32_t offset, uint16_t len, uint8_t *data, uint16_t *realLen) +{ + T_PsdkReturnCode psdkStat; + uint32_t readRtn; + + if (file == NULL) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + goto out; + } + + if (fseek(file, offset, SEEK_SET) != 0) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + + readRtn = fread(data, 1, len, file); + if (readRtn == 0 || readRtn > len) { + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + + *realLen = readRtn; + + psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + +out: + return psdkStat; +} + +bool UtilFile_IsFileExist(const char *filePath) +{ + return !access(filePath, F_OK); +} +/* Private functions definition-----------------------------------------------*/ + + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/utils/util_file.h b/sample/api_sample/utils/util_file.h new file mode 100644 index 0000000..2d31318 --- /dev/null +++ b/sample/api_sample/utils/util_file.h @@ -0,0 +1,69 @@ +/** + ******************************************************************** + * @file util_file.h + * @version V2.0.0 + * @date 2019/08/30 + * @brief This is the header file for "util_file.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTIL_FILE_H +#define UTIL_FILE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ +typedef struct { + uint32_t second:5; + uint32_t minute:6; + uint32_t hour :5; + uint32_t day :5; + uint32_t month :4; + uint32_t year :7; +} T_UtilFileCreateTime; + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode UtilFile_GetCreateTime(const char *filePath, T_UtilFileCreateTime *createTime); +T_PsdkReturnCode UtilFile_GetFileSizeByPath(const char *filePath, uint32_t *fileSize); +T_PsdkReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint16_t len, + uint8_t *data, uint16_t *realLen); +T_PsdkReturnCode PsdkFile_Delete(const char *filePath); + +T_PsdkReturnCode UtilFile_GetFileSize(FILE *file, uint32_t *fileSize); +T_PsdkReturnCode UtilFile_GetFileData(FILE *file, uint32_t offset, uint16_t len, uint8_t *data, uint16_t *realLen); +bool UtilFile_IsFileExist(const char *filePath); + +#ifdef __cplusplus +} +#endif + +#endif // UTIL_FILE_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/utils/util_math.c b/sample/api_sample/utils/util_math.c new file mode 100644 index 0000000..463dd47 --- /dev/null +++ b/sample/api_sample/utils/util_math.c @@ -0,0 +1,45 @@ +/** + ******************************************************************** + * @file util_math.c + * @brief + * + * @copyright (c) 2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "util_math.h" +#include "math.h" + +/* Private constants ---------------------------------------------------------*/ + +/* Private types -------------------------------------------------------------*/ + +/* Private values ---------------------------------------------------------*/ + +/* Private functions declaration ---------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ +int32_t UtilMath_Mod(int32_t a, int32_t b) +{ + return a - floor((double) a / (double) b) * b; +} + +/* Private functions definition-----------------------------------------------*/ + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/utils/util_math.h b/sample/api_sample/utils/util_math.h new file mode 100644 index 0000000..8fc5265 --- /dev/null +++ b/sample/api_sample/utils/util_math.h @@ -0,0 +1,49 @@ +/** + ******************************************************************** + * @file util_math.h + * @brief This is the header file for "util_math.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTIL_MATH_H +#define UTIL_MATH_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +int32_t UtilMath_Mod(int32_t a, int32_t b); + +#ifdef __cplusplus +} +#endif + +#endif //UTIL_MATH_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/utils/util_md5.c b/sample/api_sample/utils/util_md5.c new file mode 100644 index 0000000..a39ae64 --- /dev/null +++ b/sample/api_sample/utils/util_md5.c @@ -0,0 +1,240 @@ +/** + ******************************************************************** + * @file util_md5.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + * crypto-algorithms + * ================= + * + * About + * --- + * These are basic implementations of standard cryptography algorithms, written by Brad Conte (brad@bradconte.com) from + * scratch and without any cross-licensing. They exist to provide publically accessible, restriction-free implementations + * of popular cryptographic algorithms, like AES and SHA-1. These are primarily intended for educational and pragmatic + * purposes (such as comparing a specification to actual implementation code, or for building an internal application + * that computes test vectors for a product). The algorithms have been tested against standard test vectors. + * This code is released into the public domain free of any restrictions. The author requests acknowledgement if the code + * is used, but does not require it. This code is provided free of any liability and without any quality claims by the + * author. + * Note that these are *not* cryptographically secure implementations. They have no resistence to side-channel attacks + * and should not be used in contexts that need cryptographically secure implementations. + * These algorithms are not optimized for speed or space. They are primarily designed to be easy to read, although some + * basic optimization techniques have been employed. + * Building + * --- + * The source code for each algorithm will come in a pair of a source code file and a header file. There should be no + * inter-header file dependencies, no additional libraries, no platform-specific header files, or any other complicating + * matters. Compiling them should be as easy as adding the relevent source code to the project. + * + * @statement DJI has modified some symbols' name. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "util_md5.h" + +/* Private constants ---------------------------------------------------------*/ +#define ROTLEFT(a, b) ((a << b) | (a >> (32-b))) + +#define F(x, y, z) ((x & y) | (~x & z)) +#define G(x, y, z) ((x & z) | (y & ~z)) +#define H(x, y, z) (x ^ y ^ z) +#define I(x, y, z) (y ^ (x | ~z)) + +#define FF(a, b, c, d, m, s, t) { a += F(b,c,d) + m + t; \ + a = b + ROTLEFT(a,s); } +#define GG(a, b, c, d, m, s, t) { a += G(b,c,d) + m + t; \ + a = b + ROTLEFT(a,s); } +#define HH(a, b, c, d, m, s, t) { a += H(b,c,d) + m + t; \ + a = b + ROTLEFT(a,s); } +#define II(a, b, c, d, m, s, t) { a += I(b,c,d) + m + t; \ + a = b + ROTLEFT(a,s); } + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ + + +/* Exported functions definition ---------------------------------------------*/ +void UtilMd5_Transform(MD5_CTX *ctx, const BYTE *data) +{ + WORD a, b, c, d, m[16], i, j; + + // MD5 specifies big endian byte order, but this implementation assumes a little + // endian byte order CPU. Reverse all the bytes upon input, and re-reverse them + // on output (in md5_final()). + for (i = 0, j = 0; i < 16; ++i, j += 4) { + m[i] = (data[j]) + (data[j + 1] << 8) + (data[j + 2] << 16) + (data[j + 3] << 24); + } + + a = ctx->state[0]; + b = ctx->state[1]; + c = ctx->state[2]; + d = ctx->state[3]; + + FF(a, b, c, d, m[0], 7, 0xd76aa478); + FF(d, a, b, c, m[1], 12, 0xe8c7b756); + FF(c, d, a, b, m[2], 17, 0x242070db); + FF(b, c, d, a, m[3], 22, 0xc1bdceee); + FF(a, b, c, d, m[4], 7, 0xf57c0faf); + FF(d, a, b, c, m[5], 12, 0x4787c62a); + FF(c, d, a, b, m[6], 17, 0xa8304613); + FF(b, c, d, a, m[7], 22, 0xfd469501); + FF(a, b, c, d, m[8], 7, 0x698098d8); + FF(d, a, b, c, m[9], 12, 0x8b44f7af); + FF(c, d, a, b, m[10], 17, 0xffff5bb1); + FF(b, c, d, a, m[11], 22, 0x895cd7be); + FF(a, b, c, d, m[12], 7, 0x6b901122); + FF(d, a, b, c, m[13], 12, 0xfd987193); + FF(c, d, a, b, m[14], 17, 0xa679438e); + FF(b, c, d, a, m[15], 22, 0x49b40821); + + GG(a, b, c, d, m[1], 5, 0xf61e2562); + GG(d, a, b, c, m[6], 9, 0xc040b340); + GG(c, d, a, b, m[11], 14, 0x265e5a51); + GG(b, c, d, a, m[0], 20, 0xe9b6c7aa); + GG(a, b, c, d, m[5], 5, 0xd62f105d); + GG(d, a, b, c, m[10], 9, 0x02441453); + GG(c, d, a, b, m[15], 14, 0xd8a1e681); + GG(b, c, d, a, m[4], 20, 0xe7d3fbc8); + GG(a, b, c, d, m[9], 5, 0x21e1cde6); + GG(d, a, b, c, m[14], 9, 0xc33707d6); + GG(c, d, a, b, m[3], 14, 0xf4d50d87); + GG(b, c, d, a, m[8], 20, 0x455a14ed); + GG(a, b, c, d, m[13], 5, 0xa9e3e905); + GG(d, a, b, c, m[2], 9, 0xfcefa3f8); + GG(c, d, a, b, m[7], 14, 0x676f02d9); + GG(b, c, d, a, m[12], 20, 0x8d2a4c8a); + + HH(a, b, c, d, m[5], 4, 0xfffa3942); + HH(d, a, b, c, m[8], 11, 0x8771f681); + HH(c, d, a, b, m[11], 16, 0x6d9d6122); + HH(b, c, d, a, m[14], 23, 0xfde5380c); + HH(a, b, c, d, m[1], 4, 0xa4beea44); + HH(d, a, b, c, m[4], 11, 0x4bdecfa9); + HH(c, d, a, b, m[7], 16, 0xf6bb4b60); + HH(b, c, d, a, m[10], 23, 0xbebfbc70); + HH(a, b, c, d, m[13], 4, 0x289b7ec6); + HH(d, a, b, c, m[0], 11, 0xeaa127fa); + HH(c, d, a, b, m[3], 16, 0xd4ef3085); + HH(b, c, d, a, m[6], 23, 0x04881d05); + HH(a, b, c, d, m[9], 4, 0xd9d4d039); + HH(d, a, b, c, m[12], 11, 0xe6db99e5); + HH(c, d, a, b, m[15], 16, 0x1fa27cf8); + HH(b, c, d, a, m[2], 23, 0xc4ac5665); + + II(a, b, c, d, m[0], 6, 0xf4292244); + II(d, a, b, c, m[7], 10, 0x432aff97); + II(c, d, a, b, m[14], 15, 0xab9423a7); + II(b, c, d, a, m[5], 21, 0xfc93a039); + II(a, b, c, d, m[12], 6, 0x655b59c3); + II(d, a, b, c, m[3], 10, 0x8f0ccc92); + II(c, d, a, b, m[10], 15, 0xffeff47d); + II(b, c, d, a, m[1], 21, 0x85845dd1); + II(a, b, c, d, m[8], 6, 0x6fa87e4f); + II(d, a, b, c, m[15], 10, 0xfe2ce6e0); + II(c, d, a, b, m[6], 15, 0xa3014314); + II(b, c, d, a, m[13], 21, 0x4e0811a1); + II(a, b, c, d, m[4], 6, 0xf7537e82); + II(d, a, b, c, m[11], 10, 0xbd3af235); + II(c, d, a, b, m[2], 15, 0x2ad7d2bb); + II(b, c, d, a, m[9], 21, 0xeb86d391); + + ctx->state[0] += a; + ctx->state[1] += b; + ctx->state[2] += c; + ctx->state[3] += d; +} + +void UtilMd5_Init(MD5_CTX *ctx) +{ + ctx->datalen = 0; + ctx->bitlen = 0; + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; +} + +void UtilMd5_Update(MD5_CTX *ctx, const BYTE *data, size_t len) +{ + size_t i; + + for (i = 0; i < len; ++i) { + ctx->data[ctx->datalen] = data[i]; + ctx->datalen++; + if (ctx->datalen == 64) { + UtilMd5_Transform(ctx, ctx->data); + ctx->bitlen += 512; + ctx->datalen = 0; + } + } +} + +void UtilMd5_Final(MD5_CTX *ctx, BYTE *hash) +{ + size_t i; + + i = ctx->datalen; + + // Pad whatever data is left in the buffer. + if (ctx->datalen < 56) { + ctx->data[i++] = 0x80; + while (i < 56) { + ctx->data[i++] = 0x00; + } + } else if (ctx->datalen >= 56) { + ctx->data[i++] = 0x80; + while (i < 64) { + ctx->data[i++] = 0x00; + } + UtilMd5_Transform(ctx, ctx->data); + memset(ctx->data, 0, 56); + } + + // Append to the padding the total message's length in bits and transform. + ctx->bitlen += ctx->datalen * 8; + ctx->data[56] = ctx->bitlen; + ctx->data[57] = ctx->bitlen >> 8; + ctx->data[58] = ctx->bitlen >> 16; + ctx->data[59] = ctx->bitlen >> 24; + ctx->data[60] = ctx->bitlen >> 32; + ctx->data[61] = ctx->bitlen >> 40; + ctx->data[62] = ctx->bitlen >> 48; + ctx->data[63] = ctx->bitlen >> 56; + UtilMd5_Transform(ctx, ctx->data); + + // Since this implementation uses little endian byte ordering and MD uses big endian, + // reverse all the bytes when copying the final state to the output hash. + for (i = 0; i < 4; ++i) { + hash[i] = (ctx->state[0] >> (i * 8)) & 0x000000ff; + hash[i + 4] = (ctx->state[1] >> (i * 8)) & 0x000000ff; + hash[i + 8] = (ctx->state[2] >> (i * 8)) & 0x000000ff; + hash[i + 12] = (ctx->state[3] >> (i * 8)) & 0x000000ff; + } +} + +/* Private functions definition-----------------------------------------------*/ + + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/utils/util_md5.h b/sample/api_sample/utils/util_md5.h new file mode 100644 index 0000000..c8e5869 --- /dev/null +++ b/sample/api_sample/utils/util_md5.h @@ -0,0 +1,90 @@ +/** + ******************************************************************** + * @file util_md5.h + * @version V2.0.0 + * @date 2019/07/01 + * @brief This is the header file for "util_md5.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + * crypto-algorithms + * ================= + * + * About + * --- + * These are basic implementations of standard cryptography algorithms, written by Brad Conte (brad@bradconte.com) from + * scratch and without any cross-licensing. They exist to provide publically accessible, restriction-free implementations + * of popular cryptographic algorithms, like AES and SHA-1. These are primarily intended for educational and pragmatic + * purposes (such as comparing a specification to actual implementation code, or for building an internal application + * that computes test vectors for a product). The algorithms have been tested against standard test vectors. + * This code is released into the public domain free of any restrictions. The author requests acknowledgement if the code + * is used, but does not require it. This code is provided free of any liability and without any quality claims by the + * author. + * Note that these are *not* cryptographically secure implementations. They have no resistence to side-channel attacks + * and should not be used in contexts that need cryptographically secure implementations. + * These algorithms are not optimized for speed or space. They are primarily designed to be easy to read, although some + * basic optimization techniques have been employed. + * Building + * --- + * The source code for each algorithm will come in a pair of a source code file and a header file. There should be no + * inter-header file dependencies, no additional libraries, no platform-specific header files, or any other complicating + * matters. Compiling them should be as easy as adding the relevent source code to the project. + * + * @statement DJI has modified some symbols' name. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTIL_MD5_H +#define UTIL_MD5_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ +#define MD5_BLOCK_SIZE 16 // MD5 outputs a 16 byte digest + +/* Exported types ------------------------------------------------------------*/ +typedef unsigned char BYTE; // 8-bit byte +typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines + +typedef struct { + BYTE data[64]; + WORD datalen; + unsigned long long bitlen; + WORD state[4]; +} MD5_CTX; + +/* Exported functions --------------------------------------------------------*/ +void UtilMd5_Init(MD5_CTX *ctx); +void UtilMd5_Update(MD5_CTX *ctx, const BYTE *data, size_t len); +void UtilMd5_Final(MD5_CTX *ctx, BYTE *hash); + +#ifdef __cplusplus +} +#endif + +#endif // UTIL_MD5_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/utils/util_misc.c b/sample/api_sample/utils/util_misc.c new file mode 100644 index 0000000..fe4dfc4 --- /dev/null +++ b/sample/api_sample/utils/util_misc.c @@ -0,0 +1,86 @@ +/** + ******************************************************************** + * @file util.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include "util_misc.h" + +/* Private constants ---------------------------------------------------------*/ + + +/* Private types -------------------------------------------------------------*/ + + +/* Private values ------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ + + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkUserUtil_GetCurrentFileDirPath(const char *filePath, uint32_t pathBufferSize, char *dirPath) +{ + uint32_t i = strlen(filePath) - 1; + uint32_t dirPathLen; + + while (filePath[i] != '/') { + i--; + } + + dirPathLen = i + 1; + + if (dirPathLen + 1 > pathBufferSize) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + memcpy(dirPath, filePath, dirPathLen); + dirPath[dirPathLen] = 0; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +#if PSDK_ARCH_SYS_LINUX + +T_PsdkReturnCode PsdkUserUtil_RunSystemCmd(const char *systemCmdStr) +{ + FILE *fp; + + fp = popen(systemCmdStr, "r"); + if (fp == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + pclose(fp); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +#endif + +/* Private functions definition-----------------------------------------------*/ + + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/utils/util_misc.h b/sample/api_sample/utils/util_misc.h new file mode 100644 index 0000000..9343720 --- /dev/null +++ b/sample/api_sample/utils/util_misc.h @@ -0,0 +1,62 @@ +/** + ******************************************************************** + * @file util_misc.h + * @version V2.0.0 + * @date 2019/8/12 + * @brief This is the header file for "util_misc.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTIL_MISC_H +#define UTIL_MISC_H + +/* Includes ------------------------------------------------------------------*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ +#define USER_UTIL_UNUSED(x) ((x) = (x)) +#define USER_UTIL_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define USER_UTIL_MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define USER_UTIL_IS_WORK_TURN(step, workfreq, taskfreq) (!((step) % (uint32_t) ((taskfreq) / (workfreq)))) +#define UTIL_OFFSETOF(type, member) ((size_t) & ((type *)0 )-> member) +#define UTIL_ARRAY_SIZE(array) ((unsigned int) (sizeof(array) / sizeof((array)[0]))) + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkUserUtil_GetCurrentFileDirPath(const char *filePath, uint32_t pathBufferSize, char *dirPath); +#if PSDK_ARCH_SYS_LINUX +T_PsdkReturnCode PsdkUserUtil_RunSystemCmd(const char *systemCmdStr); + +#endif +#ifdef __cplusplus +} +#endif + +#endif // UTIL_MISC_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/utils/util_time.c b/sample/api_sample/utils/util_time.c new file mode 100644 index 0000000..17f6b95 --- /dev/null +++ b/sample/api_sample/utils/util_time.c @@ -0,0 +1,69 @@ +/** + ******************************************************************** + * @file psdk_util_time.c + * @version V1.0.0 + * @date 2019/01/01 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "util_time.h" +#include +#include + +/* Private constants ---------------------------------------------------------*/ + + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ + + +/* Private values ------------------------------------------------------------*/ + + +/* Exported functions definition ---------------------------------------------*/ +#if PSDK_ARCH_SYS_LINUX +T_PsdkRunTimeStamps PsdkUtilTime_GetRunTimeStamps(void) +{ + T_PsdkRunTimeStamps timeStamps; + struct rusage rusage; + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts);//系统的启动时间,不能被设置:https://blog.csdn.net/liu44235/article/details/37692635 + timeStamps.realUsec = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; + + getrusage(RUSAGE_SELF, &rusage); + timeStamps.userUsec = + (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec; + timeStamps.sysUsec = + (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec; + + return timeStamps; +} +#endif + +/* Private functions definition-----------------------------------------------*/ + + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/utils/util_time.h b/sample/api_sample/utils/util_time.h new file mode 100644 index 0000000..b35bb18 --- /dev/null +++ b/sample/api_sample/utils/util_time.h @@ -0,0 +1,60 @@ +/** + ******************************************************************** + * @file psdk_util_time.h + * @version V0.0.0 + * @date 2019/01/01 + * @brief This is the header file for "psdk_util_time.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PSDK_UTIL_TIME_H +#define PSDK_UTIL_TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ +typedef struct { + uint64_t realUsec; + uint64_t userUsec; + uint64_t sysUsec; +} T_PsdkRunTimeStamps; + +/* Exported functions --------------------------------------------------------*/ +#if PSDK_ARCH_SYS_LINUX +T_PsdkRunTimeStamps PsdkUtilTime_GetRunTimeStamps(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // PSDK_DP_UTILS_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/widget/file_binary_array_list_en.c b/sample/api_sample/widget/file_binary_array_list_en.c new file mode 100644 index 0000000..58dfd65 --- /dev/null +++ b/sample/api_sample/widget/file_binary_array_list_en.c @@ -0,0 +1,60 @@ +/** + ******************************************************************** + * @file file_binary_array_list_en.c + * @version V1.0.0 + * @date 2019/01/01 + * @brief + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "file_binary_array_list_en.h" + +#include "widget_file_c/en_big_screen/icon_button1_png.h" +#include "widget_file_c/en_big_screen/icon_button2_png.h" +#include "widget_file_c/en_big_screen/icon_list_item1_png.h" +#include "widget_file_c/en_big_screen/icon_list_item2_png.h" +#include "widget_file_c/en_big_screen/icon_scale_png.h" +#include "widget_file_c/en_big_screen/icon_switch_select_png.h" +#include "widget_file_c/en_big_screen/icon_switch_unselect_png.h" +#include "widget_file_c/en_big_screen/widget_config_json.h" + +/* Private constants ---------------------------------------------------------*/ + +/* Export types -------------------------------------------------------------*/ +// English language file binary array list +static T_PsdkWidgetFileBinaryArray s_EnWidgetFileBinaryArrayList[] = { + {widget_config_json_fileName, widget_config_json_fileSize, widget_config_json_fileBinaryArray}, + + {icon_button1_png_fileName, icon_button1_png_fileSize, icon_button1_png_fileBinaryArray}, + {icon_button2_png_fileName, icon_button2_png_fileSize, icon_button2_png_fileBinaryArray}, + {icon_list_item1_png_fileName, icon_list_item1_png_fileSize, icon_list_item1_png_fileBinaryArray}, + {icon_list_item2_png_fileName, icon_list_item2_png_fileSize, icon_list_item2_png_fileBinaryArray}, + {icon_scale_png_fileName, icon_scale_png_fileSize, icon_scale_png_fileBinaryArray}, + {icon_switch_select_png_fileName, icon_switch_select_png_fileSize, icon_switch_select_png_fileBinaryArray}, + {icon_switch_unselect_png_fileName, icon_switch_unselect_png_fileSize, icon_switch_unselect_png_fileBinaryArray} +}; + +/* Export values -------------------------------------------------------------*/ +uint32_t g_EnBinaryArrayCount = sizeof(s_EnWidgetFileBinaryArrayList) / sizeof(T_PsdkWidgetFileBinaryArray); +T_PsdkWidgetFileBinaryArray * g_EnFileBinaryArrayList = s_EnWidgetFileBinaryArrayList; + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/widget/file_binary_array_list_en.h b/sample/api_sample/widget/file_binary_array_list_en.h new file mode 100644 index 0000000..fd44d2d --- /dev/null +++ b/sample/api_sample/widget/file_binary_array_list_en.h @@ -0,0 +1,59 @@ +/** + ******************************************************************** + * @file file_binary_array_list_en.h + * @version V0.0.0 + * @date 2019/01/01 + * @brief This is the header file for "file_binary_array_list_en.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2017-2018 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef FILE_BINARY_ARRAY_LIST_EN_H +#define FILE_BINARY_ARRAY_LIST_EN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ + +extern uint32_t g_EnBinaryArrayCount; +extern T_PsdkWidgetFileBinaryArray * g_EnFileBinaryArrayList; + +#ifdef __cplusplus +} +#endif + +#endif // FILE_BINARY_ARRAY_LIST_EN_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/widget/test_widget.c b/sample/api_sample/widget/test_widget.c new file mode 100644 index 0000000..ea7cafb --- /dev/null +++ b/sample/api_sample/widget/test_widget.c @@ -0,0 +1,634 @@ +/** + ******************************************************************** + * @file test_widget.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "test_widget.h" +#include +#include +#include +#include +#include +//sbg +#include +#include + + +#if !PSDK_ARCH_SYS_LINUX + +#include "file_binary_array_list_en.h" + +#endif + +/* Private constants ---------------------------------------------------------*/ +#define WIDGET_DIR_PATH_LEN_MAX (256) +#define WIDGET_TASK_STACK_SIZE (2048) + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static void *PsdkTest_WidgetTask(void *arg); + +static T_PsdkReturnCode PsdkTestWidget_SetWidgetValue(E_PsdkWidgetType widgetType, uint32_t index, int32_t value, + void *userData); +static T_PsdkReturnCode PsdkTestWidget_GetWidgetValue(E_PsdkWidgetType widgetType, uint32_t index, int32_t *value, + void *userData); + +static T_PsdkReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_PsdkWidgetType widgetType, uint32_t index, int32_t value, + void *userData); + +static void *PsdkTest_IrisRecordSystemChanged(void *arg); + + +/* Private values ------------------------------------------------------------*/ +static T_PsdkTaskHandle s_widgetTestThread; +static T_PsdkTaskHandle s_widgetSbgThread; +static T_PsdkTaskHandle s_widgetXimeaThread; + + + +int SbgRecordCondition=0; + +static int s_sbgMagState=0; +static int s_stateOfXimea=0; +static int s_stateOfSbg=0; +static int s_stateOfFile=0; + +static char * s_strStateOfSbg="未打开"; +static char * s_strSbgMagState="等待磁矫正"; +static char * s_strSbgAccuracy="1000"; +static char * s_strSbgSolutionMode="UNINITIALIZED"; +static char * s_strStateOfXimea="未打开"; +static char * s_strStateOfFile="等待拷贝数据"; + +static int s_sockfd; +static struct sockaddr_in s_server; + +#if PSDK_ARCH_SYS_LINUX +static bool s_isWidgetFileDirPathConfigured = false; +static char s_widgetFileDirPath[PSDK_FILE_PATH_SIZE_MAX] = {0}; +#endif + +static const T_PsdkWidgetHandlerListItem s_widgetHandlerList[] = { + {0, PSDK_WIDGET_TYPE_BUTTON, PsdkTestWidget_SetWidgetValue, PsdkTestWidget_GetWidgetValue, NULL}, + {1, PSDK_WIDGET_TYPE_BUTTON, PsdkTestWidget_SetWidgetValue, PsdkTestWidget_GetWidgetValue, NULL}, + {2, PSDK_WIDGET_TYPE_LIST, PsdkTestWidget_SetWidgetValue_StartRecord, PsdkTestWidget_GetWidgetValue, NULL}, + {3, PSDK_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, PsdkTestWidget_GetWidgetValue, NULL}, + {4, PSDK_WIDGET_TYPE_SCALE, PsdkTestWidget_SetWidgetValue, PsdkTestWidget_GetWidgetValue, NULL}, + {5, PSDK_WIDGET_TYPE_BUTTON, PsdkTestWidget_SetWidgetValue_StartRecord, PsdkTestWidget_GetWidgetValue, NULL}, + {6, PSDK_WIDGET_TYPE_SCALE, PsdkTestWidget_SetWidgetValue_StartRecord, PsdkTestWidget_GetWidgetValue, NULL}, + {7, PSDK_WIDGET_TYPE_INT_INPUT_BOX, PsdkTestWidget_SetWidgetValue, PsdkTestWidget_GetWidgetValue, NULL}, + {8, PSDK_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, PsdkTestWidget_GetWidgetValue, NULL}, + {9, PSDK_WIDGET_TYPE_LIST, PsdkTestWidget_SetWidgetValue_StartRecord, PsdkTestWidget_GetWidgetValue, NULL},//PsdkTestWidget_SetWidgetValue +}; + +static char *s_widgetTypeNameArray[] = { + "Unknown", + "Button", + "Switch", + "Scale", + "List", + "Int input box" +}; + +static const uint32_t s_widgetHandlerListCount = sizeof(s_widgetHandlerList) / sizeof(T_PsdkWidgetHandlerListItem); +static int32_t s_widgetValueList[sizeof(s_widgetHandlerList) / sizeof(T_PsdkWidgetHandlerListItem)] = {0}; + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_WidgetInit(void) +{ + T_PsdkReturnCode psdkStat; + + //Step 1 : Init PSDK Widget + psdkStat = PsdkWidget_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Psdk test widget init error, stat = 0x%08llX", psdkStat); + return psdkStat; + } + +#if PSDK_ARCH_SYS_LINUX + //Step 2 : Set UI Config (Linux environment) + //获取控件图像和UI配置文件所在文件夹 + + PsdkLogger_UserLogInfo("验证是否定义了宏PSDK_ARCH_SYS_LINUX:是!--------------------------------------------------------------------------------------------------------------------------"); + + char curFileDirPath[WIDGET_DIR_PATH_LEN_MAX]; + char tempPath[WIDGET_DIR_PATH_LEN_MAX]; + psdkStat = PsdkUserUtil_GetCurrentFileDirPath(__FILE__, WIDGET_DIR_PATH_LEN_MAX, curFileDirPath); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get file current path error, stat = 0x%08llX", psdkStat); + return psdkStat; + } + + if (s_isWidgetFileDirPathConfigured == true) { + snprintf(tempPath, WIDGET_DIR_PATH_LEN_MAX, "%swidget_file/en_big_screen", s_widgetFileDirPath); + } else { + snprintf(tempPath, WIDGET_DIR_PATH_LEN_MAX, "%swidget_file/en_big_screen", curFileDirPath); + } + + //set default ui config path + psdkStat = PsdkWidget_RegDefaultUiConfigByDirPath(tempPath); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Add default widget ui config error, stat = 0x%08llX", psdkStat); + return psdkStat; + } + + //set ui config for English language + //设置系统语言为英文时控件配置文件的路径 + psdkStat = PsdkWidget_RegUiConfigByDirPath(PSDK_AIRCRAFT_INFO_MOBILE_APP_LANGUAGE_ENGLISH, + PSDK_AIRCRAFT_INFO_MOBILE_APP_SCREEN_TYPE_BIG_SCREEN, + tempPath); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Add widget ui config error, stat = 0x%08llX", psdkStat); + return psdkStat; + } + + //set ui config for Chinese language + if (s_isWidgetFileDirPathConfigured == true) { + snprintf(tempPath, WIDGET_DIR_PATH_LEN_MAX, "%swidget_file/cn_big_screen", s_widgetFileDirPath); + } else { + snprintf(tempPath, WIDGET_DIR_PATH_LEN_MAX, "%swidget_file/cn_big_screen", curFileDirPath); + } + + psdkStat = PsdkWidget_RegUiConfigByDirPath(PSDK_AIRCRAFT_INFO_MOBILE_APP_LANGUAGE_CHINESE, + PSDK_AIRCRAFT_INFO_MOBILE_APP_SCREEN_TYPE_BIG_SCREEN, + tempPath); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Add widget ui config error, stat = 0x%08llX", psdkStat); + return psdkStat; + } +#else + //Step 2 : Set UI Config (RTOS environment) + + T_PsdkWidgetBinaryArrayConfig enWidgetBinaryArrayConfig = { + .binaryArrayCount = g_EnBinaryArrayCount, + .fileBinaryArrayList = g_EnFileBinaryArrayList + }; + + //set default ui config + psdkStat = PsdkWidget_RegDefaultUiConfigByBinaryArray(&enWidgetBinaryArrayConfig); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Add default widget ui config error, stat = 0x%08llX", psdkStat); + return psdkStat; + } + +#endif + + //Step 3 : Set widget handler list + psdkStat = PsdkWidget_RegHandlerList(s_widgetHandlerList, s_widgetHandlerListCount); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Set widget handler list error, stat = 0x%08llX", psdkStat); + return psdkStat; + } + + //Step 4 : Run widget api sample task + if (PsdkOsal_TaskCreate(&s_widgetTestThread, PsdkTest_WidgetTask, "user_widget_task", WIDGET_TASK_STACK_SIZE, + NULL) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Psdk widget test task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //Step 5 : Run ximea task + if (PsdkOsal_TaskCreate(&s_widgetXimeaThread, PsdkTest_IrisRecordSystemChanged, "ximea", WIDGET_TASK_STACK_SIZE, + NULL) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Psdk widget test task(ximea) create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + /* tc-----------------------------------------------*/ + struct hostent *he; + he=gethostbyname("127.0.0.1"); + + s_sockfd=socket(AF_INET, SOCK_DGRAM,0); + + + bzero(&s_server,sizeof(s_server)); + s_server.sin_family = AF_INET; + s_server.sin_port = htons(PORT); + s_server.sin_addr= *((struct in_addr *)he->h_addr); + /* tc-----------------------------------------------*/ + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +#if PSDK_ARCH_SYS_LINUX +T_PsdkReturnCode PsdkTest_WidgetSetConfigFilePath(const char *path) +{ + memset(s_widgetFileDirPath, 0, sizeof(s_widgetFileDirPath)); + memcpy(s_widgetFileDirPath, path, USER_UTIL_MIN(strlen(path), sizeof(s_widgetFileDirPath) - 1)); + s_isWidgetFileDirPathConfigured = true; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} +#endif + +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#pragma GCC diagnostic ignored "-Wformat" +#endif + +/* Private functions definition-----------------------------------------------*/ +//在DJI pilot的浮窗上显示系统时间 +static void *PsdkTest_WidgetTask(void *arg) +{ + char message[PSDK_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN]; + uint32_t sysTimeMs = 0; + T_PsdkReturnCode psdkStat; + + USER_UTIL_UNUSED(arg); + + while (1) { + psdkStat = PsdkOsal_GetTimeMs(&sysTimeMs); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Get system time ms error, stat = 0x%08llX", psdkStat); + } + + //snprintf(message, PSDK_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN, "System time: %u ms;\nMAG: %d;\nIMAGER: %d;\nIMU: %d;\nFile: %d;\n", sysTimeMs, s_sbgMagState, s_stateOfXimea, s_stateOfSbg, s_stateOfFile); + + snprintf(message, PSDK_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN, "System time: %u ms;\n磁场矫正: %s;\n光谱仪: %s;\n惯导: %s;\n精度: %s;\nmode: %s;\n文件: %s;\n", sysTimeMs, s_strSbgMagState, s_strStateOfXimea, s_strStateOfSbg, s_strSbgAccuracy, s_strSbgSolutionMode, s_strStateOfFile); + + psdkStat = PsdkWidgetFloatingWindow_ShowMessage(message); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Floating window show message error, stat = 0x%08llX", psdkStat); + } + + PsdkOsal_TaskSleepMs(1000); + } +} + +static void *PsdkTest_IrisRecordSystemChanged(void *arg)// +{ + // FILE * fp; + // char buffer[80]; + // fp = popen("/home/iris-xport/cpp_qtcreator/ximeaImageRecorder-Release/ximeaImageRecorder", "r");ss + // fgets(buffer, sizeof(buffer), fp); + // printf("%s", buffer); + // pclose(fp); + + + int sockfd; + struct sockaddr_in server; + struct sockaddr_in client; + socklen_t addrlen; + int num; + char buf[MAXDATASIZE]; + + if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) + { + perror("Creatingsocket failed."); + } + + bzero(&server,sizeof(server)); + server.sin_family=AF_INET; + server.sin_port=htons(PORT+1); + server.sin_addr.s_addr= htonl(INADDR_ANY); + if(bind(sockfd, (struct sockaddr *)&server, sizeof(server)) == -1) + { + perror("Bind()error."); + } + + addrlen=sizeof(client); + while (1) + { + //printf("PsdkTest_IrisRecordSystemChanged: record system status change! 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n"); + + num =recvfrom(sockfd,buf,MAXDATASIZE,0,(struct sockaddr*)&client,&addrlen); + + if (num < 0) + { + perror("recvfrom() error\n"); + + continue; + } + + buf[num] = '\0'; + + printf("You got a message (%s) from client.\n",buf); + //printf("You got a message (%s%) from client.\nIt's ip is%s, port is %d.\n",buf,inet_ntoa(client.sin_addr),htons(client.sin_port)); + + + char * result[2]; + result[0] = strtok( buf, "," ); + result[1] = strtok( NULL, "," ); + + + if (strcmp(result[0],"sbg") == 0) + { + s_stateOfSbg = atoi(result[1]); + printf("sbg的状态为: %d\n\n", atoi(result[1])); + + switch (s_stateOfSbg) + { + case 0: + s_strStateOfSbg="未打开"; + break; + case 1: + s_strStateOfSbg="波特率设置失败"; + break; + case 2: + s_strStateOfSbg="打开成功"; + break; + case 3: + s_strStateOfSbg="采集中"; + break; + + default: + break; + } + } + else if (strcmp(result[0],"Accuracy") == 0) + { + + + s_strSbgAccuracy=result[1]; + + + // s_sbgMagState = atoi(result[1]); + + // switch (s_sbgMagState) + // { + // case 0: + // s_strSbgAccuracy="false"; + // break; + // case 1: + // s_strSbgAccuracy="true"; + // break; + + // default: + // break; + // } + } + else if (strcmp(result[0],"SolutionMode") == 0) + { + s_sbgMagState = atoi(result[1]); + + switch (s_sbgMagState) + { + case 0: + s_strSbgSolutionMode="UNINITIALIZED"; + break; + case 1: + s_strSbgSolutionMode="VERTICAL_GYRO"; + break; + case 2: + s_strSbgSolutionMode="AHRS"; + break; + case 3: + s_strSbgSolutionMode="NAV_VELOCITY"; + break; + case 4: + s_strSbgSolutionMode="NAV_POSITION"; + break; + + default: + break; + } + } + else if (strcmp(result[0],"mag") == 0) + { + s_sbgMagState = atoi(result[1]); + printf("磁场矫正状态为: %d\n\n", atoi(result[1])); + + switch (s_sbgMagState) + { + case 0: + s_strSbgMagState="串口打开错误"; + break; + case 1: + s_strSbgMagState="磁场矫正失败"; + break; + case 2: + s_strSbgMagState="无法获取磁场数据"; + break; + case 3: + s_strSbgMagState="磁场数据无效"; + break; + case 4: + s_strSbgMagState="写入磁场数据失败"; + break; + case 5: + s_strSbgMagState="POOR"; + break; + case 6: + s_strSbgMagState="GOOD"; + break; + case 7: + s_strSbgMagState="OPTIMAL"; + break; + + default: + break; + } + } + else if (strcmp(result[0],"ximea") == 0) + { + s_stateOfXimea = atoi(result[1]); + printf("ximea的状态为: %d\n\n", atoi(result[1])); + + switch (s_stateOfXimea) + { + case 0: + s_strStateOfXimea="未打开"; + break; + case 1: + s_strStateOfXimea="打开成功"; + break; + case 2: + s_strStateOfXimea="帧率设置完成"; + break; + case 3: + s_strStateOfXimea="自动曝光完成"; + break; + case 4: + s_strStateOfXimea="正在采集"; + break; + + case 21: + s_strStateOfXimea="未处理错误"; + break; + case 22: + s_strStateOfXimea="相机被占用"; + break; + + default: + break; + } + } + else if (strcmp(result[0],"file") == 0) + { + s_stateOfFile = atoi(result[1]); + printf("file的状态为: %d\n\n", atoi(result[1])); + + switch (s_stateOfFile) + { + case 0: + s_strStateOfFile="等待拷贝数据"; + break; + case 1: + s_strStateOfFile="正在拷贝"; + break; + case 2: + s_strStateOfFile="没有数据可拷贝"; + break; + case 3: + s_strStateOfFile="请插入u盘"; + break; + + default: + break; + } + } + } +} + + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +static T_PsdkReturnCode PsdkTestWidget_SetWidgetValue(E_PsdkWidgetType widgetType, uint32_t index, int32_t value, + void *userData) +{ + USER_UTIL_UNUSED(userData); + + PsdkLogger_UserLogInfo("Set widget value, widgetType = %s, widgetIndex = %d ,widgetValue = %d", + s_widgetTypeNameArray[widgetType], index, value); + s_widgetValueList[index] = value; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTestWidget_GetWidgetValue(E_PsdkWidgetType widgetType, uint32_t index, int32_t *value, + void *userData) +{ + USER_UTIL_UNUSED(userData); + USER_UTIL_UNUSED(widgetType); + + *value = s_widgetValueList[index]; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_PsdkWidgetType widgetType, uint32_t index, int32_t value, + void *userData) +{ + USER_UTIL_UNUSED(userData); + + PsdkLogger_UserLogInfo("Set widget value, widgetType = %s, widgetIndex = %d ,widgetValue = %d", + s_widgetTypeNameArray[widgetType], index, value); + s_widgetValueList[index] = value; + + switch (index) + { + case 2: + if (value==0)//系统关闭 + { + char* command = "2"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + } + else if (value==1)//系统启动 + { + char* command = "1"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + } + break; + case 3: + if (value==0)//停止磁场矫正 + { + char* command = "8,0"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + + //printf("ttttttttttttt\n"); + } + else if (value==1)//开始磁场矫正 + { + char* command = "8,1"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + + //printf("kkkkkkkkkkkkk\n"); + } + break; + case 5://自动曝光 + if (value==0) + { + ; + } + else if (value==1) + { + char* command = "6"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + } + break; + case 6://设置帧率 + { + char command[50] = "5,"; + char framerate[20]; + sprintf(framerate,"%d",value); + strcat(command,framerate); + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + break; + } + case 8: + if (value==0)//停止采集 + { + char* command = "4"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + } + else if (value==1)//开始采集 + { + char* command = "3"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + } + break; + case 9: + if (value==0)//无操作 + { + + } + if (value==1)//拷贝数据 + { + char* command = "7"; + sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server)); + } + else if (value==2)//重启电脑 + { + system("reboot"); + } + else if (value==3)//关机 + { + system("shutdown now"); + } + break; + default: + break; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/widget/test_widget.h b/sample/api_sample/widget/test_widget.h new file mode 100644 index 0000000..392b670 --- /dev/null +++ b/sample/api_sample/widget/test_widget.h @@ -0,0 +1,72 @@ +/** + ******************************************************************** + * @file test_widget.h + * @version V2.0.0 + * @date 2019/07/01 + * @brief This is the header file for "test_widget.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_WIDGET_H +#define TEST_WIDGET_H + +/* Includes ------------------------------------------------------------------*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* tc --------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include + + +#define PORT 45454 +#define MAXDATASIZE 100 +/* tc --------------------------------------------------------*/ + + + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_WidgetInit(void); +#if PSDK_ARCH_SYS_LINUX +T_PsdkReturnCode PsdkTest_WidgetSetConfigFilePath(const char *path); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TEST_WIDGET_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/api_sample/widget/widget_file/cn_big_screen/widget_config.json b/sample/api_sample/widget/widget_file/cn_big_screen/widget_config.json new file mode 100644 index 0000000..6b286c6 --- /dev/null +++ b/sample/api_sample/widget/widget_file/cn_big_screen/widget_config.json @@ -0,0 +1,119 @@ +{ + "version": { + "major" : 1, + "minor" : 0 + }, + "main_interface": { + "floating_window": { + "is_enable": true + }, + "widget_list": [ + { + "widget_index": 0, + "widget_type": "button", + "widget_name": "按钮_1", + "icon_file_set": { + "icon_file_name_selected" : "icon_button1.png", + "icon_file_name_unselected" : "icon_button1.png" + } + }, + { + "widget_index": 1, + "widget_type": "button", + "widget_name": "按钮_2", + "icon_file_set": { + "icon_file_name_selected" : "icon_button2.png", + "icon_file_name_unselected" : "icon_button2.png" + } + }, + { + "widget_index": 2, + "widget_type": "list", + "widget_name": "列表_3", + "list_item": [ + { + "item_name": "系统关闭", + "icon_file_set": { + "icon_file_name_selected": "icon_list_item1.png", + "icon_file_name_unselected": "icon_list_item1.png" + } + }, + { + "item_name": "系统启动", + "icon_file_set": { + "icon_file_name_selected" : "icon_list_item2.png", + "icon_file_name_unselected" : "icon_list_item2.png" + } + } + ] + }, + { + "widget_index": 3, + "widget_type": "switch", + "widget_name": "开关_4", + "icon_file_set": { + "icon_file_name_selected": "icon_switch_select.png", + "icon_file_name_unselected": "icon_switch_unselect.png" + } + }, + { + "widget_index": 4, + "widget_type": "scale", + "widget_name": "范围条_5", + "icon_file_set": { + "icon_file_name_selected": "icon_scale.png", + "icon_file_name_unselected": "icon_scale.png" + } + } + ] + }, + "config_interface": { + "text_input_box": { + "widget_name": "请输入命令", + "placeholder_text": "请输入消息", + "is_enable": true + }, + "widget_list": [ + { + "widget_index": 5, + "widget_type": "button", + "widget_name": "自动曝光" + }, + { + "widget_index": 6, + "widget_type": "scale", + "widget_name": "帧率" + }, + { + "widget_index": 7, + "widget_type": "int_input_box", + "widget_name": "整形值输入框_8", + "int_input_box_hint": "unit:s" + }, + { + "widget_index": 8, + "widget_type": "switch", + "widget_name": "开始采集" + }, + { + "widget_index": 9, + "widget_type": "list", + "widget_name": "列表_10", + "list_item": [ + { + "item_name": "等待指令" + }, + { + "item_name": "拷贝数据" + }, + { + "item_name": "重启电脑" + }, + { + "item_name": "关机" + } + ] + } + ] + } +} diff --git a/sample/api_sample/widget/widget_file/en_big_screen/widget_config.json b/sample/api_sample/widget/widget_file/en_big_screen/widget_config.json new file mode 100644 index 0000000..1c07fa8 --- /dev/null +++ b/sample/api_sample/widget/widget_file/en_big_screen/widget_config.json @@ -0,0 +1,119 @@ +{ + "version": { + "major" : 1, + "minor" : 0 + }, + "main_interface": { + "floating_window": { + "is_enable": true + }, + "widget_list": [ + { + "widget_index": 0, + "widget_type": "button", + "widget_name": "Button_1", + "icon_file_set": { + "icon_file_name_selected" : "icon_button1.png", + "icon_file_name_unselected" : "icon_button1.png" + } + }, + { + "widget_index": 1, + "widget_type": "button", + "widget_name": "Button_2", + "icon_file_set": { + "icon_file_name_selected" : "icon_button2.png", + "icon_file_name_unselected" : "icon_button2.png" + } + }, + { + "widget_index": 2, + "widget_type": "list", + "widget_name": "List_3", + "list_item": [ + { + "item_name": "Item_1", + "icon_file_set": { + "icon_file_name_selected": "icon_list_item1.png", + "icon_file_name_unselected": "icon_list_item1.png" + } + }, + { + "item_name": "Item_2", + "icon_file_set": { + "icon_file_name_selected" : "icon_list_item2.png", + "icon_file_name_unselected" : "icon_list_item2.png" + } + } + ] + }, + { + "widget_index": 3, + "widget_type": "switch", + "widget_name": "Switch_4", + "icon_file_set": { + "icon_file_name_selected": "icon_switch_select.png", + "icon_file_name_unselected": "icon_switch_unselect.png" + } + }, + { + "widget_index": 4, + "widget_type": "scale", + "widget_name": "Scale_5", + "icon_file_set": { + "icon_file_name_selected": "icon_scale.png", + "icon_file_name_unselected": "icon_scale.png" + } + } + ] + }, + "config_interface": { + "text_input_box": { + "widget_name": "TextInputBox", + "placeholder_text": "Please input message", + "is_enable": true + }, + "widget_list": [ + { + "widget_index": 5, + "widget_type": "button", + "widget_name": "Button_6" + }, + { + "widget_index": 6, + "widget_type": "scale", + "widget_name": "Scale_7" + }, + { + "widget_index": 7, + "widget_type": "int_input_box", + "widget_name": "IntegerInputBox_8", + "int_input_box_hint": "unit:s" + }, + { + "widget_index": 8, + "widget_type": "switch", + "widget_name": "Switch_9" + }, + { + "widget_index": 9, + "widget_type": "list", + "widget_name": "List_10", + "list_item": [ + { + "item_name": "Item 1" + }, + { + "item_name": "Item 2" + }, + { + "item_name": "Item 3" + }, + { + "item_name": "Item 4" + } + ] + } + ] + } +} diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_button1_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_button1_png.h new file mode 100644 index 0000000..065e870 --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_button1_png.h @@ -0,0 +1,148 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_button1_png_h_included +#define __icon_button1_png_h_included + +#include + +/* Contents of file icon_button1.png */ +#define icon_button1_png_fileName "icon_button1.png" +#define icon_button1_png_fileSize 2137 + +static const uint8_t icon_button1_png_fileBinaryArray[2137] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x08, 0x13, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x3D, 0x6F, 0x14, 0x47, 0x18, 0xC7, + 0xCF, 0x6F, 0x98, 0x84, 0x18, 0x04, 0xB2, 0xD2, 0x44, 0x89, 0x84, 0x15, 0x0B, 0x24, 0x8B, 0x86, + 0x32, 0x1F, 0xC0, 0x20, 0x45, 0xF9, 0x18, 0x40, 0x4D, 0x81, 0x42, 0x50, 0xAA, 0x28, 0x05, 0xD4, + 0xA9, 0x02, 0x5F, 0x80, 0x92, 0xC2, 0x29, 0xB0, 0xD2, 0xA6, 0x8A, 0x28, 0x23, 0x41, 0x83, 0x95, + 0x14, 0x96, 0x90, 0x10, 0x28, 0x26, 0xE4, 0x05, 0x7C, 0x38, 0xF3, 0x1B, 0xF6, 0xBF, 0x1A, 0xCF, + 0xED, 0xEE, 0xDD, 0xEE, 0x3D, 0xF6, 0xEE, 0xF9, 0x66, 0xA4, 0xF1, 0xBC, 0x3E, 0xCF, 0xCE, 0xFE, + 0xFE, 0x33, 0xFB, 0x18, 0x9D, 0xB9, 0x9D, 0xE9, 0x55, 0xA7, 0x99, 0x68, 0x38, 0x6E, 0x47, 0xC3, + 0xBD, 0x61, 0xE3, 0xF1, 0xFC, 0x49, 0x6D, 0xEF, 0x0D,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0xE3, 0x90, 0x14, 0x5E, 0x00, 0xE8, 0x38, 0x14, + 0x7C, 0x3D, 0xB2, 0x42, 0xE0, 0x61, 0x1D, 0xFB, 0xA3, 0x9A, 0x42, 0x5E, 0xD4, 0xE1, 0xA5, 0x52, + 0xA0, 0xE3, 0x52, 0x73, 0xC4, 0xD4, 0xFB, 0x08, 0x81, 0xA9, 0x4E, 0x19, 0x67, 0xED, 0x76, 0xED, + 0x78, 0x95, 0xA1, 0xCD, 0x51, 0x85, 0x5D, 0x75, 0x5F, 0x1E, 0x62, 0x06, 0x5F, 0x02, 0xA8, 0xD4, + 0xA9, 0xA0, 0x1D, 0x67, 0x7C, 0xD2, 0x37, 0xF0, 0xCC, 0x8E, 0x81, 0xC6, 0x42, 0x84, 0x6D, 0xD9, + 0xCB, 0x86, 0xF6, 0x34, 0x26, 0xC1, 0xE5, 0xDE, 0x55, 0x2F, 0x2A, 0x35, 0x1E, 0x96, 0x03, 0x02, + 0x30, 0x48, 0x12, 0x54, 0x95, 0x71, 0x5F, 0x51, 0xBF, 0x37, 0x9C, 0xC2, 0x1F, 0x7E, 0x27, 0x67, + 0xF7, 0x2D, 0xF0, 0x34, 0xE3, 0xFE, 0xB8, 0xCF, 0x9B, 0x84, 0x20, 0x7D, 0x47, 0xF4, 0x23, 0x1E, + 0x8F, 0xDB, 0xD1, 0xF4, 0x5C, 0xB8, 0xB8, 0xFF, 0xA8, 0xB5, 0x43, 0xB8, 0x45, 0xF7, 0x16, 0x8F, + 0xC7, 0xED, 0xDC, 0xE6, 0x7F, 0xAF, 0x38, 0x18, 0xCE, 0x87, 0x25, 0x84, 0x3F, 0x00, 0x00, 0x00, + 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 +}; + +#endif /* __icon_button1_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_button2_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_button2_png.h new file mode 100644 index 0000000..4ccf226 --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_button2_png.h @@ -0,0 +1,147 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_button2_png_h_included +#define __icon_button2_png_h_included + +#include + +/* Contents of file icon_button2.png */ +#define icon_button2_png_fileName "icon_button2.png" +#define icon_button2_png_fileSize 2114 + +static const uint8_t icon_button2_png_fileBinaryArray[2114] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x07, 0xFC, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x3D, 0x6F, 0x14, 0x47, 0x18, 0xC7, + 0xCF, 0x36, 0xC6, 0x24, 0xC4, 0x20, 0x90, 0x95, 0x26, 0x4A, 0x24, 0xAC, 0x58, 0x20, 0x21, 0x1A, + 0xCA, 0x7C, 0x00, 0x40, 0x8A, 0xF2, 0x31, 0x80, 0x9A, 0x02, 0x85, 0xA0, 0x54, 0x51, 0x0A, 0xA8, + 0x53, 0x05, 0xBE, 0x00, 0x25, 0x85, 0x53, 0x80, 0xD2, 0xA6, 0x8A, 0x28, 0x23, 0x41, 0x83, 0x95, + 0x14, 0x96, 0x90, 0x10, 0x28, 0x26, 0xE4, 0x05, 0xDB, 0x38, 0xCF, 0x6F, 0xBC, 0xFF, 0xD5, 0xDC, + 0xDC, 0xDA, 0x77, 0xB7, 0xF7, 0x58, 0xBB, 0xE7, 0x9D, 0x91, 0xC6, 0xCF, 0xBC, 0x3E, 0x3B, 0xFB, + 0xFB, 0xCF, 0xEC, 0x03, 0x9C, 0x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0xA4, 0x58, 0x04, 0xEA, + 0x3B, 0x12, 0x80, 0x0A, 0x89, 0xC1, 0x31, 0x7C, 0xC0, 0xA7, 0x99, 0x39, 0x12, 0x22, 0x16, 0xC1, + 0x9A, 0x3B, 0x77, 0x02, 0x52, 0xF8, 0x80, 0x27, 0x03, 0x9E, 0x0C, 0x1F, 0x6C, 0x9C, 0x10, 0xA1, + 0x14, 0x11, 0x90, 0xDA, 0xC1, 0xB2, 0x12, 0x00, 0xF0, 0x47, 0x8B, 0xBC, 0x10, 0x95, 0x69, 0xD3, + 0x89, 0xD0, 0x63, 0x49, 0x73, 0xAD, 0xAB, 0x33, 0x29, 0xDE, 0xFD, 0xEC, 0x70, 0xED, 0xF8, 0x77, + 0x56, 0x56, 0x86, 0x25, 0x6C, 0x94, 0x34, 0x27, 0x6E, 0x2B, 0x77, 0x3D, 0x62, 0x00, 0xF7, 0xB8, + 0xE5, 0x93, 0x96, 0x3F, 0xB6, 0xFC, 0xA9, 0xE5, 0x15, 0xCB, 0x17, 0xAE, 0x5F, 0xBF, 0xFE, 0xD5, + 0xF3, 0xE7, 0xCF, 0x57, 0x37, 0x36, 0x36, 0xD6, 0x76, 0x76, 0x76, 0xB6, 0x2D, 0xE7, 0xD4, 0x4F, + 0x60, 0x1B, 0x36, 0x30, 0x82, 0x15, 0xCC, 0x0A, 0x76, 0x30, 0x84, 0x25, 0x4C, 0x61, 0x0B, 0x63, + 0x58, 0x97, 0xE2, 0xA0, 0x06, 0x15, 0x76, 0xF5, 0x31, 0xCB, 0x8B, 0x96, 0x97, 0x2C, 0x7F, 0x62, + 0xF9, 0x73, 0xCB, 0x17, 0x1E, 0x3E, 0x7C, 0xF8, 0xF5, 0xD6, 0xD6, 0xD6, 0xDB, 0xFE, 0xEB, 0xE5, + 0xDA, 0x5E, 0x04, 0x60, 0x05, 0x33, 0xD8, 0x15, 0x0C, 0x61, 0x09, 0x53, 0xD8, 0xC2, 0x18, 0xD6, + 0x41, 0x80, 0xF8, 0x11,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 0x00, 0x8F, 0x43, 0xAC, 0xC0, 0xCB, 0x5A, 0x53, + 0x48, 0x87, 0x1D, 0xBE, 0xEE, 0x33, 0xE6, 0x45, 0x19, 0x5E, 0xB2, 0x02, 0x9D, 0x5A, 0x8D, 0x11, + 0xD3, 0xE0, 0x23, 0x06, 0xA6, 0x32, 0x36, 0xCD, 0xDA, 0xED, 0x02, 0x2E, 0x1B, 0xCF, 0xD1, 0xE2, + 0xBA, 0x64, 0x03, 0xC4, 0x02, 0xBE, 0x04, 0x90, 0xD5, 0xA9, 0xA0, 0x9E, 0x66, 0x18, 0xD1, 0x36, + 0xF0, 0xCC, 0x4E, 0x81, 0xA6, 0x42, 0xC4, 0x75, 0xCD, 0xD7, 0x1C, 0xEA, 0x5D, 0x4C, 0x82, 0xCB, + 0xBD, 0xAB, 0x5C, 0x65, 0xD5, 0x1F, 0xDB, 0x01, 0x01, 0xE8, 0x24, 0x09, 0xAA, 0x6C, 0xDA, 0x56, + 0xD5, 0x1E, 0x26, 0x76, 0xF0, 0x47, 0xD8, 0xC9, 0xC5, 0x7D, 0x0B, 0x3C, 0xD5, 0xB4, 0x3D, 0x6D, + 0x0B, 0x53, 0x62, 0x90, 0xA1, 0x21, 0xF9, 0x91, 0xF6, 0xA7, 0xF5, 0x64, 0x78, 0x29, 0x5C, 0xDA, + 0x7E, 0xD8, 0xEA, 0x31, 0xDC, 0xAA, 0x7B, 0x4B, 0xFB, 0xD3, 0x7A, 0x39, 0xE7, 0x7F, 0xF1, 0x70, + 0x18, 0xCE, 0xAA, 0xDB, 0xB2, 0x97, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, + 0x60, 0x82 +}; + +#endif /* __icon_button2_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item1_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item1_png.h new file mode 100644 index 0000000..7fe3a3b --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item1_png.h @@ -0,0 +1,174 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_list_item1_png_h_included +#define __icon_list_item1_png_h_included + +#include + +/* Contents of file icon_list_item1.png */ +#define icon_list_item1_png_fileName "icon_list_item1.png" +#define icon_list_item1_png_fileSize 2556 + +static const uint8_t icon_list_item1_png_fileBinaryArray[2556] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x09, 0xB6, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x4B, 0x68, 0x14, 0x49, 0x18, 0xC7, + 0x2B, 0xC9, 0x26, 0x46, 0xB3, 0x9A, 0xB8, 0x6A, 0x7C, 0xC1, 0x62, 0x2E, 0x6A, 0x50, 0x04, 0x89, + 0x28, 0x22, 0x88, 0x08, 0x2E, 0x01, 0x41, 0x51, 0x41, 0x0F, 0x1E, 0x3C, 0x88, 0x37, 0x1F, 0xE0, + 0x12, 0xF1, 0xA2, 0x07, 0xBD, 0x99, 0xC3, 0xFA, 0x3A, 0x09, 0x1E, 0x3C, 0x78, 0x50, 0x50, 0x51, + 0x10, 0xDC, 0x0D, 0x78, 0x8A, 0x07, 0xD1, 0xF8, 0xC6, 0x9B, 0xE0, 0x1E, 0x7C, 0x67, 0x91, 0x2C, + 0x79, 0x98, 0x87, 0x66, 0xEB, 0x5F, 0x99, 0x7F, 0x6F, 0x75, 0x4D, 0x4D, 0x66, 0x7A, 0x3A, 0xFD, + 0x98, 0x99, 0xFA, 0xA0, 0xE6, 0xAB, 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, 0x27, 0x4C, 0x06, 0x9F, 0xE0, 0xC7, + 0x24, 0x37, 0x06, 0xE4, 0x51, 0xE8, 0x04, 0x95, 0x06, 0x58, 0x80, 0x64, 0xE0, 0x99, 0x4F, 0xF0, + 0xB5, 0xB2, 0xCC, 0x0C, 0xA8, 0x43, 0x47, 0xD0, 0x09, 0x32, 0xCB, 0x9B, 0x41, 0x88, 0x57, 0x82, + 0xD0, 0x09, 0x04, 0xAA, 0x83, 0x1F, 0x95, 0x00, 0x18, 0xC0, 0x14, 0x71, 0x5D, 0x38, 0x23, 0xBC, + 0x25, 0x08, 0x85, 0xA6, 0x13, 0x00, 0xBE, 0x4E, 0x86, 0x69, 0x86, 0x46, 0x3E, 0x9D, 0xC0, 0x25, + 0x0A, 0x75, 0x2B, 0x51, 0xB8, 0xF4, 0x00, 0x28, 0x1C, 0x80, 0x33, 0x1E, 0xB0, 0x47, 0x64, 0x18, + 0x96, 0x01, 0x27, 0x2A, 0xD9, 0xC0, 0x96, 0xF6, 0xC8, 0xA3, 0x03, 0x95, 0x01, 0x40, 0x02, 0x6C, + 0xBD, 0x0C, 0x3F, 0xCB, 0xF0, 0x8B, 0x0C, 0x0B, 0x65, 0x68, 0x91, 0xA1, 0x75, 0xFF, 0xFE, 0xFD, + 0xED, 0xEF, 0xDE, 0xBD, 0xFB, 0x73, 0x78, 0x78, 0xB8, 0x77, 0xDC, 0xC9, 0xA4, 0x04, 0xC0, 0x08, + 0xAC, 0xC0, 0x0C, 0xEC, 0x32, 0x0C, 0xC1, 0x12, 0x4C, 0xC1, 0x16, 0x8C, 0xC1, 0x1A, 0xCC, 0x95, + 0x73, 0x10, 0x81, 0xA7, 0x70, 0xB6, 0xCF, 0x90, 0xA1, 0x51, 0x86, 0x66, 0x19, 0x7E, 0x95, 0x61, + 0x19, 0x1A, 0x1A, 0x1D, 0x1D, 0xED, 0x9B, 0xB4, 0x57, 0x57, 0x98, 0x45, 0x00, 0xCC, 0x32, 0x4E, + 0x58, 0x96, 0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0xCF, 0x38, 0xB9, 0xD0, 0x86, 0x5A, 0xE5, 0xEB, 0x30, 0x69, + 0x48, 0x6D, 0x96, 0x99, 0x69, 0xDA, 0x51, 0xE7, 0x2B, 0xA7, 0x5D, 0xB9, 0x68, 0x1F, 0x48, 0xCB, + 0xA0, 0xCC, 0x72, 0x33, 0xAD, 0xAA, 0xFC, 0x07, 0x9A, 0xB8, 0xA2, 0x7E, 0x27, 0xE3, 0x05, 0x8D, + 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 +}; + +#endif /* __icon_list_item1_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item2_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item2_png.h new file mode 100644 index 0000000..978417e --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_list_item2_png.h @@ -0,0 +1,176 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_list_item2_png_h_included +#define __icon_list_item2_png_h_included + +#include + +/* Contents of file icon_list_item2.png */ +#define icon_list_item2_png_fileName "icon_list_item2.png" +#define icon_list_item2_png_fileSize 2578 + +static const uint8_t icon_list_item2_png_fileBinaryArray[2578] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x09, 0xCC, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x59, 0x68, 0x14, 0x49, 0x18, 0xC7, + 0xBF, 0x1C, 0x26, 0x1B, 0xB3, 0x6E, 0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B1, 0xDA, 0xCD, 0x95, 0x6F, 0x02, 0x37, 0xE3, + 0x6C, 0x9F, 0xCF, 0x1E, 0x6C, 0x68, 0xE4, 0x04, 0x0F, 0x56, 0x5C, 0xB4, 0x8C, 0x33, 0x4D, 0xF8, + 0x6C, 0xA7, 0xB7, 0x10, 0x26, 0x00, 0x90, 0x10, 0xE1, 0x01, 0x9B, 0x3E, 0x28, 0x6E, 0xD6, 0x65, + 0x1F, 0x85, 0xE8, 0x29, 0x04, 0x3C, 0x85, 0x20, 0x68, 0x78, 0x33, 0x6E, 0xD7, 0xF5, 0x80, 0x03, + 0x9C, 0x0D, 0x94, 0x69, 0xC2, 0x47, 0x9A, 0x81, 0xF5, 0x59, 0x07, 0xE9, 0x42, 0x36, 0xC2, 0x07, + 0x03, 0xC6, 0xE9, 0x21, 0x00, 0xCC, 0x84, 0xEF, 0xA5, 0x83, 0x00, 0x32, 0x8F, 0x1E, 0x95, 0x19, + 0x87, 0x67, 0xDC, 0xCC, 0x47, 0xBC, 0x90, 0x8D, 0x70, 0xC1, 0x80, 0xE0, 0x19, 0x27, 0x17, 0xD6, + 0xA1, 0xD7, 0xF9, 0x26, 0x4C, 0x56, 0xA4, 0xB7, 0xCB, 0xEC, 0x34, 0xEB, 0xD1, 0xC7, 0x2B, 0x67, + 0xBD, 0x7C, 0xF1, 0x3E, 0x90, 0x01, 0x93, 0xB2, 0xCB, 0xED, 0xB4, 0x6E, 0xF2, 0x3F, 0x8E, 0x2C, + 0xA9, 0xB8, 0x4D, 0x0C, 0xA3, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, + 0x60, 0x82 +}; + +#endif /* __icon_list_item2_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_scale_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_scale_png.h new file mode 100644 index 0000000..776e2b5 --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_scale_png.h @@ -0,0 +1,167 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_scale_png_h_included +#define __icon_scale_png_h_included + +#include + +/* Contents of file icon_scale.png */ +#define icon_scale_png_fileName "icon_scale.png" +#define icon_scale_png_fileSize 2440 + +static const uint8_t icon_scale_png_fileBinaryArray[2440] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x09, 0x42, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x3D, 0x6C, 0x14, 0x47, 0x18, 0x86, + 0xC7, 0x7F, 0xB1, 0x63, 0x62, 0x40, 0x60, 0x59, 0xA0, 0x28, 0x41, 0x58, 0x71, 0x65, 0xD1, 0x20, + 0x04, 0x28, 0xA2, 0x43, 0x4A, 0x13, 0x22, 0x6A, 0x6A, 0x0A, 0x6A, 0x90, 0x50, 0x08, 0xA4, 0x8A, + 0x82, 0x80, 0x06, 0x8A, 0x54, 0x29, 0xA8, 0xA1, 0x04, 0xC9, 0x69, 0xA2, 0xD0, 0x11, 0x09, 0x08, + 0x94, 0x69, 0xB1, 0x1C, 0x09, 0x03, 0x12, 0x20, 0x62, 0x02, 0x21, 0xF8, 0x2F, 0xF3, 0xAC, 0xEF, + 0x5D, 0xCD, 0xCD, 0xFD, 0xAC, 0xEF, 0x67, 0x77, 0xD6, 0xBE, 0xF9, 0xA4, 0xF1, 0xCC, 0xCE, 0xEC, + 0x7C, 0xB3, 0xF3, 0xBC, 0x33, 0xB3, 0x7B, 0xB7, 0xEB, 0xDB, 0x3E, 0xD3, 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6E, 0x9D, + 0xCD, 0x0A, 0xBB, 0x59, 0xBF, 0x12, 0x88, 0x15, 0xF8, 0x12, 0x40, 0xB1, 0x66, 0x05, 0xDB, 0x7E, + 0xC0, 0x27, 0x79, 0x35, 0x6B, 0xB6, 0x0F, 0xD4, 0x17, 0xC2, 0xDD, 0x56, 0x7D, 0xD5, 0x61, 0xBB, + 0x17, 0x4D, 0x70, 0xE9, 0xBB, 0xD2, 0xF5, 0x62, 0x95, 0xBB, 0x71, 0x8D, 0x00, 0x14, 0x62, 0x82, + 0xAA, 0xD8, 0xCF, 0xAB, 0x97, 0x9F, 0x54, 0xEC, 0xC1, 0x3F, 0xC9, 0x48, 0xAE, 0xF4, 0x5B, 0xE0, + 0xD9, 0xF4, 0xF3, 0xFD, 0xBC, 0xA4, 0x8A, 0x0B, 0x32, 0xC9, 0xF0, 0xFE, 0xF8, 0xE5, 0xFE, 0xB6, + 0xB7, 0x7B, 0x2A, 0x9C, 0x9F, 0xBF, 0xD9, 0xB6, 0x5D, 0xB8, 0xF5, 0xFA, 0xE6, 0x97, 0xFB, 0xDB, + 0x69, 0x9D, 0xFF, 0x01, 0xE6, 0xF9, 0x19, 0xD7, 0x4A, 0xC7, 0x0D, 0x5C, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 +}; + +#endif /* __icon_scale_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_select_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_select_png.h new file mode 100644 index 0000000..5ca4a50 --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_select_png.h @@ -0,0 +1,173 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_switch_select_png_h_included +#define __icon_switch_select_png_h_included + +#include + +/* Contents of file icon_switch_select.png */ +#define icon_switch_select_png_fileName "icon_switch_select.png" +#define icon_switch_select_png_fileSize 2529 + +static const uint8_t icon_switch_select_png_fileBinaryArray[2529] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x09, 0x9B, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x5B, 0x6C, 0x54, 0x45, 0x18, 0xC7, + 0xA7, 0xDB, 0x1B, 0xB7, 0x52, 0xA3, 0x05, 0x8A, 0x04, 0x42, 0xAB, 0x25, 0x26, 0x05, 0xD3, 0x34, + 0x88, 0x11, 0x21, 0x26, 0xC6, 0x88, 0xD7, 0x68, 0xA2, 0xBC, 0x11, 0x12, 0x9F, 0x48, 0x78, 0x23, + 0x82, 0xC6, 0xC6, 0x04, 0x83, 0xC6, 0x04, 0x13, 0x13, 0x0D, 0xD1, 0x04, 0x9F, 0x7C, 0x20, 0x86, + 0x04, 0x1F, 0x78, 0xA8, 0x68, 0x50, 0xF1, 0x86, 0x18, 0x45, 0x50, 0x04, 0x34, 0xA4, 0x81, 0x72, + 0x91, 0x42, 0xA1, 0x2A, 0xB4, 0x5C, 0x4A, 0xBB, 0x17, 0xBF, 0xFF, 0xE9, 0xFE, 0x4F, 0xA6, 0xB3, + 0x67, 0xBB, 0xEC, 0xE9, 0xB9, 0x74, 0xBB, 0xF3, 0x25, 0xDF, 0xCE, 0x7D, 0xCE, 0x99, 0xDF, 0x37, + 0xF3, 0xCD, 0xEE, 0x9E, 0x73, 0x76, 0x2B, 0xD4, 0xD8, 0x52, 0x61, 0x14, 0x9B, 0x69, 0xA3, 0x58, + 0x15, 0x2A, 0x37, 0xEB, 0x97, 0x6A, 0x3A, 0x53, 0xE0, 0xC4, 0xCD, 0x72, 0x33, 0xED, 0x36, 0xCF, + 0x07, 0x8C, 0xF9, 0x0C, 0xD1, 0x80, 0x71, 0x84, 0x8C, 0xEB, 0xF9, 0x88, 0x97, 0xA3, 0xE8, 0x70, + 0x11, 0x67, 0x9A, 0x21, 0x98, 0x30, 0xCE, 0xD0, 0xE5, 0x54, 0xE5, 0xC6, 0x46, 0x22, 0x04, 0xAB, + 0x87, 0x04, 0x6E, 0x86, 0x68, 0xC1, 0x3C, 0xA3, 0x9B, 0xB2, 0x4A, 0x02, 0x2A, 0xC1, 0x32, 0x6E, + 0x86, 0x26, 0x10, 0xD6, 0xF7, 0x9C, 0xC9, 0x84, 0xAA, 0x87, 0x09, 0xE9, 0x81, 0x8A, 0x7C, 0xC4, + 0x59, 0x8E, 0xCE, 0x11, 0x2F, 0x47, 0x21, 0x48, 0x02, 0x4F, 0x0B, 0x04, 0xC4, 0x11, 0x52, 0x59, + 0xA6, 0x87, 0x60, 0x85, 0xB4, 0xF2, 0x5A, 0x01, 0x04, 0x4B, 0xE0, 0x95, 0x52, 0x0F, 0x71, 0x33, + 0xD4, 0x0D, 0x81, 0xBE, 0x20, 0xE5, 0x62, 0x08, 0x07, 0xDE, 0xC8, 0x90, 0x5D, 0xE0, 0xC8, 0x03, + 0xF4, 0x54, 0x9E, 0x10, 0x65, 0x14, 0xB7, 0x3D, 0x0D, 0x40, 0xE8, 0x0C, 0x09, 0x1C, 0xD0, 0xA1, + 0xD5, 0xD9, 0x10, 0xF5, 0x99, 0x47, 0x03, 0xB1, 0x8D, 0x14, 0x39, 0x32, 0xD9, 0x8D, 0xE0, 0xC2, + 0x93, 0xD1, 0x22, 0x4E, 0xF0, 0x84, 0x0F, 0x03, 0x24, 0x45, 0x11, 0x0E, 0x8B, 0x82, 0x07, 0xE2, + 0x10, 0xDD, 0x08, 0x48, 0x67, 0x68, 0x00, 0x24, 0x20, 0xA8, 0xAC, 0xC3, 0x07, 0x78, 0x53,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 0x24, 0x7B, 0x44, 0x78, 0x5F, 0x90, 0xDE, 0x29, 0x4A, 0xD0, 0x21, 0x44, + 0x3F, 0x00, 0xA0, 0xA3, 0x43, 0xC2, 0xA7, 0xCB, 0xD2, 0x81, 0xEB, 0x71, 0xB4, 0x9F, 0xAC, 0xA2, + 0xF3, 0x42, 0x1C, 0xBC, 0x18, 0x12, 0xB4, 0x19, 0xB2, 0x0E, 0x99, 0x3A, 0x7D, 0xE8, 0xC0, 0x18, + 0x47, 0x68, 0x2A, 0x5D, 0x0D, 0xDD, 0x0D, 0x43, 0xBD, 0xCD, 0x64, 0x85, 0x3D, 0xD6, 0xB8, 0x1C, + 0x88, 0x59, 0xF8, 0x34, 0x00, 0x43, 0xAE, 0x0A, 0xA4, 0x4D, 0x45, 0x9F, 0xC8, 0xCB, 0xF1, 0xD9, + 0x26, 0x50, 0xD3, 0x10, 0x7A, 0x9A, 0xED, 0xD9, 0x06, 0xE9, 0x72, 0x14, 0xC2, 0xC5, 0xD8, 0x19, + 0xF7, 0x0A, 0x59, 0xAE, 0x87, 0x39, 0x06, 0x40, 0x21, 0x84, 0x50, 0x19, 0x9A, 0x79, 0x5E, 0xF9, + 0x4E, 0xC3, 0x32, 0x7C, 0x71, 0x66, 0x72, 0x76, 0xDC, 0x04, 0x8F, 0xA4, 0x99, 0x6F, 0xE6, 0x39, + 0x4D, 0x74, 0x90, 0x4E, 0x86, 0xF1, 0x62, 0x96, 0x9B, 0x69, 0xA3, 0xBA, 0x6B, 0x38, 0x33, 0x7F, + 0xB2, 0xA5, 0x75, 0xB8, 0x5E, 0x63, 0x33, 0xCB, 0xCD, 0xB4, 0xDB, 0xE6, 0x7F, 0x62, 0xCE, 0x22, + 0x70, 0x90, 0xCB, 0xAB, 0x5B, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, + 0x82 +}; + +#endif /* __icon_switch_select_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_unselect_png.h b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_unselect_png.h new file mode 100644 index 0000000..4d93930 --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/icon_switch_unselect_png.h @@ -0,0 +1,172 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __icon_switch_unselect_png_h_included +#define __icon_switch_unselect_png_h_included + +#include + +/* Contents of file icon_switch_unselect.png */ +#define icon_switch_unselect_png_fileName "icon_switch_unselect.png" +#define icon_switch_unselect_png_fileSize 2514 + +static const uint8_t icon_switch_unselect_png_fileBinaryArray[2514] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x08, 0x06, 0x00, 0x00, 0x00, 0xE2, 0x98, 0x77, + 0x38, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, + 0x09, 0x8C, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0x9D, 0x49, 0x68, 0x54, 0x49, 0x1C, 0xC6, + 0x2B, 0x8B, 0x93, 0x68, 0x12, 0x77, 0x07, 0x64, 0x54, 0x30, 0x4E, 0x14, 0x8D, 0x51, 0x11, 0x0F, + 0xA2, 0x20, 0x8A, 0x30, 0x07, 0x43, 0xF0, 0xE2, 0x51, 0x6F, 0x82, 0x5E, 0x45, 0x64, 0x88, 0x0C, + 0x08, 0xE3, 0x5C, 0xBC, 0x29, 0x03, 0x42, 0xBC, 0x78, 0x10, 0x41, 0x14, 0x41, 0x21, 0x03, 0x32, + 0x8C, 0x37, 0xF7, 0x51, 0x71, 0x21, 0xEE, 0x18, 0x26, 0xEE, 0xB8, 0x8E, 0xEB, 0x24, 0x9A, 0x64, + 0xFE, 0x5F, 0xD9, 0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0x9E, 0x7D, 0x05, 0x4D, 0x20, 0xC1, 0x0E, 0xAB, 0x0A, 0x58, 0x9A, + 0xCB, 0x3D, 0x79, 0x07, 0x02, 0x10, 0x19, 0x33, 0xB8, 0x1F, 0xB0, 0x12, 0xF3, 0xBD, 0x5F, 0x18, + 0x01, 0x9B, 0x23, 0xF9, 0x06, 0xAD, 0x70, 0x09, 0x42, 0x02, 0x33, 0x91, 0x46, 0x07, 0x01, 0xBC, + 0x7D, 0x1B, 0x01, 0x0E, 0x62, 0x32, 0x25, 0x67, 0xDD, 0x2A, 0x12, 0x91, 0x00, 0x33, 0x7D, 0x84, + 0xCD, 0x3C, 0x5D, 0xC0, 0xFF, 0x09, 0x45, 0xC0, 0x64, 0x69, 0x32, 0x46, 0x63, 0x55, 0x80, 0x0C, + 0x4B, 0xC9, 0x48, 0xA4, 0x31, 0x5F, 0x17, 0xF2, 0x7F, 0x42, 0x11, 0xE0, 0x40, 0x4E, 0xC7, 0x38, + 0x65, 0x0F, 0x40, 0x0F, 0x2C, 0x18, 0xAA, 0x37, 0x5F, 0x29, 0x2B, 0x81, 0x14, 0xB6, 0x99, 0x46, + 0x38, 0x0A, 0xD2, 0x65, 0x6D, 0xD1, 0x67, 0xE6, 0x24, 0x40, 0x8E, 0x29, 0xF0, 0x51, 0x33, 0x93, + 0x00, 0x39, 0x5B, 0xF5, 0x05, 0x8A, 0x43, 0xC0, 0x0B, 0x50, 0x1C, 0x8E, 0xA1, 0x5B, 0xF1, 0x02, + 0x84, 0x46, 0x57, 0x9C, 0x8A, 0x5E, 0x80, 0xE2, 0x70, 0x0C, 0xDD, 0x8A, 0x17, 0x20, 0x34, 0xBA, + 0xE2, 0x54, 0xF4, 0x02, 0x14, 0x87, 0x63, 0xE8, 0x56, 0xBC, 0x00, 0xA1, 0xD1, 0x15, 0xA7, 0xA2, + 0x17, 0xA0, 0x38, 0x1C, 0x43, 0xB7, 0x12, 0x2B, 0x01, 0x1E, 0x3D, 0x7A, 0xA4, 0x2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 0xB8, 0xE9, 0x8E, 0xCD, 0xCE, 0xB7, 0xE3, 0x41, 0x9D, 0xFF, 0x01, 0xB2, 0x15, + 0x34, 0x9A, 0xBC, 0x3E, 0x46, 0x6A, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, + 0x60, 0x82 +}; + +#endif /* __icon_switch_unselect_png_h_included */ diff --git a/sample/api_sample/widget/widget_file_c/en_big_screen/widget_config_json.h b/sample/api_sample/widget/widget_file_c/en_big_screen/widget_config_json.h new file mode 100644 index 0000000..5fef7f6 --- /dev/null +++ b/sample/api_sample/widget/widget_file_c/en_big_screen/widget_config_json.h @@ -0,0 +1,256 @@ +/* Generated by file2c, do not edit manually */ +#ifndef __widget_config_json_h_included +#define __widget_config_json_h_included + +#include + +/* Contents of file widget_config.json */ +#define widget_config_json_fileName "widget_config.json" +#define widget_config_json_fileSize 3858 + +static const uint8_t widget_config_json_fileBinaryArray[3858] = { + 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x22, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x22, 0x3A, + 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6D, 0x61, 0x6A, + 0x6F, 0x72, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x31, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x22, 0x6D, 0x69, 0x6E, 0x6F, 0x72, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x30, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6D, 0x61, 0x69, 0x6E, 0x5F, + 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x22, 0x3A, 0x20, 0x7B, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x69, 0x6E, 0x67, 0x5F, + 0x77, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0x22, 0x3A, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x73, 0x5F, 0x65, 0x6E, 0x61, 0x62, 0x6C, + 0x65, 0x22, 0x3A, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, + 0x67, 0x65, 0x74, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x22, 0x3A, 0x20, 0x5B, 0x0A, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, + 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x30, 0x2C, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, + 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x62, 0x75, + 0x74, 0x74, 0x6F, 0x6E, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, + 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x5F, 0x31, 0x22, + 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x73, 0x65, 0x74, + 0x22, 0x3A, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, + 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, + 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x62, 0x75, 0x74, + 0x74, 0x6F, 0x6E, 0x31, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, + 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x75, + 0x6E, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, + 0x63, 0x6F, 0x6E, 0x5F, 0x62, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x31, 0x2E, 0x70, 0x6E, 0x67, 0x22, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x7D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, + 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, + 0x31, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, + 0x3A, 0x20, 0x22, 0x62, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, + 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x42, 0x75, 0x74, 0x74, + 0x6F, 0x6E, 0x5F, 0x32, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, + 0x65, 0x5F, 0x73, 0x65, 0x74, 0x22, 0x3A, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, + 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x73, + 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, + 0x6E, 0x5F, 0x62, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x32, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x2C, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, + 0x61, 0x6D, 0x65, 0x5F, 0x75, 0x6E, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, + 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x62, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x32, + 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, + 0x65, 0x78, 0x22, 0x3A, 0x20, 0x32, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, + 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x6C, 0x69, 0x73, 0x74, 0x22, 0x2C, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, + 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x4C, + 0x69, 0x73, 0x74, 0x5F, 0x33, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6C, 0x69, 0x73, 0x74, 0x5F, 0x69, 0x74, + 0x65, 0x6D, 0x22, 0x3A, 0x20, 0x5B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6D, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, + 0x3A, 0x20, 0x22, 0x49, 0x74, 0x65, 0x6D, 0x5F, 0x31, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x73, + 0x65, 0x74, 0x22, 0x3A, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, + 0x61, 0x6D, 0x65, 0x5F, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, + 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x5F, 0x69, 0x74, 0x65, 0x6D, + 0x31, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, + 0x61, 0x6D, 0x65, 0x5F, 0x75, 0x6E, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, + 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x5F, 0x69, 0x74, + 0x65, 0x6D, 0x31, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x7D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6D, 0x5F, 0x6E, 0x61, + 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x49, 0x74, 0x65, 0x6D, 0x5F, 0x32, 0x22, 0x2C, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, + 0x65, 0x5F, 0x73, 0x65, 0x74, 0x22, 0x3A, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, + 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, + 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x5F, 0x69, + 0x74, 0x65, 0x6D, 0x32, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, + 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x75, 0x6E, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, + 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x6C, 0x69, 0x73, 0x74, + 0x5F, 0x69, 0x74, 0x65, 0x6D, 0x32, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5D, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, + 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x33, 0x2C, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, + 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x73, 0x77, + 0x69, 0x74, 0x63, 0x68, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, + 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x5F, 0x34, 0x22, + 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x73, 0x65, 0x74, + 0x22, 0x3A, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, + 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, + 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x73, 0x77, 0x69, + 0x74, 0x63, 0x68, 0x5F, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x2C, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, + 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x75, 0x6E, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, + 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, + 0x5F, 0x75, 0x6E, 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, + 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x34, 0x2C, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, + 0x22, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, + 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x53, 0x63, 0x61, 0x6C, 0x65, 0x5F, 0x35, + 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x73, 0x65, + 0x74, 0x22, 0x3A, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, + 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x73, 0x65, 0x6C, 0x65, 0x63, + 0x74, 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, 0x6F, 0x6E, 0x5F, 0x73, 0x63, + 0x61, 0x6C, 0x65, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, + 0x63, 0x6F, 0x6E, 0x5F, 0x66, 0x69, 0x6C, 0x65, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x5F, 0x75, 0x6E, + 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x20, 0x3A, 0x20, 0x20, 0x22, 0x69, 0x63, + 0x6F, 0x6E, 0x5F, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x2E, 0x70, 0x6E, 0x67, 0x22, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x22, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x5F, 0x69, 0x6E, 0x74, 0x65, 0x72, + 0x66, 0x61, 0x63, 0x65, 0x22, 0x3A, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x22, 0x74, 0x65, 0x78, 0x74, 0x5F, 0x69, 0x6E, 0x70, 0x75, 0x74, 0x5F, 0x62, 0x6F, 0x78, + 0x22, 0x3A, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, + 0x22, 0x54, 0x65, 0x78, 0x74, 0x49, 0x6E, 0x70, 0x75, 0x74, 0x42, 0x6F, 0x78, 0x22, 0x2C, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x6C, 0x61, + 0x63, 0x65, 0x68, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x5F, 0x74, 0x65, 0x78, 0x74, 0x22, 0x3A, 0x20, + 0x22, 0x50, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x20, 0x69, 0x6E, 0x70, 0x75, 0x74, 0x20, 0x6D, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x73, 0x5F, 0x65, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x22, 0x3A, + 0x20, 0x74, 0x72, 0x75, 0x65, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, + 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x22, 0x3A, 0x20, 0x5B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, + 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x35, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, + 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x62, 0x75, 0x74, 0x74, 0x6F, + 0x6E, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, + 0x22, 0x3A, 0x20, 0x22, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x5F, 0x36, 0x22, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, + 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x36, 0x2C, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, + 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x73, 0x63, + 0x61, 0x6C, 0x65, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, + 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x53, 0x63, 0x61, 0x6C, 0x65, 0x5F, 0x37, 0x22, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, + 0x67, 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x37, 0x2C, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, + 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x69, + 0x6E, 0x74, 0x5F, 0x69, 0x6E, 0x70, 0x75, 0x74, 0x5F, 0x62, 0x6F, 0x78, 0x22, 0x2C, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, + 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x49, + 0x6E, 0x74, 0x65, 0x67, 0x65, 0x72, 0x49, 0x6E, 0x70, 0x75, 0x74, 0x42, 0x6F, 0x78, 0x5F, 0x38, + 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x22, 0x69, 0x6E, 0x74, 0x5F, 0x69, 0x6E, 0x70, 0x75, 0x74, 0x5F, 0x62, 0x6F, + 0x78, 0x5F, 0x68, 0x69, 0x6E, 0x74, 0x22, 0x3A, 0x20, 0x22, 0x75, 0x6E, 0x69, 0x74, 0x3A, 0x73, + 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, + 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, 0x3A, 0x20, 0x38, + 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3A, + 0x20, 0x22, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, + 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x53, 0x77, 0x69, 0x74, 0x63, + 0x68, 0x5F, 0x39, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x22, + 0x3A, 0x20, 0x39, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x5F, 0x74, 0x79, 0x70, + 0x65, 0x22, 0x3A, 0x20, 0x22, 0x6C, 0x69, 0x73, 0x74, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x77, 0x69, 0x64, + 0x67, 0x65, 0x74, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x4C, 0x69, 0x73, 0x74, + 0x5F, 0x31, 0x30, 0x22, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6C, 0x69, 0x73, 0x74, 0x5F, 0x69, 0x74, 0x65, 0x6D, + 0x22, 0x3A, 0x20, 0x5B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6D, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, + 0x22, 0x49, 0x74, 0x65, 0x6D, 0x20, 0x31, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, + 0x74, 0x65, 0x6D, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x49, 0x74, 0x65, 0x6D, + 0x20, 0x32, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, + 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6D, 0x5F, 0x6E, + 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x20, 0x22, 0x49, 0x74, 0x65, 0x6D, 0x20, 0x33, 0x22, 0x0A, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x7D, 0x2C, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x74, 0x65, 0x6D, 0x5F, 0x6E, 0x61, 0x6D, 0x65, 0x22, 0x3A, + 0x20, 0x22, 0x49, 0x74, 0x65, 0x6D, 0x20, 0x34, 0x22, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x5D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x7D, 0x0A, + 0x7D, 0x0A +}; + +#endif /* __widget_config_json_h_included */ diff --git a/sample/api_sample/xport/test_xport.c b/sample/api_sample/xport/test_xport.c new file mode 100644 index 0000000..5347017 --- /dev/null +++ b/sample/api_sample/xport/test_xport.c @@ -0,0 +1,361 @@ +/** + ******************************************************************** + * @file test_xport.c + * @version V2.0.0 + * @date 2019/10/16 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include +#include "test_xport.h" +#include "psdk_logger.h" +#include "psdk_platform.h" +#include "utils/util_misc.h" +#include "psdk_aircraft_info.h" +#include "camera_emu/test_payload_cam_emu.h" + +/* Private constants ---------------------------------------------------------*/ +#define XPORT_TASK_FREQ (10) +#define XPORT_TASK_STACK_SIZE (2048) + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static void *UserXPort_Task(void *arg);//用户自定义xport任务 +static T_PsdkReturnCode ReceiveXPortSystemState(T_PsdkGimbalSystemState systemState);//通过构造回调函数接收X-Port 的状态信息。 +static T_PsdkReturnCode ReceiveXPortAttitudeInformation(T_PsdkGimbalAttitudeInformation attitudeInformation);//构造回调函数获取X-Port 的姿态,在回调函数中打印X-Port 的姿态信息。 + +/* Private variables ---------------------------------------------------------*/ +static T_PsdkTaskHandle s_userXPortThread;//线程句柄 +static T_PsdkMutexHandle s_userXPortMutex; +static T_PsdkGimbalSystemState s_userXPortSystemState = {0}; +static bool s_isUserXPortInited = false; +static bool s_isUserXPortSystemStateVaild = false; + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkTest_XPortInit(void) +{ + T_PsdkReturnCode psdkStat; + T_PsdkXPortLimitAngle limitAngle = {0}; + T_PsdkAircraftInfoBaseInfo aircraftInfoBaseInfo = {0}; + + //X-Port 功能模块初始化 + psdkStat = PsdkXPort_Init(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("XPort init error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_isUserXPortInited = true; + + psdkStat = PsdkOsal_MutexCreate(&s_userXPortMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user XPort mutex create error: 0x%08llX.", psdkStat); + return psdkStat; + } + + //通过注册回调函数接收X-Port 的状态信息。注册后,回调函数将会被自动调用,调用频率为1Hz + psdkStat = PsdkXPort_RegReceiveSystemStateCallback(ReceiveXPortSystemState); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register receive XPort system state callback function error: 0x%08llX.", psdkStat); + return psdkStat; + } + + //通过注册回调函数获取X-Port 的姿态信息.注册后,回调函数将会被自动调用,调用频率为10Hz + psdkStat = PsdkXPort_RegReceiveAttitudeInformationCallback(ReceiveXPortAttitudeInformation); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("register receive XPort attitude information callback function error: 0x%08llX.", + psdkStat); + return psdkStat; + } + + //配置xport信息;开始------------------------------------------------------------------------------------------------------ + //下述代码中X-Port 的角度单位为0.1度 + + //设置俯仰轴关节角(JOINT_ANGLE)限位 + limitAngle.upperLimit = 300; + limitAngle.lowerLimit = -1000; + psdkStat = PsdkXPort_SetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_JOINT_ANGLE, limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set pitch joint angle limit angle for XPort error: 0x%08llX.", psdkStat); + return psdkStat; + } + //设置俯仰轴欧拉角(EULER_ANGLE)限位 + limitAngle.upperLimit = 300; + limitAngle.lowerLimit = -800; + psdkStat = PsdkXPort_SetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_EULER_ANGLE, limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set pitch euler angle limit angle for XPort error: 0x%08llX.", psdkStat); + return psdkStat; + } + //设置扩展俯仰轴欧拉角(EULER_ANGLE_EXTENSION)限位 + limitAngle.upperLimit = 300; + limitAngle.lowerLimit = -1000; + psdkStat = PsdkXPort_SetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_EULER_ANGLE_EXTENSION, limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set pitch extension euler angle limit angle for XPort error: 0x%08llX.", psdkStat); + return psdkStat; + } + //设置航向轴关节角(YAW_JOINT_ANGLE)限位1、获取飞机信息 → 判断云台在飞机上的挂载点 + psdkStat = PsdkAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get aircraft base information error: 0x%08llX.", psdkStat); + return psdkStat; + } + + if (aircraftInfoBaseInfo.payloadMountPosition == PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO1) { + limitAngle.upperLimit = 300; + limitAngle.lowerLimit = -1500; + } else if (aircraftInfoBaseInfo.payloadMountPosition == PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO2) { + limitAngle.upperLimit = 1500; + limitAngle.lowerLimit = -300; + } else if (aircraftInfoBaseInfo.payloadMountPosition == PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO3) { + limitAngle.upperLimit = 1500; + limitAngle.lowerLimit = -1500; + } else { + PsdkLogger_UserLogWarn("payload mount position is unknown."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + //设置航向轴关节角(YAW_JOINT_ANGLE)限位2、 + psdkStat = PsdkXPort_SetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_YAW_JOINT_ANGLE, limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set yaw joint angle limit angle for XPort error: 0x%08llX.", psdkStat); + return psdkStat; + } + + //设置X-Port 工作模式 + psdkStat = PsdkXPort_SetGimbalModeSync(PSDK_GIMBAL_MODE_YAW_FOLLOW); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set XPort gimbal mode error: 0x%08llX.", psdkStat); + return psdkStat; + } + //使用X-Port 复位功能 + psdkStat = PsdkXPort_ResetSync(PSDK_GIMBAL_RESET_MODE_PITCH_AND_YAW); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("reset XPort gimbal error: 0x%08llX.", psdkStat); + return psdkStat; + } + + //用户自定义xport功能 + if (PsdkOsal_TaskCreate(&s_userXPortThread, UserXPort_Task, "user_xport_task", XPORT_TASK_STACK_SIZE, NULL) != + PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user XPort task create error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_XPortDeInit(void) +{ + T_PsdkReturnCode psdkStat; + + psdkStat = PsdkOsal_TaskDestroy(s_userXPortThread); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Destroy test xport thread error: 0x%08llX.", psdkStat); + return psdkStat; + } + + psdkStat = PsdkOsal_MutexDestroy(s_userXPortMutex); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Destroy test xport mutex error: 0x%08llX.", psdkStat); + return psdkStat; + } + + psdkStat = PsdkXPort_DeInit(); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("XPort de-init error: 0x%08llX.", psdkStat); + return psdkStat; + } + + s_isUserXPortInited = false; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkTest_XPortGetSystemState(T_PsdkGimbalSystemState *systemState) +{ + T_PsdkReturnCode returnCode; + + if (s_isUserXPortInited != true || s_isUserXPortSystemStateVaild != true) { + PsdkLogger_UserLogWarn("user XPort has not inited."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE; + } + + returnCode = PsdkOsal_MutexLock(s_userXPortMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user XPort mutex lock error: 0x%08llX.", returnCode); + return returnCode; + } + + memcpy(systemState, &s_userXPortSystemState, sizeof(T_PsdkGimbalSystemState)); + + returnCode = PsdkOsal_MutexUnlock(s_userXPortMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user XPort mutex unlock error: 0x%08llX.", returnCode); + return returnCode; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +#ifndef __CC_ARM +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +//用户自定义xport功能函数实现 +static void *UserXPort_Task(void *arg) +{ + T_PsdkReturnCode psdkStat; + T_PsdkXPortLimitAngle limitAngle = {0}; + float opticalZoomFactor = 1.0f; + float digitalZoomFactor = 1.0f; + int step = 0; + + USER_UTIL_UNUSED(arg); + + while (1) { + PsdkOsal_TaskSleepMs(1000 / XPORT_TASK_FREQ); + step++; + + //XPORT_TASK_FREQ(10)的整数才执行if后面的代码:获取xport限位角并打印出来 + if (USER_UTIL_IS_WORK_TURN(step, 1, XPORT_TASK_FREQ)) { + psdkStat = PsdkXPort_GetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_ROLL_JOINT_ANGLE, &limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get roll joint angle limit angle from XPort error: 0x%08llX.", psdkStat); + continue; + } + + PsdkLogger_UserLogDebug("roll joint angle limit angle of XPort: upper limit %d, lower limit %d.", + limitAngle.upperLimit, limitAngle.lowerLimit); + + psdkStat = PsdkXPort_GetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_JOINT_ANGLE, &limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get pitch joint angle limit angle from XPort error: 0x%08llX.", psdkStat); + continue; + } + + PsdkLogger_UserLogDebug("pitch joint angle limit angle of XPort: upper limit %d, lower limit %d.", + limitAngle.upperLimit, limitAngle.lowerLimit); + + psdkStat = PsdkXPort_GetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_EULER_ANGLE, &limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get pitch euler angle limit angle from XPort error: 0x%08llX.", psdkStat); + continue; + } + + PsdkLogger_UserLogDebug("pitch euler angle limit angle of XPort: upper limit %d, lower limit %d.", + limitAngle.upperLimit, limitAngle.lowerLimit); + + psdkStat = PsdkXPort_GetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_EULER_ANGLE_EXTENSION, + &limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get pitch extension euler angle limit angle from XPort error: 0x%08llX.", + psdkStat); + continue; + } + + PsdkLogger_UserLogDebug("pitch extension euler angle limit angle of XPort: upper limit %d, lower limit %d.", + limitAngle.upperLimit, limitAngle.lowerLimit); + + psdkStat = PsdkXPort_GetLimitAngleSync(PSDK_XPORT_LIMIT_ANGLE_CATEGORY_YAW_JOINT_ANGLE, &limitAngle); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get yaw joint angle limit angle from XPort error: 0x%08llX.", psdkStat); + continue; + } + + PsdkLogger_UserLogDebug("yaw joint angle limit angle of XPort: upper limit %d, lower limit %d.", + limitAngle.upperLimit, limitAngle.lowerLimit); + } + + //XPORT_TASK_FREQ(1)的整数才执行if后面的代码:设置xport速度转换系数 + if (USER_UTIL_IS_WORK_TURN(step, 10, XPORT_TASK_FREQ)) { + if (PsdkTest_CameraIsInited()) { + psdkStat = PsdkTest_CameraGetOpticalZoomFactor(&opticalZoomFactor); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get camera optical zoom factor error: %d.", psdkStat); + continue; + } + + psdkStat = PsdkTest_CameraGetDigitalZoomFactor(&digitalZoomFactor); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get camera digital zoom factor error: %d.", psdkStat); + continue; + } + + psdkStat = PsdkXPort_SetSpeedConversionFactor(1 / (opticalZoomFactor * digitalZoomFactor)); + if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set speed conversion factor error: %d.", psdkStat); + continue; + } + } + } + } +} + +#ifndef __CC_ARM +#pragma GCC diagnostic pop +#endif + +static T_PsdkReturnCode ReceiveXPortSystemState(T_PsdkGimbalSystemState systemState) +{ + T_PsdkReturnCode returnCode; + + returnCode = PsdkOsal_MutexLock(s_userXPortMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user XPort mutex lock error: 0x%08llX.", returnCode); + return returnCode; + } + + s_isUserXPortSystemStateVaild = true; + memcpy(&s_userXPortSystemState, &systemState, sizeof(T_PsdkGimbalSystemState)); + + returnCode = PsdkOsal_MutexUnlock(s_userXPortMutex); + if (returnCode != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("user XPort mutex unlock error: 0x%08llX.", returnCode); + return returnCode; + } + + PsdkLogger_UserLogDebug("receive XPort system state: mounted upward flag %d, gimbal mode %d.", + systemState.mountedUpward, systemState.gimbalMode); + + PsdkLogger_UserLogDebug("XPort fine tune: %d %d %d.", systemState.fineTuneAngle.pitch, + systemState.fineTuneAngle.roll, systemState.fineTuneAngle.yaw); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode ReceiveXPortAttitudeInformation(T_PsdkGimbalAttitudeInformation attitudeInformation) +{ + PsdkLogger_UserLogDebug("receive XPort attitude information:"); + PsdkLogger_UserLogDebug("XPort attitude: pitch %d, roll %d, yaw %d.", attitudeInformation.attitude.pitch, + attitudeInformation.attitude.roll, attitudeInformation.attitude.yaw); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/api_sample/xport/test_xport.h b/sample/api_sample/xport/test_xport.h new file mode 100644 index 0000000..c221d75 --- /dev/null +++ b/sample/api_sample/xport/test_xport.h @@ -0,0 +1,56 @@ +/** + ******************************************************************** + * @file test_xport.h + * @version V2.0.0 + * @date 2019/10/16 + * @brief This is the header file for "test_xport.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TEST_XPORT_H +#define TEST_XPORT_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" +#include "psdk_xport.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ + + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkTest_XPortInit(void); +T_PsdkReturnCode PsdkTest_XPortDeInit(void); +T_PsdkReturnCode PsdkTest_XPortGetSystemState(T_PsdkGimbalSystemState *systemState); +#ifdef __cplusplus +} +#endif + +#endif // TEST_XPORT_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/common/monitor/sys_monitor.c b/sample/platform/linux/common/monitor/sys_monitor.c new file mode 100644 index 0000000..11fe1a5 --- /dev/null +++ b/sample/platform/linux/common/monitor/sys_monitor.c @@ -0,0 +1,484 @@ +/** + ******************************************************************** + * @file sys_monitor.c + * @version V2.0.0 + * @date 2019/11/10 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include +#include "sys_monitor.h" +#include "psdk_logger.h" +#include "utils/util_misc.h" + +/* Private constants ---------------------------------------------------------*/ +#define MONITOR_VMRSS_LINE 15 +#define MONITOR_PROCESS_ITEM 14 +#define MONITOR_CMD_BUF_SIZE 512 + +/* Private types -------------------------------------------------------------*/ + + +/* Private functions declaration ---------------------------------------------*/ +static const char *Monitor_GetItems(const char *buffer, int ie); + +/* Private variables ---------------------------------------------------------*/ + + +/* Exported functions definition ---------------------------------------------*/ +int Monitor_GetPhyMem(pid_t p) +{ + int i; + char file[64] = {0}; + FILE *fd; + char lineBuf[256] = {0}; + char name[32]; + int vmrss = 0; //memory peak + char *ret = NULL; + + sprintf(file, "/proc/%d/status", (int) p); + fd = fopen(file, "r"); + if (fd == NULL) { + PsdkLogger_UserLogError("open file fail."); + return 0; + } + + for (i = 0; i < MONITOR_VMRSS_LINE - 1; i++) { + ret = fgets(lineBuf, sizeof(lineBuf), fd); + USER_UTIL_UNUSED(ret); + } + + ret = fgets(lineBuf, sizeof(lineBuf), fd); + if (ret == NULL) + goto out; + + sscanf(lineBuf, "%31s %d", name, &vmrss); + +out: + fclose(fd); + + return vmrss; +} + +int Monitor_GetTotalMem(void) +{ + char *file = "/proc/meminfo"; + FILE *fd; + char lineBuf[256] = {0}; + char name[32]; + int memtotal = 0; + char *ret = NULL; + + fd = fopen(file, "r"); + if (fd == NULL) { + PsdkLogger_UserLogError("open file fail."); + return 0; + } + + ret = fgets(lineBuf, sizeof(lineBuf), fd); + if (ret == NULL) + goto out; + + sscanf(lineBuf, "%31s %d", name, &memtotal); + +out: + fclose(fd); + + return memtotal; +} + +float Monitor_GetPmem(pid_t p) +{ + int phy = Monitor_GetPhyMem(p); + int total = Monitor_GetTotalMem(); + float occupy = (float) ((phy * 1.0) / (total * 1.0)); + + return occupy; +} + +unsigned int Monitor_GetCpuOccupyOfProcess(pid_t pid) +{ + char file[64] = {0}; + T_MonitorProcessCpuOccupy t = {0}; + FILE *fd; + char lineBuf[1024] = {0}; + char *q = NULL; + char *ret = NULL; + + sprintf(file, "/proc/%d/stat", (int) pid); + fd = fopen(file, "r"); + if (fd == NULL) { + PsdkLogger_UserLogError("open file fail."); + return 0; + } + + ret = fgets(lineBuf, sizeof(lineBuf), fd); + if (ret == NULL) + goto out; + + sscanf(lineBuf, "%u", (unsigned int *) &t.pid); + q = (char *) Monitor_GetItems(lineBuf, MONITOR_PROCESS_ITEM); + if (q == NULL) { + PsdkLogger_UserLogError("get item fail."); + goto out; + } + + sscanf(q, "%u %u %u %u", &t.utime, &t.stime, &t.cutime, &t.cstime); + +out: + fclose(fd); + + return (t.utime + t.stime + t.cutime + t.cstime); +} + +unsigned int Monitor_GetCpuOccupyOfThread(pid_t pid, pid_t tid) +{ + char file[64] = {0}; + T_MonitorProcessCpuOccupy t = {0}; + FILE *fd; + char lineBuf[1024] = {0}; + char *q = NULL; + char *ret = NULL; + + sprintf(file, "/proc/%d/task/%d/stat", (int) pid, (int) tid); + fd = fopen(file, "r"); + if (fd == NULL) { + PsdkLogger_UserLogError("open file fail."); + return 0; + } + + ret = fgets(lineBuf, sizeof(lineBuf), fd); + if (ret == NULL) + goto out; + + sscanf(lineBuf, "%u", (unsigned int *) &t.pid); + q = (char *) Monitor_GetItems(lineBuf, MONITOR_PROCESS_ITEM); + if (q == NULL) { + PsdkLogger_UserLogError("get item fail."); + goto out; + } + + sscanf(q, "%u %u %u %u", &t.utime, &t.stime, &t.cutime, &t.cstime); + +out: + fclose(fd); + + return (t.utime + t.stime + t.cutime + t.cstime); +} + +unsigned int Monitor_GetCpuTotalOccupy(void) +{ + FILE *fd; + char buff[1024] = {0}; + T_MonitorTotalCpuOccupy t = {0}; + char name[16]; + char *ret = NULL; + + fd = fopen("/proc/stat", "r"); + if (fd == NULL) { + PsdkLogger_UserLogError("open file fail."); + return 0; + } + + ret = fgets(buff, sizeof(buff), fd); + if (ret == NULL) + goto out; + + sscanf(buff, "%15s %u %u %u %u", name, &t.user, &t.nice, &t.system, &t.idle); + +out: + fclose(fd); + + return (t.user + t.nice + t.system + t.idle); +} + +float Monitor_GetPcpuOfThread(pid_t pid, pid_t tid) +{ + FILE *fp; + char cmdStr[MONITOR_CMD_BUF_SIZE]; + char lineBuf[256] = {0}; + pid_t tidInCommandLine = 0; + float pcpuInCommandLine = 0.0f; + int ret; + char *q = NULL; + + snprintf(cmdStr, MONITOR_CMD_BUF_SIZE, "ps -mp %d -o tid,pcpu", (int) pid); + fp = popen(cmdStr, "r"); + if (fp == NULL) { + PsdkLogger_UserLogError("fp is null."); + return 0; + } + + while (fgets(lineBuf, sizeof(lineBuf), fp) != NULL) { + q = (char *) Monitor_GetItems(lineBuf, 1); + if (q == NULL) { + PsdkLogger_UserLogError("get item fail."); + goto out; + } + + sscanf(q, "%u", (unsigned int *) &tidInCommandLine); + + if (tidInCommandLine == tid) { + q = (char *) Monitor_GetItems(lineBuf, 2); + if (q == NULL) { + PsdkLogger_UserLogError("get item fail."); + goto out; + } + + ret = sscanf(q, "%f", &pcpuInCommandLine); + if (ret <= 0) { + PsdkLogger_UserLogError("get pcpu error."); + pcpuInCommandLine = 0; + } + + goto out; + } + } + + PsdkLogger_UserLogDebug("not found thread."); + +out: + pclose(fp); + + return pcpuInCommandLine; +} + +unsigned int Monitor_GetThreadCountOfProcess(pid_t pid) +{ + FILE *fp; + char cmdStr[MONITOR_CMD_BUF_SIZE]; + unsigned int count; + int ret; + + snprintf(cmdStr, MONITOR_CMD_BUF_SIZE, "ps -T -p %d | wc -l", (int) pid); + fp = popen(cmdStr, "r"); + if (fp == NULL) { + PsdkLogger_UserLogError("fp is null."); + return 0; + } + + ret = fscanf(fp, "%u", &count); + if (ret <= 0) { + PsdkLogger_UserLogError("get count error."); + count = 0; + goto out; + } + count--; + +out: + pclose(fp); + + return count; +} + +void Monitor_GetTidListOfProcess(pid_t pid, pid_t *tidList, unsigned int size) +{ + int i = 0; + FILE *fp; + char cmdStr[MONITOR_CMD_BUF_SIZE]; + char lineBuf[256] = {0}; + int ret = 0; + + if (Monitor_GetThreadCountOfProcess(pid) > size) { + PsdkLogger_UserLogError("size is too small."); + return; + } + + snprintf(cmdStr, MONITOR_CMD_BUF_SIZE, "ps -mp %d -o tid", (int) pid); + fp = popen(cmdStr, "r"); + if (fp == NULL) { + PsdkLogger_UserLogError("fp is null."); + return; + } + + while (fgets(lineBuf, sizeof(lineBuf), fp) != NULL && i <= size) { + ret = sscanf(lineBuf, "%u", (unsigned int *) &tidList[i]); + if (ret > 0) + i++; + } + + pclose(fp); +} + +void Monitor_GetNameOfThread(pid_t pid, pid_t tid, char *name, unsigned int size) +{ + char file[64] = {0}; + FILE *fd; + char lineBuf[32] = {0}; + char *ret = NULL; + + memset(name, 0, size); + + sprintf(file, "/proc/%d/task/%d/comm", (int) pid, (int) tid); + fd = fopen(file, "r"); + if (fd == NULL) { + PsdkLogger_UserLogDebug("open file fail."); + return; + } + + ret = fgets(lineBuf, sizeof(lineBuf), fd); + if (ret == NULL) + goto out; + + if (lineBuf[strlen(lineBuf) - 1] == '\n') + lineBuf[strlen(lineBuf) - 1] = '\0'; + strncpy(name, lineBuf, USER_UTIL_MIN(size - 1, sizeof(lineBuf))); + +out: + fclose(fd); +} + +/** + * @brief + * @param pid + * @return Unit: B. + */ +unsigned int Monitor_GetHeapUsed(pid_t pid) +{ + FILE *fp; + char cmdStr[MONITOR_CMD_BUF_SIZE]; + char lineBuf[256] = {0}; + int ret = 0; + unsigned int heapUsed = 0; + char *q = NULL; + char *rett = NULL; + + snprintf(cmdStr, MONITOR_CMD_BUF_SIZE, "cat /proc/%d/smaps | grep -A 18 heap | grep Private_Dirty", (int) pid); + fp = popen(cmdStr, "r"); + if (fp == NULL) { + PsdkLogger_UserLogError("fp is null."); + return 0; + } + + rett = fgets(lineBuf, sizeof(lineBuf), fp); + if (rett == NULL) { + goto out; + } + + q = (char *) Monitor_GetItems(lineBuf, 2); + if (q == NULL) { + PsdkLogger_UserLogError("get item fail."); + goto out; + } + + ret = sscanf(q, "%u", &heapUsed); + if (ret <= 0) { + PsdkLogger_UserLogError("can not find heapUsed."); + heapUsed = 0; + goto out; + } + heapUsed *= 1024; + +out: + pclose(fp); + + return heapUsed; +} + +/** + * @brief + * @param pid + * @return Unit: B. + */ +unsigned int Monitor_GetStackUsed(pid_t pid) +{ + FILE *fp; + char cmdStr[MONITOR_CMD_BUF_SIZE]; + char lineBuf[256] = {0}; + int ret = 0; + unsigned int stackUsed = 0; + char *q = NULL; + char *rett = NULL; + + snprintf(cmdStr, MONITOR_CMD_BUF_SIZE, "cat /proc/%d/smaps | grep -A 18 stack | grep Private_Dirty", (int) pid); + fp = popen(cmdStr, "r"); + if (fp == NULL) { + PsdkLogger_UserLogError("fp is null."); + return 0; + } + + rett = fgets(lineBuf, sizeof(lineBuf), fp); + if (rett == NULL) + goto out; + + q = (char *) Monitor_GetItems(lineBuf, 2); + if (q == NULL) { + PsdkLogger_UserLogError("get item fail."); + goto out; + } + + ret = sscanf(q, "%u", &stackUsed); + if (ret <= 0) { + PsdkLogger_UserLogError("can not find stackUsed."); + stackUsed = 0; + goto out; + } + stackUsed *= 1024; + +out: + pclose(fp); + + return stackUsed; +} + +/* Private functions definition-----------------------------------------------*/ +static const char *Monitor_GetItems(const char *buffer, int ie) +{ + int i = 0; + int j = 0; + char *p = (char *) buffer; + int len = (int) strlen(buffer); + int count = 0; + + if (1 == ie || ie < 1) { + return p; + } + + while (1) { + for (i = j; i < len; i++) { + if (*(buffer + i) != ' ') { + count++; + + if (count == ie) + return buffer + i; + + break; + } + } + + for (j = i; j < len; ++j) { + if (*(buffer + j) == ' ') + break; + } + + if (i == len || j == len) + break; + } + + return NULL; +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/platform/linux/common/monitor/sys_monitor.h b/sample/platform/linux/common/monitor/sys_monitor.h new file mode 100644 index 0000000..78fb7f2 --- /dev/null +++ b/sample/platform/linux/common/monitor/sys_monitor.h @@ -0,0 +1,78 @@ +/** + ******************************************************************** + * @file sys_monitor.h + * @version V2.0.0 + * @date 2019/11/10 + * @brief This is the header file for "sys_monitor.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef SYS_MONITOR_H +#define SYS_MONITOR_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + + +/* Exported types ------------------------------------------------------------*/ +typedef struct { + unsigned int user; + unsigned int nice; + unsigned int system; + unsigned int idle; +} T_MonitorTotalCpuOccupy; + +typedef struct { + pid_t pid; + unsigned int utime; + unsigned int stime; + unsigned int cutime; + unsigned int cstime; +} T_MonitorProcessCpuOccupy; + +/* Exported functions --------------------------------------------------------*/ +int Monitor_GetPhyMem(pid_t p); +int Monitor_GetTotalMem(); +unsigned int Monitor_GetCpuTotalOccupy(); +unsigned int Monitor_GetCpuOccupyOfProcess(pid_t pid); +unsigned int Monitor_GetCpuOccupyOfThread(pid_t pid, pid_t tid); +float Monitor_GetPcpuOfThread(pid_t pid, pid_t tid); +float Monitor_GetPmem(pid_t p); +unsigned int Monitor_GetThreadCountOfProcess(pid_t pid); +void Monitor_GetTidListOfProcess(pid_t pid, pid_t *tidList, unsigned int size); +void Monitor_GetNameOfThread(pid_t pid, pid_t tid, char *name, unsigned int size); +unsigned int Monitor_GetHeapUsed(pid_t pid); +unsigned int Monitor_GetStackUsed(pid_t pid); + +#ifdef __cplusplus +} +#endif + +#endif //SYS_MONITOR_H + +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/common/osal/osal.c b/sample/platform/linux/common/osal/osal.c new file mode 100644 index 0000000..98dd65d --- /dev/null +++ b/sample/platform/linux/common/osal/osal.c @@ -0,0 +1,294 @@ +/** + ******************************************************************** + * @file psdk_osal.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "osal.h" +#include "utils/util_misc.h" +#include "psdk_logger.h" + +/* Private constants ---------------------------------------------------------*/ + +/* Private types -------------------------------------------------------------*/ + +/* Private functions declaration ---------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ + +/* Private functions definition-----------------------------------------------*/ + +/* Private functions declaration ---------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ + +T_PsdkReturnCode +Osal_TaskCreate(T_PsdkTaskHandle *task, void *(*taskFunc)(void *), const char *name, uint32_t stackSize, void *arg) +{ + int result; + char nameDealed[16] = {0}; + + USER_UTIL_UNUSED(stackSize); + + *task = malloc(sizeof(pthread_t)); + if (*task == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + result = pthread_create(*task, NULL, taskFunc, arg); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + if (name != NULL) + strncpy(nameDealed, name, sizeof(nameDealed) - 1); + result = pthread_setname_np(*(pthread_t * ) * task, nameDealed); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode Osal_TaskDestroy(T_PsdkTaskHandle task) +{ + pthread_cancel(*(pthread_t *) task); + free(task); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode Osal_TaskSleepMs(uint32_t timeMs) +{ + usleep(1000 * timeMs); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Declare the mutex container, initialize the mutex, and + * create mutex ID. + * @param mutex: pointer to the created mutex ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_MutexCreate(T_PsdkMutexHandle *mutex) +{ + int result; + + *mutex = malloc(sizeof(pthread_mutex_t)); + if (*mutex == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + result = pthread_mutex_init(*mutex, NULL); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Delete the created mutex. + * @param mutex: pointer to the created mutex ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_MutexDestroy(T_PsdkMutexHandle mutex) +{ + int result; + + result = pthread_mutex_destroy(mutex); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + free(mutex); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Acquire and lock the mutex when peripheral access is required + * @param mutex: pointer to the created mutex ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_MutexLock(T_PsdkMutexHandle mutex) +{ + int result = pthread_mutex_lock(mutex); + + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Unlock and release the mutex, when done with the peripheral access. + * @param mutex: pointer to the created mutex ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_MutexUnlock(T_PsdkMutexHandle mutex) +{ + int result = pthread_mutex_unlock(mutex); + + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Declare the semaphore container, initialize the semaphore, and + * create semaphore ID. + * @param semaphore: pointer to the created semaphore ID. + * @param initValue: initial value of semaphore. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_SemaphoreCreate(T_PsdkSemHandle *semaphore, uint32_t initValue) +{ + int result; + + *semaphore = malloc(sizeof(sem_t)); + if (*semaphore == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED; + } + + result = sem_init(*semaphore, 0, (unsigned int) initValue); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Delete the created semaphore. + * @param semaphore: pointer to the created semaphore ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_SemaphoreDestroy(T_PsdkSemHandle semaphore) +{ + int result; + + result = sem_destroy((sem_t *) semaphore); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + free(semaphore); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Wait the semaphore until token becomes available. + * @param semaphore: pointer to the created semaphore ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_SemaphoreWait(T_PsdkSemHandle semaphore) +{ + int result; + + result = sem_wait(semaphore); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Wait the semaphore until token becomes available. + * @param semaphore: pointer to the created semaphore ID. + * @param waitTime: timeout value of waiting semaphore, unit: millisecond. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_SemaphoreTimedWait(T_PsdkSemHandle semaphore, uint32_t waitTime) +{ + int result; + struct timespec semaphoreWaitTime; + struct timeval systemTime; + + gettimeofday(&systemTime, NULL); + + systemTime.tv_usec += waitTime * 1000; + if (systemTime.tv_usec >= 1000000) { + systemTime.tv_sec += systemTime.tv_usec / 1000000; + systemTime.tv_usec %= 1000000; + } + + semaphoreWaitTime.tv_sec = systemTime.tv_sec; + semaphoreWaitTime.tv_nsec = systemTime.tv_usec * 1000; + + result = sem_timedwait(semaphore, &semaphoreWaitTime); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Release the semaphore token. + * @param semaphore: pointer to the created semaphore ID. + * @return an enum that represents a status of PSDK + */ +T_PsdkReturnCode Osal_SemaphorePost(T_PsdkSemHandle semaphore) +{ + int result; + + result = sem_post(semaphore); + if (result != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/** + * @brief Get the system time for ms. + * @return an uint32 that the time of system, uint:ms + */ +T_PsdkReturnCode Osal_GetTimeMs(uint32_t *ms) +{ + struct timeval time; + + gettimeofday(&time, NULL); + *ms = (time.tv_sec * 1000 + time.tv_usec / 1000); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +void *Osal_Malloc(uint32_t size) +{ + return malloc(size); +} + +void Osal_Free(void *ptr) +{ + free(ptr); +} + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ \ No newline at end of file diff --git a/sample/platform/linux/common/osal/osal.h b/sample/platform/linux/common/osal/osal.h new file mode 100644 index 0000000..b62c50d --- /dev/null +++ b/sample/platform/linux/common/osal/osal.h @@ -0,0 +1,77 @@ +/** + ******************************************************************** + * @file osal.h + * @version V2.0.0 + * @date 2019/8/28 + * @brief This is the header file for "osal.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef OSAL_H +#define OSAL_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include "psdk_typedef.h" + +#include "psdk_platform.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode +Osal_TaskCreate(T_PsdkTaskHandle *task, void *(*taskFunc)(void *), const char *name, uint32_t stackSize, void *arg); +T_PsdkReturnCode Osal_TaskDestroy(T_PsdkTaskHandle task); +T_PsdkReturnCode Osal_TaskSleepMs(uint32_t timeMs); + +T_PsdkReturnCode Osal_MutexCreate(T_PsdkMutexHandle *mutex); +T_PsdkReturnCode Osal_MutexDestroy(T_PsdkMutexHandle mutex); +T_PsdkReturnCode Osal_MutexLock(T_PsdkMutexHandle mutex); +T_PsdkReturnCode Osal_MutexUnlock(T_PsdkMutexHandle mutex); + +T_PsdkReturnCode Osal_SemaphoreCreate(T_PsdkSemHandle *semaphore, uint32_t initValue); +T_PsdkReturnCode Osal_SemaphoreDestroy(T_PsdkSemHandle semaphore); +T_PsdkReturnCode Osal_SemaphoreWait(T_PsdkSemHandle semaphore); +T_PsdkReturnCode Osal_SemaphoreTimedWait(T_PsdkSemHandle semaphore, uint32_t waitTime); +T_PsdkReturnCode Osal_SemaphorePost(T_PsdkSemHandle semaphore); + +T_PsdkReturnCode Osal_GetTimeMs(uint32_t *ms); +void *Osal_Malloc(uint32_t size); +void Osal_Free(void *ptr); + +#ifdef __cplusplus +} +#endif + +#endif // OSAL_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.c b/sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.c new file mode 100644 index 0000000..f7714b3 --- /dev/null +++ b/sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.c @@ -0,0 +1,219 @@ +/** + ******************************************************************** + * @file upgrade_platform_opt_linux.c + * @version V2.0.0 + * @date 3/25/20 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "upgrade_platform_opt_linux.h" +#include +#include +#include +#include +#include + +/* Private constants ---------------------------------------------------------*/ +#define PSDK_TEST_CMD_CALL_MAX_LEN (PSDK_FILE_PATH_SIZE_MAX + 256) +#define PSDK_REBOOT_STATE_FILE_NAME "reboot_state" + +/* Private types -------------------------------------------------------------*/ + +/* Private values -------------------------------------------------------------*/ +static FILE *s_upgradeProgramFile = NULL; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkTest_RunSystemCmd(char *systemCmdStr); + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode PsdkUpgradePlatformLinux_RebootSystem(void) +{ + // attention: you need su permission to reboot system + return PsdkTest_RunSystemCmd("reboot -h now"); +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_CleanUpgradeProgramFileStoreArea(void) +{ + char cmdBuffer[PSDK_TEST_CMD_CALL_MAX_LEN]; + + snprintf(cmdBuffer, PSDK_TEST_CMD_CALL_MAX_LEN, "rm -rf %s*", PSDK_TEST_UPGRADE_FILE_DIR); + + return PsdkTest_RunSystemCmd(cmdBuffer); +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_ReplaceOldProgram(void) +{ + char cmdBuffer[PSDK_TEST_CMD_CALL_MAX_LEN]; + + snprintf(cmdBuffer, PSDK_TEST_CMD_CALL_MAX_LEN, "cp -f %s*_V*.*.*.bin %s", PSDK_TEST_UPGRADE_FILE_DIR, + PSDK_TEST_UPGRADE_OLD_FIRMWARE_PATH); + + return PsdkTest_RunSystemCmd(cmdBuffer); +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_SetUpgradeRebootState(const T_PsdkUpgradeEndInfo *upgradeEndInfo) +{ + FILE *rebootStateFile; + size_t res; + T_PsdkReturnCode returnCode; + + rebootStateFile = fopen(PSDK_REBOOT_STATE_FILE_NAME, "w+"); + if (rebootStateFile == NULL) { + PsdkLogger_UserLogError("Create reboot state file error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + res = fwrite((uint8_t *) upgradeEndInfo, 1, sizeof(T_PsdkUpgradeEndInfo), rebootStateFile); + if (res != sizeof(T_PsdkUpgradeEndInfo)) { + PsdkLogger_UserLogError("Write data len is not equal"); + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + goto out; + } + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + +out: + fclose(rebootStateFile); + return returnCode; +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_GetUpgradeRebootState(bool *isUpgradeReboot, + T_PsdkUpgradeEndInfo *upgradeEndInfo) +{ + FILE *rebootStateFile; + size_t res; + + rebootStateFile = fopen(PSDK_REBOOT_STATE_FILE_NAME, "r"); + if (rebootStateFile == NULL) { + *isUpgradeReboot = false; + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } + + res = fread(upgradeEndInfo, 1, sizeof(T_PsdkUpgradeEndInfo), rebootStateFile); + if (res != sizeof(T_PsdkUpgradeEndInfo)) { + PsdkLogger_UserLogError("Read data len is not equal"); + *isUpgradeReboot = false; + goto out; + } + *isUpgradeReboot = true; + +out: + fclose(rebootStateFile); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_CleanUpgradeRebootState(void) +{ + return PsdkTest_RunSystemCmd("rm -f "PSDK_REBOOT_STATE_FILE_NAME); +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_CreateUpgradeProgramFile(const T_PsdkUpgradeFileInfo *fileInfo) +{ + char filePath[PSDK_FILE_PATH_SIZE_MAX]; + + s_upgradeProgramFile = NULL; + snprintf(filePath, PSDK_FILE_PATH_SIZE_MAX, "%s%s", PSDK_TEST_UPGRADE_FILE_DIR, fileInfo->fileName); + s_upgradeProgramFile = fopen(filePath, "w+"); + if (s_upgradeProgramFile == NULL) { + PsdkLogger_UserLogError("Upgrade program file can't create"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode +PsdkUpgradePlatformLinux_WriteUpgradeProgramFile(uint32_t offset, const uint8_t *data, uint16_t dataLen) +{ + size_t writeLen; + + if (s_upgradeProgramFile == NULL) { + PsdkLogger_UserLogError("upgrade program file can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (fseek(s_upgradeProgramFile, offset, SEEK_SET) != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + writeLen = fwrite(data, 1, dataLen, s_upgradeProgramFile); + if (writeLen != dataLen) { + PsdkLogger_UserLogError("Write upgrade program file error, writeLen = %d, dataLen = %d", writeLen); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_ReadUpgradeProgramFile(uint32_t offset, uint16_t readDataLen, uint8_t *data, + uint16_t *realLen) +{ + uint32_t readRtn; + + if (s_upgradeProgramFile == NULL) { + PsdkLogger_UserLogError("upgrade program file can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (fseek(s_upgradeProgramFile, offset, SEEK_SET) != 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + readRtn = fread(data, 1, readDataLen, s_upgradeProgramFile); + if (readRtn == 0 || readRtn > readDataLen) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + *realLen = readRtn; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +T_PsdkReturnCode PsdkUpgradePlatformLinux_CloseUpgradeProgramFile(void) +{ + if (s_upgradeProgramFile == NULL) { + PsdkLogger_UserLogError("upgrade program file can't be NULL"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + fclose(s_upgradeProgramFile); + s_upgradeProgramFile = NULL; + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkTest_RunSystemCmd(char *systemCmdStr) +{ + int status; + + status = system(systemCmdStr); + if (status == -1 || WIFEXITED(status) == false) { + PsdkLogger_UserLogError("Call %s error, status = %d", systemCmdStr, status); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + if (WEXITSTATUS(status) == 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } else { + PsdkLogger_UserLogError("Exit status is = %d", WEXITSTATUS(status)); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } +} +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.h b/sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.h new file mode 100644 index 0000000..ab236af --- /dev/null +++ b/sample/platform/linux/common/upgrade_platform_opt/upgrade_platform_opt_linux.h @@ -0,0 +1,71 @@ +/** + ******************************************************************** + * @file upgrade_platform_opt_linux.h + * @version V2.0.0 + * @date 3/25/20 + * @brief This is the header file for "upgrade_platform_opt_linux.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UPGRADE_PLATFORM_OPT_LINUX_H +#define UPGRADE_PLATFORM_OPT_LINUX_H + +/* Includes ------------------------------------------------------------------*/ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ +#define PSDK_TEST_UPGRADE_OLD_FIRMWARE_PATH "/usr/local/bin/psdk_demo" +#define PSDK_TEST_UPGRADE_FILE_DIR "/upgrade/" + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode PsdkUpgradePlatformLinux_RebootSystem(void); + +T_PsdkReturnCode PsdkUpgradePlatformLinux_CleanUpgradeProgramFileStoreArea(void); +T_PsdkReturnCode PsdkUpgradePlatformLinux_CreateUpgradeProgramFile(const T_PsdkUpgradeFileInfo *fileInfo); +T_PsdkReturnCode PsdkUpgradePlatformLinux_WriteUpgradeProgramFile(uint32_t offset, const uint8_t *data, + uint16_t dataLen); +T_PsdkReturnCode PsdkUpgradePlatformLinux_ReadUpgradeProgramFile(uint32_t offset, uint16_t readDataLen, uint8_t *data, + uint16_t *realLen); +T_PsdkReturnCode PsdkUpgradePlatformLinux_CloseUpgradeProgramFile(void); + +T_PsdkReturnCode PsdkUpgradePlatformLinux_ReplaceOldProgram(void); + +T_PsdkReturnCode PsdkUpgradePlatformLinux_SetUpgradeRebootState(const T_PsdkUpgradeEndInfo *upgradeEndInfo); +T_PsdkReturnCode PsdkUpgradePlatformLinux_GetUpgradeRebootState(bool *isUpgradeReboot, + T_PsdkUpgradeEndInfo *upgradeEndInfo); +T_PsdkReturnCode PsdkUpgradePlatformLinux_CleanUpgradeRebootState(void); + + +#ifdef __cplusplus +} +#endif + +#endif // UPGRADE_PLATFORM_OPT_LINUX_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/manifold2/README.txt b/sample/platform/linux/manifold2/README.txt new file mode 100644 index 0000000..2127821 --- /dev/null +++ b/sample/platform/linux/manifold2/README.txt @@ -0,0 +1,38 @@ +Payload SDK Linux Sample. + +Test Environment: +Hardware: Manifold2-C/G +Serial: USB-to-Serial Controller CP210x +C Compiler: GCC version 5.4.0 20160609 +CMake Version: Cmake version 3.5.1 +IDE: CLion 2020.3.1 + +Communication Serial Configuration: +Baud Rate: 460800 + +Network Port Configuration: +IP Address: Auto Config (Need root permission) +Network Port: Auto Config +NetMask: Auto Config +Gateway: Auto Config + +====== The steps to run the Payload SDK linux sample ====== +Step 1 : modify related device information, such as device name of network or uart, uart baud rate. + +Step 2 : fill in your app info to file with path 'sample/platform/linux/manifold2/application/app_info.h'. +This info can be obtained by logging in to the developer website https://developer.dji.com/payload-sdk. + +Step 3 : build source file, use following cmd: +cd source_code_dir/project +mkdir build +cd build +cmake .. +make + +Step 4 : Manifold should connect to Skyport 2.0/XPort via usb-to-serial controller and network cable, make sure the +serial pins are connected properly. + +Step 5 : use the root permission to execute this program, use following cmd: +sudo ./psdk_demo + +Step 6: open DJI Pilot APP/MSDK APP to use the payload demo functions. \ No newline at end of file diff --git a/sample/platform/linux/manifold2/application/app_info.h b/sample/platform/linux/manifold2/application/app_info.h new file mode 100644 index 0000000..c7a821f --- /dev/null +++ b/sample/platform/linux/manifold2/application/app_info.h @@ -0,0 +1,57 @@ +/** + ******************************************************************** + * @file app_info.h + * @version V2.0.0 + * @date 2019/07/01 + * @brief This is the header file for "app_info.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_INFO_H +#define APP_INFO_H + +/* Includes ------------------------------------------------------------------*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ +// ATTENTION: User must goto developer.dji.com to create your own payload sdk application, get payload sdk application +// information then fill in the application information here. +#define USER_APP_NAME "imager" +#define USER_APP_ID "90210" +#define USER_APP_KEY "2c309ca22fb1e67cc166ccc9dc261f4" +#define USER_DEVELOPER_ACCOUNT "735056338@qq.com" + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif //APP_INFO_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/manifold2/application/main.c b/sample/platform/linux/manifold2/application/main.c new file mode 100644 index 0000000..5f355fa --- /dev/null +++ b/sample/platform/linux/manifold2/application/main.c @@ -0,0 +1,563 @@ +/** + ******************************************************************** + * @file main.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "errno.h" +#include + +#include "psdk_logger.h" +#include "psdk_core.h" +#include "psdk_platform.h" + +#include "osal/osal.h" +#include "utils/util_misc.h" +#include "hal/hal_uart.h" +#include "hal/hal_network.h" +#include "psdk_config.h" +#include "app_info.h" +#include "psdk_aircraft_info.h" +#include "camera_emu/test_payload_cam_emu.h" +#include "data_transmission/test_data_transmission.h" +#include "data_subscription/test_data_subscription.h" +#include "payload_collaboration/test_payload_collaboration.h" +#include "camera_media_emu/test_payload_cam_media.h" +#include "widget/test_widget.h" +#include "gimbal_emu/test_payload_gimbal_emu.h" +#include "psdk_data_channel.h" +#include "data_channel/test_data_channel.h" +#include "power_management/test_power_management.h" +#include "xport/test_xport.h" +#include "monitor/sys_monitor.h" +#include "psdk_product_info.h" +#include "mop_channel/test_mop_channel.h" +#include "upgrade/test_upgrade.h" +#include "upgrade_platform_opt/upgrade_platform_opt_linux.h" +#include + +/* Private constants ---------------------------------------------------------*/ +#define PSDK_LOG_PATH "Logs/psdk_local" +#define PSDK_LOG_INDEX_FILE_NAME "Logs/latest" +#define PSDK_LOG_FOLDER_NAME "Logs" +#define PSDK_LOG_PATH_MAX_SIZE (128) +#define PSDK_LOG_FOLDER_NAME_MAX_SIZE (32) + +/* Private types -------------------------------------------------------------*/ +typedef struct { + pid_t tid;//linux进程号类型定义,实际就是int + char name[16]; + float pcpu;// +} T_ThreadAttribute; + +/* Private functions declaration ---------------------------------------------*/ +static T_PsdkReturnCode PsdkUser_FillInUserInfo(T_PsdkUserInfo *userInfo);//填写用户信息 +static T_PsdkReturnCode PsdkUser_Console(const uint8_t *data, uint16_t dataLen);//位于结构体中的回调函数:将日志信息打印到控制台 +static T_PsdkReturnCode PsdkUser_LocalWrite(const uint8_t *data, uint16_t dataLen);//位于结构体中的回调函数:将日志信息写入文件 +static T_PsdkReturnCode PsdkUser_FileSystemInit(const char *path);//会打开日志文件,将日志文件指针返回到s_psdkLogFile +static void *PsdkUser_MonitorTask(void *argument); + +/* Exported functions definition ---------------------------------------------*/ +static FILE *s_psdkLogFile;//函数PsdkUser_FileSystemInit中打开的日志文件指针 +static FILE *s_psdkLogFileCnt;//函数PsdkUser_FileSystemInit中打开的一个文件,此文件用于记录日志文件个数 +static pthread_t s_monitorThread = 0;//用于生成线程ID + +/* Private functions definition-----------------------------------------------*/ +static T_PsdkReturnCode PsdkUser_FillInUserInfo(T_PsdkUserInfo *userInfo) +{ + //先清空结构体userInfo中的数据 + memset(userInfo->appName, 0, sizeof(userInfo->appName)); + memset(userInfo->appId, 0, sizeof(userInfo->appId)); + memset(userInfo->appKey, 0, sizeof(userInfo->appKey)); + memset(userInfo->developerAccount, 0, sizeof(userInfo->developerAccount)); + + //判断输入的用户信息是否合法 + if (strlen(USER_APP_NAME) >= sizeof(userInfo->appName) || + strlen(USER_APP_ID) > sizeof(userInfo->appId) || + strlen(USER_APP_KEY) > sizeof(userInfo->appKey) || + strlen(USER_DEVELOPER_ACCOUNT) >= sizeof(userInfo->developerAccount)) { + PsdkLogger_UserLogError("Length of user information string is beyond limit. Please check."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + if (!strcmp(USER_APP_NAME, "your_app_name") || + !strcmp(USER_APP_ID, "your_app_id") || + !strcmp(USER_APP_KEY, "your_app_key") || + !strcmp(USER_DEVELOPER_ACCOUNT, "your_developer_account")) { + PsdkLogger_UserLogError("Please fill in correct user information to psdk_app_info.h file."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + //如果输入的用户信息合法,就写入到结构体userInfo中。但是用两个函数(strncpy/memcpy)的目的是啥????????????????????????????? + strncpy(userInfo->appName, USER_APP_NAME, sizeof(userInfo->appName) - 1); + memcpy(userInfo->appId, USER_APP_ID, USER_UTIL_MIN(sizeof(userInfo->appId), strlen(USER_APP_ID))); + memcpy(userInfo->appKey, USER_APP_KEY, USER_UTIL_MIN(sizeof(userInfo->appKey), strlen(USER_APP_KEY))); + strncpy(userInfo->developerAccount, USER_DEVELOPER_ACCOUNT, sizeof(userInfo->developerAccount) - 1); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkUser_Console(const uint8_t *data, uint16_t dataLen) +{ + USER_UTIL_UNUSED(dataLen);//?????????????????????????????????????????????????????????? + + /* + * Warning: printf() is a blocking interface. If print speed is too low, PSDK will be blocked and many abnormal + * situations occur, such as initialization failure and payload disconnection. Users can raise corresponding + * console level to INFO or even higher to solve this problem. + */ + printf("%s", data); + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +static T_PsdkReturnCode PsdkUser_LocalWrite(const uint8_t *data, uint16_t dataLen) +{ + int32_t realLen; + + if (s_psdkLogFile == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + realLen = fwrite(data, 1, dataLen, s_psdkLogFile); + fflush(s_psdkLogFile);//清空缓冲区 + if (realLen == dataLen) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } else { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } +} + +static T_PsdkReturnCode PsdkUser_FileSystemInit(const char *path) +{ + T_PsdkReturnCode psdkStat = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + char filePath[PSDK_LOG_PATH_MAX_SIZE]; + char folderName[PSDK_LOG_FOLDER_NAME_MAX_SIZE]; + time_t currentTime = time(NULL);//time为内联函数 + struct tm *localTime = localtime(¤tTime);//localtime为内联函数 + uint16_t logFileIndex = 0;//存储日志文件个数 + uint16_t currentLogFileIndex = 0; + uint8_t ret = 0; + + if (localTime == NULL) { + printf("Get local time error.\r\n"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + //创建日志文件夹 + if (access(PSDK_LOG_FOLDER_NAME, F_OK) != 0) { + printf("Log file is not existed, need create new.\r\n"); + sprintf(folderName, "mkdir %s", PSDK_LOG_FOLDER_NAME); + ret = system(folderName); + if (ret != 0) { + printf("Create new log folder error, ret:%d.\r\n", ret); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + } + + //查询日志文件个数,并将结果写入到变量currentLogFileIndex中 + s_psdkLogFileCnt = fopen(PSDK_LOG_INDEX_FILE_NAME, "rb+"); + if (s_psdkLogFileCnt == NULL) {//如果没有就创建日志文件 + s_psdkLogFileCnt = fopen(PSDK_LOG_INDEX_FILE_NAME, "wb+"); + if (s_psdkLogFileCnt == NULL) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + } else { + ret = fseek(s_psdkLogFileCnt, 0, SEEK_SET);//文件指针归零 + if (ret != 0) { + printf("Seek log count file error, ret: %d, errno: %d.\r\n", ret, errno); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + ret = fread((uint16_t *) &logFileIndex, 1, sizeof(uint16_t), s_psdkLogFileCnt);//读取日志文件中的数据 + if (ret != sizeof(uint16_t)) { + printf("Read log file index error.\r\n"); + } + } + + printf("Get current log index: %d\r\n", logFileIndex); + currentLogFileIndex = logFileIndex; + logFileIndex++; + + ret = fseek(s_psdkLogFileCnt, 0, SEEK_SET);//文件指针再次归零 + if (ret != 0) { + printf("Seek log file error, ret: %d, errno: %d.\r\n", ret, errno); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + ret = fwrite((uint16_t *) &logFileIndex, 1, sizeof(uint16_t), s_psdkLogFileCnt);//更新日志文件个数 + if (ret != sizeof(uint16_t)) { + printf("Write log file index error.\r\n"); + fclose(s_psdkLogFileCnt); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + fclose(s_psdkLogFileCnt); + + //创建日志文件 + sprintf(filePath, "%s_%04d_%04d%02d%02d_%02d-%02d-%02d.log", path, currentLogFileIndex, + localTime->tm_year + 1900, localTime->tm_mon + 1, localTime->tm_mday, + localTime->tm_hour, localTime->tm_min, localTime->tm_sec); + + s_psdkLogFile = fopen(filePath, "wb+"); + if (s_psdkLogFile == NULL) { + PsdkLogger_UserLogWarn("Open filepath time error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return psdkStat; +} + +static void PsdkUser_NormalExitHandler(int signalNum) +{ + USER_UTIL_UNUSED(signalNum); + exit(0); +} + +#pragma GCC diagnostic push//??????????????????????????????????????????????????????????? +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +static void *PsdkUser_MonitorTask(void *argument) +{ + unsigned int i = 0; + unsigned int threadCount = 0;//本进程线程个数 + pid_t *tidList = NULL;//指线程id + T_ThreadAttribute *threadAttribute = NULL; + + USER_UTIL_UNUSED(argument);//??????????????????????????????????????????????????????????? + + while (1) { + threadCount = Monitor_GetThreadCountOfProcess(getpid()); + + //为tidList分配内存 + tidList = PsdkOsal_Malloc(threadCount * sizeof(pid_t)); + if (tidList == NULL) { + PsdkLogger_UserLogError("malloc fail."); + goto delay; + } + Monitor_GetTidListOfProcess(getpid(), tidList, threadCount); + + //为threadAttribute分配内存 + threadAttribute = PsdkOsal_Malloc(threadCount * sizeof(T_ThreadAttribute)); + if (threadAttribute == NULL) { + PsdkLogger_UserLogError("malloc fail."); + goto freeTidList; + } + + //向threadAttribute中填写线程id号 + for (i = 0; i < threadCount; ++i) { + threadAttribute[i].tid = tidList[i]; + } + + //向threadAttribute中填写pcpu和线程name + PsdkLogger_UserLogDebug("thread pcpu:");//????????????????????????????????????????????????????????????????????????????????? + PsdkLogger_UserLogDebug("tid\tname\tpcpu"); + for (i = 0; i < threadCount; ++i) { + threadAttribute[i].pcpu = Monitor_GetPcpuOfThread(getpid(), tidList[i]); + Monitor_GetNameOfThread(getpid(), tidList[i], threadAttribute[i].name, sizeof(threadAttribute[i].name)); + PsdkLogger_UserLogDebug("%d\t%15s\t%f %%.", threadAttribute[i].tid, threadAttribute[i].name, + threadAttribute[i].pcpu); + } + + PsdkLogger_UserLogDebug("heap used: %d B.", Monitor_GetHeapUsed(getpid())); + PsdkLogger_UserLogDebug("stack used: %d B.", Monitor_GetStackUsed(getpid())); + + PsdkOsal_Free(threadAttribute); +freeTidList: + PsdkOsal_Free(tidList); + +delay: + sleep(10); + } +} + +#pragma GCC diagnostic pop + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wreturn-type" + +int main(void) +{ + T_PsdkUserInfo userInfo; + const T_PsdkDataChannelBandwidthProportionOfHighspeedChannel bandwidthProportionOfHighspeedChannel = + {10, 60, 30};//dataStream,videoStream,downloadStream + T_PsdkLoggerConsole printConsole = { + .consoleLevel = PSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO, + .func = PsdkUser_Console, + }; + + T_PsdkLoggerConsole localRecordConsole = { + .consoleLevel = PSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO, + .func = PsdkUser_LocalWrite, + }; + + T_PsdkHalUartHandler halUartHandler = { + .UartInit = Hal_UartInit, + .UartReadData = Hal_UartReadData, + .UartWriteData = Hal_UartSendData, + }; + + T_PsdkHalNetWorkHandler halNetWorkHandler = { + .NetWorkConfig = HalNetWork_Config, + }; + + T_PsdkOsalHandler osalHandler = { + .Malloc = Osal_Malloc, + .Free = Osal_Free, + .TaskCreate = Osal_TaskCreate, + .TaskDestroy = Osal_TaskDestroy, + .TaskSleepMs = Osal_TaskSleepMs, + .MutexCreate = Osal_MutexCreate, + .MutexDestroy = Osal_MutexDestroy, + .MutexLock = Osal_MutexLock, + .MutexUnlock = Osal_MutexUnlock, + .SemaphoreCreate = Osal_SemaphoreCreate, + .SemaphoreDestroy = Osal_SemaphoreDestroy, + .SemaphoreWait = Osal_SemaphoreWait, + .SemaphorePost = Osal_SemaphorePost, + .SemaphoreTimedWait = Osal_SemaphoreTimedWait, + .GetTimeMs = Osal_GetTimeMs, + }; + + T_PsdkAircraftInfoBaseInfo aircraftBaseInfo = {0}; + + //https://developer.dji.com/cn/document/5c34a334-bde6-471b-88c6-f9f6f8f287a6 + //通过注册Hal 层串口设备的函数,负载设备控制程序能够通过开发平台的串口与无人机通信,实现负载设备控制程序在不同硬件平台上的移植。 + if (PsdkPlatform_RegHalUartHandler(&halUartHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk register hal uart handler error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //https://developer.dji.com/cn/document/5c34a334-bde6-471b-88c6-f9f6f8f287a6 + //通过注册Hal 层网口函数,负载设备控制程序能够通过网口与无人机通信。 + if (PsdkPlatform_RegHalNetworkHandler(&halNetWorkHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk register hal network handler error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //https://developer.dji.com/cn/document/5c34a334-bde6-471b-88c6-f9f6f8f287a6 + //通过注册Osal 层的函数,负载设备控制程序能够访问不同操作系统的内核和资源,实现负载设备控制程序在不同操作系统上的移植。 + if (PsdkPlatform_RegOsalHandler(&osalHandler) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk register osal handler error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //logger打印到控制台 + if (PsdkLogger_AddConsole(&printConsole) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk add console print error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //logger写入到文件1:会打开日志文件,将日志文件指针返回到s_psdkLogFile + if (PsdkUser_FileSystemInit(PSDK_LOG_PATH) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk file system init error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + //logger写入到文件2:注册写入函数到psdk中 + if (PsdkLogger_AddConsole(&localRecordConsole) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk add console record error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //填写用户信息到变量userInfo中 + if (PsdkUser_FillInUserInfo(&userInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + printf("psdk fill in user info error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //初始化psdk,此函数的调用时机有要求 + if (PsdkCore_Init(&userInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk instance init error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //设置负载设备的别称 + if (PsdkProductInfo_SetAlias("PSDK_APPALIAS") != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set product alias error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //获取飞机信息 + if (PsdkAircraftInfo_GetBaseInfo(&aircraftBaseInfo) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("get aircraft information error."); + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + //通过宏来判断 是否初始化各种设备和功能;开始----------------------------------------------------------------------------------------------------------------------------------------- + + PsdkLogger_UserLogInfo("通过宏来判断 是否初始化各种设备和功能;开始--------------------------------------------------------------------------------------------------------------------------"); + + + //如果要申请高功率,需要在执行PsdkTest_PowerManagementInit函数前,先执行PsdkTest_RegApplyHighPowerHandler函数 +#ifdef PSDK_USING_POWER_MANAGEMENT + PsdkLogger_UserLogInfo("使用电源模块--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_PowerManagementInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("power management init error"); + } +#endif + + //相机相关 +#ifdef PSDK_USING_CAMERA_EMU + PsdkLogger_UserLogInfo("使用PSDK_USING_CAMERA_EMU--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_CameraInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk camera init error"); + } +#endif + +#ifdef PSDK_USING_CAMERA_MEDIA_EMU +#if PSDK_ARCH_SYS_LINUX + PsdkLogger_UserLogInfo("使用PSDK_USING_CAMERA_MEDIA_EMU--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_CameraMediaInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk camera media init error"); + } +#endif +#endif + + //数据传输:Should call this function before sending data to mobile end/onboard computer or receiving data. +#ifdef PSDK_USING_DATA_TRANSMISSION + PsdkLogger_UserLogInfo("使用数据传输模块--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_DataTransmissionInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {//其中的用户自定义任务UserDataTransmission_Task,有点不懂机制???????????????????????????????????????????????? + PsdkLogger_UserLogError("psdk data transmission init error"); + } +#endif + + //数据通道,带宽设置:3类数据通道:dataStream,videoStream,downloadStream +#ifdef PSDK_USING_DATA_CHANNEL + PsdkLogger_UserLogInfo("设置数据通道带宽--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_DataChannelSetBandwidthProportionForHighspeedChannel( + bandwidthProportionOfHighspeedChannel) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("set bandwidth distribution for high-speed channel error"); + } +#endif + + //消息订阅 +#ifdef PSDK_USING_DATA_SUBSCRIPTION + PsdkLogger_UserLogInfo("使用消息订阅--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_DataSubscriptionInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk data subscription init error"); + } +#endif + + //负载协同 +#ifdef PSDK_USING_PAYLOAD_COLLABORATION + PsdkLogger_UserLogInfo("使用COLLABORATION--------------------------------------------------------------------------------------------------------------------------"); + if (((aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M200_V2 || + aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210_V2 || + aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M210RTK_V2) && + aircraftBaseInfo.payloadMountPosition == PSDK_AIRCRAFT_INFO_PAYLOAD_MOUNT_POSITION_NO2) || + aircraftBaseInfo.aircraftType == PSDK_AIRCRAFT_INFO_TYPE_M300_RTK) { + if (PsdkTest_PayloadCollaborationInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk payload collaboration init error"); + } + } +#endif + + //使用UI +#ifdef PSDK_USING_WIDGET + PsdkLogger_UserLogInfo("使用WIDGET--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_WidgetInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk widget init error"); + } +#endif + + //云台相关1、判断是否为天空端(SKYPORT_V2) +#ifdef PSDK_USING_GIMBAL_EMU + PsdkLogger_UserLogInfo("判断是否为天空端(SKYPORT_V2)--------------------------------------------------------------------------------------------------------------------------"); + if (aircraftBaseInfo.psdkAdapterType == PSDK_AIRCRAFT_INFO_PSDK_ADAPTER_TYPE_SKYPORT_V2) { + if (PsdkTest_GimbalInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk gimbal init error"); + } + } +#endif + + //云台相关2、判断是否为xport +#ifdef PSDK_USING_XPORT + PsdkLogger_UserLogDebug("使用xport--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"); + if (aircraftBaseInfo.psdkAdapterType == PSDK_AIRCRAFT_INFO_PSDK_ADAPTER_TYPE_XPORT) { + if (PsdkTest_XPortInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk XPort init error"); + } + } +#endif + +#ifdef PSDK_USING_UPGRADE + PsdkLogger_UserLogInfo("使用PSDK_USING_UPGRADE--------------------------------------------------------------------------------------------------------------------------"); + T_PsdkTestUpgradePlatformOpt linuxUpgradePlatformOpt = { + .rebootSystem = PsdkUpgradePlatformLinux_RebootSystem, + .cleanUpgradeProgramFileStoreArea = PsdkUpgradePlatformLinux_CleanUpgradeProgramFileStoreArea, + .createUpgradeProgramFile = PsdkUpgradePlatformLinux_CreateUpgradeProgramFile, + .writeUpgradeProgramFile = PsdkUpgradePlatformLinux_WriteUpgradeProgramFile, + .readUpgradeProgramFile = PsdkUpgradePlatformLinux_ReadUpgradeProgramFile, + .closeUpgradeProgramFile = PsdkUpgradePlatformLinux_CloseUpgradeProgramFile, + .replaceOldProgram = PsdkUpgradePlatformLinux_ReplaceOldProgram, + .setUpgradeRebootState = PsdkUpgradePlatformLinux_SetUpgradeRebootState, + .getUpgradeRebootState = PsdkUpgradePlatformLinux_GetUpgradeRebootState, + .cleanUpgradeRebootState = PsdkUpgradePlatformLinux_CleanUpgradeRebootState, + }; + if (PsdkTest_UpgradeInit(&linuxUpgradePlatformOpt) != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk upgrade init error"); + } +#endif + +#ifdef PSDK_USING_MOP_CHANNEL + PsdkLogger_UserLogInfo("使用PSDK_USING_MOP_CHANNEL--------------------------------------------------------------------------------------------------------------------------"); + if (PsdkTest_MopChannelInit() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk mop channel init error"); + } +#endif + + //通过宏来判断 是否初始化各种设备和功能;结束--------------------------------------------------------------------------------------------- + PsdkLogger_UserLogInfo("通过宏来判断 是否初始化各种设备和功能;结束--------------------------------------------------------------------------------------------------------------------------"); + + + //创建并执行一个监控线程 + if (pthread_create(&s_monitorThread, NULL, PsdkUser_MonitorTask, NULL) != 0) { + PsdkLogger_UserLogError("create monitor task fail."); + } + + if (pthread_setname_np(s_monitorThread, "monitor task") != 0) { + PsdkLogger_UserLogError("set name for monitor task fail."); + } + + //启动负载设备控制程序 ,如果没有这些代码 → 移动端的APP 将无法正常控制负载设备; + if (PsdkCore_ApplicationStart() != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("psdk application start error"); + } + + signal(SIGTERM, PsdkUser_NormalExitHandler); + + PsdkLogger_UserLogInfo("进入无限循环--------------------------------------------------------------------------------------------------------------------------"); + while (1) { + sleep(1); + } +} + +#pragma GCC diagnostic pop + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ \ No newline at end of file diff --git a/sample/platform/linux/manifold2/application/psdk_config.h b/sample/platform/linux/manifold2/application/psdk_config.h new file mode 100644 index 0000000..9ff6e55 --- /dev/null +++ b/sample/platform/linux/manifold2/application/psdk_config.h @@ -0,0 +1,75 @@ +/** + ******************************************************************** + * @file psdk_config.h + * @version V2.0.0 + * @date 2019/9/11 + * @brief This is the header file for "psdk_config.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PSDK_CONFIG_H +#define PSDK_CONFIG_H + +/* Includes ------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ +#define PSDK_USING_POWER_MANAGEMENT + +#define PSDK_USING_CAMERA_EMU + +#define PSDK_USING_CAMERA_MEDIA_EMU//相机类负载设备的下载回放功能 + +#define PSDK_USING_DATA_TRANSMISSION + +#define PSDK_USING_DATA_CHANNEL + +#define PSDK_USING_DATA_SUBSCRIPTION + +#define PSDK_USING_PAYLOAD_COLLABORATION//负载协同 + +#define PSDK_USING_WIDGET + +#define PSDK_USING_GIMBAL_EMU + +#define PSDK_USING_XPORT + +#define PSDK_USING_UPGRADE + +/*!< Attention: This function needs to be used together with OSDK/MSDK mop sample. + * */ +//#define PSDK_USING_MOP_CHANNEL + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif // PSDK_CONFIG_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/manifold2/hal/hal_network.c b/sample/platform/linux/manifold2/hal/hal_network.c new file mode 100644 index 0000000..66df06d --- /dev/null +++ b/sample/platform/linux/manifold2/hal/hal_network.c @@ -0,0 +1,90 @@ +/** + ******************************************************************** + * @file hal_network.c + * @version V2.0.0 + * @date 3/27/20 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "string.h" +#include "stdlib.h" +#include "stdio.h" +#include "hal_network.h" +#include "psdk_logger.h" + +/* Private constants ---------------------------------------------------------*/ +#define LINUX_NETWORK_DEV "eth0"//enx00e04c360a7d +#define LINUX_CMD_STR_MAX_SIZE (128) + +/* Private types -------------------------------------------------------------*/ + +/* Private values -------------------------------------------------------------*/ + +/* Private functions declaration ---------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode HalNetWork_Config(const char *ipAddr, const char *netMask) +{ + int32_t ret; + char cmdStr[LINUX_CMD_STR_MAX_SIZE]; + + if (ipAddr == NULL || netMask == NULL) { + PsdkLogger_UserLogError("hal network config param error"); + return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; + } + + //Attention: need root permission to config ip addr and netmask. + memset(cmdStr, 0, sizeof(cmdStr)); + + snprintf(cmdStr, sizeof(cmdStr), "ifconfig | grep %s", LINUX_NETWORK_DEV); + ret = system(cmdStr); + if (ret != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Can't find the network device. " + "Probably the name of network device is not match or device is not properly initialized. " + "Please check the name or status of network device. "); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + snprintf(cmdStr, sizeof(cmdStr), "ifconfig %s up", LINUX_NETWORK_DEV); + ret = system(cmdStr); + if (ret != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Can't open the network. " + "Probably the program not execute with root permission. " + "Please use the root permission to execute the program. "); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + snprintf(cmdStr, sizeof(cmdStr), "ifconfig %s %s netmask %s", LINUX_NETWORK_DEV, ipAddr, netMask); + ret = system(cmdStr); + if (ret != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) { + PsdkLogger_UserLogError("Can't config the ip address of network. " + "Probably the program not execute with root permission. " + "Please use the root permission to execute the program. "); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; +} + +/* Private functions definition-----------------------------------------------*/ + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/platform/linux/manifold2/hal/hal_network.h b/sample/platform/linux/manifold2/hal/hal_network.h new file mode 100644 index 0000000..9e6ed12 --- /dev/null +++ b/sample/platform/linux/manifold2/hal/hal_network.h @@ -0,0 +1,52 @@ +/** + ******************************************************************** + * @file hal_network.h + * @version V2.0.0 + * @date 3/27/20 + * @brief This is the header file for "hal_network.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HAL_NETWORK_H +#define HAL_NETWORK_H + +/* Includes ------------------------------------------------------------------*/ +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode HalNetWork_Config(const char *ipAddr, const char *netMask); + + +#ifdef __cplusplus +} +#endif + +#endif // HAL_NETWORK_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/manifold2/hal/hal_uart.c b/sample/platform/linux/manifold2/hal/hal_uart.c new file mode 100644 index 0000000..eba73e6 --- /dev/null +++ b/sample/platform/linux/manifold2/hal/hal_uart.c @@ -0,0 +1,139 @@ +/** + ******************************************************************** + * @file psdk_hal.c + * @version V2.0.0 + * @date 2019/07/01 + * @brief + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Includes ------------------------------------------------------------------*/ +#include "hal_uart.h" + +/* Private constants ---------------------------------------------------------*/ +#define LINUX_UART_DEV "/dev/ttyUSB0"///dev/dji_serial_port + +/* Private types -------------------------------------------------------------*/ +static int s_psdkUartFd = -1; + +/* Private functions declaration ---------------------------------------------*/ + +/* Exported functions definition ---------------------------------------------*/ +T_PsdkReturnCode Hal_UartInit(void) +{ + struct termios options; + struct flock lock; + T_PsdkReturnCode returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + + s_psdkUartFd = open(LINUX_UART_DEV, O_RDWR | O_NOCTTY | O_NDELAY); + if (s_psdkUartFd == -1) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + // Forbid multiple psdk programs to access the serial port + lock.l_type = F_WRLCK; + lock.l_pid = getpid(); + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 0; + + if (fcntl(s_psdkUartFd, F_GETLK, &lock) < 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + if (lock.l_type != F_UNLCK) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + lock.l_type = F_WRLCK; + lock.l_pid = getpid(); + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 0; + if (fcntl(s_psdkUartFd, F_SETLKW, &lock) < 0) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + if (tcgetattr(s_psdkUartFd, &options) != 0) { + close(s_psdkUartFd); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + cfsetispeed(&options, B460800); + cfsetospeed(&options, B460800); + + options.c_cflag |= CLOCAL; + options.c_cflag |= CREAD; + options.c_cflag &= ~CRTSCTS; + options.c_cflag &= ~CSIZE; + options.c_cflag |= CS8; + options.c_cflag &= ~PARENB; + options.c_iflag &= ~INPCK; + options.c_cflag &= ~CSTOPB; + options.c_oflag &= ~OPOST; + options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); + options.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + options.c_cc[VTIME] = 0; + options.c_cc[VMIN] = 0; + + tcflush(s_psdkUartFd, TCIFLUSH); + + if (tcsetattr(s_psdkUartFd, TCSANOW, &options) != 0) { + close(s_psdkUartFd); + return PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return returnCode; +} + +T_PsdkReturnCode Hal_UartSendData(const uint8_t *pBuf, uint16_t bufLen) +{ + int32_t realLen; + + if (s_psdkUartFd == -1) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } + + realLen = write(s_psdkUartFd, pBuf, bufLen); + if (realLen == bufLen) { + return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } else { + return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN; + } +} + +T_PsdkReturnCode Hal_UartReadData(uint8_t *pBuf, uint16_t bufLen, uint16_t *realBufLen) +{ + int result; + T_PsdkReturnCode returnCode; + + result = read(s_psdkUartFd, pBuf, bufLen); + if (result >= 0) { + *realBufLen = result; + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS; + } else { + *realBufLen = 0; + returnCode = PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR; + } + + return returnCode; +} + +/* Private functions definition-----------------------------------------------*/ + +/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/ diff --git a/sample/platform/linux/manifold2/hal/hal_uart.h b/sample/platform/linux/manifold2/hal/hal_uart.h new file mode 100644 index 0000000..3efc7b0 --- /dev/null +++ b/sample/platform/linux/manifold2/hal/hal_uart.h @@ -0,0 +1,62 @@ +/** + ******************************************************************** + * @file hal.h + * @version V2.0.0 + * @date 2019/8/28 + * @brief This is the header file for "hal.c", defining the structure and + * (exported) function prototypes. + * + * @copyright (c) 2018-2019 DJI. All rights reserved. + * + * All information contained herein is, and remains, the property of DJI. + * The intellectual and technical concepts contained herein are proprietary + * to DJI and may be covered by U.S. and foreign patents, patents in process, + * and protected by trade secret or copyright law. Dissemination of this + * information, including but not limited to data and other proprietary + * material(s) incorporated within the information, in any form, is strictly + * prohibited without the express written consent of DJI. + * + * If you receive this source code without DJI’s authorization, you may not + * further disseminate the information, and you must immediately remove the + * source code and notify DJI of its removal. DJI reserves the right to pursue + * legal actions against you for any loss(es) or damage(s) caused by your + * failure to do so. + * + ********************************************************************* + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HAL_H +#define HAL_H + +/* Includes ------------------------------------------------------------------*/ +#include "stdint.h" +#include +#include +#include +#include +#include +#include + +#include "psdk_platform.h" +#include "psdk_typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +T_PsdkReturnCode Hal_UartInit(void); +T_PsdkReturnCode Hal_UartSendData(const uint8_t *pBuf, uint16_t bufLen); +T_PsdkReturnCode Hal_UartReadData(uint8_t *pBuf, uint16_t bufLen, uint16_t *realBufLen); + +#ifdef __cplusplus +} +#endif + +#endif // HAL_H +/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/ diff --git a/sample/platform/linux/manifold2/project/CMakeLists.txt b/sample/platform/linux/manifold2/project/CMakeLists.txt new file mode 100644 index 0000000..dfa8629 --- /dev/null +++ b/sample/platform/linux/manifold2/project/CMakeLists.txt @@ -0,0 +1,91 @@ +cmake_minimum_required(VERSION 2.8) +project(psdk_demo C) + +### Set toolchain flags +set(CMAKE_C_FLAGS "-D_REENTRANT -std=gnu99") +set(CMAKE_EXE_LINKER_FLAGS "-pthread -lpthread") + +set(CMAKE_C_COMPILER "gcc") +set(CMAKE_CXX_COMPILER "g++") + +set(PSDK_ARCH_SYS linux) + + + +include_directories(..) +include_directories(../../common) +include_directories(../../../../api_sample) +include_directories(${CMAKE_CURRENT_LIST_DIR}/../../../../../psdk_lib/api_headers) + +#include_directories(/home/iris-xport/projects/ellipse_n_sdk/SoftwareDevelopment/sbgECom/common/) +#include_directories(/home/iris-xport/projects/ellipse_n_sdk/SoftwareDevelopment/sbgECom/src) +#include_directories(/home/iris-xport/projects/ximea) + +include_directories(/home/rock/ffmpeg_build/include) +#include_directories(/usr/local/include) +#include_directories(/home/rock/ffmpeg_build) + +## Srcs +file(GLOB_RECURSE APP_SRC ../../manifold2/application/*.c + ../../manifold2/hal/*.c) +file(GLOB_RECURSE COMMON_SRC ../../common/*.c) +file(GLOB_RECURSE SAMPLE_SRC ../../../../api_sample/*.c) + +## "uname -m" to auto distinguish Manifold2-G or Manifold2-C +execute_process(COMMAND uname -m + OUTPUT_VARIABLE DEVICE_SYSTEM_ID) + +if (NOT PSDK_ARCH_SYS) + message(FATAL_ERROR + "to use psdk inc src cmake , + you must set value to indicate your system arch! + This value can be linux, baremetal or rtos_xxxx (xxxx is the specific name of rtos." + ) +endif () + +string(TOUPPER ${PSDK_ARCH_SYS} PSDK_ARCH_SYS_DEF) +add_definitions(-DPSDK_ARCH_SYS_${PSDK_ARCH_SYS_DEF}=1) +add_definitions(-D_GNU_SOURCE) + +## Include directories and library +if (DEVICE_SYSTEM_ID MATCHES x86_64) + link_directories(${CMAKE_CURRENT_LIST_DIR}/../../../../../psdk_lib/lib/x86_64-linux-gnu-gcc) + link_libraries(${CMAKE_CURRENT_LIST_DIR}/../../../../../psdk_lib/lib/x86_64-linux-gnu-gcc/libpayloadsdk.a) + + link_libraries(/home/rock/ffmpeg_build/lib) +# link_libraries(/usr/local/lib) + + #link_libraries(/home/iris-xport/projects/ellipse_n_sdk/SoftwareDevelopment/sbgECom/bin/libsbgECom.a) + # link_libraries(/home/iris-xport/projects/ximea/libximea.a) + # link_libraries(/home/iris-xport/projects/ximea/libximeaWrapper.a) +elseif (DEVICE_SYSTEM_ID MATCHES aarch64) + link_directories(${CMAKE_CURRENT_LIST_DIR}/../../../../../psdk_lib/lib/aarch64-linux-gnu-gcc) + link_libraries(${CMAKE_CURRENT_LIST_DIR}/../../../../../psdk_lib/lib/aarch64-linux-gnu-gcc/libpayloadsdk.a) + + link_directories(/home/rock/ffmpeg_build/lib) + #link_libraries(/home/rock/ffmpeg_build/lib) +endif () + +## Outputs +add_executable(${CMAKE_PROJECT_NAME} + ${APP_SRC} + ${COMMON_SRC} + ${SAMPLE_SRC} + ) + +#target_link_libraries(${CMAKE_PROJECT_NAME} m) + +target_link_libraries(${CMAKE_PROJECT_NAME} + avformat + avfilter + avcodec + swscale + avutil + swresample + avdevice + avutil + postproc + z + m + pthread + ) \ No newline at end of file diff --git a/sample/platform/linux/manifold2/project/build.sh b/sample/platform/linux/manifold2/project/build.sh new file mode 100644 index 0000000..e6c9805 --- /dev/null +++ b/sample/platform/linux/manifold2/project/build.sh @@ -0,0 +1,37 @@ +#test -e build/ || mkdir build +#echo "mkdir build/\n" + +echo "\nCompile ximea record program " + +cd /home/iris-xport/projects/ximea + +g++ -c ximea.cpp -lstdc++ -lm3api +ar -r libximea.a ximea.o + +g++ -c ximeaWrapper.cpp -lstdc++ +ar -r libximeaWrapper.a ximea.o ximeaWrapper.o + + + + +cd /home/iris-xport/projects/Payload_SDK_V2.2.1 +echo "\nThe current dirctory is " +pwd + +cd sample/platform/linux/manifold2/project + +if [ ! -e build ]; then + mkdir build + echo "\ndirctory: build do not exit! making dirctory: build\n" +else + echo "\ndirctory: build exit!\n" +fi + +cd build/ + +echo "\n执行cmake命令-------------------------------------------------------------\n" +cmake .. + +echo "\n执行make命令--------------------------------------------------------------\n" + +make diff --git a/sample/platform/linux/manifold2/project/cmake-build-debug/psdk_demo.cbp b/sample/platform/linux/manifold2/project/cmake-build-debug/psdk_demo.cbp new file mode 100644 index 0000000..bbfc0ff --- /dev/null +++ b/sample/platform/linux/manifold2/project/cmake-build-debug/psdk_demo.cbp @@ -0,0 +1,292 @@ + + + + + + diff --git a/sample/platform/linux/manifold2/project/hahahah/psdk_demo.cbp b/sample/platform/linux/manifold2/project/hahahah/psdk_demo.cbp new file mode 100644 index 0000000..2fc0db2 --- /dev/null +++ b/sample/platform/linux/manifold2/project/hahahah/psdk_demo.cbp @@ -0,0 +1,292 @@ + + + + + +