forked from xuos/xiuos
				
			merge codes
This commit is contained in:
		
						commit
						7052951624
					
				|  | @ -4,10 +4,6 @@ menu "test app" | ||||||
|         default n |         default n | ||||||
| 
 | 
 | ||||||
|         if USER_TEST |         if USER_TEST | ||||||
|             config USER_TEST_SPI_FLASH |  | ||||||
|                 bool "Config test spi flash" |  | ||||||
|                 default n |  | ||||||
| 
 |  | ||||||
|             menuconfig USER_TEST_ADC |             menuconfig USER_TEST_ADC | ||||||
|                 bool "Config test adc" |                 bool "Config test adc" | ||||||
|                 default n |                 default n | ||||||
|  |  | ||||||
|  | @ -1,8 +1,4 @@ | ||||||
| SRC_FILES := | SRC_FILES := test_shell.c | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y) |  | ||||||
| 	SRC_FILES += test_spi_flash.c |  | ||||||
| endif |  | ||||||
| 
 | 
 | ||||||
| ifeq ($(CONFIG_USER_TEST_ADC),y) | ifeq ($(CONFIG_USER_TEST_ADC),y) | ||||||
| 	SRC_FILES += test_adc.c | 	SRC_FILES += test_adc.c | ||||||
|  |  | ||||||
|  | @ -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")  | ||||||
|  | @ -22,7 +22,7 @@ | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <transform.h> | #include <transform.h> | ||||||
| 
 | 
 | ||||||
| void test_adc() | void TestAdc(void) | ||||||
| { | { | ||||||
|     int adc_fd; |     int adc_fd; | ||||||
|     uint8 adc_channel = 0x0; |     uint8 adc_channel = 0x0; | ||||||
|  | @ -56,6 +56,4 @@ void test_adc() | ||||||
| 
 | 
 | ||||||
|     return; |     return; | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
|  SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), |  | ||||||
|                                                  adc, test_adc, read 3.3 voltage data from adc); |  | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <transform.h> | #include <transform.h> | ||||||
| 
 | 
 | ||||||
| void test_dac() | void TestDac(void) | ||||||
| { | { | ||||||
|     int dac_fd; |     int dac_fd; | ||||||
|     uint16 dac_set_value = 800; |     uint16 dac_set_value = 800; | ||||||
|  | @ -56,5 +56,4 @@ void test_dac() | ||||||
| 
 | 
 | ||||||
|     return; |     return; | ||||||
| } | } | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), | PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
|                                                 test_dac, test_dac, set digital data to dac); |  | ||||||
|  |  | ||||||
|  | @ -1,11 +1,26 @@ | ||||||
|  | /*
 | ||||||
|  | * 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 <xizi.h> | * @file:    test_extsram.c | ||||||
| #endif | * @brief:   a extsram test application | ||||||
|  | * @version: 2.0 | ||||||
|  | * @author:  AIIT XUOS Lab | ||||||
|  | * @date:    2022/9/26 | ||||||
|  | * | ||||||
|  | */ | ||||||
| 
 | 
 | ||||||
| #include <stdio.h> | #include <transform.h> | ||||||
| #include <stdint.h> | #include "stdio.h" | ||||||
| #include "transform.h" |  | ||||||
| 
 | 
 | ||||||
| /* parameters for sram peripheral */ | /* parameters for sram peripheral */ | ||||||
| // /* stm32f4 Bank3:0X68000000 */
 | // /* stm32f4 Bank3:0X68000000 */
 | ||||||
|  | @ -22,7 +37,7 @@ | ||||||
| 
 | 
 | ||||||
| #define TICK_PER_SECOND 100 | #define TICK_PER_SECOND 100 | ||||||
| 
 | 
 | ||||||
| int extsram_test(void) | int ExtsramTest(void) | ||||||
| { | { | ||||||
|     int i = 0; |     int i = 0; | ||||||
|     uint32_t start_time = 0, time_cast = 0; |     uint32_t start_time = 0, time_cast = 0; | ||||||
|  | @ -89,9 +104,4 @@ int extsram_test(void) | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(ExtsramTest, a extsram test 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), |  | ||||||
|     sram_test, sram_test, sram_test); |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -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 <transform.h> | ||||||
|  | 
 | ||||||
|  | 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); | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ||||||
| SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c | SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c | ||||||
| include $(KERNEL_ROOT)/compiler.mk | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  |  | ||||||
|  | @ -50,7 +50,6 @@ uint16_t tcp_socket_port = LWIP_TARGET_PORT; | ||||||
| char tcp_ip_str[128] = {0}; | char tcp_ip_str[128] = {0}; | ||||||
| 
 | 
 | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| 
 |  | ||||||
| void tcp_set_ip(char *ip_str) | void tcp_set_ip(char *ip_str) | ||||||
| { | { | ||||||
|     int ip1, ip2, ip3, ip4, port = 0; |     int ip1, ip2, ip3, ip4, port = 0; | ||||||
|  | @ -170,9 +169,7 @@ void TCPSocketRecvTest(int argc, char *argv[]) | ||||||
|     lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); |     lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); | ||||||
|     sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); |     sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(TCPSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|      TCPSocketRecv, TCPSocketRecvTest, TCP recv echo); |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| static void TCPSocketSendTask(void *arg) | static void TCPSocketSendTask(void *arg) | ||||||
|  | @ -234,12 +231,9 @@ void TCPSocketSendTest(int argc, char *argv[]) | ||||||
|     lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); |     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); |     sys_thread_new("TCP Socket Send", TCPSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(TCPSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|      TCPSocketSend, TCPSocketSendTest, TCP send demo); |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #ifdef ADD_NUTTX_FETURES | #ifdef ADD_NUTTX_FETURES | ||||||
| void tcp_recv_demo(char *ip_str) | void tcp_recv_demo(char *ip_str) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -45,7 +45,6 @@ char udp_ip_str[128] = {0}; | ||||||
| uint16_t udp_socket_port = LWIP_LOCAL_PORT; | uint16_t udp_socket_port = LWIP_LOCAL_PORT; | ||||||
| 
 | 
 | ||||||
| /*****************************************************************************/ | /*****************************************************************************/ | ||||||
| 
 |  | ||||||
| void udp_set_ip(char *ip_str) | void udp_set_ip(char *ip_str) | ||||||
| { | { | ||||||
|     int ip1, ip2, ip3, ip4, port = 0; |     int ip1, ip2, ip3, ip4, port = 0; | ||||||
|  | @ -149,9 +148,7 @@ void UdpSocketRecvTest(int argc, char *argv[]) | ||||||
|     sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, |     sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, | ||||||
|         LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); |         LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|      UDPSocketRecv, UdpSocketRecvTest, UDP Receive DEMO); |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| static void UdpSocketSendTask(void *arg) | static void UdpSocketSendTask(void *arg) | ||||||
|  | @ -211,9 +208,7 @@ void UdpSocketSendTest(int argc, char *argv[]) | ||||||
|     sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, |     sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, | ||||||
|         sLWIP_DEMO_TASK_PRIO); |         sLWIP_DEMO_TASK_PRIO); | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|      UDPSocketSend, UdpSocketSendTest, UDP send echo); |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_NUTTX_FETURES | #ifdef ADD_NUTTX_FETURES | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| SRC_DIR := | SRC_DIR := plc_demo | ||||||
| 
 | 
 | ||||||
