-
华为算法精英实战营第十期-用户位置与站址同步估计问题,最终的用户也是200个吗
-
rk3568使用uart进行串口通信代码实现,napi代码如下#include "napi/native_api.h"#include "platform_if.h"#include "uart_if.h"#include "hdf_base.h"#include <cstdint>#include "hdf_types.h"#include <cstdlib>#include <functional>#include <hilog/log.h>#include <js_native_api_types.h>static napi_value Add(napi_env env, napi_callback_info info){ size_t argc = 2; napi_value args[2] = {nullptr}; napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env, args[0], &valuetype0); napi_valuetype valuetype1; napi_typeof(env, args[1], &valuetype1); double value0; napi_get_value_double(env, args[0], &value0); double value1; napi_get_value_double(env, args[1], &value1); napi_value sum; napi_create_double(env, value0 + value1, &sum); return sum;}unsigned long open(char port[50]) { return open(port); }static napi_value UartOpen(napi_env env, napi_callback_info info){ size_t requireArgc = 1; size_t argc = 1; napi_value args[1] = {nullptr}; napi_get_cb_info(env, info,&argc,args ,nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env,args[0], &valuetype0); size_t size; char port[50] ; napi_get_value_string_utf8(env, args[0], port, 50, &size); size_t ret; ret = open(port); if (ret == NULL) { HDF_FAILURE; } }unsigned long setAttribute(char port, char attribute) { setAttribute(port, attribute); }static napi_value UartSetAttribute(napi_env env , napi_callback_info info){ size_t requireArgc = 2; size_t argc = 2; napi_value args[2] = {nullptr}; napi_get_cb_info(env, info,&argc,args ,nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env,args[0], &valuetype0); napi_valuetype valuetype1; napi_typeof(env,args[0], &valuetype1); char port{50}; size_t size; size_t ret; struct UartAttribute attribute; attribute.dataBits = UART_ATTR_DATABIT_8; attribute.parity = UART_ATTR_PARITY_NONE; attribute.stopBits = UART_ATTR_STOPBIT_1; // UART传输数据停止位为1位 attribute.rts = UART_ATTR_RTS_DIS; // UART禁用RTS attribute.cts = UART_ATTR_CTS_DIS; // UART禁用CTS attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; // UART使能RX FIFO attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN; // UART使能TX FIFO ret = UartSetAttribute(&port, &attribute); if (ret != HDF_SUCCESS) { LOG_ERROR; } LOG_INFO;} struct napi_value__ * write(int port, unsigned long data) {return write(port, data);}static napi_value UartWrite(napi_env env , napi_callback_info info){ size_t requireArgc = 2; size_t argc = 2; napi_value args[2] = {nullptr}; napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env, args[0], &valuetype0); napi_valuetype valuetype1; napi_typeof(env, args[1], &valuetype1); int32_t port; DevHandle handle = UartOpen(port); napi_get_value_int32(env, args[0], &port); napi_get_value_int32(env, args[0], &port); char value0[50]; size_t data; napi_get_value_string_utf8(env, args[1], value0, 50, &data); int32_t size; size = sizeof(data); napi_value ret;ret = write(port,data); napi_create_int32(env, data,&ret ); return ret; if (ret == NULL) { LOG_ERROR; }return ret;} struct napi_value__ * read(int port, char data[512]) { return read(port, data); }static napi_value UartRead(napi_env env , napi_callback_info info){ size_t requireArgc = 2; size_t argc = 2; napi_value args[2] = {nullptr}; napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env, args[0], &valuetype0); napi_valuetype valuetype1; napi_typeof(env, args[1], &valuetype1); int32_t port; napi_get_value_int32(env, args[0], &port); char value0[50]; size_t data; napi_get_value_string_utf8(env, args[1], value0, 50, &data); napi_value ret; ret = read(port,value0); napi_create_int32(env, data,&ret ); return ret; if (ret == NULL) { LOG_ERROR; }return ret;}struct napi_value__ * set(char port[50], unsigned int BaudRate) { return set(port, BaudRate);}static napi_value UartSetBaud(napi_env env, napi_callback_info info){ size_t requireArgc = 2; size_t argc = 2; napi_value args[2] = {nullptr}; napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env, args[0], &valuetype0); napi_valuetype valuetype1; napi_typeof(env, args[1], &valuetype1); char port[50]; size_t size1; napi_get_value_string_utf8(env, args[0], port, 50, &size1); int32_t BaudRate ; BaudRate= 150000; napi_value result; napi_create_int32(env, 1500000,&result); napi_value ret; ret = set(port,15000000); if (ret == NULL ) { HDF_FAILURE; } return ret; } struct napi_value__ * get(char port[50], int BaudRate) { return get(port, BaudRate);}static napi_value UartGetBaud(napi_env env, napi_callback_info info){ size_t requireArgc = 2; size_t argc = 2; napi_value args[2] = {nullptr}; napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env, args[0], &valuetype0); napi_valuetype valuetype1; napi_typeof(env, args[1], &valuetype1); char port[50]; size_t size1; napi_get_value_string_utf8(env, args[0], port, 50, &size1); int32_t BaudRate; napi_value ret; napi_create_int32(env, BaudRate, &ret); napi_create_int32(env, size1, &ret); ret = get(port, BaudRate); if (ret == nullptr) { HDF_FAILURE;; } return ret; }struct napi_value__ * close(int port) { return close(port);}static napi_value UartClose(napi_env env, napi_callback_info info){ size_t requireArgc = 1; size_t argc = 1; napi_value args[1] = {nullptr}; napi_get_cb_info(env, info,&argc,args ,nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env,args[0], &valuetype0); int port; napi_get_value_int32(env, args[0], &port); close(port); napi_value ret; napi_create_int32(env, port, &ret); if (ret == NULL) { HDF_FAILURE; }return ret;}EXTERN_C_STARTstatic int32_t UartTest(void ) { int32_t ret; uint32_t port; uint32_t baud = 15000000; DevHandle handle = NULL; uint8_t wbuff[] = {}; uint8_t rbuff[] = {}; struct UartAttribute attribute; attribute.dataBits = UART_ATTR_DATABIT_8; // UART传输数据位宽,一次传输8个bit attribute.parity = UART_ATTR_PARITY_NONE; // UART传输数据无校检 attribute.stopBits = UART_ATTR_STOPBIT_1; // UART传输数据停止位为1位 attribute.rts = UART_ATTR_RTS_DIS; // UART禁用RTS attribute.cts = UART_ATTR_CTS_DIS; // UART禁用CTS attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; // UART使能RX FIFO attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN;// UART使能TX FIFO ret = UartSetAttribute(handle, &attribute); handle = UartOpen(port); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } ret = UartSetBaud(handle, 1500000); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } ret = UartGetBaud(handle, &baud); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } ret = UartWrite(handle, wbuff, sizeof(wbuff)); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } ret = UartRead(handle, rbuff, sizeof(rbuff)); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } UartClose(handle); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } return HDF_SUCCESS;}static napi_value Init(napi_env env, napi_value exports){ napi_property_descriptor desc[] = { { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }, { "UartOpen", nullptr, UartOpen, nullptr, nullptr, nullptr, napi_default, nullptr }, { "UartClose", nullptr, UartClose, nullptr, nullptr, nullptr, napi_default, nullptr }, { "UartWrite", nullptr, UartWrite, nullptr, nullptr, nullptr, napi_default, nullptr }, { "UartRead", nullptr, UartRead, nullptr, nullptr, nullptr, napi_default, nullptr }, { "UartSetBaud", nullptr, UartSetBaud, nullptr, nullptr, nullptr, napi_default, nullptr }, { "UartGetBaud", nullptr, UartGetBaud, nullptr, nullptr, nullptr, napi_default, nullptr } }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); return exports;}EXTERN_C_ENDstatic napi_module demoModule = { .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, .nm_register_func = Init, .nm_modname = "entry", .nm_priv = ((void*)0), .reserved = { 0 },};extern "C" __attribute__((constructor)) void RegisterEntryModule(void){ napi_module_register(&demoModule);}cmakelist.txt内容如下:# the minimum version of CMake.cmake_minimum_required(VERSION 3.4.1)project(Uart)if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a")endif()if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/path/to/openharmony/libs")endif()set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})SET (CMAKE_BUILD_TYPE Debug CACHE INTERNAL “” FORCE)if(DEFINED PACKAGE_FIND_FILE) include(${PACKAGE_FIND_FILE})endif()include_directories(${NATIVERENDER_ROOT_PATH} ${NATIVERENDER_ROOT_PATH}/include)add_library(entry SHARED napi_init.cpp) target_link_libraries(serialhelper PUBLIC libace_napi.z.so libc++.a libhilog_ndk.z.so libuv.so libserialport_service_api.z.so)运行工程报错: > hvigor ERROR: Failed :entry:default@BuildNativeWithCmake... > hvigor ERROR: Exceptions happened while executing: Not searching for unused variables given on the command line. -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:3 (project): The CMAKE_CXX_COMPILER: C:/Program Files/Huawei/DevEco Studio/license/DevEco Studio/sdk/HarmonyOS-NEXT-DB1/openharmony/native/llvm/bin/clang++.exe is not a full path to an existing compiler tool. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "C:/Users/Administrator/DevEcoStudioProjects/Uart/entry/.cxx/default/default/arm64-v8a/CMakeFiles/CMakeOutput.log". See also "C:/Users/Administrator/DevEcoStudioProjects/Uart/entry/.cxx/default/default/arm64-v8a/CMakeFiles/CMakeError.log". > hvigor ERROR: BUILD FAILED in 2 s 908 ms hilog中报错如下:08-05 17:28:11.725 5162-5162 C02f00/teecd pid-5162 E open tee client dev failed, fd is <private> 08-05 17:28:11.726 5162-5162 C02f00/teecd pid-5162 E fs agent init failed 08-05 17:28:11.726 5162-5162 C02f00/teecd pid-5162 E open tee client dev failed, fd is <private> 08-05 17:28:11.726 5162-5162 C02f00/teecd pid-5162 E misc agent init failed 08-05 17:28:11.750 5163-5163 C02f00/teecd pid-5163 E open tee client dev failed, fd is <private> 08-05 17:28:11.750 5163-5163 C02f00/teecd pid-5163 E fs agent init failed 08-05 17:28:11.750 5163-5163 C02f00/teecd pid-5163 E open tee client dev failed, fd is <private> 08-05 17:28:11.750 5163-5163 C02f00/teecd pid-5163 E misc agent init failed 08-05 17:28:11.768 5164-5164 C02f00/teecd pid-5164 E open tee client dev failed, fd is <private> 08-05 17:28:11.768 5164-5164 C02f00/teecd pid-5164 E fs agent init failed 08-05 17:28:11.769 5164-5164 C02f00/teecd pid-5164 E open tee client dev failed, fd is <private> 08-05 17:28:11.769 5164-5164 C02f00/teecd pid-5164 E misc agent init failed 08-05 17:28:11.784 5165-5165 C02f00/teecd pid-5165 E open tee client dev failed, fd is <private> 08-05 17:28:11.784 5165-5165 C02f00/teecd pid-5165 E fs agent init failed 08-05 17:28:11.784 5165-5165 C02f00/teecd pid-5165 E open tee client dev failed, fd is <private> 08-05 17:28:11.784 5165-5165 C02f00/teecd pid-5165 E misc agent init failed 08-05 17:28:14.679 547-866 C01719/ffrt foundation E 20299:FFRTQosApplyForOther:242 qos apply failed for task 5170 08-05 17:28:15.883 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:15.884 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:16.279 5179-5179 C01810/SAFWK pid-5179 E CheckAndGetProfilePath file path does not exist! 08-05 17:28:16.280 5179-5179 C01810/SAFWK pid-5179 E DoStartSAProcess DoStartSAProcess invalid path 08-05 17:28:16.330 5180-5180 C01810/SAFWK pid-5180 E CheckAndGetProfilePath file path does not exist! 08-05 17:28:16.330 5180-5180 C01810/SAFWK pid-5180 E DoStartSAProcess DoStartSAProcess invalid path 08-05 17:28:16.378 5181-5181 C01810/SAFWK pid-5181 E CheckAndGetProfilePath file path does not exist! 08-05 17:28:16.378 5181-5181 C01810/SAFWK pid-5181 E DoStartSAProcess DoStartSAProcess invalid path 08-05 17:28:16.426 5182-5182 C01810/SAFWK pid-5182 E CheckAndGetProfilePath file path does not exist! 08-05 17:28:16.426 5182-5182 C01810/SAFWK pid-5182 E DoStartSAProcess DoStartSAProcess invalid path 08-05 17:28:18.399 263-298 C01719/ffrt samgr E 8683:FFRTQosApplyForOther:242 qos apply failed for task 5183 08-05 17:28:18.411 469-469 C01560/WifiHalWpaCommon wifi_hal_service E WpaCliCmd, ctrl/ctrl->pSend is NULL! 08-05 17:28:18.412 469-469 C01560/WifiHalWpaCommon wifi_hal_service E WpaCliCmd, ctrl/ctrl->pSend is NULL! 08-05 17:28:18.412 469-469 C01560/WifiHalStaInterface wifi_hal_service E StartScan failed! ret=-1 08-05 17:28:18.413 1002-1285 C01562/ScanStateMachine wifi_manager_se E WifiStaHalInterface::GetInstance().scan failed. 08-05 17:28:18.413 1002-1285 C01560/WifiScanManager wifi_manager_se E DealScanFinished, state: 0! 08-05 17:28:18.421 547-5170 C01719/ffrt foundation E 20338:FFRTQosApplyForOther:242 qos apply failed for task 5184 08-05 17:28:18.423 547-5170 C01719/ffrt foundation E 20353:FFRTQosApplyForOther:242 qos apply failed for task 5185 08-05 17:28:18.428 547-5170 C01719/ffrt foundation E 20379:FFRTQosApplyForOther:242 qos apply failed for task 5186 08-05 17:28:18.430 547-5170 C01719/ffrt foundation E 20396:FFRTQosApplyForOther:242 qos apply failed for task 5187 08-05 17:28:18.747 264-944 C01719/ffrt hiview E 3023:FFRTQosApplyForOther:242 qos apply failed for task 5188 08-05 17:28:21.044 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:21.045 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:22.536 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:22.537 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:22.633 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:22.634 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:22.641 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:22.642 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:26.180 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:26.180 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:27.812 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:27.812 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:28.838 264-944 C01719/ffrt hiview E 3041:FFRTQosApplyForOther:242 qos apply failed for task 5223 08-05 17:28:31.342 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:31.343 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:32.974 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:32.975 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:36.502 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:36.503 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106! 08-05 17:28:38.165 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.control.shell, errNum is:106! 08-05 17:28:38.166 632-720 C02c02/PARAM hdcd E [param_manager.c:736]SystemReadParam failed! name is:persist.hdc.root, errNum is:106!
-
使用了一个第三方的动态库libgmssl.so来编写生成了一个新的动态库tlcp.so,但是使用时出现undefined symbol后面使用ldd -r tlcp.so查看,显示如下内容undefined symbol: tls_send (./tlcp.so) undefined symbol: tls_ctx_cleanup (./tlcp.so) undefined symbol: tls_socket_accept (./tlcp.so) undefined symbol: tls_do_handshake (./tlcp.so) undefined symbol: tls_ctx_set_certificate_and_key (./tlcp.so) undefined symbol: tls_socket_connect (./tlcp.so) 这些函数的实现在libgmssl.so内已经实现,且使用nm libgmssl.so显示
-
当我访问比如https://192.168.1.120/SDCAPI/V1.0/demoapp/时,可以获得成功的结果。当我访问https://localhost/SDCAPI/V1.0/demoapp/或者https://127.0.0.1/SDCAPI/V1.0/demoapp/时,返回错误。而我在实际的开发中,网页端无法获得类似于192.168.1.120的ip地址。请问是哪里出了问题呢
推荐直播
-
华为AI技术发展与挑战:集成需求分析的实战指南
2024/11/26 周二 18:20-20:20
Alex 华为云学堂技术讲师
本期直播将综合讨论华为AI技术的发展现状,技术挑战,并深入探讨华为AI应用开发过程中的需求分析过程,从理论到实践帮助开发者快速掌握华为AI应用集成需求的框架和方法。
去报名 -
华为云DataArts+DWS助力企业数据治理一站式解决方案及应用实践
2024/11/27 周三 16:30-18:00
Walter.chi 华为云数据治理DTSE技术布道师
想知道数据治理项目中,数据主题域如何合理划分?数据标准及主数据标准如何制定?数仓分层模型如何合理规划?华为云DataArts+DWS助力企业数据治理项目一站式解决方案和应用实践告诉您答案!本期将从数据趋势、数据治理方案、数据治理规划及落地,案例分享四个方面来助力企业数据治理项目合理咨询规划及顺利实施。
去报名
热门标签