diff --git a/APP_Framework/Applications/app_test/Kconfig b/APP_Framework/Applications/app_test/Kconfig index b2e94cf6e..91c24c2e7 100644 --- a/APP_Framework/Applications/app_test/Kconfig +++ b/APP_Framework/Applications/app_test/Kconfig @@ -4,10 +4,6 @@ menu "test app" default n if USER_TEST - config USER_TEST_SPI_FLASH - bool "Config test spi flash" - default n - menuconfig USER_TEST_ADC bool "Config test adc" default n diff --git a/APP_Framework/Applications/app_test/Makefile b/APP_Framework/Applications/app_test/Makefile index c6f0f3a9d..29f6341cc 100644 --- a/APP_Framework/Applications/app_test/Makefile +++ b/APP_Framework/Applications/app_test/Makefile @@ -1,8 +1,4 @@ -SRC_FILES := - -ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y) - SRC_FILES += test_spi_flash.c -endif +SRC_FILES := test_shell.c ifeq ($(CONFIG_USER_TEST_ADC),y) SRC_FILES += test_adc.c diff --git a/APP_Framework/Applications/app_test/SConscript b/APP_Framework/Applications/app_test/SConscript new file mode 100644 index 000000000..66a967d9d --- /dev/null +++ b/APP_Framework/Applications/app_test/SConscript @@ -0,0 +1,11 @@ +import os +from building import * +Import('RTT_ROOT') +Import('rtconfig') +cwd = GetCurrentDir() +DEPENDS = [""] + +SOURCES = ['test_shell.c'] +path = [cwd] +objs = DefineGroup('app_test', src = SOURCES, depend = DEPENDS,CPPPATH = path) +Return("objs") diff --git a/APP_Framework/Applications/app_test/test_adc.c b/APP_Framework/Applications/app_test/test_adc.c index e6ab38ec1..1d6ad202a 100644 --- a/APP_Framework/Applications/app_test/test_adc.c +++ b/APP_Framework/Applications/app_test/test_adc.c @@ -22,7 +22,7 @@ #include #include -void test_adc() +void TestAdc(void) { int adc_fd; uint8 adc_channel = 0x0; @@ -56,6 +56,4 @@ void test_adc() return; } - - SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), - adc, test_adc, read 3.3 voltage data from adc); +PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/app_test/test_dac.c b/APP_Framework/Applications/app_test/test_dac.c index 60c2f8bfb..386464b8b 100644 --- a/APP_Framework/Applications/app_test/test_dac.c +++ b/APP_Framework/Applications/app_test/test_dac.c @@ -22,7 +22,7 @@ #include #include -void test_dac() +void TestDac(void) { int dac_fd; uint16 dac_set_value = 800; @@ -56,5 +56,4 @@ void test_dac() return; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), - test_dac, test_dac, set digital data to dac); +PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/app_test/test_extsram.c b/APP_Framework/Applications/app_test/test_extsram.c index 7ab4a173e..332488868 100755 --- a/APP_Framework/Applications/app_test/test_extsram.c +++ b/APP_Framework/Applications/app_test/test_extsram.c @@ -1,11 +1,25 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ -#ifdef ADD_XIZI_FETURES -#include -#endif +/** +* @file: test_extsram.c +* @brief: a extsram test application +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ -#include -#include -#include "transform.h" +#include /* parameters for sram peripheral */ // /* stm32f4 Bank3:0X68000000 */ @@ -22,7 +36,7 @@ #define TICK_PER_SECOND 100 -int extsram_test(void) +int ExtsramTest(void) { int i = 0; uint32_t start_time = 0, time_cast = 0; @@ -89,9 +103,4 @@ int extsram_test(void) return 0; } - -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), - sram_test, sram_test, sram_test); -#endif - +PRIV_SHELL_CMD_FUNCTION(ExtsramTest, a extsram test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/app_test/test_shell.c b/APP_Framework/Applications/app_test/test_shell.c new file mode 100644 index 000000000..a1b7dd4d0 --- /dev/null +++ b/APP_Framework/Applications/app_test/test_shell.c @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: test_shell.c +* @brief: a application of shell function +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +*/ + +#include + +void TestShellMain(int argc, char *agrv[]) +{ + printf("%dparameter(s)\r\n", argc); + for (char i = 1; i < argc; i++) { + printf("%s\r\n", agrv[i]); + } +} +PRIV_SHELL_CMD_FUNCTION(TestShellMain, a shell main sample 1, PRIV_SHELL_CMD_MAIN_ATTR); + +void TestShellMainVoid(void) +{ + printf("XiUOS test_shell_main_void\r\n"); +} +PRIV_SHELL_CMD_FUNCTION(TestShellMainVoid, a shell main sample 2, PRIV_SHELL_CMD_MAIN_ATTR); + +void TestShellFunc(int i, char ch, char *str) +{ + printf("input int: %d, char: %c, string: %s\r\n", i, ch, str); +} +PRIV_SHELL_CMD_FUNCTION(TestShellFunc, a shell func sample, PRIV_SHELL_CMD_FUNC_ATTR); diff --git a/APP_Framework/Applications/connection_app/socket_demo/Makefile b/APP_Framework/Applications/connection_app/socket_demo/Makefile index 29964c1d8..f75bae3ee 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/Makefile +++ b/APP_Framework/Applications/connection_app/socket_demo/Makefile @@ -1,5 +1,3 @@ - - ifeq ($(CONFIG_ADD_XIZI_FETURES),y) SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c index d9eb4788a..c28dc262c 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c @@ -56,7 +56,6 @@ char tcp_socket_ip[] = {192, 168, 250, 252}; uint16_t tcp_socket_port = LWIP_TARGET_PORT; /******************************************************************************/ - static void TCPSocketRecvTask(void *arg) { int fd = -1, clientfd; @@ -65,18 +64,15 @@ static void TCPSocketRecvTask(void *arg) struct sockaddr_in tcp_addr; socklen_t addr_len; - while(1) - { + while(1) { recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE); - if (recv_buf == NULL) - { + if (recv_buf == NULL) { lw_error("No memory\n"); continue; } fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) - { + if (fd < 0) { lw_error("Socket error\n"); free(recv_buf); continue; @@ -87,8 +83,7 @@ static void TCPSocketRecvTask(void *arg) tcp_addr.sin_port = htons(tcp_socket_port); memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero)); - if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) - { + if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) { lw_error("Unable to bind\n"); close(fd); free(recv_buf); @@ -99,8 +94,7 @@ static void TCPSocketRecvTask(void *arg) lw_notice("\n\nLocal Port:%d\n\n", tcp_socket_port); // setup socket fd as listening mode - if (listen(fd, 5) != 0 ) - { + if (listen(fd, 5) != 0 ) { lw_error("Unable to listen\n"); close(fd); free(recv_buf); @@ -111,12 +105,10 @@ static void TCPSocketRecvTask(void *arg) clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len); lw_notice("client %s connected\n", inet_ntoa(tcp_addr.sin_addr)); - while(1) - { + while(1) { memset(recv_buf, 0, TCP_DEMO_BUF_SIZE); recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0, (struct sockaddr *)&tcp_addr, &addr_len); - if(recv_len > 0) - { + if(recv_len > 0) { lw_notice("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr)); lw_notice("Receive data : %d - %s\n\n", recv_len, recv_buf); } @@ -133,11 +125,9 @@ void TCPSocketRecvTest(int argc, char *argv[]) { int result = 0; - if(argc >= 2) - { + if(argc >= 2) { lw_print("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == EOK) - { + if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0) { sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]); } } @@ -145,12 +135,9 @@ void TCPSocketRecvTest(int argc, char *argv[]) lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - TCPSocketRecv, TCPSocketRecvTest, TCP recv echo); +PRIV_SHELL_CMD_FUNCTION(TCPSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif - static void TCPSocketSendTask(void *arg) { int cnt = LWIP_DEMO_TIMES; @@ -161,8 +148,7 @@ static void TCPSocketSendTask(void *arg) memset(send_msg, 0, sizeof(send_msg)); fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) - { + if (fd < 0) { lw_print("Socket error\n"); return; } @@ -173,8 +159,7 @@ static void TCPSocketSendTask(void *arg) tcp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(tcp_socket_ip[0], tcp_socket_ip[1], tcp_socket_ip[2], tcp_socket_ip[3])); memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero)); - if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr))) - { + if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr))) { lw_print("Unable to connect\n"); close(fd); return; @@ -182,8 +167,7 @@ static void TCPSocketSendTask(void *arg) lw_notice("\n\nTarget Port:%d\n\n", tcp_socket_port); - while (cnt --) - { + while (cnt --) { lw_print("Lwip client is running.\n"); snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt); sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr)); @@ -195,14 +179,12 @@ static void TCPSocketSendTask(void *arg) return; } - #ifdef ADD_XIZI_FETURES void TCPSocketSendTest(int argc, char *argv[]) { - if(argc >= 2) - { + if(argc >= 2) { lw_print("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == EOK) + if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0) { sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]); } @@ -211,12 +193,9 @@ void TCPSocketSendTest(int argc, char *argv[]) lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); sys_thread_new("TCP Socket Send", TCPSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0), - TCPSocketSend, TCPSocketSendTest, TCP send demo); +PRIV_SHELL_CMD_FUNCTION(TCPSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif - #ifdef ADD_NUTTX_FETURES void tcp_recv_demo(void) { diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c index 2637dd830..28eb918cf 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c @@ -53,7 +53,6 @@ char udp_socket_ip[] = {192, 168, 250, 252}; uint16_t udp_socket_port = LWIP_LOCAL_PORT; /*****************************************************************************/ - static void UdpSocketRecvTask(void *arg) { int fd = -1; @@ -62,18 +61,15 @@ static void UdpSocketRecvTask(void *arg) int recv_len; socklen_t addr_len; - while(1) - { + while(1) { recv_buf = (char *)malloc(UDP_BUF_SIZE); - if(recv_buf == NULL) - { + if(recv_buf == NULL) { lw_error("No memory\n"); continue; } fd = socket(AF_INET, SOCK_DGRAM, 0); - if(fd < 0) - { + if(fd < 0) { lw_error("Socket error\n"); free(recv_buf); continue; @@ -84,8 +80,7 @@ static void UdpSocketRecvTask(void *arg) udp_addr.sin_port = htons(udp_socket_port); memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero)); - if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) - { + if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) { lw_error("Unable to bind\n"); close(fd); free(recv_buf); @@ -95,8 +90,7 @@ static void UdpSocketRecvTask(void *arg) lw_notice("UDP bind sucess, start to receive.\n"); lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port); - while(1) - { + while(1) { memset(recv_buf, 0, UDP_BUF_SIZE); recv_len = recvfrom(fd, recv_buf, UDP_BUF_SIZE, 0, (struct sockaddr *)&server_addr, &addr_len); if(recv_len > 0) @@ -115,11 +109,9 @@ static void UdpSocketRecvTask(void *arg) #ifdef ADD_XIZI_FETURES void UdpSocketRecvTest(int argc, char *argv[]) { - if(argc >= 2) - { + if(argc >= 2) { lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == EOK) - { + if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) { sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]); } } @@ -127,9 +119,7 @@ void UdpSocketRecvTest(int argc, char *argv[]) lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip); sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - UDPSocketRecv, UdpSocketRecvTest, UDP Receive DEMO); +PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif static void UdpSocketSendTask(void *arg) @@ -141,8 +131,7 @@ static void UdpSocketSendTask(void *arg) memset(send_str, 0, sizeof(send_str)); fd = socket(AF_INET, SOCK_DGRAM, 0); - if(fd < 0) - { + if(fd < 0) { lw_error("Socket error\n"); return; } @@ -153,8 +142,7 @@ static void UdpSocketSendTask(void *arg) udp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(udp_socket_ip[0], udp_socket_ip[1], udp_socket_ip[2], udp_socket_ip[3])); memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero)); - if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr))) - { + if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr))) { lw_error("Unable to connect\n"); close(fd); return; @@ -163,8 +151,7 @@ static void UdpSocketSendTask(void *arg) lw_print("UDP connect success, start to send.\n"); lw_notice("\n\nTarget Port:%d\n\n", udp_sock.sin_port); - while (cnt --) - { + while (cnt --) { snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt); sendto(fd, send_str, strlen(send_str), 0, (struct sockaddr*)&udp_sock, sizeof(struct sockaddr)); lw_notice("Send UDP msg: %s ", send_str); @@ -178,11 +165,9 @@ static void UdpSocketSendTask(void *arg) #ifdef ADD_XIZI_FETURES void UdpSocketSendTest(int argc, char *argv[]) { - if(argc >= 2) - { + if(argc >= 2) { lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == EOK) - { + if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) { sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]); } } @@ -190,9 +175,7 @@ void UdpSocketSendTest(int argc, char *argv[]) lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip); sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - UDPSocketSend, UdpSocketSendTest, UDP send echo); +PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif #ifdef ADD_NUTTX_FETURES diff --git a/APP_Framework/Applications/control_app/opcua_demo/opcua_demo.c b/APP_Framework/Applications/control_app/opcua_demo/opcua_demo.c index 6cabf185c..d208a3689 100755 --- a/APP_Framework/Applications/control_app/opcua_demo/opcua_demo.c +++ b/APP_Framework/Applications/control_app/opcua_demo/opcua_demo.c @@ -20,9 +20,8 @@ #include #include -#include "board.h" -#include "open62541.h" -#include "ua_api.h" +#include +#include /******************************************************************************* * Definitions @@ -58,8 +57,7 @@ static void UaConnectTestTask(void* arg) UA_Client* client = UA_Client_new(); - if(client == NULL) - { + if(client == NULL) { ua_error("ua: [%s] tcp client null\n", __func__); return; } @@ -76,8 +74,7 @@ static void UaConnectTestTask(void* arg) ret = UA_Client_connect(client, url); - if(ret != UA_STATUSCODE_GOOD) - { + if(ret != UA_STATUSCODE_GOOD) { ua_error("ua: [%s] connected failed %x\n", __func__, ret); UA_Client_delete(client); fail_cnt++; @@ -90,12 +87,9 @@ static void UaConnectTestTask(void* arg) static void UaConnectTest(int argc, char *argv[]) { - if(argc == 2) - { - if(isdigit(argv[1][0])) - { - if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF) - { + if(argc == 2) { + if(isdigit(argv[1][0])) { + if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) { lw_notice("input wrong ip\n"); return; } @@ -105,9 +99,7 @@ static void UaConnectTest(int argc, char *argv[]) lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip); sys_thread_new("ua test", UaConnectTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0), - UaConnect, UaConnectTest, Test Opc UA connection); +PRIV_SHELL_CMD_FUNCTION(UaConnectTest, a opcua connect sample, PRIV_SHELL_CMD_MAIN_ATTR); void UaBrowserObjectsTestTask(void* param) { @@ -115,8 +107,7 @@ void UaBrowserObjectsTestTask(void* param) UA_Client* client = UA_Client_new(); - if(client == NULL) - { + if(client == NULL) { ua_error("ua: [%s] tcp client NULL\n", __func__); return; } @@ -125,8 +116,7 @@ void UaBrowserObjectsTestTask(void* param) UA_ClientConfig_setDefault(config); UA_StatusCode ret = UA_Client_connect(client, opc_server_url); - if(ret != UA_STATUSCODE_GOOD) - { + if(ret != UA_STATUSCODE_GOOD) { ua_error("ua: [%s] connect failed %#x\n", __func__, ret); UA_Client_delete(client); return; @@ -144,12 +134,9 @@ void UaBrowserObjectsTestTask(void* param) static void* UaBrowserObjectsTest(int argc, char* argv[]) { - if(argc == 2) - { - if(isdigit(argv[1][0])) - { - if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF) - { + if(argc == 2) { + if(isdigit(argv[1][0])) { + if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) { lw_notice("input wrong ip\n"); return NULL; } @@ -160,17 +147,14 @@ static void* UaBrowserObjectsTest(int argc, char* argv[]) sys_thread_new("ua object", UaBrowserObjectsTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); return NULL; } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - UaObject, UaBrowserObjectsTest, UaObject [IP]); +PRIV_SHELL_CMD_FUNCTION(UaBrowserObjectsTest, a opcua object sample, PRIV_SHELL_CMD_MAIN_ATTR); void UaGetInfoTestTask(void* param) { UA_Client* client = UA_Client_new(); ua_notice("--- Get OPUCA objects ---\n", __func__); - if(client == NULL) - { + if(client == NULL) { ua_error("ua: [%s] tcp client null\n", __func__); return; } @@ -179,8 +163,7 @@ void UaGetInfoTestTask(void* param) UA_ClientConfig_setDefault(config); UA_StatusCode ret = UA_Client_connect(client, opc_server_url); - if(ret != UA_STATUSCODE_GOOD) - { + if(ret != UA_STATUSCODE_GOOD) { ua_error("ua: [%s] connect failed %#x\n", __func__, ret); UA_Client_delete(client); return; @@ -192,14 +175,11 @@ void UaGetInfoTestTask(void* param) UA_Client_delete(client); /* Disconnects the client internally */ } -void* UaGetInfoTest(int argc, char* argv[]) +void *UaGetInfoTest(int argc, char* argv[]) { - if(argc == 2) - { - if(isdigit(argv[1][0])) - { - if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF) - { + if(argc == 2) { + if(isdigit(argv[1][0])) { + if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) { lw_notice("input wrong ip\n"); return NULL; } @@ -210,17 +190,14 @@ void* UaGetInfoTest(int argc, char* argv[]) sys_thread_new("ua info", UaGetInfoTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); return NULL; } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - UaInfo, UaGetInfoTest, UaInfo [IP]); +PRIV_SHELL_CMD_FUNCTION(UaGetInfoTest, a opcua info sample, PRIV_SHELL_CMD_MAIN_ATTR); void UaAddNodesTask(void* param) { UA_Client* client = UA_Client_new(); ua_notice("ua: [%s] start ...\n", __func__); - if(client == NULL) - { + if(client == NULL) { ua_error("ua: [%s] client null\n", __func__); return; } @@ -229,8 +206,7 @@ void UaAddNodesTask(void* param) UA_ClientConfig_setDefault(config); UA_StatusCode ret = UA_Client_connect(client, opc_server_url); - if(ret != UA_STATUSCODE_GOOD) - { + if(ret != UA_STATUSCODE_GOOD) { ua_print("ua: [%s] connect failed %#x\n", __func__, ret); UA_Client_delete(client); return; @@ -242,14 +218,11 @@ void UaAddNodesTask(void* param) UA_Client_delete(client); /* Disconnects the client internally */ } -void* UaAddNodesTest(int argc, char* argv[]) +void *UaAddNodesTest(int argc, char* argv[]) { - if(argc == 2) - { - if(isdigit(argv[1][0])) - { - if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF) - { + if(argc == 2){ + if(isdigit(argv[1][0])) { + if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) { lw_notice("input wrong ip\n"); return NULL; } @@ -260,7 +233,4 @@ void* UaAddNodesTest(int argc, char* argv[]) sys_thread_new("ua add nodes", UaAddNodesTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); return NULL; } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - UaAdd, UaAddNodesTest, UA Add Nodes); - +PRIV_SHELL_CMD_FUNCTION(UaAddNodesTest, a opcua add nodes sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/control_app/plc_demo/plc_control_demo.c b/APP_Framework/Applications/control_app/plc_demo/plc_control_demo.c index fed4063bf..28a4d508b 100755 --- a/APP_Framework/Applications/control_app/plc_demo/plc_control_demo.c +++ b/APP_Framework/Applications/control_app/plc_demo/plc_control_demo.c @@ -18,10 +18,10 @@ * @date 2022.2.22 */ -#include "transform.h" -#include "open62541.h" -#include "ua_api.h" -#include "sys_arch.h" +#include +#include +#include +#include #include "plc_demo.h" #define PLC_NS_FORMAT "n%d,%s" @@ -41,8 +41,7 @@ UA_NodeId test_nodeid = {4, UA_NODEIDTYPE_NUMERIC, 5}; void PlcDelay(int sec) { volatile uint32_t i = 0; - for (i = 0; i < 100000000 * sec; ++i) - { + for (i = 0; i < 100000000 * sec; ++i) { __asm("NOP"); /* delay */ } } @@ -55,16 +54,12 @@ void PlcGetTestNodeId(char *str, UA_NodeId *id) plc_print("plc: arg %s\n", str); - if(sscanf(str, PLC_NS_FORMAT, &id->namespaceIndex, node_str) != EOF) - { - if(isdigit(node_str[0])) - { + if(sscanf(str, PLC_NS_FORMAT, &id->namespaceIndex, node_str) != EOF) { + if(isdigit(node_str[0])) { id->identifierType = UA_NODEIDTYPE_NUMERIC; id->identifier.numeric = atoi(node_str); plc_print("ns %d num %d\n", id->namespaceIndex, id->identifier.numeric); - } - else - { + } else { id->identifierType = UA_NODEIDTYPE_STRING; id->identifier.string.length = strlen(node_str); id->identifier.string.data = node_str; @@ -82,8 +77,7 @@ void PlcDemoChannelDrvInit(void) lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip); PlcChannelInit(&plc_demo_ch, PLC_CH_NAME); - if(PlcDriverInit(&plc_demo_drv, PLC_DRV_NAME) == EOK) - { + if(PlcDriverInit(&plc_demo_drv, PLC_DRV_NAME) == 0) { PlcDriverAttachToChannel(PLC_DRV_NAME, PLC_CH_NAME); } memset(&plc_demo_dev, 0, sizeof(plc_demo_dev)); @@ -101,8 +95,7 @@ static void PlcGetDemoDev(PlcDeviceType *dev, UA_NodeId *id) dev->net = PLC_IND_ENET_OPCUA; // register UA parameter - if(!dev->priv_data) - { + if(!dev->priv_data) { dev->priv_data = (UaParamType*)malloc(sizeof(UaParamType)); } UaParamType* ua_ptr = dev->priv_data; @@ -121,14 +114,12 @@ static void PlcCtrlDemoInit(void) // register plc device PlcGetDemoDev(&plc_demo_dev, &test_nodeid); - if(init_flag) - { + if(init_flag){ return; } init_flag = 1; - if(PlcDevRegister(&plc_demo_dev, NULL, plc_demo_dev.name) != EOK) - { + if(PlcDevRegister(&plc_demo_dev, NULL, plc_demo_dev.name) != 0) { return; } PlcDeviceAttachToChannel(plc_demo_dev.name, PLC_CH_NAME); @@ -144,16 +135,14 @@ void PlcReadUATask(void* arg) ops = plc_demo_dev.ops; ret = ops->open(&plc_demo_dev); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] open failed %#x\n", __func__, ret); return; } ret = ops->read(&plc_demo_dev, buf, PLC_BUF_SIZE); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] read failed %x\n", __func__, ret); } @@ -165,16 +154,13 @@ void PlcReadTestShell(int argc, char* argv[]) static char node_str[UA_NODE_LEN]; memset(node_str, 0, sizeof(node_str)); - if(argc > 1) - { + if(argc > 1) { PlcGetTestNodeId(argv[1], &test_nodeid); } sys_thread_new("plc read", PlcReadUATask, NULL, PLC_STACK_SIZE, PLC_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - PlcRead, PlcReadTestShell, Read PLC); +PRIV_SHELL_CMD_FUNCTION(PlcReadTestShell, a plc read sample, PRIV_SHELL_CMD_MAIN_ATTR); void PlcWriteUATask(void* arg) { @@ -187,16 +173,14 @@ void PlcWriteUATask(void* arg) ops = plc_demo_dev.ops; ret = ops->open(&plc_demo_dev); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] open failed %#x\n", __func__, ret); return; } ret = ops->write(&plc_demo_dev, arg, PLC_BUF_SIZE); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] write failed\n", __func__); } @@ -210,22 +194,18 @@ void PlcWriteTestShell(int argc, char* argv[]) memset(node_str, 0, sizeof(node_str)); memset(val_param, 0, sizeof(val_param)); - if(argc > 1) - { + if(argc > 1) { PlcGetTestNodeId(argv[1], &test_nodeid); } - if(argc > 2) - { + if(argc > 2) { strcpy(val_param, argv[2]); plc_print("write value %s\n", val_param); } sys_thread_new("plc write", PlcWriteUATask, val_param, PLC_STACK_SIZE, PLC_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - PlcWrite, PlcWriteTestShell, Read PLC); +PRIV_SHELL_CMD_FUNCTION(PlcWriteTestShell, a plc write sample, PRIV_SHELL_CMD_MAIN_ATTR); // test motor // clear parameter @@ -267,8 +247,7 @@ void PlcMotorTestTask(void* arg) ops = plc_demo_dev.ops; ret = ops->open(&plc_demo_dev); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] open failed %#x\n", __func__, ret); return; } @@ -276,38 +255,32 @@ void PlcMotorTestTask(void* arg) UaParamType* ua_ptr = plc_demo_dev.priv_data; // initialize step - for(int i = 0; i < 5; i++) - { + for(int i = 0; i < 5; i++) { plc_print("###\n### Clear %s\n###\n", test_notice[i]); PlcGetTestNodeId(test_nodeid[i], &ua_ptr->ua_id); ret = ops->write(&plc_demo_dev, "0b", PLC_BUF_SIZE); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] %d write failed\n", __func__, __LINE__); } PlcDelay(1); } - if(plc_test_speed != 50) - { + if(plc_test_speed != 50) { snprintf(test_cmd[1], 4, "%d", plc_test_speed); } if(plc_test_dir == 0) // if not postive, next running test_sort[2] = 3; - for(int i = 0; i < sizeof(test_sort)/sizeof(test_sort[0]); i++) - { + for(int i = 0; i < sizeof(test_sort)/sizeof(test_sort[0]); i++) { PlcGetTestNodeId(test_nodeid[test_sort[i]], &ua_ptr->ua_id); plc_print("###\n### %s\n###\n", test_notice[i]); ret = ops->write(&plc_demo_dev, test_cmd[i], PLC_BUF_SIZE); - if(EOK != ret) - { + if(0 != ret) { plc_print("plc: [%s] %d write failed\n", __func__, __LINE__); } PlcDelay(1); - if(i == 2) // postive - { + if(i == 2) {// postive PlcDelay(10); } } @@ -331,24 +304,18 @@ void PlcGetMotorParam(char *str) void PlcMotorTestShell(int argc, char* argv[]) { - if(plc_test_flag) - { + if(plc_test_flag) { plc_print("PLC Motor testing!\n"); return; } plc_test_flag = 1; - if(argc > 1) - { - for(int i = 0; i < argc; i++) - { + if(argc > 1) { + for(int i = 0; i < argc; i++) { PlcGetMotorParam(argv[i]); } } sys_thread_new("plc motor", PlcMotorTestTask, NULL, PLC_STACK_SIZE, PLC_TASK_PRIO); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - PlcMotorTest, PlcMotorTestShell, Run motor); - +PRIV_SHELL_CMD_FUNCTION(PlcMotorTestShell, a plc motor sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/control_app/plc_demo/plc_show_demo.c b/APP_Framework/Applications/control_app/plc_demo/plc_show_demo.c index 71a15a20d..2b8df3628 100755 --- a/APP_Framework/Applications/control_app/plc_demo/plc_show_demo.c +++ b/APP_Framework/Applications/control_app/plc_demo/plc_show_demo.c @@ -18,14 +18,13 @@ * @date 2022.02.24 */ -#include "transform.h" -#include "list.h" - -#include "open62541.h" -#include "ua_api.h" -#include "sys_arch.h" -#include "plc_demo.h" +#include +#include +#include +#include +#include +#include #define PLC_DEMO_NUM 5 @@ -62,36 +61,31 @@ extern DoublelistType ch_linklist; void PlcShowTitle(const char* item_array[]) { int i = 0, max_len = 65; - KPrintf(" %-15s%-15s%-15s%-15s%-20s\n", item_array[0], item_array[1], item_array[2], item_array[3], item_array[4]); + printf(" %-15s%-15s%-15s%-15s%-20s\n", item_array[0], item_array[1], item_array[2], item_array[3], item_array[4]); - while(i < max_len) - { + while(i < max_len) { i++; - if(max_len == i) - { - KPrintf("-\n"); - } - else - { - KPrintf("-"); + if(max_len == i) { + printf("-\n"); + } else { + printf("-"); } } } static ChDrvType ShowChannelFindDriver(struct Channel* ch) { - struct ChDrv* driver = NONE; - DoublelistType* node = NONE; + struct ChDrv* driver = NULL; + DoublelistType* node = NULL; DoublelistType* head = &ch->ch_drvlink; - for(node = head->node_next; node != head; node = node->node_next) - { + for(node = head->node_next; node != head; node = node->node_next) { driver = DOUBLE_LIST_ENTRY(node, struct ChDrv, driver_link); return driver; } - return NONE; + return NULL; } static void PlcShowDemoInit(void) @@ -100,8 +94,7 @@ static void PlcShowDemoInit(void) int i; PlcDemoChannelDrvInit(); - for(i = 0; i < PLC_DEMO_NUM; i++) - { + for(i = 0; i < PLC_DEMO_NUM; i++) { // register plc device plc_demo_array[i].state = CHDEV_INIT; snprintf(plc_demo_array[i].name, PLC_NAME_SIZE, "PLC Demo %d", i); @@ -116,10 +109,8 @@ static void PlcShowDemoInit(void) return; init_flag = 1; - for(i = 0; i < PLC_DEMO_NUM; i++) - { - if(PlcDevRegister(&plc_demo_array[i], NULL, plc_demo_array[i].name) == EOK) - { + for(i = 0; i < PLC_DEMO_NUM; i++) { + if(PlcDevRegister(&plc_demo_array[i], NULL, plc_demo_array[i].name) == 0) { PlcDeviceAttachToChannel(plc_demo_array[i].name, PLC_CH_NAME); } } @@ -131,78 +122,60 @@ void PlcShowChannel(void) ChDrvType driver; ChDevType device; int dev_cnt; - DoublelistType* ch_node = NONE; + DoublelistType* ch_node = NULL; DoublelistType* ch_head = &ch_linklist; const char* item_array[] = {"ch_type", "ch_name", "drv_name", "dev_name", "cnt"}; PlcShowDemoInit(); PlcShowTitle(item_array); ch_node = ch_head->node_next; - do - { + do { ch = DOUBLE_LIST_ENTRY(ch_node, struct Channel, ch_link); - if((ch) && (ch->ch_type == CH_PLC_TYPE)) - { - KPrintf("%s", " "); - KPrintf("%-15s%-15s", + if((ch) && (ch->ch_type == CH_PLC_TYPE)) { + printf("%s", " "); + printf("%-15s%-15s", channel_type_str[ch->ch_type], ch->ch_name); driver = ShowChannelFindDriver(ch); - if(driver) - { - KPrintf("%-15s", driver->drv_name); - } - else - { - KPrintf("%-15s", "nil"); + if(driver) { + printf("%-15s", driver->drv_name); + } else { + printf("%-15s", "nil"); } - if(ch->haldev_cnt) - { - DoublelistType* dev_node = NONE; + if(ch->haldev_cnt) { + DoublelistType* dev_node = NULL; DoublelistType* dev_head = &ch->ch_devlink; dev_node = dev_head->node_next; dev_cnt = 1; - while(dev_node != dev_head) - { + while(dev_node != dev_head) { device = DOUBLE_LIST_ENTRY(dev_node, struct ChDev, dev_link); - if(1 == dev_cnt) - { - if(device) - { - KPrintf("%-16s%-4d\n", device->dev_name, dev_cnt); + if(1 == dev_cnt) { + if(device) { + printf("%-16s%-4d\n", device->dev_name, dev_cnt); + } else { + printf("%-16s%-4d\n", "nil", dev_cnt); } - else - { - KPrintf("%-16s%-4d\n", "nil", dev_cnt); - } - } - else - { - KPrintf("%46s", " "); + } else { + printf("%46s", " "); - if(device) - { - KPrintf("%-16s%-4d\n", device->dev_name, dev_cnt); - } - else - { - KPrintf("%-16s%-4d\n", "nil", dev_cnt); + if(device) { + printf("%-16s%-4d\n", device->dev_name, dev_cnt); + } else { + printf("%-16s%-4d\n", "nil", dev_cnt); } } dev_cnt++; dev_node = dev_node->node_next; } - } - else - { - KPrintf("\n"); + } else { + printf("\n"); } } @@ -212,36 +185,32 @@ void PlcShowChannel(void) return; } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - ShowChannel, PlcShowChannel, Show PLC information); +PRIV_SHELL_CMD_FUNCTION(PlcShowChannel, a plc show channel sample, PRIV_SHELL_CMD_MAIN_ATTR); void PlcShowDev(void) { PlcDeviceType* plc_dev; ChDrvType driver; ChDevType device; - DoublelistType* plc_node = NONE; + DoublelistType* plc_node = NULL; DoublelistType* plc_head = &plcdev_list; const char* item_array[] = {"device", "vendor", "model", "product", "id"}; PlcShowDemoInit(); PlcShowTitle(item_array); plc_node = plc_head->node_next; - do - { + do { plc_dev = DOUBLE_LIST_ENTRY(plc_node, struct PlcDevice, link); - if(plc_dev) - { - KPrintf("%s", " "); - KPrintf("%-15s%-15s%-15s%-15s%-20d", + if(plc_dev) { + printf("%s", " "); + printf("%-15s%-15s%-15s%-15s%-20d", plc_dev->name, plc_dev->info.vendor, plc_dev->info.model, plc_dev->info.product, plc_dev->info.id); - KPrintf("\n"); + printf("\n"); } plc_node = plc_node->node_next; @@ -250,8 +219,4 @@ void PlcShowDev(void) return; } - - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - ShowPlc, PlcShowDev, Show PLC information); - +PRIV_SHELL_CMD_FUNCTION(PlcShowDev, a plc show dev sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/embedded_database_app/flashdb_app/flashdb_example.c b/APP_Framework/Applications/embedded_database_app/flashdb_app/flashdb_example.c index 7c89822a3..1a4e23abe 100644 --- a/APP_Framework/Applications/embedded_database_app/flashdb_app/flashdb_example.c +++ b/APP_Framework/Applications/embedded_database_app/flashdb_app/flashdb_example.c @@ -123,7 +123,4 @@ int flashdb_app(void) return 0; } - -#ifdef __RT_THREAD_H__ -MSH_CMD_EXPORT(flashdb_app, flashdb test); -#endif +PRIV_SHELL_CMD_FUNCTION(flashdb_app, a flashdb test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/knowing_app/mnist/mnistmain.c b/APP_Framework/Applications/knowing_app/mnist/mnistmain.c index 8c715e170..fa1c26821 100644 --- a/APP_Framework/Applications/knowing_app/mnist/mnistmain.c +++ b/APP_Framework/Applications/knowing_app/mnist/mnistmain.c @@ -26,6 +26,3 @@ void mnist_app(void); int tfmnist(void) { mnist_app(); } -// #ifndef SEPARATE_COMPILE -// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, tfmnist, tfmnist, run mnist demo of tflite); -// #endif \ No newline at end of file diff --git a/APP_Framework/Applications/lv_app/lv_demo.c b/APP_Framework/Applications/lv_app/lv_demo.c index a847ade90..ae3491c0d 100644 --- a/APP_Framework/Applications/lv_app/lv_demo.c +++ b/APP_Framework/Applications/lv_app/lv_demo.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_demo.c +* @brief: a application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #include #include #include "lv_demo_calendar.h" @@ -38,5 +59,4 @@ static int lvgl_demo_init(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_demo_init, lvgl_demo_init, lvgl_demo_init ); - +PRIV_SHELL_CMD_FUNCTION(lvgl_demo_init, a littlevgl init sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/lv_app/lv_demo_calendar.c b/APP_Framework/Applications/lv_app/lv_demo_calendar.c index e7f6fbdc4..49855cd54 100644 --- a/APP_Framework/Applications/lv_app/lv_demo_calendar.c +++ b/APP_Framework/Applications/lv_app/lv_demo_calendar.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_demo_calendar.c +* @brief: a calendar application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #include #include "lv_demo_calendar.h" // #include diff --git a/APP_Framework/Applications/lv_app/lv_demo_calendar.h b/APP_Framework/Applications/lv_app/lv_demo_calendar.h index b8a7772f2..f6f6398dc 100644 --- a/APP_Framework/Applications/lv_app/lv_demo_calendar.h +++ b/APP_Framework/Applications/lv_app/lv_demo_calendar.h @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_demo_calendar.h +* @brief: a calendar application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #ifndef __LV_DEMO_CALENDAR_H__ #define __LV_DEMO_CALENDAR_H__ diff --git a/APP_Framework/Applications/lv_app/lv_init.c b/APP_Framework/Applications/lv_app/lv_init.c index c5989a514..16cd86dd1 100644 --- a/APP_Framework/Applications/lv_app/lv_init.c +++ b/APP_Framework/Applications/lv_app/lv_init.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_init.c +* @brief: init littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #include #define DBG_TAG "LVGL" #define DBG_LVL DBG_INFO diff --git a/APP_Framework/Applications/lv_app/lv_sensor_info.c b/APP_Framework/Applications/lv_app/lv_sensor_info.c index fae473d55..70a6f24c5 100644 --- a/APP_Framework/Applications/lv_app/lv_sensor_info.c +++ b/APP_Framework/Applications/lv_app/lv_sensor_info.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_sensor_info.c +* @brief: a sensor info application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #include "lv_sensor_info.h" static void draw_part_event_cb(lv_event_t* e) { @@ -25,12 +46,11 @@ static void draw_part_event_cb(lv_event_t* e) { } } -char* Double2Str(char* buf, double value) { - sprintf(buf,"%.8f",value);//保留8位小数,不够补0 +char *Double2Str(char* buf, double value) { + sprintf(buf,"%.8f",value);//keep 8 bit float data int index = 0; int len = strlen(buf); - for(int i = len-1;i>0;i--) - { + for(int i = len-1;i>0;i--) { if(buf[i] == '0') continue; else { @@ -71,8 +91,7 @@ void lv_sensor_info(void) { for (uint32_t i = 0; i < 2 * NR_VAL_PERLINE; ++i) { if (i % 2 == 0) { lv_table_set_col_width(lv_ssr_tb, i, 75); - } - else { + } else { lv_table_set_col_width(lv_ssr_tb, i, 85); } } @@ -100,12 +119,11 @@ void lv_sensor_info(void) { lv_obj_add_event_cb(lv_ssr_tb, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL); } -void* lvgl_thd_show_sensor_info(void *parameter) +void *lvgl_thd_show_sensor_info(void *parameter) { lv_sensor_info(); PrivMutexCreate(&ssr_val_lock, 0); - while (1) - { + while (1) { lv_task_handler(); sensor_update_table(); @@ -123,5 +141,4 @@ static int lvgl_show_sensor_info(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_show_sensor_info, lvgl_show_sensor_info, lvgl_show_sensor_info ); - +PRIV_SHELL_CMD_FUNCTION(lvgl_show_sensor_info, a littlevgl sensor info show sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/lv_app/lv_sensor_info.h b/APP_Framework/Applications/lv_app/lv_sensor_info.h index 963adc703..93993e477 100644 --- a/APP_Framework/Applications/lv_app/lv_sensor_info.h +++ b/APP_Framework/Applications/lv_app/lv_sensor_info.h @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_sensor_info.h +* @brief: a sensor info application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #ifndef __LVGL_SENSOR_INFO_H__ #define __LVGL_SENSOR_INFO_H__ diff --git a/APP_Framework/Applications/lv_app/lv_sensor_info_update_demo.c b/APP_Framework/Applications/lv_app/lv_sensor_info_update_demo.c index 072ed4566..7c661f894 100644 --- a/APP_Framework/Applications/lv_app/lv_sensor_info_update_demo.c +++ b/APP_Framework/Applications/lv_app/lv_sensor_info_update_demo.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_sensor_info_update_demo.c +* @brief: a sensor info update application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #include "lv_sensor_info.h" void* lvgl_thd_sensor_info_update_demo(void *parameter) @@ -28,5 +49,4 @@ static int lvgl_sensor_info_update_demo(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_sensor_info_update_demo, lvgl_sensor_info_update_demo, lvgl_sensor_info_update_demo ); - +PRIV_SHELL_CMD_FUNCTION(lvgl_sensor_info_update_demo, a littlevgl sensor infor update sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/lv_app/lv_sensor_update_info.c b/APP_Framework/Applications/lv_app/lv_sensor_update_info.c index 1cea87a40..62a3816a6 100644 --- a/APP_Framework/Applications/lv_app/lv_sensor_update_info.c +++ b/APP_Framework/Applications/lv_app/lv_sensor_update_info.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: lv_sensor_update_info.c +* @brief: a sensor update info application using littleVgl +* @version: 2.0 +* @author: AIIT XUOS Lab +* @date: 2022/9/26 +* +*/ + #include "lv_sensor_info.h" uint32_t lv_ssr_map_idx(enum sensor_type st) { diff --git a/APP_Framework/Applications/ota/ota_server.c b/APP_Framework/Applications/ota/ota_server.c index e5760f065..335b0a226 100644 --- a/APP_Framework/Applications/ota/ota_server.c +++ b/APP_Framework/Applications/ota/ota_server.c @@ -1,3 +1,24 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: ota_server.c +* @brief: a application ota task of system running in Linux +* @version: 1.0 +* @author: AIIT XUOS Lab +* @date: 2021/11/3 +* +*/ + #include #include #include diff --git a/APP_Framework/Applications/sensor_app/altitude_bmp180.c b/APP_Framework/Applications/sensor_app/altitude_bmp180.c index a9ea40ca6..36d87868e 100644 --- a/APP_Framework/Applications/sensor_app/altitude_bmp180.c +++ b/APP_Framework/Applications/sensor_app/altitude_bmp180.c @@ -18,7 +18,6 @@ * @date 2021.12.23 */ -#include #include /** diff --git a/APP_Framework/Applications/sensor_app/ch4_as830.c b/APP_Framework/Applications/sensor_app/ch4_as830.c index cd16ebe5a..6eb026b4e 100644 --- a/APP_Framework/Applications/sensor_app/ch4_as830.c +++ b/APP_Framework/Applications/sensor_app/ch4_as830.c @@ -18,9 +18,6 @@ * @date 2021.12.10 */ -#ifdef ADD_XIZI_FETURES -# include -#endif #include /** diff --git a/APP_Framework/Applications/sensor_app/co2_g8s.c b/APP_Framework/Applications/sensor_app/co2_g8s.c index d62f4c0f5..176149661 100644 --- a/APP_Framework/Applications/sensor_app/co2_g8s.c +++ b/APP_Framework/Applications/sensor_app/co2_g8s.c @@ -18,9 +18,7 @@ * @date 2021.12.23 */ // -#ifdef ADD_XIZI_FETURES -# include -#endif + #include /** diff --git a/APP_Framework/Applications/sensor_app/co2_zg09.c b/APP_Framework/Applications/sensor_app/co2_zg09.c index 0b08cadd1..ca3cffcb2 100644 --- a/APP_Framework/Applications/sensor_app/co2_zg09.c +++ b/APP_Framework/Applications/sensor_app/co2_zg09.c @@ -18,9 +18,6 @@ * @date 2021.04.23 */ -#ifdef ADD_XIZI_FETURES -# include -#endif #include /** diff --git a/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c b/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c index 3f4522b69..010696799 100644 --- a/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c +++ b/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c @@ -18,12 +18,8 @@ * @date 2021.12.15 */ -#ifdef ADD_XIZI_FETURES -# include -#endif #include - /** * @description: Read a hcho * @return 0 diff --git a/APP_Framework/Applications/sensor_app/humidity_hs300x.c b/APP_Framework/Applications/sensor_app/humidity_hs300x.c index 01e7bbd6e..a35094a72 100644 --- a/APP_Framework/Applications/sensor_app/humidity_hs300x.c +++ b/APP_Framework/Applications/sensor_app/humidity_hs300x.c @@ -18,10 +18,6 @@ * @date 2021.04.23 */ -#ifdef ADD_XIZI_FETURES -# include -#endif - #include /** @@ -31,7 +27,7 @@ void HumiHs300x(void) { int i = 0; - int32 humidity; + int32_t humidity; struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI); SensorQuantityOpen(humi); for (i = 0; i < 100; i ++) { diff --git a/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c b/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c index 09545d34b..12c82d6ed 100644 --- a/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c +++ b/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c @@ -18,18 +18,8 @@ * @date 2021.12.14 */ -#ifdef ADD_XIZI_FETURES -# include -#endif #include -// struct iaq_data { -// uint16_t gas; -// uint8_t TH; -// uint8_t TL; -// uint8_t RhH; -// uint8_t RhL; -// }; /** * @description: Read a iaq * @return 0 diff --git a/APP_Framework/Applications/sensor_app/pm10_0_ps5308.c b/APP_Framework/Applications/sensor_app/pm10_0_ps5308.c index a7f173b28..8d47c6aec 100644 --- a/APP_Framework/Applications/sensor_app/pm10_0_ps5308.c +++ b/APP_Framework/Applications/sensor_app/pm10_0_ps5308.c @@ -18,10 +18,6 @@ * @date 2021.04.23 */ -#ifdef ADD_XIZI_FETURES -# include -#endif - #include /** diff --git a/APP_Framework/Applications/sensor_app/pm1_0_ps5308.c b/APP_Framework/Applications/sensor_app/pm1_0_ps5308.c index dc9448bc8..585156207 100644 --- a/APP_Framework/Applications/sensor_app/pm1_0_ps5308.c +++ b/APP_Framework/Applications/sensor_app/pm1_0_ps5308.c @@ -18,10 +18,6 @@ * @date 2021.04.23 */ -#ifdef ADD_XIZI_FETURES -# include -#endif - #include /** diff --git a/APP_Framework/Applications/sensor_app/pm2_5_ps5308.c b/APP_Framework/Applications/sensor_app/pm2_5_ps5308.c index 672826be2..cee35b76c 100644 --- a/APP_Framework/Applications/sensor_app/pm2_5_ps5308.c +++ b/APP_Framework/Applications/sensor_app/pm2_5_ps5308.c @@ -18,10 +18,6 @@ * @date 2021.12.28 */ -#ifdef ADD_XIZI_FETURES -# include -#endif - #include /** diff --git a/APP_Framework/Applications/sensor_app/temperature_hs300x.c b/APP_Framework/Applications/sensor_app/temperature_hs300x.c index 83f8594b1..bb5922f3a 100644 --- a/APP_Framework/Applications/sensor_app/temperature_hs300x.c +++ b/APP_Framework/Applications/sensor_app/temperature_hs300x.c @@ -18,10 +18,6 @@ * @date 2021.04.23 */ -#ifdef ADD_XIZI_FETURES -# include -#endif - #include /** @@ -31,7 +27,7 @@ void TempHs300x(void) { int i = 0; - int32 temperature; + int32_t temperature; struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP); SensorQuantityOpen(temp); for (i = 0; i < 100; i ++) { diff --git a/APP_Framework/Applications/sensor_app/tvoc_tb600b_tvoc10.c b/APP_Framework/Applications/sensor_app/tvoc_tb600b_tvoc10.c index c3fe7d7f6..4ffb49560 100644 --- a/APP_Framework/Applications/sensor_app/tvoc_tb600b_tvoc10.c +++ b/APP_Framework/Applications/sensor_app/tvoc_tb600b_tvoc10.c @@ -18,12 +18,8 @@ * @date 2021.12.15 */ -#ifdef ADD_XIZI_FETURES -# include -#endif #include - /** * @description: Read a tvoc * @return 0 diff --git a/APP_Framework/Applications/sensor_app/voice_d124.c b/APP_Framework/Applications/sensor_app/voice_d124.c index 033e6dfcf..8b7e9a353 100644 --- a/APP_Framework/Applications/sensor_app/voice_d124.c +++ b/APP_Framework/Applications/sensor_app/voice_d124.c @@ -18,7 +18,6 @@ * @date 2021.04.23 */ -#include #include /** @@ -30,7 +29,7 @@ void VoiceD124(void) struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE); SensorQuantityOpen(voice); PrivTaskDelay(2000); - uint16 result = SensorQuantityReadValue(voice); + uint16_t result = SensorQuantityReadValue(voice); printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places)); SensorQuantityClose(voice); } \ No newline at end of file diff --git a/APP_Framework/Applications/sensor_app/winddirection_qs_fx.c b/APP_Framework/Applications/sensor_app/winddirection_qs_fx.c index bef5b54c3..26d53601a 100644 --- a/APP_Framework/Applications/sensor_app/winddirection_qs_fx.c +++ b/APP_Framework/Applications/sensor_app/winddirection_qs_fx.c @@ -18,7 +18,6 @@ * @date 2021.12.14 */ -#include #include /** @@ -30,11 +29,7 @@ void WindDirectionQsFx(void) struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION); SensorQuantityOpen(wind_direction); PrivTaskDelay(2000); - uint16 result = SensorQuantityReadValue(wind_direction); + uint16_t result = SensorQuantityReadValue(wind_direction); printf("wind direction : %d degree\n", result); SensorQuantityClose(wind_direction); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindDirectionQsFx, WindDirectionQsFx, WindDirectionQsFx function); -#endif - diff --git a/APP_Framework/Applications/sensor_app/windspeed_qs_fs.c b/APP_Framework/Applications/sensor_app/windspeed_qs_fs.c index e3d3b959b..d9ec38f5f 100644 --- a/APP_Framework/Applications/sensor_app/windspeed_qs_fs.c +++ b/APP_Framework/Applications/sensor_app/windspeed_qs_fs.c @@ -18,7 +18,6 @@ * @date 2021.12.14 */ -#include #include /** @@ -30,11 +29,7 @@ void WindSpeedQsFs(void) struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED); SensorQuantityOpen(wind_speed); PrivTaskDelay(2000); - uint16 result = SensorQuantityReadValue(wind_speed); + uint16_t result = SensorQuantityReadValue(wind_speed); printf("wind speed : %d.%d m/s\n", result/10, result%10); SensorQuantityClose(wind_speed); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindSpeedQsFs, WindSpeedQsFs, WindSpeedQsFs function); -#endif - diff --git a/APP_Framework/Framework/connection/4g/adapter_4g.c b/APP_Framework/Framework/connection/4g/adapter_4g.c index a75808f77..57fbf0718 100644 --- a/APP_Framework/Framework/connection/4g/adapter_4g.c +++ b/APP_Framework/Framework/connection/4g/adapter_4g.c @@ -110,10 +110,4 @@ int Adapter4GTest(void) return 0; } - -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(Adapter4GTest,a EC200T adpter sample); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, Adapter4GTest, Adapter4GTest, show adapter 4G information); -#endif \ No newline at end of file +PRIV_SHELL_CMD_FUNCTION(Adapter4GTest, a EC200T adpter sample, PRIV_SHELL_CMD_FUNC_ATTR); diff --git a/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c b/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c index 2f72ba2e2..902f2ca63 100644 --- a/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c +++ b/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c @@ -111,9 +111,4 @@ int AdapterBlueToothTest(void) return 0; } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(AdapterBlueToothTest,a bt adpter sample); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter bluetooth information); -#endif \ No newline at end of file +PRIV_SHELL_CMD_FUNCTION(AdapterBlueToothTest, a bluetooth test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/connection/ethernet/adapter_ethernet.c b/APP_Framework/Framework/connection/ethernet/adapter_ethernet.c index d687d0268..b7ee8e40a 100644 --- a/APP_Framework/Framework/connection/ethernet/adapter_ethernet.c +++ b/APP_Framework/Framework/connection/ethernet/adapter_ethernet.c @@ -122,8 +122,4 @@ int AdapterEthernetTest(void) return 0; } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(AdapterEthernetTest,a ethernet adpter sample); -#elif definded ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterEthernetTest, AdapterEthernetTest, show adapter ethernet information); -#endif +PRIV_SHELL_CMD_FUNCTION(AdapterEthernetTest, a ethernet test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/connection/industrial_ethernet/ethercat/adapter_ethercat.c b/APP_Framework/Framework/connection/industrial_ethernet/ethercat/adapter_ethercat.c index 05c4b3c40..205625d86 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/ethercat/adapter_ethercat.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/ethercat/adapter_ethercat.c @@ -205,4 +205,4 @@ int AdapterEthercatTest(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_PARAM_NUM(0) | SHELL_CMD_DISABLE_RETURN, AdapterEthercatTest, AdapterEthercatTest, show adapter ethercat information); +PRIV_SHELL_CMD_FUNCTION(AdapterEthercatTest, a ethercat test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c b/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c index a484b1a47..1eb27cb42 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c @@ -4,25 +4,11 @@ #ifdef POWERLINK_MN extern int OplkDemoMnConsole(int argc, char *argv[]); -SHELL_EXPORT_CMD( - SHELL_CMD_PERMISSION(0) | - SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | - SHELL_CMD_PARAM_NUM(0) | - SHELL_CMD_DISABLE_RETURN, - OplkDemoMnConsole, - OplkDemoMnConsole, - openPOWERLINK demo MN (console version)); +PRIV_SHELL_CMD_FUNCTION(OplkDemoMnConsole, a openPOWERLINK MN sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif #ifdef POWERLINK_CN extern int OplkDemoCnConsole(int argc, char *argv[]); -SHELL_EXPORT_CMD( - SHELL_CMD_PERMISSION(0) | - SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | - SHELL_CMD_PARAM_NUM(0) | - SHELL_CMD_DISABLE_RETURN, - OplkDemoCnConsole, - OplkDemoCnConsole, - openPOWERLINK demo CN (console version)); +PRIV_SHELL_CMD_FUNCTION(OplkDemoCnConsole, a openPOWERLINK CN sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif diff --git a/APP_Framework/Framework/connection/lora/adapter_lora.c b/APP_Framework/Framework/connection/lora/adapter_lora.c index 2e848ef35..dbb76bcad 100644 --- a/APP_Framework/Framework/connection/lora/adapter_lora.c +++ b/APP_Framework/Framework/connection/lora/adapter_lora.c @@ -979,10 +979,4 @@ int AdapterLoraTest(void) return 0; } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(AdapterLoraTest,a Lora adpter sample); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterLoraTest, AdapterLoraTest, show adapter lora information); -#endif - +PRIV_SHELL_CMD_FUNCTION(AdapterLoraTest, a lora test sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/connection/lora/e220/e220.c b/APP_Framework/Framework/connection/lora/e220/e220.c index b075851da..7f3c4638c 100644 --- a/APP_Framework/Framework/connection/lora/e220/e220.c +++ b/APP_Framework/Framework/connection/lora/e220/e220.c @@ -705,8 +705,7 @@ static void LoraTest(void) return; } } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), -LoraTest, LoraTest, lora send and receive message); +PRIV_SHELL_CMD_FUNCTION(LoraTest, a lora test init sample, PRIV_SHELL_CMD_MAIN_ATTR); static void LoraSend(int argc, char *argv[]) { @@ -724,8 +723,7 @@ static void LoraSend(int argc, char *argv[]) E220Send(adapter, Msg, strlen(Msg)); } } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), -LoraSend, LoraSend, lora send message); +PRIV_SHELL_CMD_FUNCTION(LoraSend, a lora test send sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif #ifdef ADD_NUTTX_FETURES @@ -765,39 +763,40 @@ void E220LoraSend(int argc, char *argv[]) #endif #ifdef ADD_RTTHREAD_FETURES - static void LoraReadStart(void) { int ret; LoraOpen(); - rt_thread_t tid= rt_thread_create("LoraReadStart", LoraRead, RT_NULL,2048,10,5); - if(tid!=RT_NULL){ + rt_thread_t tid = rt_thread_create("LoraReadStart", LoraRead, RT_NULL,2048,10,5); + if(tid!=RT_NULL) { rt_thread_startup(tid); - }else{ + } else { rt_kprintf("LoraReadStart task_lora_read failed \r\n"); return; } - } -MSH_CMD_EXPORT(LoraReadStart,Lora read task start sample); +PRIV_SHELL_CMD_FUNCTION(LoraReadStart, a lora test start sample, PRIV_SHELL_CMD_MAIN_ATTR); + #define E22400T_M1_PIN (11U) #define E22400T_M0_PIN (9U) static void LoraSend(int argc, char *argv[]) { - int8_t cmd[10]={0xFF,0xFF,0x02,0xAA,0XBB,0xCC}; //sned AA BB CC to address 01 channel05 - LoraOpen(); + int8_t cmd[10]={0xFF,0xFF,0x02,0xAA,0XBB,0xCC}; //sned AA BB CC to address 01 channel05 + + LoraOpen(); struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME); if (NULL == adapter) { printf("LoraRead find lora adapter error\n"); return; } - rt_pin_mode (E22400T_M1_PIN, PIN_MODE_OUTPUT); - rt_pin_mode (E22400T_M0_PIN, PIN_MODE_OUTPUT); + + rt_pin_mode (E22400T_M1_PIN, PIN_MODE_OUTPUT); + rt_pin_mode (E22400T_M0_PIN, PIN_MODE_OUTPUT); rt_pin_write(E22400T_M1_PIN, PIN_LOW); - rt_pin_write(E22400T_M0_PIN, PIN_HIGH); + rt_pin_write(E22400T_M0_PIN, PIN_HIGH); E220Send(adapter, cmd, 6); } -MSH_CMD_EXPORT(LoraSend,Lora send sample); +PRIV_SHELL_CMD_FUNCTION(LoraSend, a lora test send sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif \ No newline at end of file diff --git a/APP_Framework/Framework/connection/nbiot/adapter_nbiot.c b/APP_Framework/Framework/connection/nbiot/adapter_nbiot.c index 952aab005..05221b81c 100644 --- a/APP_Framework/Framework/connection/nbiot/adapter_nbiot.c +++ b/APP_Framework/Framework/connection/nbiot/adapter_nbiot.c @@ -17,6 +17,7 @@ * @author AIIT XUOS Lab * @date 2021.06.25 */ + #include #include #include @@ -80,7 +81,7 @@ int AdapterNbiotInit(void) } /******************TEST*********************/ -int opennb(void) +int OpenNb(void) { int ret = 0; @@ -88,23 +89,18 @@ int opennb(void) #ifdef ADAPTER_BC28 ret = AdapterDeviceOpen(adapter); - if(ret < 0){ + if(ret < 0) { printf("open adapter failed\n"); return -1; } #endif - return 0; - } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(opennb,open nb sample); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, opennb, opennb, show adapter nb information); -#endif + return 0; +} +PRIV_SHELL_CMD_FUNCTION(OpenNb, a NBiot open sample, PRIV_SHELL_CMD_MAIN_ATTR); -int closenb(void) +int CloseNb(void) { int ret = 0; @@ -112,87 +108,62 @@ int closenb(void) #ifdef ADAPTER_BC28 ret = AdapterDeviceClose(adapter); - if(ret < 0){ + if(ret < 0) { printf("open adapter failed\n"); return -1; } - #endif - return 0; - } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(closenb,close nb sample); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, closenb, closenb, show adapter nb information); -#endif + return 0; +} +PRIV_SHELL_CMD_FUNCTION(CloseNb, a NBiot close sample, PRIV_SHELL_CMD_MAIN_ATTR); - int connectnb(int argc, char *argv[]) - { - const char *send_msg = argv[1]; - int ret = 0; +int ConnectNb(int argc, char *argv[]) +{ + const char *send_msg = argv[1]; + int ret = 0; - struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME); + struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME); - - ret = AdapterDeviceConnect(adapter, 1, "101.68.82.219","9898",1); - if(ret < 0){ - printf(" adapter send failed\n"); - return -1; - } - + ret = AdapterDeviceConnect(adapter, 1, "101.68.82.219","9898",1); + if(ret < 0) { + printf(" adapter send failed\n"); + return -1; + } + return 0; +} +PRIV_SHELL_CMD_FUNCTION(ConnectNb, a NBiot connect sample, PRIV_SHELL_CMD_MAIN_ATTR); - return 0; - } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(connectnb,connect nb test); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, connectnb, connectnb, show adapter nb information); -#endif +int SendNb(int argc, char *argv[]) +{ + const char *send_msg = argv[1]; + int msg_len = atoi(argv[2]); + int ret = 0; - int sendnb(int argc, char *argv[]) - { - const char *send_msg = argv[1]; - int msg_len = atoi(argv[2]); - int ret = 0; + struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME); - struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME); + printf("send argv1 %s len = %d\n",argv[1],msg_len); + ret = AdapterDeviceSend(adapter, send_msg, msg_len); + if(ret < 0) { + printf(" adapter send failed\n"); + return -1; + } + printf("nb send msg %s\n", send_msg); - printf("send argv1 %s len = %d\n",argv[1],msg_len); - ret = AdapterDeviceSend(adapter, send_msg, msg_len); - if(ret < 0){ - printf(" adapter send failed\n"); - return -1; - } - printf("nb send msg %s\n", send_msg); + return 0; +} +PRIV_SHELL_CMD_FUNCTION(SendNb, a NBiot send sample, PRIV_SHELL_CMD_MAIN_ATTR); +int RecvNb(void) +{ + char recv_msg[128]; + struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME); + memset(recv_msg,0,128); + AdapterDeviceRecv(adapter, recv_msg, 128); + PrivTaskDelay(2000); + printf("nb recv msg %s\n", recv_msg); - return 0; - } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(sendnb,send nb test); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendnb, sendnb, show adapter nb information); -#endif - - int recvnb(void) - { - char recv_msg[128]; - struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME); - memset(recv_msg,0,128); - AdapterDeviceRecv(adapter, recv_msg, 128); - PrivTaskDelay(2000); - printf("nb recv msg %s\n", recv_msg); - - return 0; - } -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(recvnb,receive nb test); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvnb, recvnb, show adapter nb information); -#endif + return 0; +} +PRIV_SHELL_CMD_FUNCTION(RecvNb, a NBiot receive sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/connection/nbiot/adapter_nbiot.h b/APP_Framework/Framework/connection/nbiot/adapter_nbiot.h index 97c698622..d718a9696 100644 --- a/APP_Framework/Framework/connection/nbiot/adapter_nbiot.h +++ b/APP_Framework/Framework/connection/nbiot/adapter_nbiot.h @@ -1,3 +1,23 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file adapter_nbiot.h + * @brief Implement the connection nbiot adapter function + * @version 1.1 + * @author AIIT XUOS Lab + * @date 2021.06.25 + */ + #ifndef ADAPTER_NBIOT_H #define ADAPTER_NBIOT_H diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.c b/APP_Framework/Framework/connection/wifi/adapter_wifi.c index a42942ac6..b9e1abdfb 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.c +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.c @@ -11,7 +11,7 @@ */ /** - * @file adapter_wifiiiii.c + * @file adapter_wifi.c * @brief Implement the connection wifi adapter function * @version 1.1 * @author AIIT XUOS Lab @@ -20,9 +20,6 @@ #include #include "adapter_wifi.h" -#ifdef ADD_XIZI_FETURES -#include -#endif #ifdef ADAPTER_HFA21_WIFI extern AdapterProductInfoType Hfa21WifiAttach(struct Adapter *adapter); @@ -100,7 +97,6 @@ int AdapterWifiInit(void) } /******************wifi TEST*********************/ -#ifdef ADD_XIZI_FETURES int AdapterWifiTest(void) { char cmd[64]; @@ -108,6 +104,7 @@ int AdapterWifiTest(void) struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); +#if 0 #ifdef ADAPTER_HFA21_DRIVER_EXT_PORT static BusType ch438_pin; ch438_pin = PinBusInitGet(); @@ -154,7 +151,7 @@ int AdapterWifiTest(void) PrivClose(pin_fd); #endif - +#endif AdapterDeviceOpen(adapter); // AdapterDeviceControl(adapter, OPE_INT, &baud_rate); @@ -182,38 +179,23 @@ int AdapterWifiTest(void) PrivTaskDelay(1000); } } -#endif +PRIV_SHELL_CMD_FUNCTION(AdapterWifiTest, a WiFi test sample, PRIV_SHELL_CMD_MAIN_ATTR); -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(AdapterWifiTest,a wifi adpter sample); -#endif -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterWifiTest, AdapterWifiTest, show adapter wifi information); -#endif - -int wifiopen(void) +int WifiOpen(void) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); return AdapterDeviceOpen(adapter); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, wifiopen, wifiopen, open adapter wifi ); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wifiopen,a wifi adpter sample); -#endif -int wificlose(void) +PRIV_SHELL_CMD_FUNCTION(WifiOpen, a WiFi open sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiClose(void) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); return AdapterDeviceClose(adapter); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, wificlose, wificlose, close adapter wifi ); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wificlose,a wifi adpter sample); -#endif -int wifisetup(int argc, char *argv[]) +PRIV_SHELL_CMD_FUNCTION(WifiClose, a WiFi close sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiSetup(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); struct WifiParam param; @@ -225,13 +207,9 @@ int wifisetup(int argc, char *argv[]) return AdapterDeviceSetUp(adapter); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifisetup, wifisetup, setup adapter wifi ); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wifisetup,a wifi adpter sample:wifisetup ); -#endif -int wifiaddrset(int argc, char *argv[]) +PRIV_SHELL_CMD_FUNCTION(WifiSetup, a WiFi setup sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiAddrSet(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); char *ip = argv[1]; @@ -242,25 +220,17 @@ int wifiaddrset(int argc, char *argv[]) AdapterDevicePing(adapter, "36.152.44.95");///< ping www.baidu.com return AdapterDeviceNetstat(adapter); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(4)|SHELL_CMD_DISABLE_RETURN, wifiaddrset, wifiaddrset, addrset adapter wifi); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wifiaddrset,a wifi adpter sample:wifiaddrset ); -#endif -int wifiping(int argc, char *argv[]) +PRIV_SHELL_CMD_FUNCTION(WifiAddrSet, a WiFi addr set sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiPing(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); printf("ping %s\n",argv[1]); return AdapterDevicePing(adapter, argv[1]); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3), wifiping, wifiping, wifiping adapter ); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wifiping,a wifi adpter sample:wifiping ); -#endif -int wificonnect(int argc, char *argv[]) +PRIV_SHELL_CMD_FUNCTION(WifiPing, a WiFi ping sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiConnect(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); char *ip = argv[1]; @@ -278,13 +248,9 @@ int wificonnect(int argc, char *argv[]) return AdapterDeviceConnect(adapter, net_role, ip, port, ip_type); } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(4)|SHELL_CMD_DISABLE_RETURN, wificonnect, wificonnect, wificonnect adapter); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wificonnect,a wifi adpter sample:wificonnect ); -#endif -int wifisend(int argc, char *argv[]) +PRIV_SHELL_CMD_FUNCTION(WifiConnect, a WiFi connect sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiSend(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); @@ -296,13 +262,9 @@ int wifisend(int argc, char *argv[]) } return 0; } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifisend, wifisend, wifisend adapter wifi information); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wifisend,a wifi adpter sample:wifisend ); -#endif -int wifirecv(int argc, char *argv[]) +PRIV_SHELL_CMD_FUNCTION(WifiSend, a WiFi send sample, PRIV_SHELL_CMD_MAIN_ATTR); + +int WifiRecv(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); @@ -313,12 +275,7 @@ int wifirecv(int argc, char *argv[]) printf("wifi recv [%s]\n",wifi_recv_msg); } } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifirecv, wifirecv, wifirecv adapter wifi information); -#endif -#ifdef ADD_RTTHREAD_FETURES -MSH_CMD_EXPORT(wifirecv,a wifi adpter sample:wifirecv ); -#endif +PRIV_SHELL_CMD_FUNCTION(WifiRecv, a WiFi receive sample, PRIV_SHELL_CMD_MAIN_ATTR); #ifdef ADD_NUTTX_FETURES diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.h b/APP_Framework/Framework/connection/wifi/adapter_wifi.h index e0ea7a9ee..25c6709a7 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.h +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.h @@ -1,3 +1,23 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file adapter_wifi.h + * @brief Implement the connection wifi adapter function + * @version 1.1 + * @author AIIT XUOS Lab + * @date 2021.07.25 + */ + #ifndef ADAPTER_WIFI_H #define ADAPTER_WIFI_H diff --git a/APP_Framework/Framework/connection/zigbee/adapter_zigbee.c b/APP_Framework/Framework/connection/zigbee/adapter_zigbee.c index e3577cf22..8089ed60f 100644 --- a/APP_Framework/Framework/connection/zigbee/adapter_zigbee.c +++ b/APP_Framework/Framework/connection/zigbee/adapter_zigbee.c @@ -90,7 +90,7 @@ int AdapterZigbeeInit(void) } /******************TEST*********************/ -int openzigbee(void) +int OpenZigbee(void) { int ret = 0; @@ -98,19 +98,19 @@ int openzigbee(void) #ifdef ADAPTER_E18 ret = AdapterDeviceOpen(adapter); - if(ret < 0){ + if(ret < 0) { printf("open adapter failed\n"); return -1; } adapter->info->work_mode = 1; ret = AdapterDeviceControl(adapter, CONFIG_ZIGBEE_NET_MODE,NULL); - if(ret < 0){ + if(ret < 0) { printf("control adapter failed\n"); return -1; } ret = AdapterDeviceJoin(adapter, NULL); - if(ret < 0){ + if(ret < 0) { printf("join adapter failed\n"); return -1; } @@ -118,12 +118,9 @@ int openzigbee(void) return 0; } +PRIV_SHELL_CMD_FUNCTION(OpenZigbee, a ZigBee open sample, PRIV_SHELL_CMD_MAIN_ATTR); -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, openzigbee, openzigbee, show adapter zigbee information); -#endif - -int sendzigbee(int argc, char *argv[]) +int SendZigbee(int argc, char *argv[]) { const char *send_msg = argv[1]; int ret = 0; @@ -132,20 +129,17 @@ int sendzigbee(int argc, char *argv[]) printf("send argv1 %s\n",argv[1]); ret = AdapterDeviceSend(adapter, send_msg, strlen(send_msg)); - if(ret < 0){ + if(ret < 0) { printf(" adapter send failed\n"); return -1; } printf("zigbee send msg %s\n", send_msg); - return 0; } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendzigbee, sendzigbee, show adapter zigbee information); -#endif +PRIV_SHELL_CMD_FUNCTION(SendZigbee, a ZigBee send sample, PRIV_SHELL_CMD_MAIN_ATTR); -int recvzigbee(void) +int RecvZigbee(void) { char recv_msg[128]; struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME); @@ -156,7 +150,4 @@ int recvzigbee(void) return 0; } -#ifdef ADD_XIZI_FETURES -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvzigbee, recvzigbee, show adapter zigbee information); -#endif - +PRIV_SHELL_CMD_FUNCTION(RecvZigbee, a ZigBee receive sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/connection/zigbee/adapter_zigbee.h b/APP_Framework/Framework/connection/zigbee/adapter_zigbee.h index 3e9200bb1..b1f568074 100644 --- a/APP_Framework/Framework/connection/zigbee/adapter_zigbee.h +++ b/APP_Framework/Framework/connection/zigbee/adapter_zigbee.h @@ -1,3 +1,23 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file adapter_zigbee.h + * @brief Implement the connection zigbee adapter function + * @version 1.1 + * @author AIIT XUOS Lab + * @date 2021.09.15 + */ + #ifndef ADAPTER_ZIGBEE_H #define ADAPTER_ZIGBEE_H diff --git a/APP_Framework/Framework/connection/zigbee/e18/e18.c b/APP_Framework/Framework/connection/zigbee/e18/e18.c index 87bd6c2a7..41197dc5a 100644 --- a/APP_Framework/Framework/connection/zigbee/e18/e18.c +++ b/APP_Framework/Framework/connection/zigbee/e18/e18.c @@ -460,7 +460,7 @@ static int E18Recv(struct Adapter *adapter, void *buf, size_t len) return 0; } -static int E18Quit(struct Adapter *adapter) +static int E18Quit(struct Adapter *adapter, unsigned char *priv_net_group) { return 0; diff --git a/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c b/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c index 74eba30c9..fb7e1ecfa 100755 --- a/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c +++ b/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c @@ -358,7 +358,3 @@ void PlcSocketTask(int argc, char *argv[]) lwip_config_net(lwip_ipaddr, lwip_netmask, param->ip); PrivTaskCreate(&th_id, &attr, PlcSocketStart, param); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - PlcSocket, PlcSocketTask, Test PLC Socket); - diff --git a/APP_Framework/Framework/control/shared/control_file.c b/APP_Framework/Framework/control/shared/control_file.c index 3b383c7f3..8843d52cf 100755 --- a/APP_Framework/Framework/control/shared/control_file.c +++ b/APP_Framework/Framework/control/shared/control_file.c @@ -112,9 +112,6 @@ void CtlCreateFileTest(void) CtlFileClose(fd); } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0), - CtlCreateFile, CtlCreateFileTest, Test control file); - #ifdef LIB_USING_CJSON void CtlParseJsonArray(cJSON *dat, int *cmd_len, char *cmd) @@ -205,9 +202,5 @@ void CtlParseFileTest(void) CtlParseJsonData(file_buf); free(file_buf); } - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0), - CtlParseFile, CtlParseFileTest, Parse control file); - #endif diff --git a/APP_Framework/Framework/security/crypto/test/sm3_test.c b/APP_Framework/Framework/security/crypto/test/sm3_test.c index ab103a75c..0ffd869a5 100755 --- a/APP_Framework/Framework/security/crypto/test/sm3_test.c +++ b/APP_Framework/Framework/security/crypto/test/sm3_test.c @@ -24,30 +24,30 @@ void sm3_test_case(){ uint8_t result[SM3_DIGEST_LENGTH] = { 0 }; //test case 1 - KPrintf("\n#################### sm3 test ##########################\n"); + printf("\n#################### sm3 test ##########################\n"); char *msg = "abc"; - KPrintf("\n####sm3 test case 1:\n"); - KPrintf( "%-15s %s\n", "digest message1:",msg); + printf("\n####sm3 test case 1:\n"); + printf( "%-15s %s\n", "digest message1:",msg); sm3(msg,3,result); - KPrintf("%-15s ","digest result1: "); + printf("%-15s ","digest result1: "); for ( int i = 0 ; i < SM3_DIGEST_LENGTH ; i++){ - KPrintf("%02x",result[i]); + printf("%02x",result[i]); } - KPrintf("\n"); + printf("\n"); //test case 2 - KPrintf("\n####sm3 test case 2:\n"); + printf("\n####sm3 test case 2:\n"); //msg = "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" char msg1[64] = { 0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 }; - KPrintf("digest message2: "); + printf("digest message2: "); for ( int i = 0 ; i < 64 ; i++){ - KPrintf("%02x",msg1[i]); + printf("%02x",msg1[i]); } - KPrintf("\n"); + printf("\n"); sm3(msg1, 64,result); - KPrintf("digest result2: "); + printf("digest result2: "); for ( int i = 0 ; i < SM3_DIGEST_LENGTH ; i++){ - KPrintf("%02x",result[i]); + printf("%02x",result[i]); } - KPrintf("\n"); - KPrintf("\n########################################################\n"); + printf("\n"); + printf("\n########################################################\n"); } \ No newline at end of file diff --git a/APP_Framework/Framework/security/crypto/test/sm4_test.c b/APP_Framework/Framework/security/crypto/test/sm4_test.c index c46aee1fc..05883fbee 100755 --- a/APP_Framework/Framework/security/crypto/test/sm4_test.c +++ b/APP_Framework/Framework/security/crypto/test/sm4_test.c @@ -31,63 +31,63 @@ void sm4_test_case(){ sms4_key_t key; //test case 1 - KPrintf("\n#################### sm4 test ##########################\n"); - KPrintf("\n####sm4 test case1:\n"); - KPrintf("plaintext: "); + printf("\n#################### sm4 test ##########################\n"); + printf("\n####sm4 test case1:\n"); + printf("plaintext: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x ",input[i]); + printf("%02x ",input[i]); } - KPrintf("\n"); - KPrintf("key: "); + printf("\n"); + printf("key: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x",ukey[i]); + printf("%02x",ukey[i]); } - KPrintf("\n"); + printf("\n"); - KPrintf("encryption:\n"); + printf("encryption:\n"); sms4_set_encrypt_key(&key, ukey); Sms4EcbEncryptNoPadding(input,16,res,&olen,&key); - KPrintf("ciphertext: "); + printf("ciphertext: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x",res[i]); + printf("%02x",res[i]); } - KPrintf("\n"); - KPrintf("decryption:\n"); + printf("\n"); + printf("decryption:\n"); sms4_set_decrypt_key(&key, ukey); - KPrintf("round key in sms4_set_decrypt_key:\n"); + printf("round key in sms4_set_decrypt_key:\n"); for (int i = 0; i < 32; i++){ - KPrintf("rk%d:%08x\n", i, key.rk[i]); + printf("rk%d:%08x\n", i, key.rk[i]); } Sms4EcbDecryptNoPadding(res,16,res,&olen,&key); printf("plaintext: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x",res[i]); + printf("%02x",res[i]); } printf("\n"); ////test case 2 - KPrintf("\n####sm4 test case2:\n"); - KPrintf("plaintext: "); + printf("\n####sm4 test case2:\n"); + printf("plaintext: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x",input[i]); + printf("%02x",input[i]); } - KPrintf("\n"); - KPrintf("key: "); + printf("\n"); + printf("key: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x",ukey[i]); + printf("%02x",ukey[i]); } - KPrintf("\n"); - KPrintf("encrypt 1000000 times:\n"); + printf("\n"); + printf("encrypt 1000000 times:\n"); sms4_set_encrypt_key(&key, ukey); memcpy(plaintext, input, 16); for (int i = 0;i< 1000000; i++){ Sms4EcbEncryptNoPadding(plaintext,16,ciphertext,&olen,&key); memcpy(plaintext, ciphertext, 16); } - KPrintf("ciphertext: "); + printf("ciphertext: "); for (int i = 0; i< 16; i++){ - KPrintf("%02x",ciphertext[i]); + printf("%02x",ciphertext[i]); } - KPrintf("\n"); - KPrintf("\n########################################################\n"); + printf("\n"); + printf("\n########################################################\n"); } diff --git a/APP_Framework/Framework/security/crypto/test/sm9_test.c b/APP_Framework/Framework/security/crypto/test/sm9_test.c index b88d8d98e..fdc36088b 100755 --- a/APP_Framework/Framework/security/crypto/test/sm9_test.c +++ b/APP_Framework/Framework/security/crypto/test/sm9_test.c @@ -62,11 +62,11 @@ void SignAndVerifyTest() SM9Init(); - KPrintf("------------------------------below is ks---------------------------------\n"); + printf("------------------------------below is ks---------------------------------\n"); Big8wPrint(&ks); Ppub_s = G2PointMult(ks, P2); - KPrintf("------------------------------below is Ppub_s-----------------------------\n"); + printf("------------------------------below is Ppub_s-----------------------------\n"); Big8wPrint(&Ppub_s.x.high); Big8wPrint(&Ppub_s.x.low); Big8wPrint(&Ppub_s.y.high); @@ -75,79 +75,79 @@ void SignAndVerifyTest() JoinIDhid(ID_Alice, 5, hid, Id_Alice_hid); t1 = Big8wAddMod(H(Id_Alice_hid, 5 + 1, 0x01), ks, curve.N); - KPrintf("------------------------------below is t1---------------------------------\n"); + printf("------------------------------below is t1---------------------------------\n"); Big8wPrint(&t1); t2 = Big8wMultMod(ks, Big8wReverse(t1, curve.N), curve.N); - KPrintf("------------------------------below is t2---------------------------------\n"); + printf("------------------------------below is t2---------------------------------\n"); Big8wPrint(&t2); dsA = G1pointMult(t2, P1); - KPrintf("------------------------------below is dsA--------------------------------\n"); + printf("------------------------------below is dsA--------------------------------\n"); Big8wPrint(&dsA.x); Big8wPrint(&dsA.y); g = BiLinearPairing(P1, Ppub_s); - KPrintf("------------------------below is bilineapairing---------------------------\n"); + printf("------------------------below is bilineapairing---------------------------\n"); Q12Print(&g); w = Q12PowerMod(g, r); - KPrintf("------------------------------below is w----------------------------------\n"); + printf("------------------------------below is w----------------------------------\n"); Q12Print(&w); msg_w = (uint8_t*)(malloc(msglen + BIG8W_BYTESIZE * 12)); JoinMsgW(message, msglen, &w, msg_w); h = H(msg_w, msglen + BIG8W_BYTESIZE * 12, 0x02); - KPrintf("------------------------------below is h----------------------------------\n"); + printf("------------------------------below is h----------------------------------\n"); Big8wPrint(&h); big8w L = Big8wMinusMod(r, h, curve.N); - KPrintf("------------------------------below is L----------------------------------\n"); + printf("------------------------------below is L----------------------------------\n"); Big8wPrint(&L); G1point S = G1pointMult(L, dsA); - KPrintf("------------------------------below is S----------------------------------\n"); + printf("------------------------------below is S----------------------------------\n"); Big8wPrint(&S.x); Big8wPrint(&S.y); - KPrintf("\n"); + printf("\n"); // verify the signature g = BiLinearPairing(P1, Ppub_s); - KPrintf("------------------------below is bilineapairing---------------------------\n"); + printf("------------------------below is bilineapairing---------------------------\n"); Q12Print(&g); t = Q12PowerMod(g, h); - KPrintf("-----------------------------below is t-----------------------------------\n"); + printf("-----------------------------below is t-----------------------------------\n"); Q12Print(&t); h1 = H(Id_Alice_hid, 5 + 1, 0x01); - KPrintf("-----------------------------below is h1----------------------------------\n"); + printf("-----------------------------below is h1----------------------------------\n"); Big8wPrint(&h1); P = G2PointAdd(Ppub_s, G2PointMult(h1, P2)); - KPrintf("------------------------------below is P----------------------------------\n"); + printf("------------------------------below is P----------------------------------\n"); G2pointPrint(&P); u = BiLinearPairing(S, P); - KPrintf("------------------------------below is u----------------------------------\n"); + printf("------------------------------below is u----------------------------------\n"); Q12Print(&u); w = Q12MultMod(u, t); - KPrintf("------------------------------below is w----------------------------------\n"); + printf("------------------------------below is w----------------------------------\n"); Q12Print(&w); h2 = H(msg_w, msglen + BIG8W_BYTESIZE * 12, 0x02); - KPrintf("------------------------------below is h2---------------------------------\n"); + printf("------------------------------below is h2---------------------------------\n"); Big8wPrint(&h2); - KPrintf("------------------------------below is h----------------------------------\n"); + printf("------------------------------below is h----------------------------------\n"); Big8wPrint(&h); if (Big8wEqual(&h2, &h)) - KPrintf("\nh2 = h, test verify success!\n"); + printf("\nh2 = h, test verify success!\n"); sig = SM9Sign(message, msglen, dsA, Ppub_s); if (SM9VerifySignature(ID_Alice, 5, hid, message, msglen, sig, Ppub_s)) - KPrintf("SM9 Sign and VerifySignature API run success!\n"); + printf("SM9 Sign and VerifySignature API run success!\n"); /* @@ -172,8 +172,8 @@ void SignAndVerifyTest() end = clock(); end_start = end - start; - KPrintf("\n"); - KPrintf("runtime of sign in: %d ms\n", end_start); + printf("\n"); + printf("runtime of sign in: %d ms\n", end_start); */ free(Id_Alice_hid); @@ -239,21 +239,21 @@ void SM9KeyExchangeTest() SM9Init(); Ppub_e = G1pointMult(ke, P1); - KPrintf("------------------------------below is Ppub_e-----------------------------\n"); + printf("------------------------------below is Ppub_e-----------------------------\n"); Big8wPrint(&Ppub_e.x); Big8wPrint(&Ppub_e.y); JoinIDhid(ID_Alice, 5, hid, Id_Alice_hid); t1 = Big8wAddMod(H(Id_Alice_hid, 5 + 1, 0x01), ke, curve.N); - KPrintf("-----------------------------below is t1----------------------------------\n"); + printf("-----------------------------below is t1----------------------------------\n"); Big8wPrint(&t1); t2 = Big8wMultMod(ke, Big8wReverse(t1, curve.N), curve.N); - KPrintf("-----------------------------below is t2----------------------------------\n"); + printf("-----------------------------below is t2----------------------------------\n"); Big8wPrint(&t2); deA = G2PointMult(t2, P2); - KPrintf("------------------------------below is deA--------------------------------\n"); + printf("------------------------------below is deA--------------------------------\n"); Big8wPrint(&deA.x.high); Big8wPrint(&deA.x.low); Big8wPrint(&deA.y.high); @@ -262,15 +262,15 @@ void SM9KeyExchangeTest() JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid); t3 = Big8wAddMod(H(ID_Bob_hid, 3 + 1, 0x01), ke, curve.N); - KPrintf("-----------------------------below is t3----------------------------------\n"); + printf("-----------------------------below is t3----------------------------------\n"); Big8wPrint(&t3); t4 = Big8wMultMod(ke, Big8wReverse(t3, curve.N), curve.N); - KPrintf("-----------------------------below is t4----------------------------------\n"); + printf("-----------------------------below is t4----------------------------------\n"); Big8wPrint(&t4); deB = G2PointMult(t4, P2); - KPrintf("------------------------------below is deB--------------------------------\n"); + printf("------------------------------below is deB--------------------------------\n"); Big8wPrint(&deB.x.high); Big8wPrint(&deB.x.low); Big8wPrint(&deB.y.high); @@ -279,208 +279,208 @@ void SM9KeyExchangeTest() JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid); h1 = H(ID_Bob_hid, 3 + 1, 0x01); - KPrintf("-----------------------------below is h1----------------------------------\n"); + printf("-----------------------------below is h1----------------------------------\n"); Big8wPrint(&h1); QB = G1pointAdd(Ppub_e, G1pointMult(h1, P1)); - KPrintf("-----------------------------below is QB----------------------------------\n"); + printf("-----------------------------below is QB----------------------------------\n"); Big8wPrint(&QB.x); Big8wPrint(&QB.y); RA = G1pointMult(rA, QB); - KPrintf("-----------------------------below is RA----------------------------------\n"); + printf("-----------------------------below is RA----------------------------------\n"); Big8wPrint(&RA.x); Big8wPrint(&RA.y); JoinIDhid(ID_Alice, 5, hid, Id_Alice_hid); h1 = H(Id_Alice_hid, 5 + 1, 0x01); - KPrintf("-----------------------------below is h1----------------------------------\n"); + printf("-----------------------------below is h1----------------------------------\n"); Big8wPrint(&h1); QA = G1pointAdd(Ppub_e, G1pointMult(h1, P1)); - KPrintf("-----------------------------below is QA----------------------------------\n"); + printf("-----------------------------below is QA----------------------------------\n"); Big8wPrint(&QA.x); Big8wPrint(&QA.y); RB = G1pointMult(rB, QA); - KPrintf("-----------------------------below is RB----------------------------------\n"); + printf("-----------------------------below is RB----------------------------------\n"); Big8wPrint(&RB.x); Big8wPrint(&RB.y); g1 = BiLinearPairing(RA, deB); - KPrintf("-----------------------------below is g1----------------------------------\n"); + printf("-----------------------------below is g1----------------------------------\n"); Q12Print(&g1); g2 = BiLinearPairing(Ppub_e, P2); g2 = Q12PowerMod(g2, rB); - KPrintf("-----------------------------below is g2----------------------------------\n"); + printf("-----------------------------below is g2----------------------------------\n"); Q12Print(&g2); g3 = Q12PowerMod(g1, rB); - KPrintf("-----------------------------below is g3----------------------------------\n"); + printf("-----------------------------below is g3----------------------------------\n"); Q12Print(&g3); JoinIDAIDBRARBg123(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, strA); KDF(strA, 5 + 3 + BIG8W_BYTESIZE * 2 * 2 + BIG8W_BYTESIZE * 12 * 3, klen, SKB); - KPrintf("-----------------------------below is SKB---------------------------------\n"); + printf("-----------------------------below is SKB---------------------------------\n"); for (i = 0; i < klen/8; i++){ - KPrintf("%02x", SKB[i]); + printf("%02x", SKB[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); - } - KPrintf("\n"); - - KPrintf("-----------------------------below is SB----------------------------------\n"); - HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, SB); - HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x83, S2); - for (i = 0; i < 256/8; i++){ - KPrintf("%02x", SB[i]); - if (((i+1)&0x3) == 0) - KPrintf(" "); - if (((i + 1) % 32) == 0) - KPrintf("\n"); - } - KPrintf("\n"); - - g1 = BiLinearPairing(Ppub_e, P2); - g1 = Q12PowerMod(g1, rA); - KPrintf("-----------------------------below is g1----------------------------------\n"); - Q12Print(&g1); - - g2 = BiLinearPairing(RB, deA); - KPrintf("-----------------------------below is g2----------------------------------\n"); - Q12Print(&g2); - - g3 = Q12PowerMod(g2, rA); - KPrintf("-----------------------------below is g3----------------------------------\n"); - Q12Print(&g3); - - KPrintf("-----------------------------below is S1----------------------------------\n"); - HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, S1); - - for (i = 0; i < 256/8; i++){ - KPrintf("%02x", S1[i]); - if (((i+1)&0x3) == 0) - KPrintf(" "); - if (((i + 1) % 32) == 0) - KPrintf("\n"); - } - KPrintf("\n"); - - KDF(strA, 5 + 3 + BIG8W_BYTESIZE * 2 * 2 + BIG8W_BYTESIZE * 12 * 3, klen, SKA); - KPrintf("-----------------------------below is SKA---------------------------------\n"); - for (i = 0; i < klen/8; i++){ - KPrintf("%02x", SKA[i]); - if (((i+1)&0x3) == 0) - KPrintf(" "); - if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } printf("\n"); - KPrintf("-----------------------------below is SA----------------------------------\n"); + printf("-----------------------------below is SB----------------------------------\n"); + HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, SB); + HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x83, S2); + for (i = 0; i < 256/8; i++){ + printf("%02x", SB[i]); + if (((i+1)&0x3) == 0) + printf(" "); + if (((i + 1) % 32) == 0) + printf("\n"); + } + printf("\n"); + + g1 = BiLinearPairing(Ppub_e, P2); + g1 = Q12PowerMod(g1, rA); + printf("-----------------------------below is g1----------------------------------\n"); + Q12Print(&g1); + + g2 = BiLinearPairing(RB, deA); + printf("-----------------------------below is g2----------------------------------\n"); + Q12Print(&g2); + + g3 = Q12PowerMod(g2, rA); + printf("-----------------------------below is g3----------------------------------\n"); + Q12Print(&g3); + + printf("-----------------------------below is S1----------------------------------\n"); + HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, S1); + + for (i = 0; i < 256/8; i++){ + printf("%02x", S1[i]); + if (((i+1)&0x3) == 0) + printf(" "); + if (((i + 1) % 32) == 0) + printf("\n"); + } + printf("\n"); + + KDF(strA, 5 + 3 + BIG8W_BYTESIZE * 2 * 2 + BIG8W_BYTESIZE * 12 * 3, klen, SKA); + printf("-----------------------------below is SKA---------------------------------\n"); + for (i = 0; i < klen/8; i++){ + printf("%02x", SKA[i]); + if (((i+1)&0x3) == 0) + printf(" "); + if (((i + 1) % 32) == 0) + printf("\n"); + } + printf("\n"); + + printf("-----------------------------below is SA----------------------------------\n"); HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x83, SA); for (i = 0; i < 256/8; i++){ - KPrintf("%02x", SA[i]); + printf("%02x", SA[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); - KPrintf("-----------------------------below is S2----------------------------------\n"); + printf("-----------------------------below is S2----------------------------------\n"); for (i = 0; i < 256/8; i++){ - KPrintf("%02x", S2[i]); + printf("%02x", S2[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); // Following is test of API, random big number generated in SM9KeyExchangeProduceR, so result is different from the former. // To get the same result, you should delete the line "*r = RandomNumGenerate();" in function SM9KeyExchangeR. (or set as note) - KPrintf("---------------------------SM9 key exchange API test----------------------\n"); + printf("---------------------------SM9 key exchange API test----------------------\n"); SM9KeyExchangeProduceR(ID_Bob, 3, &rA, &RA, Ppub_e); - KPrintf("-----------------------------below is RA----------------------------------\n"); + printf("-----------------------------below is RA----------------------------------\n"); Big8wPrint(&RA.x); Big8wPrint(&RA.y); SM9KeyExchangeProduceR(ID_Alice, 5, &rB, &RB, Ppub_e); - KPrintf("-----------------------------below is RB----------------------------------\n"); + printf("-----------------------------below is RB----------------------------------\n"); Big8wPrint(&RB.x); Big8wPrint(&RB.y); SM9KeyExchangeProduceKey(&RA, &RB, &rA, klen, ID_Alice, 5, ID_Bob, 3, &g1, &g2, &g3, SKA, true, Ppub_e, deA); - KPrintf("-----------------------------below is g1----------------------------------\n"); + printf("-----------------------------below is g1----------------------------------\n"); Q12Print(&g1); - KPrintf("-----------------------------below is g2----------------------------------\n"); + printf("-----------------------------below is g2----------------------------------\n"); Q12Print(&g2); - KPrintf("-----------------------------below is g3----------------------------------\n"); + printf("-----------------------------below is g3----------------------------------\n"); Q12Print(&g3); - KPrintf("-----------------------------below is SKA---------------------------------\n"); + printf("-----------------------------below is SKA---------------------------------\n"); for (i = 0; i < klen/8; i++){ - KPrintf("%02x", SKA[i]); + printf("%02x", SKA[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); // g1,g2,g3 changed // SM9KeyExchangeProduceKey(&RA, &RB, &rB, klen, ID_Alice, 5, ID_Bob, 3, &g1, &g2, &g3, SKB, false, Ppub_e, deB); SM9KeyExchangeVerifyKey(&g1, &g2, &g3, &RA, &RB, ID_Alice, 5, ID_Bob, 3, S1, SA); - KPrintf("-----------------------------below is SA----------------------------------\n"); + printf("-----------------------------below is SA----------------------------------\n"); for (i = 0; i < 256/8; i++){ - KPrintf("%02x", SA[i]); + printf("%02x", SA[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); - KPrintf("-----------------------------below is S1----------------------------------\n"); + printf("-----------------------------below is S1----------------------------------\n"); for (i = 0; i < 256/8; i++){ - KPrintf("%02x", S1[i]); + printf("%02x", S1[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); SM9KeyExchangeVerifyKey(&g1, &g2, &g3, &RA, &RB, ID_Alice, 5, ID_Bob, 3, SB, S2); - KPrintf("-----------------------------below is SB----------------------------------\n"); + printf("-----------------------------below is SB----------------------------------\n"); for (i = 0; i < 256/8; i++){ - KPrintf("%02x", SB[i]); + printf("%02x", SB[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); - KPrintf("-----------------------------below is S2----------------------------------\n"); + printf("-----------------------------below is S2----------------------------------\n"); for (i = 0; i < 256/8; i++){ - KPrintf("%02x", S2[i]); + printf("%02x", S2[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); free(strA); free(strB); @@ -535,25 +535,25 @@ void SM9PackDepackTest() SM9Init(); Ppub_e = G1pointMult(ke, P1); - KPrintf("-----------------------------below is Ppub_e------------------------------\n"); + printf("-----------------------------below is Ppub_e------------------------------\n"); Big8wPrint(&Ppub_e.x); Big8wPrint(&Ppub_e.y); JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid); t1 = H(ID_Bob_hid, 3 + 1, 0x01); - KPrintf("-----------------------------below is H1()--------------------------------\n"); + printf("-----------------------------below is H1()--------------------------------\n"); Big8wPrint(&t1); t1 = Big8wAddMod(t1, ke, curve.N); - KPrintf("-----------------------------below is t1----------------------------------\n"); + printf("-----------------------------below is t1----------------------------------\n"); Big8wPrint(&t1); t1 = Big8wReverse(t1, curve.N); t2 = Big8wMultMod(ke, t1, curve.N); - KPrintf("-----------------------------below is t2----------------------------------\n"); + printf("-----------------------------below is t2----------------------------------\n"); Big8wPrint(&t2); deB = G2PointMult(t2, P2); - KPrintf("------------------------------below is deB--------------------------------\n"); + printf("------------------------------below is deB--------------------------------\n"); Big8wPrint(&deB.x.high); Big8wPrint(&deB.x.low); Big8wPrint(&deB.y.high); @@ -562,53 +562,53 @@ void SM9PackDepackTest() QB = G1pointAdd( G1pointMult(H(ID_Bob_hid, 3 + 1, 0x01), P1), Ppub_e); - KPrintf("-----------------------------below is QB----------------------------------\n"); + printf("-----------------------------below is QB----------------------------------\n"); Big8wPrint(&QB.x); Big8wPrint(&QB.y); C = G1pointMult(r, QB); - KPrintf("-----------------------------below is C----------------------------------\n"); + printf("-----------------------------below is C----------------------------------\n"); Big8wPrint(&C.x); Big8wPrint(&C.y); g = BiLinearPairing(Ppub_e, P2); - KPrintf("-----------------------------below is g----------------------------------\n"); + printf("-----------------------------below is g----------------------------------\n"); Q12Print(&g); w = Q12PowerMod(g, r); - KPrintf("-----------------------------below is w----------------------------------\n"); + printf("-----------------------------below is w----------------------------------\n"); Q12Print(&w); JoinCwID(&C, &w, ID_Bob, 3, c_w_id); KDF(c_w_id, c_w_id_len, klen, K_encap); - KPrintf("-----------------------------below is K-----------------------------------\n"); + printf("-----------------------------below is K-----------------------------------\n"); for (i = 0; i < klen / 8; i++){ - KPrintf("%02x", K_encap[i]); + printf("%02x", K_encap[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); w = BiLinearPairing(C, deB); - KPrintf("-----------------------------below is w'----------------------------------\n"); + printf("-----------------------------below is w'----------------------------------\n"); Q12Print(&w); JoinCwID(&C, &w, ID_Bob, 3, c_w_id); KDF(c_w_id, c_w_id_len, klen, K_encap); - KPrintf("-----------------------------below is K'----------------------------------\n"); + printf("-----------------------------below is K'----------------------------------\n"); for (i = 0; i < klen / 8; i++){ - KPrintf("%02x", K_encap[i]); + printf("%02x", K_encap[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); - KPrintf("pack and depack done\n"); + printf("\n"); + printf("pack and depack done\n"); free(ID_Bob_hid); free(K_encap); @@ -671,22 +671,22 @@ void SM9EncryptDecryptTest() SM9Init(); Ppub_e = G1pointMult(ke, P1); - KPrintf("-----------------------------below is Ppub_e------------------------------\n"); + printf("-----------------------------below is Ppub_e------------------------------\n"); Big8wPrint(&Ppub_e.x); Big8wPrint(&Ppub_e.y); JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid); t1 = Big8wAddMod(H(ID_Bob_hid, 3 + 1, 0x01), ke, curve.N); - KPrintf("-----------------------------below is t1----------------------------------\n"); + printf("-----------------------------below is t1----------------------------------\n"); Big8wPrint(&t1); t1 = Big8wReverse(t1, curve.N); t2 = Big8wMultMod(ke, t1, curve.N); - KPrintf("-----------------------------below is t2----------------------------------\n"); + printf("-----------------------------below is t2----------------------------------\n"); Big8wPrint(&t2); deB = G2PointMult(t2, P2); - KPrintf("------------------------------below is deB--------------------------------\n"); + printf("------------------------------below is deB--------------------------------\n"); Big8wPrint(&deB.x.high); Big8wPrint(&deB.x.low); Big8wPrint(&deB.y.high); @@ -695,46 +695,46 @@ void SM9EncryptDecryptTest() QB = G1pointAdd( G1pointMult(H(ID_Bob_hid, 3 + 1, 0x01), P1), Ppub_e); - KPrintf("-----------------------------below is QB----------------------------------\n"); + printf("-----------------------------below is QB----------------------------------\n"); Big8wPrint(&QB.x); Big8wPrint(&QB.y); C1 = G1pointMult(r, QB); - KPrintf("-----------------------------below is C1----------------------------------\n"); + printf("-----------------------------below is C1----------------------------------\n"); Big8wPrint(&C1.x); Big8wPrint(&C1.y); g = BiLinearPairing(Ppub_e, P2); - KPrintf("-----------------------------below is g-----------------------------------\n"); + printf("-----------------------------below is g-----------------------------------\n"); Q12Print(&g); w = Q12PowerMod(g, r); - KPrintf("-----------------------------below is w-----------------------------------\n"); + printf("-----------------------------below is w-----------------------------------\n"); Q12Print(&w); JoinCwID(&C1, &w, ID_Bob, 3, C_w_id); KDF(C_w_id, c_w_id_len, klen, K); - KPrintf("-----------------------------below is K-----------------------------------\n"); + printf("-----------------------------below is K-----------------------------------\n"); for (i = 0; i < klen / 8; i++) { - KPrintf("%02x", K[i]); + printf("%02x", K[i]); if (((i+1)&0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); XOR(message, mlen / 8, K, C2); - KPrintf("-----------------------------below is C2----------------------------------\n"); + printf("-----------------------------below is C2----------------------------------\n"); for (i = 0; i < mlen / 8; i++) { - KPrintf("%02x", C2[i]); + printf("%02x", C2[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); for (i = 0; i < mlen / 8; i++) C2K2[i] = C2[i]; @@ -742,15 +742,15 @@ void SM9EncryptDecryptTest() C2K2[i] = K[i]; sm3(C2K2, (mlen / 8) + (K2_len / 8), C3); - KPrintf("----------------------------below is C3-----------------------------------\n"); + printf("----------------------------below is C3-----------------------------------\n"); for (i = 0; i < 256/8; i++) { - KPrintf("%02x", C3[i]); + printf("%02x", C3[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); i = 0; Big8wIntou8string(&C1.x, C, i); @@ -764,44 +764,44 @@ void SM9EncryptDecryptTest() for (; i < BIG8W_BYTESIZE * 2 + (256 / 8) + (mlen / 8); i++) C[i] = C2[i - (BIG8W_BYTESIZE * 2 + 256 / 8)]; - KPrintf("----------------------------below is C------------------------------------\n"); + printf("----------------------------below is C------------------------------------\n"); for (i = 0; i < BIG8W_BYTESIZE * 2 + (256 / 8) + (mlen / 8); i++) { - KPrintf("%02x", C[i]); + printf("%02x", C[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); // decrypt w = BiLinearPairing(C1, deB); - KPrintf("----------------------------below is w'-----------------------------------\n"); + printf("----------------------------below is w'-----------------------------------\n"); Q12Print(&w); JoinCwID(&C1, &w, ID_Bob, 3, C_w_id); KDF(C_w_id, c_w_id_len, klen, K); - KPrintf("----------------------------below is K'----------------------------------\n"); + printf("----------------------------below is K'----------------------------------\n"); for (i = 0; i < (klen / 8); i++) { - KPrintf("%02x", K[i]); + printf("%02x", K[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); XOR(C2, mlen / 8, K, message); - KPrintf("----------------------------below is M'----------------------------------\n"); + printf("----------------------------below is M'----------------------------------\n"); for (i = 0; i < mlen / 8; i++) { - KPrintf("%02x", message[i]); + printf("%02x", message[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); for (i = 0; i < mlen / 8; i++) C2K2[i] = C2[i]; @@ -809,53 +809,53 @@ void SM9EncryptDecryptTest() C2K2[i] = K[i]; sm3(C2K2, (mlen / 8) + (K2_len / 8), C3); - KPrintf("----------------------------below is u-----------------------------------\n"); + printf("----------------------------below is u-----------------------------------\n"); for (i = 0; i < 256 / 8; i++) { - KPrintf("%02x", C3[i]); + printf("%02x", C3[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); - KPrintf("decrypted message:\n%s\n", message); + printf("decrypted message:\n%s\n", message); - KPrintf("-------------SM9EncryptWithKDF and SM9DecryptWithKDF test----------------\n"); + printf("-------------SM9EncryptWithKDF and SM9DecryptWithKDF test----------------\n"); SM9EncryptWithKDF(message, mlen, K2_len, ID_Bob, 3, hid, Ppub_e, C); - KPrintf("------------------below is C, encrypted message--------------------------\n"); + printf("------------------below is C, encrypted message--------------------------\n"); for (i = 0; i < Cbyteslen_KDF; i++) { - KPrintf("%02x", C[i]); + printf("%02x", C[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); SM9DecryptWithKDF(ID_Bob, 3, message, 20 * 8, K2_len, C, deB); - KPrintf("---------------below is M, decrypted message in test.c-------------------\n"); - KPrintf("message:\n%s\n", message); + printf("---------------below is M, decrypted message in test.c-------------------\n"); + printf("message:\n%s\n", message); - KPrintf("-------------SM9EncryptWithSM4 and SM9DecryptWithSM4 test----------------\n"); + printf("-------------SM9EncryptWithSM4 and SM9DecryptWithSM4 test----------------\n"); SM9EncryptWithSM4(message, mlen, K1_len, K2_len, ID_Bob, 3, hid, Ppub_e, C_SM4); - KPrintf("---------------below is C_SM4 in test.c, encrypted message---------------\n"); + printf("---------------below is C_SM4 in test.c, encrypted message---------------\n"); for (i = 0; i < Cbyteslen_SM4; i++) { - KPrintf("%02x", C_SM4[i]); + printf("%02x", C_SM4[i]); if (((i + 1) & 0x3) == 0) - KPrintf(" "); + printf(" "); if (((i + 1) % 32) == 0) - KPrintf("\n"); + printf("\n"); } - KPrintf("\n"); + printf("\n"); if (!SM9DecryptWithSM4(ID_Bob, 3, sm4msg, (mlen / 8), K1_len, K2_len, C_SM4, Cbyteslen_SM4, deB)) - KPrintf("SM9DecryptWithSM4 failed\n"); - KPrintf("---------------------below is M, decrypted message-----------------------\n"); + printf("SM9DecryptWithSM4 failed\n"); + printf("---------------------below is M, decrypted message-----------------------\n"); for (i = 0; i < (mlen / 8); i++) - KPrintf("%c", sm4msg[i]); - KPrintf("\n"); + printf("%c", sm4msg[i]); + printf("\n"); free(C_w_id); free(K); diff --git a/APP_Framework/Framework/transform_layer/nuttx/transform.h b/APP_Framework/Framework/transform_layer/nuttx/transform.h index 9a05b7e1c..400bf39ff 100644 --- a/APP_Framework/Framework/transform_layer/nuttx/transform.h +++ b/APP_Framework/Framework/transform_layer/nuttx/transform.h @@ -177,6 +177,22 @@ FAR void *realloc(FAR void *oldmem, size_t size); FAR void *calloc(size_t n, size_t elem_size); void free(FAR void *mem); +/*********************shell***********************/ +//for int func(int argc, char *agrv[]) +#define PRIV_SHELL_CMD_MAIN_ATTR + +//for int func(int i, char ch, char *str) +#define PRIV_SHELL_CMD_FUNC_ATTR + +/** + * @brief Priv-shell Command definition + * + * @param _func Command function + * @param _desc Command description + * @param _attr Command attributes if need + */ +#define PRIV_SHELL_CMD_FUNCTION(_func, _desc, _attr) + /**********************mutex**************************/ int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr); diff --git a/APP_Framework/Framework/transform_layer/rtthread/transform.h b/APP_Framework/Framework/transform_layer/rtthread/transform.h index 5eb7fecee..e24bf0552 100644 --- a/APP_Framework/Framework/transform_layer/rtthread/transform.h +++ b/APP_Framework/Framework/transform_layer/rtthread/transform.h @@ -165,6 +165,23 @@ struct PrivIoctlCfg void *args; }; +/*********************shell***********************/ +//for int func(int argc, char *agrv[]) +#define PRIV_SHELL_CMD_MAIN_ATTR + +//for int func(int i, char ch, char *str) +#define PRIV_SHELL_CMD_FUNC_ATTR + +/** + * @brief Priv-shell Command definition + * + * @param _func Command function + * @param _desc Command description + * @param _attr Command attributes if need + */ +#define PRIV_SHELL_CMD_FUNCTION(_func, _desc, _attr) \ + MSH_CMD_EXPORT(_func, _desc) + /**********************mutex**************************/ int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr); diff --git a/APP_Framework/Framework/transform_layer/xizi/transform.h b/APP_Framework/Framework/transform_layer/xizi/transform.h index f6ec84fb3..eddcf2153 100644 --- a/APP_Framework/Framework/transform_layer/xizi/transform.h +++ b/APP_Framework/Framework/transform_layer/xizi/transform.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -200,6 +201,24 @@ typedef struct #define PRIV_TOUCH_DEV "/dev/touch_dev" #define MY_INDEV_X BSP_LCD_Y_MAX #define MY_INDEV_Y BSP_LCD_X_MAX + +/*********************shell***********************/ +//for int func(int argc, char *agrv[]) +#define PRIV_SHELL_CMD_MAIN_ATTR (SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)) + +//for int func(int i, char ch, char *str) +#define PRIV_SHELL_CMD_FUNC_ATTR (SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)) + +/** + * @brief Priv-shell Command definition + * + * @param _func Command function + * @param _desc Command description + * @param _attr Command attributes if need + */ +#define PRIV_SHELL_CMD_FUNCTION(_func, _desc, _attr) \ + SHELL_EXPORT_CMD(_attr, _func, _func, _desc) + /**********************mutex**************************/ int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr); diff --git a/Ubiquitous/XiZi/kernel/kernel_test/Kconfig b/Ubiquitous/XiZi/kernel/kernel_test/Kconfig index 72033058b..4a9ae18ee 100644 --- a/Ubiquitous/XiZi/kernel/kernel_test/Kconfig +++ b/Ubiquitous/XiZi/kernel/kernel_test/Kconfig @@ -57,6 +57,9 @@ menuconfig KERNEL_TEST bool "Config test i2c" default n config KERNEL_TEST_RISC_CAN - bool "Config test riscv can " + bool "Config test riscv can" + default n + config KERNEL_TEST_SPI_FLASH + bool "Config test spi flash" default n endif diff --git a/Ubiquitous/XiZi/kernel/kernel_test/Makefile b/Ubiquitous/XiZi/kernel/kernel_test/Makefile index d8d58996c..1c4f0656a 100644 --- a/Ubiquitous/XiZi/kernel/kernel_test/Makefile +++ b/Ubiquitous/XiZi/kernel/kernel_test/Makefile @@ -88,4 +88,8 @@ ifeq ($(CONFIG_KERNEL_TEST_RISC_CAN),y) SRC_FILES += riscv_test_can.c endif +ifeq ($(CONFIG_KERNEL_TEST_SPI_FLASH),y) + SRC_FILES += test_spi_flash.c +endif + include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/app_test/test_spi_flash.c b/Ubiquitous/XiZi/kernel/kernel_test/test_spi_flash.c similarity index 100% rename from APP_Framework/Applications/app_test/test_spi_flash.c rename to Ubiquitous/XiZi/kernel/kernel_test/test_spi_flash.c