| ifeq ($(CONFIG_RESOURCES_LWIP),y) | ifeq ($(CONFIG_RESOURCES_LWIP),y) | ||||||
| 
 | 
 | ||||||
| ifeq ($(CONFIG_USING_CONTROL_PLC_OPCUA), y) | ifeq ($(CONFIG_USING_CONTROL_PLC_OPCUA), y) | ||||||
| 	SRC_DIR += opcua_demo plc_demo | 	SRC_DIR += opcua_demo  | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| endif | endif | ||||||
|  |  | ||||||
|  | @ -20,9 +20,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <list.h> | #include <list.h> | ||||||
| #include <transform.h> | #include <transform.h> | ||||||
| #include "board.h" | #include <open62541.h> | ||||||
| #include "open62541.h" | #include <ua_api.h> | ||||||
| #include "ua_api.h" |  | ||||||
| 
 | 
 | ||||||
| /*******************************************************************************
 | /*******************************************************************************
 | ||||||
|  * Definitions |  * Definitions | ||||||
|  | @ -58,8 +57,7 @@ static void UaConnectTestTask(void* arg) | ||||||
| 
 | 
 | ||||||
|     UA_Client* client = UA_Client_new(); |     UA_Client* client = UA_Client_new(); | ||||||
| 
 | 
 | ||||||
|     if(client == NULL) |     if(client == NULL) { | ||||||
|     { |  | ||||||
|         ua_error("ua: [%s] tcp client null\n", __func__); |         ua_error("ua: [%s] tcp client null\n", __func__); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | @ -76,8 +74,7 @@ static void UaConnectTestTask(void* arg) | ||||||
| 
 | 
 | ||||||
|     ret = UA_Client_connect(client, url); |     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_error("ua: [%s] connected failed %x\n", __func__, ret); | ||||||
|         UA_Client_delete(client); |         UA_Client_delete(client); | ||||||
|         fail_cnt++; |         fail_cnt++; | ||||||
|  | @ -90,12 +87,9 @@ static void UaConnectTestTask(void* arg) | ||||||
| 
 | 
 | ||||||
| static void UaConnectTest(int argc, char *argv[]) | static void UaConnectTest(int argc, char *argv[]) | ||||||
| { | { | ||||||
|     if(argc == 2) |     if(argc == 2) { | ||||||
|     { |         if(isdigit(argv[1][0])) { | ||||||
|         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) { | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|             { |  | ||||||
|                 lw_notice("input wrong ip\n"); |                 lw_notice("input wrong ip\n"); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  | @ -105,9 +99,7 @@ static void UaConnectTest(int argc, char *argv[]) | ||||||
|     lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip); |     lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip); | ||||||
|     sys_thread_new("ua test", UaConnectTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); |     sys_thread_new("ua test", UaConnectTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(UaConnectTest, a opcua connect sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| 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); |  | ||||||
| 
 | 
 | ||||||
| void UaBrowserObjectsTestTask(void* param) | void UaBrowserObjectsTestTask(void* param) | ||||||
| { | { | ||||||
|  | @ -115,8 +107,7 @@ void UaBrowserObjectsTestTask(void* param) | ||||||
| 
 | 
 | ||||||
|     UA_Client* client = UA_Client_new(); |     UA_Client* client = UA_Client_new(); | ||||||
| 
 | 
 | ||||||
|     if(client == NULL) |     if(client == NULL) { | ||||||
|     { |  | ||||||
|         ua_error("ua: [%s] tcp client NULL\n", __func__); |         ua_error("ua: [%s] tcp client NULL\n", __func__); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | @ -125,8 +116,7 @@ void UaBrowserObjectsTestTask(void* param) | ||||||
|     UA_ClientConfig_setDefault(config); |     UA_ClientConfig_setDefault(config); | ||||||
|     UA_StatusCode ret = UA_Client_connect(client, opc_server_url); |     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_error("ua: [%s] connect failed %#x\n", __func__, ret); | ||||||
|         UA_Client_delete(client); |         UA_Client_delete(client); | ||||||
|         return; |         return; | ||||||
|  | @ -144,12 +134,9 @@ void UaBrowserObjectsTestTask(void* param) | ||||||
| 
 | 
 | ||||||
| static void* UaBrowserObjectsTest(int argc, char* argv[]) | static void* UaBrowserObjectsTest(int argc, char* argv[]) | ||||||
| { | { | ||||||
|     if(argc == 2) |     if(argc == 2) { | ||||||
|     { |         if(isdigit(argv[1][0])) { | ||||||
|         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) { | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|             { |  | ||||||
|                 lw_notice("input wrong ip\n"); |                 lw_notice("input wrong ip\n"); | ||||||
|                 return NULL; |                 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); |     sys_thread_new("ua object", UaBrowserObjectsTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); | ||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(UaBrowserObjectsTest, a opcua object sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|                  UaObject, UaBrowserObjectsTest, UaObject [IP]); |  | ||||||
| 
 | 
 | ||||||
| void UaGetInfoTestTask(void* param) | void UaGetInfoTestTask(void* param) | ||||||
| { | { | ||||||
|     UA_Client* client = UA_Client_new(); |     UA_Client* client = UA_Client_new(); | ||||||
|     ua_notice("--- Get OPUCA objects ---\n", __func__); |     ua_notice("--- Get OPUCA objects ---\n", __func__); | ||||||
| 
 | 
 | ||||||
|     if(client == NULL) |     if(client == NULL) { | ||||||
|     { |  | ||||||
|         ua_error("ua: [%s] tcp client null\n", __func__); |         ua_error("ua: [%s] tcp client null\n", __func__); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | @ -179,8 +163,7 @@ void UaGetInfoTestTask(void* param) | ||||||
|     UA_ClientConfig_setDefault(config); |     UA_ClientConfig_setDefault(config); | ||||||
|     UA_StatusCode ret = UA_Client_connect(client, opc_server_url); |     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_error("ua: [%s] connect failed %#x\n", __func__, ret); | ||||||
|         UA_Client_delete(client); |         UA_Client_delete(client); | ||||||
|         return; |         return; | ||||||
|  | @ -192,14 +175,11 @@ void UaGetInfoTestTask(void* param) | ||||||
|     UA_Client_delete(client);    /* Disconnects the client internally */ |     UA_Client_delete(client);    /* Disconnects the client internally */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void* UaGetInfoTest(int argc, char* argv[]) | void *UaGetInfoTest(int argc, char* argv[]) | ||||||
| { | { | ||||||
|     if(argc == 2) |     if(argc == 2) { | ||||||
|     { |         if(isdigit(argv[1][0])) { | ||||||
|         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) { | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|             { |  | ||||||
|                 lw_notice("input wrong ip\n"); |                 lw_notice("input wrong ip\n"); | ||||||
|                 return NULL; |                 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); |     sys_thread_new("ua info", UaGetInfoTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); | ||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(UaGetInfoTest, a opcua info sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|                  UaInfo, UaGetInfoTest, UaInfo [IP]); |  | ||||||
| 
 | 
 | ||||||
| void UaAddNodesTask(void* param) | void UaAddNodesTask(void* param) | ||||||
| { | { | ||||||
|     UA_Client* client = UA_Client_new(); |     UA_Client* client = UA_Client_new(); | ||||||
|     ua_notice("ua: [%s] start ...\n", __func__); |     ua_notice("ua: [%s] start ...\n", __func__); | ||||||
| 
 | 
 | ||||||
|     if(client == NULL) |     if(client == NULL) { | ||||||
|     { |  | ||||||
|         ua_error("ua: [%s] client null\n", __func__); |         ua_error("ua: [%s] client null\n", __func__); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | @ -229,8 +206,7 @@ void UaAddNodesTask(void* param) | ||||||
|     UA_ClientConfig_setDefault(config); |     UA_ClientConfig_setDefault(config); | ||||||
|     UA_StatusCode ret = UA_Client_connect(client, opc_server_url); |     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_print("ua: [%s] connect failed %#x\n", __func__, ret); | ||||||
|         UA_Client_delete(client); |         UA_Client_delete(client); | ||||||
|         return; |         return; | ||||||
|  | @ -242,14 +218,11 @@ void UaAddNodesTask(void* param) | ||||||
|     UA_Client_delete(client);    /* Disconnects the client internally */ |     UA_Client_delete(client);    /* Disconnects the client internally */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void* UaAddNodesTest(int argc, char* argv[]) | void *UaAddNodesTest(int argc, char* argv[]) | ||||||
| { | { | ||||||
|     if(argc == 2) |     if(argc == 2){ | ||||||
|     { |         if(isdigit(argv[1][0])) { | ||||||
|         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) { | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|             { |  | ||||||
|                 lw_notice("input wrong ip\n"); |                 lw_notice("input wrong ip\n"); | ||||||
|                 return NULL; |                 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); |     sys_thread_new("ua add nodes", UaAddNodesTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO); | ||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(UaAddNodesTest, a opcua add nodes sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), |  | ||||||
|                  UaAdd, UaAddNodesTest, UA Add Nodes); |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,3 +1,3 @@ | ||||||
| SRC_FILES := plc_show_demo.c plc_control_demo.c | SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens | ||||||
| 
 | 
 | ||||||
| include $(KERNEL_ROOT)/compiler.mk | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  |  | ||||||
|  | @ -1,48 +0,0 @@ | ||||||
| # PLC DEMO README |  | ||||||
| 
 |  | ||||||
| ## 文件说明 |  | ||||||
| 
 |  | ||||||
| 用于PLC设备相关测试命令演示,目前支持OPCUA协议对PLC进行远程控制,该命令基于LWIP和OPCUA,需要开启相关开关。 |  | ||||||
| 
 |  | ||||||
| 多个PLC设备可以组成一个channel,用于一条相关业务线控制。 |  | ||||||
| 
 |  | ||||||
| ### 命令行 |  | ||||||
| 
 |  | ||||||
| ShowChannel |  | ||||||
| 
 |  | ||||||
| 显示注册到channel上的PLC设备,范例如下: |  | ||||||
| 
 |  | ||||||
|  ch_type        ch_name        drv_name       dev_name       cnt                  |  | ||||||
| ----------------------------------------------------------------- |  | ||||||
|  PLC_Channel    PLC            OPCUA          PLC Demo 4      1    |  | ||||||
|                                               PLC Demo 3      2    |  | ||||||
|                                               PLC Demo 2      3    |  | ||||||
|                                               PLC Demo 1      4    |  | ||||||
|                                               PLC Demo 0      5   |  | ||||||
| 
 |  | ||||||
| ShowPLC |  | ||||||
| 
 |  | ||||||
| 用于显示PLC,范例如下: |  | ||||||
| 
 |  | ||||||
|  device         vendor         model          product        id                   |  | ||||||
| ----------------------------------------------------------------- |  | ||||||
|  PLC Demo 4     B&R            X20            X20 CP1381     5                    |  | ||||||
|  PLC Demo 3     B&R            X20            X20 CP1586     4                    |  | ||||||
|  PLC Demo 2     SIEMSNS        S7-200         CPU SR60       3                    |  | ||||||
|  PLC Demo 1     SIEMENS        S7-1200        CPU 1215C      2                    |  | ||||||
|  PLC Demo 0     SIEMENS        S7-1500        CPU 1512SP-1PN 1       |  | ||||||
|   |  | ||||||
|  PlcRead [NodeID]  |  | ||||||
|   |  | ||||||
|  用于读取PLC节点信息 |  | ||||||
| 
 |  | ||||||
|  - [NodeID]: 如n4,1, 其中4代表namespace,1代表节点号 |  | ||||||
|   |  | ||||||
|   |  | ||||||
|  PlcWrite |  | ||||||
|   |  | ||||||
|  用于写入PLC节点数值 |  | ||||||
|   |  | ||||||
|  - [NodeID]: 如n4,1, 其中4代表namespace,1代表节点号 |  | ||||||
| 
 |  | ||||||
|  - [value]: 为写入数值,目前支持bool类型,和int类型。bool型应为0b(代表false), 1b(代表true) |  | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := advantech_ark_2250.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 beckhoff_c6920.c | ||||||
|  |  * @brief PLC BECKHOFF C6920 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := beckhoff_c6920.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 advantech_ark_2250.c | ||||||
|  |  * @brief PLC ADVANTECH ARK-2250 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 br_x20cp0410.c | ||||||
|  |  * @brief PLC B&R X20CP0410 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 br_x20cp1381.c | ||||||
|  |  * @brief PLC B&R X20CP1381 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 br_x20cp1586.c | ||||||
|  |  * @brief PLC B&R X20CP1586 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := delta_as228t.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 delta_as228t.c | ||||||
|  |  * @brief PLC DELTA AS228T app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 delta_as332t.c | ||||||
|  |  * @brief PLC DELTA AS332T app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 mitsubishi_fx3u.c | ||||||
|  |  * @brief PLC MITSUBISHI FX3U app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 mitsubishi_fx5u.c | ||||||
|  |  * @brief PLC MITSUBISHI FX5U app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 omron_cj2m.c | ||||||
|  |  * @brief PLC OMRON CJ2M app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 omron_nj501.c | ||||||
|  |  * @brief PLC OMRON NJ501 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 omron_nx102.c | ||||||
|  |  * @brief PLC OMRON NX102 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -1,354 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (c) 2022 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 plc_control_demo.c |  | ||||||
|  * @brief Demo for PLC control |  | ||||||
|  * @version 1.0 |  | ||||||
|  * @author AIIT XUOS Lab |  | ||||||
|  * @date 2022.2.22 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #include "transform.h" |  | ||||||
| #include "open62541.h" |  | ||||||
| #include "ua_api.h" |  | ||||||
| #include "sys_arch.h" |  | ||||||
| #include "plc_demo.h" |  | ||||||
| 
 |  | ||||||
| #define PLC_NS_FORMAT "n%d,%s" |  | ||||||
| 
 |  | ||||||
| struct PlcChannel plc_demo_ch; |  | ||||||
| struct PlcDriver plc_demo_drv; |  | ||||||
| struct PlcDevice plc_demo_dev; |  | ||||||
| 
 |  | ||||||
| int plc_test_flag = 0; |  | ||||||
| 
 |  | ||||||
| PlcCtrlParamType plc_ctrl_param; |  | ||||||
| 
 |  | ||||||
| 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) |  | ||||||
|     { |  | ||||||
|         __asm("NOP"); /* delay */ |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // get NodeId from str
 |  | ||||||
| void PlcGetTestNodeId(char *str, UA_NodeId *id) |  | ||||||
| { |  | ||||||
|     static char node_str[UA_NODE_LEN]; |  | ||||||
|     memset(node_str, 0, sizeof(node_str)); |  | ||||||
| 
 |  | ||||||
|     plc_print("plc: arg %s\n", str); |  | ||||||
| 
 |  | ||||||
|     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 |  | ||||||
|         { |  | ||||||
|             id->identifierType = UA_NODEIDTYPE_STRING; |  | ||||||
|             id->identifier.string.length = strlen(node_str); |  | ||||||
|             id->identifier.string.data = node_str; |  | ||||||
|             plc_print("ns %d str %s\n", id->namespaceIndex, id->identifier.string.data); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void PlcDemoChannelDrvInit(void) |  | ||||||
| { |  | ||||||
|     static uint8_t init_flag = 0; |  | ||||||
|     if(init_flag) |  | ||||||
|         return; |  | ||||||
|     init_flag = 1; |  | ||||||
| 
 |  | ||||||
|     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) |  | ||||||
|     { |  | ||||||
|         PlcDriverAttachToChannel(PLC_DRV_NAME, PLC_CH_NAME); |  | ||||||
|     } |  | ||||||
|     memset(&plc_demo_dev, 0, sizeof(plc_demo_dev)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void PlcGetDemoDev(PlcDeviceType *dev, UA_NodeId *id) |  | ||||||
| { |  | ||||||
|     // register plc device
 |  | ||||||
|     dev->state = CHDEV_INIT; |  | ||||||
|     strcpy(dev->name, "UA Demo"); |  | ||||||
|     dev->info.product = "CPU 1215C"; |  | ||||||
|     dev->info.vendor = "SIEMENS"; |  | ||||||
|     dev->info.model = "S7-1200"; |  | ||||||
|     dev->info.id = 123; |  | ||||||
|     dev->net = PLC_IND_ENET_OPCUA; |  | ||||||
| 
 |  | ||||||
|     // register UA parameter
 |  | ||||||
|     if(!dev->priv_data) |  | ||||||
|     { |  | ||||||
|         dev->priv_data = (UaParamType*)malloc(sizeof(UaParamType)); |  | ||||||
|     } |  | ||||||
|     UaParamType* ua_ptr = dev->priv_data; |  | ||||||
|     memset(ua_ptr, 0, sizeof(UaParamType)); |  | ||||||
|     strcpy(ua_ptr->ua_remote_ip, opc_server_url); |  | ||||||
|     ua_ptr->act = UA_ACT_ATTR; |  | ||||||
|     memcpy(&ua_ptr->ua_id, id, sizeof(*id)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void PlcCtrlDemoInit(void) |  | ||||||
| { |  | ||||||
|     static uint8_t init_flag = 0; |  | ||||||
| 
 |  | ||||||
|     PlcDemoChannelDrvInit(); |  | ||||||
| 
 |  | ||||||
|     // register plc device
 |  | ||||||
|     PlcGetDemoDev(&plc_demo_dev, &test_nodeid); |  | ||||||
| 
 |  | ||||||
|     if(init_flag) |  | ||||||
|     { |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|     init_flag = 1; |  | ||||||
| 
 |  | ||||||
|     if(PlcDevRegister(&plc_demo_dev, NULL, plc_demo_dev.name) != EOK) |  | ||||||
|     { |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|     PlcDeviceAttachToChannel(plc_demo_dev.name, PLC_CH_NAME); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void PlcReadUATask(void* arg) |  | ||||||
| { |  | ||||||
|     int ret = 0; |  | ||||||
|     struct PlcOps* ops = NULL; |  | ||||||
|     char buf[PLC_BUF_SIZE]; |  | ||||||
|     memset(buf, 0, sizeof(buf)); |  | ||||||
|     PlcCtrlDemoInit(); |  | ||||||
|     ops = plc_demo_dev.ops; |  | ||||||
|     ret = ops->open(&plc_demo_dev); |  | ||||||
| 
 |  | ||||||
|     if(EOK != 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) |  | ||||||
|     { |  | ||||||
|         plc_print("plc: [%s] read failed %x\n", __func__, ret); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     ops->close(&plc_demo_dev); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void PlcReadTestShell(int argc, char* argv[]) |  | ||||||
| { |  | ||||||
|     static char node_str[UA_NODE_LEN]; |  | ||||||
|     memset(node_str, 0, sizeof(node_str)); |  | ||||||
| 
 |  | ||||||
|     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); |  | ||||||
| 
 |  | ||||||
| void PlcWriteUATask(void* arg) |  | ||||||
| { |  | ||||||
|     int ret = 0; |  | ||||||
|     struct PlcOps* ops = NULL; |  | ||||||
|     char buf[PLC_BUF_SIZE]; |  | ||||||
|     memset(buf, 0, sizeof(buf)); |  | ||||||
| 
 |  | ||||||
|     PlcCtrlDemoInit(); |  | ||||||
|     ops = plc_demo_dev.ops; |  | ||||||
|     ret = ops->open(&plc_demo_dev); |  | ||||||
| 
 |  | ||||||
|     if(EOK != 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) |  | ||||||
|     { |  | ||||||
|         plc_print("plc: [%s] write failed\n", __func__); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     ops->close(&plc_demo_dev); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void PlcWriteTestShell(int argc, char* argv[]) |  | ||||||
| { |  | ||||||
|     static char node_str[UA_NODE_LEN]; |  | ||||||
|     static char val_param[UA_NODE_LEN]; |  | ||||||
|     memset(node_str, 0, sizeof(node_str)); |  | ||||||
|     memset(val_param, 0, sizeof(val_param)); |  | ||||||
| 
 |  | ||||||
|     if(argc > 1) |  | ||||||
|     { |  | ||||||
|         PlcGetTestNodeId(argv[1], &test_nodeid); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     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); |  | ||||||
| 
 |  | ||||||
| // test motor
 |  | ||||||
| // clear parameter
 |  | ||||||
| // PlcWrite n4,2 0b
 |  | ||||||
| // PlcWrite n4,3 0b
 |  | ||||||
| // PlcWrite n4,4 0b
 |  | ||||||
| // PlcWrite n4,5 0b
 |  | ||||||
| //
 |  | ||||||
| // enable
 |  | ||||||
| // PlcWrite n4,2 1b
 |  | ||||||
| //
 |  | ||||||
| // set rotate speed
 |  | ||||||
| // PlcWrite n4,3 50
 |  | ||||||
| //
 |  | ||||||
| // positive turn
 |  | ||||||
| // PlcWrite n4,4 1b
 |  | ||||||
| //
 |  | ||||||
| // reversal turn
 |  | ||||||
| // PlcWrite n4,5 1b
 |  | ||||||
| 
 |  | ||||||
| static int plc_test_speed = 50; |  | ||||||
| static int plc_test_dir = 1; // direction positive: 1 reversal: 0
 |  | ||||||
| 
 |  | ||||||
| void PlcMotorTestTask(void* arg) |  | ||||||
| { |  | ||||||
|     //support node id
 |  | ||||||
|     char *test_nodeid[] = {"n4,2", "n4,3", "n4,4", "n4,5", "n4,7"}; |  | ||||||
|     // enable -> speed -> positive dir or inversal dir -> stop -> enable
 |  | ||||||
|     char test_sort[] = {0, 4, 2, 1, 0}; |  | ||||||
|     char test_cmd[][4] = {"1b", "50", "1b", "1b", "0b"}; |  | ||||||
|     char *test_notice[] = {"Enable Motor", "Set Speed", "Set Forward", "Set Reverse", "Stop Motor"}; |  | ||||||
| 
 |  | ||||||
|     int ret = 0; |  | ||||||
|     struct PlcOps* ops = NULL; |  | ||||||
|     char buf[PLC_BUF_SIZE]; |  | ||||||
|     memset(buf, 0, sizeof(buf)); |  | ||||||
| 
 |  | ||||||
|     PlcCtrlDemoInit(); |  | ||||||
|     ops = plc_demo_dev.ops; |  | ||||||
|     ret = ops->open(&plc_demo_dev); |  | ||||||
| 
 |  | ||||||
|     if(EOK != ret) |  | ||||||
|     { |  | ||||||
|         plc_print("plc: [%s] open failed %#x\n", __func__, ret); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     UaParamType* ua_ptr = plc_demo_dev.priv_data; |  | ||||||
| 
 |  | ||||||
|     // initialize step
 |  | ||||||
|     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) |  | ||||||
|         { |  | ||||||
|             plc_print("plc: [%s] %d write failed\n", __func__, __LINE__); |  | ||||||
|         } |  | ||||||
|         PlcDelay(1); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     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++) |  | ||||||
|     { |  | ||||||
|         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) |  | ||||||
|         { |  | ||||||
|             plc_print("plc: [%s] %d write failed\n", __func__, __LINE__); |  | ||||||
|         } |  | ||||||
|         PlcDelay(1); |  | ||||||
|         if(i == 2) // postive
 |  | ||||||
|         { |  | ||||||
|             PlcDelay(10); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     ops->close(&plc_demo_dev); |  | ||||||
|     plc_test_flag = 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // get parameter from
 |  | ||||||
| void PlcGetMotorParam(char *str) |  | ||||||
| { |  | ||||||
|     static char node_str[UA_NODE_LEN]; |  | ||||||
|     memset(node_str, 0, sizeof(node_str)); |  | ||||||
| 
 |  | ||||||
|     plc_print("plc: arg %s\n", str); |  | ||||||
| 
 |  | ||||||
|     sscanf(str, "speed=%d", &plc_test_speed); |  | ||||||
|     sscanf(str, "dir=%d", &plc_test_dir); |  | ||||||
|     plc_print("speed is %d\n", plc_test_speed); |  | ||||||
|     plc_print("dir is %d\n", plc_test_dir); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void PlcMotorTestShell(int argc, char* argv[]) |  | ||||||
| { |  | ||||||
|     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++) |  | ||||||
|         { |  | ||||||
|             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); |  | ||||||
| 
 |  | ||||||
|  | @ -1,257 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (c) 2022 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 plc_show_demo.c |  | ||||||
|  * @brief Demo for PLC information show |  | ||||||
|  * @version 1.0 |  | ||||||
|  * @author AIIT XUOS Lab |  | ||||||
|  * @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" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| #define PLC_DEMO_NUM 5 |  | ||||||
| 
 |  | ||||||
| struct PlcDevice plc_demo_array[PLC_DEMO_NUM]; |  | ||||||
| 
 |  | ||||||
| typedef struct PlcShowParam |  | ||||||
| { |  | ||||||
|     int id; |  | ||||||
|     char* vector; |  | ||||||
|     char* model; |  | ||||||
|     char* product; |  | ||||||
| } PlcShowParamType; |  | ||||||
| 
 |  | ||||||
| PlcShowParamType plc_demo_param[PLC_NAME_SIZE] = |  | ||||||
| { |  | ||||||
|     {1, "SIEMENS", "S7-1500", "CPU 1512SP-1PN"}, |  | ||||||
|     {2, "SIEMENS", "S7-1200", "CPU 1215C"}, |  | ||||||
|     {3, "SIEMSNS", "S7-200", "CPU SR60"}, |  | ||||||
|     {4, "B&R", "X20", "X20 CP1586"}, |  | ||||||
|     {5, "B&R", "X20", "X20 CP1381"} |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| static char* const channel_type_str[] = |  | ||||||
| { |  | ||||||
|     "PLC_Channel", |  | ||||||
|     "Unknown" |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| extern DoublelistType plcdev_list; |  | ||||||
| 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]); |  | ||||||
| 
 |  | ||||||
|     while(i < max_len) |  | ||||||
|     { |  | ||||||
|         i++; |  | ||||||
| 
 |  | ||||||
|         if(max_len == i) |  | ||||||
|         { |  | ||||||
|             KPrintf("-\n"); |  | ||||||
|         } |  | ||||||
|         else |  | ||||||
|         { |  | ||||||
|             KPrintf("-"); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static ChDrvType ShowChannelFindDriver(struct Channel* ch) |  | ||||||
| { |  | ||||||
|     struct ChDrv* driver = NONE; |  | ||||||
|     DoublelistType* node = NONE; |  | ||||||
|     DoublelistType* head = &ch->ch_drvlink; |  | ||||||
| 
 |  | ||||||
|     for(node = head->node_next; node != head; node = node->node_next) |  | ||||||
|     { |  | ||||||
|         driver = DOUBLE_LIST_ENTRY(node, struct ChDrv, driver_link); |  | ||||||
|         return driver; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return NONE; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void PlcShowDemoInit(void) |  | ||||||
| { |  | ||||||
|     static uint8_t init_flag = 0; |  | ||||||
|     int i; |  | ||||||
|     PlcDemoChannelDrvInit(); |  | ||||||
| 
 |  | ||||||
|     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); |  | ||||||
|         plc_demo_array[i].info.vendor = plc_demo_param[i].vector; |  | ||||||
|         plc_demo_array[i].info.model = plc_demo_param[i].model; |  | ||||||
|         plc_demo_array[i].info.id = plc_demo_param[i].id; |  | ||||||
|         plc_demo_array[i].info.product = plc_demo_param[i].product; |  | ||||||
|         plc_demo_array[i].net = PLC_IND_ENET_OPCUA; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if(init_flag) |  | ||||||
|         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) |  | ||||||
|         { |  | ||||||
|             PlcDeviceAttachToChannel(plc_demo_array[i].name, PLC_CH_NAME); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void PlcShowChannel(void) |  | ||||||
| { |  | ||||||
|     ChannelType ch; |  | ||||||
|     ChDrvType driver; |  | ||||||
|     ChDevType device; |  | ||||||
|     int dev_cnt; |  | ||||||
|     DoublelistType* ch_node = NONE; |  | ||||||
|     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 |  | ||||||
|     { |  | ||||||
|         ch = DOUBLE_LIST_ENTRY(ch_node, struct Channel, ch_link); |  | ||||||
| 
 |  | ||||||
|         if((ch) && (ch->ch_type == CH_PLC_TYPE)) |  | ||||||
|         { |  | ||||||
|             KPrintf("%s", " "); |  | ||||||
|             KPrintf("%-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(ch->haldev_cnt) |  | ||||||
|             { |  | ||||||
|                 DoublelistType* dev_node = NONE; |  | ||||||
|                 DoublelistType* dev_head = &ch->ch_devlink; |  | ||||||
|                 dev_node = dev_head->node_next; |  | ||||||
|                 dev_cnt = 1; |  | ||||||
| 
 |  | ||||||
|                 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); |  | ||||||
|                         } |  | ||||||
|                         else |  | ||||||
|                         { |  | ||||||
|                             KPrintf("%-16s%-4d\n", "nil", dev_cnt); |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         KPrintf("%46s", " "); |  | ||||||
| 
 |  | ||||||
|                         if(device) |  | ||||||
|                         { |  | ||||||
|                             KPrintf("%-16s%-4d\n", device->dev_name, dev_cnt); |  | ||||||
|                         } |  | ||||||
|                         else |  | ||||||
|                         { |  | ||||||
|                             KPrintf("%-16s%-4d\n", "nil", dev_cnt); |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     dev_cnt++; |  | ||||||
|                     dev_node = dev_node->node_next; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 KPrintf("\n"); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         ch_node = ch_node->node_next; |  | ||||||
|     } |  | ||||||
|     while(ch_node != ch_head); |  | ||||||
| 
 |  | ||||||
|     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); |  | ||||||
| 
 |  | ||||||
| void PlcShowDev(void) |  | ||||||
| { |  | ||||||
|     PlcDeviceType* plc_dev; |  | ||||||
|     ChDrvType driver; |  | ||||||
|     ChDevType device; |  | ||||||
|     DoublelistType* plc_node = NONE; |  | ||||||
|     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 |  | ||||||
|     { |  | ||||||
|         plc_dev = DOUBLE_LIST_ENTRY(plc_node, struct PlcDevice, link); |  | ||||||
| 
 |  | ||||||
|         if(plc_dev) |  | ||||||
|         { |  | ||||||
|             KPrintf("%s", " "); |  | ||||||
|             KPrintf("%-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"); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         plc_node = plc_node->node_next; |  | ||||||
|     } |  | ||||||
|     while(plc_node != plc_head); |  | ||||||
| 
 |  | ||||||
|     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); |  | ||||||
| 
 |  | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := schneider_m241.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 schneider_m241.c | ||||||
|  |  * @brief PLC SCHNEIDER M241 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_FILES := siemens_s7_200_cn.c siemens_s7_200_smart.c siemens_s7_300.c siemens_s7_1200.c siemens_s7_1500.c | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 siemens_s7_1200.c | ||||||
|  |  * @brief PLC SIEMENS S7-1200 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 siemens_s7_1500.c | ||||||
|  |  * @brief PLC SIEMENS S7-1500 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 siemens_s7_200_cn.c | ||||||
|  |  * @brief PLC SIEMENS S7-200CN app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 siemens_s7_200_smart.c | ||||||
|  |  * @brief PLC SIEMENS S7-200 SMART app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2022 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 siemens_s7_300.c | ||||||
|  |  * @brief PLC SIEMENS S7-300 app | ||||||
|  |  * @version 3.0 | ||||||
|  |  * @author AIIT XUOS Lab | ||||||
|  |  * @date 2022.9.27 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -123,7 +123,4 @@ int flashdb_app(void) | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(flashdb_app, a flashdb test sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| #ifdef __RT_THREAD_H__ |  | ||||||
| MSH_CMD_EXPORT(flashdb_app, flashdb test); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|  | @ -26,6 +26,3 @@ void mnist_app(void); | ||||||
| int tfmnist(void) { | int tfmnist(void) { | ||||||
|     mnist_app(); |     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
 |  | ||||||
|  | @ -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 <lvgl.h> | #include <lvgl.h> | ||||||
| #include <lv_port_indev_template.h> | #include <lv_port_indev_template.h> | ||||||
| #include "lv_demo_calendar.h" | #include "lv_demo_calendar.h" | ||||||
|  | @ -38,5 +59,4 @@ static int lvgl_demo_init(void) | ||||||
| 
 | 
 | ||||||
|     return 0; |     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); | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -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 <lvgl.h> | #include <lvgl.h> | ||||||
| #include "lv_demo_calendar.h" | #include "lv_demo_calendar.h" | ||||||
| // #include <drv_lcd.h>
 | // #include <drv_lcd.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__ | #ifndef __LV_DEMO_CALENDAR_H__ | ||||||
| #define __LV_DEMO_CALENDAR_H__ | #define __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_init.c | ||||||
|  | * @brief:   init littleVgl | ||||||
|  | * @version: 2.0 | ||||||
|  | * @author:  AIIT XUOS Lab | ||||||
|  | * @date:    2022/9/26 | ||||||
|  | * | ||||||
|  | */ | ||||||
|  | 
 | ||||||
| #include <lvgl.h> | #include <lvgl.h> | ||||||
| #define DBG_TAG    "LVGL" | #define DBG_TAG    "LVGL" | ||||||
| #define DBG_LVL    DBG_INFO | #define DBG_LVL    DBG_INFO | ||||||
|  |  | ||||||
|  | @ -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" | #include "lv_sensor_info.h" | ||||||
| 
 | 
 | ||||||
| static void draw_part_event_cb(lv_event_t* e) { | 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) { | char *Double2Str(char* buf, double value) { | ||||||
| 	sprintf(buf,"%.8f",value);//保留8位小数,不够补0
 | 	sprintf(buf,"%.8f",value);//keep 8 bit float data
 | ||||||
| 	int index = 0; | 	int index = 0; | ||||||
| 	int len = strlen(buf); | 	int len = strlen(buf); | ||||||
| 	for(int i = len-1;i>0;i--) | 	for(int i = len-1;i>0;i--) { | ||||||
| 	{ |  | ||||||
| 		if(buf[i] == '0') | 		if(buf[i] == '0') | ||||||
| 			continue; | 			continue; | ||||||
|         else { |         else { | ||||||
|  | @ -71,8 +91,7 @@ void lv_sensor_info(void) { | ||||||
|     for (uint32_t i = 0; i < 2 * NR_VAL_PERLINE; ++i) { |     for (uint32_t i = 0; i < 2 * NR_VAL_PERLINE; ++i) { | ||||||
|         if (i % 2 == 0) { |         if (i % 2 == 0) { | ||||||
|             lv_table_set_col_width(lv_ssr_tb, i, 75); |             lv_table_set_col_width(lv_ssr_tb, i, 75); | ||||||
|         } |         } else { | ||||||
|         else { |  | ||||||
|             lv_table_set_col_width(lv_ssr_tb, i, 85); |             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); |     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(); |     lv_sensor_info(); | ||||||
|     PrivMutexCreate(&ssr_val_lock, 0); |     PrivMutexCreate(&ssr_val_lock, 0); | ||||||
|     while (1) |     while (1) { | ||||||
|     { |  | ||||||
|         lv_task_handler(); |         lv_task_handler(); | ||||||
| 
 | 
 | ||||||
|         sensor_update_table(); |         sensor_update_table(); | ||||||
|  | @ -123,5 +141,4 @@ static int lvgl_show_sensor_info(void) | ||||||
| 
 | 
 | ||||||
|     return 0; |     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); | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -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__ | #ifndef __LVGL_SENSOR_INFO_H__ | ||||||
| #define __LVGL_SENSOR_INFO_H__ | #define __LVGL_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_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" | #include "lv_sensor_info.h" | ||||||
| 
 | 
 | ||||||
| void* lvgl_thd_sensor_info_update_demo(void *parameter) | void* lvgl_thd_sensor_info_update_demo(void *parameter) | ||||||
|  | @ -28,5 +49,4 @@ static int lvgl_sensor_info_update_demo(void) | ||||||
| 
 | 
 | ||||||
|     return 0; |     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); | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -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" | #include "lv_sensor_info.h" | ||||||
| 
 | 
 | ||||||
| uint32_t lv_ssr_map_idx(enum sensor_type st) { | uint32_t lv_ssr_map_idx(enum sensor_type st) { | ||||||
|  |  | ||||||
|  | @ -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 <stdio.h> | #include <stdio.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  |  | ||||||
|  | @ -18,7 +18,6 @@ | ||||||
|  * @date 2021.12.23 |  * @date 2021.12.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <user_api.h> |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,9 +18,6 @@ | ||||||
|  * @date 2021.12.10 |  * @date 2021.12.10 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,9 +18,7 @@ | ||||||
|  * @date 2021.12.23 |  * @date 2021.12.23 | ||||||
|  */ |  */ | ||||||
| //
 | //
 | ||||||
| #ifdef ADD_XIZI_FETURES | 
 | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,9 +18,6 @@ | ||||||
|  * @date 2021.04.23 |  * @date 2021.04.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,12 +18,8 @@ | ||||||
|  * @date 2021.12.15 |  * @date 2021.12.15 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|  * @description: Read a hcho |  * @description: Read a hcho | ||||||
|  * @return 0 |  * @return 0 | ||||||
|  |  | ||||||
|  | @ -18,10 +18,6 @@ | ||||||
|  * @date 2021.04.23 |  * @date 2021.04.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | @ -31,7 +27,7 @@ | ||||||
| void HumiHs300x(void) | void HumiHs300x(void) | ||||||
| { | { | ||||||
|     int i = 0; |     int i = 0; | ||||||
|     int32 humidity; |     int32_t humidity; | ||||||
|     struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI); |     struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI); | ||||||
|     SensorQuantityOpen(humi); |     SensorQuantityOpen(humi); | ||||||
|     for (i = 0; i < 100; i ++) { |     for (i = 0; i < 100; i ++) { | ||||||
|  |  | ||||||
|  | @ -18,18 +18,8 @@ | ||||||
|  * @date 2021.12.14 |  * @date 2021.12.14 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| // struct iaq_data {
 |  | ||||||
| //     uint16_t gas;
 |  | ||||||
| //     uint8_t TH;
 |  | ||||||
| //     uint8_t TL;
 |  | ||||||
| //     uint8_t RhH;
 |  | ||||||
| //     uint8_t RhL;
 |  | ||||||
| // };
 |  | ||||||
| /**
 | /**
 | ||||||
|  * @description: Read a iaq |  * @description: Read a iaq | ||||||
|  * @return 0 |  * @return 0 | ||||||
|  |  | ||||||
|  | @ -18,10 +18,6 @@ | ||||||
|  * @date 2021.04.23 |  * @date 2021.04.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,10 +18,6 @@ | ||||||
|  * @date 2021.04.23 |  * @date 2021.04.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,10 +18,6 @@ | ||||||
|  * @date 2021.12.28 |  * @date 2021.12.28 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -18,10 +18,6 @@ | ||||||
|  * @date 2021.04.23 |  * @date 2021.04.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | @ -31,7 +27,7 @@ | ||||||
| void TempHs300x(void) | void TempHs300x(void) | ||||||
| { | { | ||||||
|     int i = 0; |     int i = 0; | ||||||
|     int32 temperature; |     int32_t temperature; | ||||||
|     struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP); |     struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP); | ||||||
|     SensorQuantityOpen(temp); |     SensorQuantityOpen(temp); | ||||||
|     for (i = 0; i < 100; i ++) { |     for (i = 0; i < 100; i ++) { | ||||||
|  |  | ||||||
|  | @ -18,12 +18,8 @@ | ||||||
|  * @date 2021.12.15 |  * @date 2021.12.15 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_XIZI_FETURES |  | ||||||
| # include <user_api.h> |  | ||||||
| #endif |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|  * @description: Read a tvoc |  * @description: Read a tvoc | ||||||
|  * @return 0 |  * @return 0 | ||||||
|  |  | ||||||
|  | @ -18,7 +18,6 @@ | ||||||
|  * @date 2021.04.23 |  * @date 2021.04.23 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <transform.h> |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | @ -30,7 +29,7 @@ void VoiceD124(void) | ||||||
|     struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE); |     struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE); | ||||||
|     SensorQuantityOpen(voice); |     SensorQuantityOpen(voice); | ||||||
|     PrivTaskDelay(2000); |     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)); |     printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places)); | ||||||
|     SensorQuantityClose(voice); |     SensorQuantityClose(voice); | ||||||
| } | } | ||||||
|  | @ -18,7 +18,6 @@ | ||||||
|  * @date 2021.12.14 |  * @date 2021.12.14 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <transform.h> |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | @ -30,11 +29,7 @@ void WindDirectionQsFx(void) | ||||||
|     struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION); |     struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION); | ||||||
|     SensorQuantityOpen(wind_direction); |     SensorQuantityOpen(wind_direction); | ||||||
|     PrivTaskDelay(2000); |     PrivTaskDelay(2000); | ||||||
|     uint16 result = SensorQuantityReadValue(wind_direction); |     uint16_t result = SensorQuantityReadValue(wind_direction); | ||||||
|     printf("wind direction : %d degree\n", result); |     printf("wind direction : %d degree\n", result); | ||||||
|     SensorQuantityClose(wind_direction); |     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 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -18,7 +18,6 @@ | ||||||
|  * @date 2021.12.14 |  * @date 2021.12.14 | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <transform.h> |  | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | @ -30,11 +29,7 @@ void WindSpeedQsFs(void) | ||||||
|     struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED); |     struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED); | ||||||
|     SensorQuantityOpen(wind_speed); |     SensorQuantityOpen(wind_speed); | ||||||
|     PrivTaskDelay(2000); |     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); |     printf("wind speed : %d.%d m/s\n", result/10, result%10); | ||||||
|     SensorQuantityClose(wind_speed); |     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 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -110,10 +110,4 @@ int Adapter4GTest(void) | ||||||
| 
 | 
 | ||||||
|     return 0;     |     return 0;     | ||||||
| } | } | ||||||
| 
 | PRIV_SHELL_CMD_FUNCTION(Adapter4GTest, a EC200T adpter sample, PRIV_SHELL_CMD_FUNC_ATTR); | ||||||
| #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 |  | ||||||
|  |  | ||||||
|  | @ -8,11 +8,11 @@ if SUPPORT_CONNECTION_FRAMEWORK | ||||||
|         bool "Using connection framework debug log function" |         bool "Using connection framework debug log function" | ||||||
|         default y |         default y | ||||||
| 
 | 
 | ||||||
|         menuconfig CONNECTION_INDUSTRIAL_ETHERNET |         menuconfig CONNECTION_INDUSTRIAL_NETWORK | ||||||
|                 bool "Using industrial ethernet" |                 bool "Using industrial network" | ||||||
|                 default n |                 default n | ||||||
|         if CONNECTION_INDUSTRIAL_ETHERNET |         if CONNECTION_INDUSTRIAL_NETWORK | ||||||
|         source "$APP_DIR/Framework/connection/industrial_ethernet/Kconfig" |         source "$APP_DIR/Framework/connection/industrial_network/Kconfig" | ||||||
|         endif |         endif | ||||||
| 
 | 
 | ||||||
|         menuconfig CONNECTION_INDUSTRIAL_FIELDBUS |         menuconfig CONNECTION_INDUSTRIAL_FIELDBUS | ||||||
|  |  | ||||||
|  | @ -9,8 +9,8 @@ endif | ||||||
| ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ||||||
|     SRC_FILES := adapter.c adapter_agent.c |     SRC_FILES := adapter.c adapter_agent.c | ||||||
| 
 | 
 | ||||||
|     ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_ETHERNET),y) |     ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_NETWORK),y) | ||||||
|         SRC_DIR += industrial_ethernet |         SRC_DIR += industrial_network | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|     ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y) |     ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y) | ||||||
|  |  | ||||||
|  | @ -111,9 +111,4 @@ int AdapterBlueToothTest(void) | ||||||
| 
 | 
 | ||||||
|     return 0;     |     return 0;     | ||||||
| } | } | ||||||
| #ifdef ADD_RTTHREAD_FETURES | PRIV_SHELL_CMD_FUNCTION(AdapterBlueToothTest, a bluetooth test sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| 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 |  | ||||||
|  |  | ||||||
|  | @ -122,8 +122,4 @@ int AdapterEthernetTest(void) | ||||||
|      |      | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| #ifdef ADD_RTTHREAD_FETURES | PRIV_SHELL_CMD_FUNCTION(AdapterEthernetTest, a ethernet test sample, PRIV_SHELL_CMD_MAIN_ATTR); | ||||||
| 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 |  | ||||||
|  |  | ||||||
|  | @ -1,15 +0,0 @@ | ||||||
| config CONNECTION_ADAPTER_ETHERCAT |  | ||||||
|     bool "Using ethercat on industrial_ethernet adapter device" |  | ||||||
|     default n |  | ||||||
| 
 |  | ||||||
|     if CONNECTION_ADAPTER_ETHERCAT |  | ||||||
|         source "$APP_DIR/Framework/connection/industrial_ethernet/ethercat/Kconfig" |  | ||||||
|     endif |  | ||||||
| 
 |  | ||||||
| menuconfig POWERLINK_MN |  | ||||||
|     bool "Using powerlink MN" |  | ||||||
|     default n |  | ||||||
| 
 |  | ||||||
| menuconfig POWERLINK_CN |  | ||||||
|     bool "Using powerlink CN" |  | ||||||
|     default n |  | ||||||
|  | @ -1,28 +0,0 @@ | ||||||
| #include <xizi.h> |  | ||||||
| #include <xsconfig.h> |  | ||||||
| 
 |  | ||||||
| #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)); |  | ||||||
| #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)); |  | ||||||
| #endif |  | ||||||
|  | @ -1,2 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
| 
 | 
 | ||||||
| include $(KERNEL_ROOT)/compiler.mk | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  |  | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,15 @@ | ||||||
|  | config CONNECTION_ADAPTER_ETHERCAT | ||||||
|  |     bool "Using EtherCAT on industrial network adapter device" | ||||||
|  |     default n | ||||||
|  | 
 | ||||||
|  |     if CONNECTION_ADAPTER_ETHERCAT | ||||||
|  |         source "$APP_DIR/Framework/connection/industrial_network/ethercat/Kconfig" | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|  | config CONNECTION_ADAPTER_POWERLINK | ||||||
|  |     bool "Using POWERLINK on industrial network adapter device" | ||||||
|  |     default n | ||||||
|  | 
 | ||||||
|  |     if CONNECTION_ADAPTER_POWERLINK | ||||||
|  |         source "$APP_DIR/Framework/connection/industrial_network/powerlink/Kconfig" | ||||||
|  |     endif | ||||||
|  | @ -0,0 +1,11 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | ifeq ($(CONFIG_CONNECTION_ADAPTER_POWERLINK),y) | ||||||
|  | 	SRC_DIR += powerlink | ||||||
|  | endif | ||||||
|  | 
 | ||||||
|  | ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERCAT),y) | ||||||
|  | 	SRC_DIR += ethercat | ||||||
|  | endif | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | SRC_DIR :=  | ||||||
|  | 
 | ||||||
|  | include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | @ -2,10 +2,10 @@ config ADAPTER_HFA21_ETHERCAT | ||||||
|         depends on ADAPTER_HFA21_ETHERNET # ADAPTER_HFA21_WIFI |         depends on ADAPTER_HFA21_ETHERNET # ADAPTER_HFA21_WIFI | ||||||
|         help |         help | ||||||
|             Ethercat is dependant on Ethernet. Please enable hfa21 ethernet first. And this is a software-defined experiment module, without supports on ECS and on-the-fly. |             Ethercat is dependant on Ethernet. Please enable hfa21 ethernet first. And this is a software-defined experiment module, without supports on ECS and on-the-fly. | ||||||
|         bool "Using ethercat on ethernet adapter device HFA21" |         bool "Using ethercat on industrial network adapter device HFA21" | ||||||
|         default n |         default n | ||||||
| 
 | 
 | ||||||
|     if ADAPTER_HFA21_ETHERCAT |     if ADAPTER_HFA21_ETHERCAT | ||||||
|         source "$APP_DIR/Framework/connection/industrial_ethernet/ethercat/hfa21_ethercat/Kconfig" |         source "$APP_DIR/Framework/connection/industrial_network/ethercat/hfa21_ethercat/Kconfig" | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|  | @ -205,4 +205,4 @@ int AdapterEthercatTest(void) | ||||||
| 
 | 
 | ||||||
|     return 0; |     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); | ||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue