forked from xuos/xiuos
Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into develop
This commit is contained in:
commit
64da177d6a
|
@ -2,6 +2,7 @@
|
|||
# APP_Framework/Applications/Make.defs
|
||||
############################################################################
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
|
||||
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)
|
||||
|
|
|
@ -4,10 +4,6 @@ menu "test app"
|
|||
default n
|
||||
|
||||
if USER_TEST
|
||||
config USER_TEST_SPI_FLASH
|
||||
bool "Config test spi flash"
|
||||
default n
|
||||
|
||||
menuconfig USER_TEST_ADC
|
||||
bool "Config test adc"
|
||||
default n
|
||||
|
@ -29,5 +25,9 @@ menu "test app"
|
|||
default "/dev/dac_dev"
|
||||
endif
|
||||
endif
|
||||
|
||||
config USER_TEST_SEMC
|
||||
bool "Config test semc sdram"
|
||||
default n
|
||||
endif
|
||||
endmenu
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Applications/app_test/Make.defs
|
||||
############################################################################
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
|
||||
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/app_test/*/Make.defs)
|
||||
|
|
@ -1,8 +1,4 @@
|
|||
SRC_FILES :=
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y)
|
||||
SRC_FILES += test_spi_flash.c
|
||||
endif
|
||||
SRC_FILES := test_shell.c
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_ADC),y)
|
||||
SRC_FILES += test_adc.c
|
||||
|
@ -12,4 +8,18 @@ ifeq ($(CONFIG_USER_TEST_DAC),y)
|
|||
SRC_FILES += test_dac.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USER_TEST_SEMC),y)
|
||||
SRC_FILES += test_extsram.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += test_extsram.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
|
|
|
@ -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 <transform.h>
|
||||
|
||||
void test_adc()
|
||||
void TestAdc(void)
|
||||
{
|
||||
int adc_fd;
|
||||
uint8 adc_channel = 0x0;
|
||||
|
@ -56,6 +56,4 @@ void test_adc()
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||
adc, test_adc, read 3.3 voltage data from adc);
|
||||
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <string.h>
|
||||
#include <transform.h>
|
||||
|
||||
void test_dac()
|
||||
void TestDac(void)
|
||||
{
|
||||
int dac_fd;
|
||||
uint16 dac_set_value = 800;
|
||||
|
@ -56,5 +56,4 @@ void test_dac()
|
|||
|
||||
return;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||
test_dac, test_dac, set digital data to dac);
|
||||
PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* 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_extsram.c
|
||||
* @brief: a extsram test application
|
||||
* @version: 2.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/9/26
|
||||
*
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
/* parameters for sram peripheral */
|
||||
// /* stm32f4 Bank3:0X68000000 */
|
||||
// #define SRAM_BANK_ADDR ((uint32_t)0X68000000)
|
||||
|
||||
/* OK-1052 semc:0X80000000 */
|
||||
#define SRAM_BANK_ADDR ((uint32_t)0X80000000)
|
||||
|
||||
/* data width: 8, 16, 32 */
|
||||
#define SRAM_DATA_WIDTH 16
|
||||
|
||||
/* sram size */
|
||||
#define SRAM_SIZE ((uint32_t)0x2000000)
|
||||
|
||||
#define TICK_PER_SECOND 100
|
||||
|
||||
int ExtsramTest(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint32_t start_time = 0, time_cast = 0;
|
||||
#if SRAM_DATA_WIDTH == 8
|
||||
char data_width = 1;
|
||||
uint8_t data = 0;
|
||||
#elif SRAM_DATA_WIDTH == 16
|
||||
char data_width = 2;
|
||||
uint16_t data = 0;
|
||||
#else
|
||||
char data_width = 4;
|
||||
uint32_t data = 0;
|
||||
#endif
|
||||
|
||||
/* write data */
|
||||
printf("Writing the %ld bytes data, waiting....", SRAM_SIZE);
|
||||
start_time = PrivGetTickTime();
|
||||
for (i = 0; i < SRAM_SIZE / data_width; i++)
|
||||
{
|
||||
#if SRAM_DATA_WIDTH == 8
|
||||
*(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width) = (uint8_t)0x55;
|
||||
#elif SRAM_DATA_WIDTH == 16
|
||||
*(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width) = (uint16_t)0x5555;
|
||||
#else
|
||||
*(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width) = (uint32_t)0x55555555;
|
||||
#endif
|
||||
}
|
||||
time_cast = PrivGetTickTime() - start_time;
|
||||
printf("Write data success, total time: %ld.%03ldS.\n", time_cast / TICK_PER_SECOND,
|
||||
time_cast % TICK_PER_SECOND / ((TICK_PER_SECOND * 1 + 999) / 1000));
|
||||
|
||||
/* read data */
|
||||
printf("start Reading and verifying data, waiting....\n");
|
||||
for (i = 0; i < SRAM_SIZE / data_width; i++)
|
||||
{
|
||||
#if SRAM_DATA_WIDTH == 8
|
||||
data = *(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||
if (data != 0x55)
|
||||
{
|
||||
printf("SRAM test failed!");
|
||||
break;
|
||||
}
|
||||
#elif SRAM_DATA_WIDTH == 16
|
||||
data = *(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||
if (data != 0x5555)
|
||||
{
|
||||
printf("SRAM test failed! data = 0x%x\n",data);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
data = *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||
if (data != 0x55555555)
|
||||
{
|
||||
printf("SRAM test failed!");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i >= SRAM_SIZE / data_width)
|
||||
{
|
||||
printf("SRAM test success!\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(ExtsramTest, a extsram test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
|
@ -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);
|
|
@ -3,5 +3,11 @@ menu "connection app"
|
|||
menuconfig APPLICATION_CONNECTION
|
||||
bool "Using connection apps"
|
||||
default n
|
||||
|
||||
|
||||
if APPLICATION_CONNECTION
|
||||
menuconfig SOCKET_DEMO
|
||||
bool "Config test socket demo"
|
||||
default n
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Application/connection_app/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_APPLICATION_CONNECTION),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo
|
||||
endif
|
|
@ -1,7 +1,20 @@
|
|||
SRC_DIR :=
|
||||
|
||||
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
||||
SRC_DIR += socket_demo
|
||||
ifeq ($(CONFIG_SOCKET_DEMO),y)
|
||||
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
|
||||
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
||||
SRC_DIR += socket_demo
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Application/connection_app/socket_demo/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SOCKET_DEMO),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo/*/Make.defs
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo/*/Make.defs)
|
||||
endif
|
|
@ -1,3 +1,12 @@
|
|||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
|
|
|
@ -19,17 +19,43 @@
|
|||
*/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#include "sys_arch.h"
|
||||
#include <lwip/sockets.h>
|
||||
#include "lwip/sys.h"
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include "stdio.h"
|
||||
#endif
|
||||
|
||||
#define TCP_DEMO_BUF_SIZE 65535
|
||||
|
||||
char tcp_socket_ip[] = {192, 168, 250, 252};
|
||||
u16_t tcp_socket_port = LWIP_TARGET_PORT;
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#define lw_print printf
|
||||
#define lw_notice printf
|
||||
#define lw_error printf
|
||||
|
||||
#define LWIP_DEMO_TIMES 3
|
||||
|
||||
/** Create u32_t value from bytes */
|
||||
#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
|
||||
((uint32_t)((b) & 0xff) << 16) | \
|
||||
((uint32_t)((c) & 0xff) << 8) | \
|
||||
(uint32_t)((d) & 0xff))
|
||||
|
||||
#define PP_HTONL(x) ((uint32_t)(x))
|
||||
#define LWIP_TARGET_PORT 6000
|
||||
#endif
|
||||
|
||||
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static void TCPSocketRecvTask(void *arg)
|
||||
{
|
||||
int fd = -1, clientfd;
|
||||
|
@ -38,18 +64,15 @@ static void TCPSocketRecvTask(void *arg)
|
|||
struct sockaddr_in tcp_addr;
|
||||
socklen_t addr_len;
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE);
|
||||
if (recv_buf == NULL)
|
||||
{
|
||||
if (recv_buf == NULL) {
|
||||
lw_error("No memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (fd < 0) {
|
||||
lw_error("Socket error\n");
|
||||
free(recv_buf);
|
||||
continue;
|
||||
|
@ -60,10 +83,9 @@ static void TCPSocketRecvTask(void *arg)
|
|||
tcp_addr.sin_port = htons(tcp_socket_port);
|
||||
memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero));
|
||||
|
||||
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) {
|
||||
lw_error("Unable to bind\n");
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
continue;
|
||||
}
|
||||
|
@ -72,10 +94,9 @@ static void TCPSocketRecvTask(void *arg)
|
|||
lw_notice("\n\nLocal Port:%d\n\n", tcp_socket_port);
|
||||
|
||||
// setup socket fd as listening mode
|
||||
if (listen(fd, 5) != 0 )
|
||||
{
|
||||
if (listen(fd, 5) != 0 ) {
|
||||
lw_error("Unable to listen\n");
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
continue;
|
||||
}
|
||||
|
@ -84,12 +105,10 @@ static void TCPSocketRecvTask(void *arg)
|
|||
clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len);
|
||||
lw_notice("client %s connected\n", inet_ntoa(tcp_addr.sin_addr));
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
memset(recv_buf, 0, TCP_DEMO_BUF_SIZE);
|
||||
recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0, (struct sockaddr *)&tcp_addr, &addr_len);
|
||||
if(recv_len > 0)
|
||||
{
|
||||
if(recv_len > 0) {
|
||||
lw_notice("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr));
|
||||
lw_notice("Receive data : %d - %s\n\n", recv_len, recv_buf);
|
||||
}
|
||||
|
@ -97,19 +116,18 @@ static void TCPSocketRecvTask(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
void TCPSocketRecvTest(int argc, char *argv[])
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == EOK)
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0) {
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]);
|
||||
}
|
||||
}
|
||||
|
@ -117,9 +135,8 @@ void TCPSocketRecvTest(int argc, char *argv[])
|
|||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||
sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
TCPSocketRecv, TCPSocketRecvTest, TCP recv echo);
|
||||
PRIV_SHELL_CMD_FUNCTION(TCPSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
||||
static void TCPSocketSendTask(void *arg)
|
||||
{
|
||||
|
@ -131,8 +148,7 @@ static void TCPSocketSendTask(void *arg)
|
|||
|
||||
memset(send_msg, 0, sizeof(send_msg));
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (fd < 0) {
|
||||
lw_print("Socket error\n");
|
||||
return;
|
||||
}
|
||||
|
@ -143,35 +159,32 @@ static void TCPSocketSendTask(void *arg)
|
|||
tcp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(tcp_socket_ip[0], tcp_socket_ip[1], tcp_socket_ip[2], tcp_socket_ip[3]));
|
||||
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr)))
|
||||
{
|
||||
if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr))) {
|
||||
lw_print("Unable to connect\n");
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
lw_notice("\n\nTarget Port:%d\n\n", tcp_socket_port);
|
||||
|
||||
while (cnt --)
|
||||
{
|
||||
while (cnt --) {
|
||||
lw_print("Lwip client is running.\n");
|
||||
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
|
||||
sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr));
|
||||
lw_notice("Send tcp msg: %s ", send_msg);
|
||||
MdelayKTask(1000);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
void TCPSocketSendTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == EOK)
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0)
|
||||
{
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]);
|
||||
}
|
||||
|
@ -180,7 +193,18 @@ void TCPSocketSendTest(int argc, char *argv[])
|
|||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||
sys_thread_new("TCP Socket Send", TCPSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TCPSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||
TCPSocketSend, TCPSocketSendTest, TCP send demo);
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
void tcp_recv_demo(void)
|
||||
{
|
||||
TCPSocketRecvTask(NULL);
|
||||
}
|
||||
|
||||
void tcp_send_demo(void)
|
||||
{
|
||||
TCPSocketSendTask(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,16 +18,41 @@
|
|||
* @date 2022-03-21
|
||||
*/
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#include "sys_arch.h"
|
||||
#include "lwip/sockets.h"
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define LWIP_DEMO_TIMES 3
|
||||
#define LWIP_LOCAL_PORT 6000
|
||||
|
||||
#define lw_error printf
|
||||
#define lw_notice printf
|
||||
#define lw_print printf
|
||||
|
||||
/** Create u32_t value from bytes */
|
||||
#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
|
||||
((uint32_t)((b) & 0xff) << 16) | \
|
||||
((uint32_t)((c) & 0xff) << 8) | \
|
||||
(uint32_t)((d) & 0xff))
|
||||
|
||||
#define PP_HTONL(x) ((uint32_t)(x))
|
||||
|
||||
#endif
|
||||
|
||||
#define UDP_BUF_SIZE 65536
|
||||
|
||||
char udp_socket_ip[] = {192, 168, 250, 252};
|
||||
u16_t udp_socket_port = LWIP_LOCAL_PORT;
|
||||
uint16_t udp_socket_port = LWIP_LOCAL_PORT;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void UdpSocketRecvTask(void *arg)
|
||||
{
|
||||
int fd = -1;
|
||||
|
@ -36,18 +61,15 @@ static void UdpSocketRecvTask(void *arg)
|
|||
int recv_len;
|
||||
socklen_t addr_len;
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
recv_buf = (char *)malloc(UDP_BUF_SIZE);
|
||||
if(recv_buf == NULL)
|
||||
{
|
||||
if(recv_buf == NULL) {
|
||||
lw_error("No memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0)
|
||||
{
|
||||
if(fd < 0) {
|
||||
lw_error("Socket error\n");
|
||||
free(recv_buf);
|
||||
continue;
|
||||
|
@ -58,10 +80,9 @@ static void UdpSocketRecvTask(void *arg)
|
|||
udp_addr.sin_port = htons(udp_socket_port);
|
||||
memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero));
|
||||
|
||||
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) {
|
||||
lw_error("Unable to bind\n");
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
continue;
|
||||
}
|
||||
|
@ -69,8 +90,7 @@ static void UdpSocketRecvTask(void *arg)
|
|||
lw_notice("UDP bind sucess, start to receive.\n");
|
||||
lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port);
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
memset(recv_buf, 0, UDP_BUF_SIZE);
|
||||
recv_len = recvfrom(fd, recv_buf, UDP_BUF_SIZE, 0, (struct sockaddr *)&server_addr, &addr_len);
|
||||
if(recv_len > 0)
|
||||
|
@ -81,18 +101,17 @@ static void UdpSocketRecvTask(void *arg)
|
|||
sendto(fd, recv_buf, recv_len, 0, (struct sockaddr*)&server_addr, addr_len);
|
||||
}
|
||||
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
void UdpSocketRecvTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == EOK)
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) {
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]);
|
||||
}
|
||||
}
|
||||
|
@ -100,9 +119,8 @@ void UdpSocketRecvTest(int argc, char *argv[])
|
|||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
UDPSocketRecv, UdpSocketRecvTest, UDP Receive DEMO);
|
||||
PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
||||
static void UdpSocketSendTask(void *arg)
|
||||
{
|
||||
|
@ -113,8 +131,7 @@ static void UdpSocketSendTask(void *arg)
|
|||
memset(send_str, 0, sizeof(send_str));
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0)
|
||||
{
|
||||
if(fd < 0) {
|
||||
lw_error("Socket error\n");
|
||||
return;
|
||||
}
|
||||
|
@ -125,35 +142,32 @@ static void UdpSocketSendTask(void *arg)
|
|||
udp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(udp_socket_ip[0], udp_socket_ip[1], udp_socket_ip[2], udp_socket_ip[3]));
|
||||
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
|
||||
|
||||
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
|
||||
{
|
||||
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr))) {
|
||||
lw_error("Unable to connect\n");
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
lw_print("UDP connect success, start to send.\n");
|
||||
lw_notice("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
|
||||
|
||||
while (cnt --)
|
||||
{
|
||||
while (cnt --) {
|
||||
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
|
||||
sendto(fd, send_str, strlen(send_str), 0, (struct sockaddr*)&udp_sock, sizeof(struct sockaddr));
|
||||
lw_notice("Send UDP msg: %s ", send_str);
|
||||
MdelayKTask(1000);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
||||
closesocket(fd);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
void UdpSocketSendTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
if(argc >= 2) {
|
||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == EOK)
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) {
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +175,17 @@ void UdpSocketSendTest(int argc, char *argv[])
|
|||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
UDPSocketSend, UdpSocketSendTest, UDP send echo);
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
void udp_recv_demo(void)
|
||||
{
|
||||
UdpSocketRecvTask(NULL);
|
||||
}
|
||||
|
||||
void udp_send_demo(void)
|
||||
{
|
||||
UdpSocketSendTask(NULL);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
SRC_DIR :=
|
||||
SRC_DIR := plc_demo
|
||||
|
||||
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
||||
|
||||
ifeq ($(CONFIG_USING_CONTROL_PLC_OPCUA), y)
|
||||
SRC_DIR += opcua_demo plc_demo
|
||||
SRC_DIR += opcua_demo
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
|
||||
#include <list.h>
|
||||
#include <transform.h>
|
||||
#include "board.h"
|
||||
#include "open62541.h"
|
||||
#include "ua_api.h"
|
||||
#include <open62541.h>
|
||||
#include <ua_api.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
|
@ -58,8 +57,7 @@ static void UaConnectTestTask(void* arg)
|
|||
|
||||
UA_Client* client = UA_Client_new();
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
if(client == NULL) {
|
||||
ua_error("ua: [%s] tcp client null\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
@ -76,8 +74,7 @@ static void UaConnectTestTask(void* arg)
|
|||
|
||||
ret = UA_Client_connect(client, url);
|
||||
|
||||
if(ret != UA_STATUSCODE_GOOD)
|
||||
{
|
||||
if(ret != UA_STATUSCODE_GOOD) {
|
||||
ua_error("ua: [%s] connected failed %x\n", __func__, ret);
|
||||
UA_Client_delete(client);
|
||||
fail_cnt++;
|
||||
|
@ -90,12 +87,9 @@ static void UaConnectTestTask(void* arg)
|
|||
|
||||
static void UaConnectTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
if(isdigit(argv[1][0]))
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
||||
{
|
||||
if(argc == 2) {
|
||||
if(isdigit(argv[1][0])) {
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||
lw_notice("input wrong ip\n");
|
||||
return;
|
||||
}
|
||||
|
@ -105,9 +99,7 @@ static void UaConnectTest(int argc, char *argv[])
|
|||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip);
|
||||
sys_thread_new("ua test", UaConnectTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||
UaConnect, UaConnectTest, Test Opc UA connection);
|
||||
PRIV_SHELL_CMD_FUNCTION(UaConnectTest, a opcua connect sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
void UaBrowserObjectsTestTask(void* param)
|
||||
{
|
||||
|
@ -115,8 +107,7 @@ void UaBrowserObjectsTestTask(void* param)
|
|||
|
||||
UA_Client* client = UA_Client_new();
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
if(client == NULL) {
|
||||
ua_error("ua: [%s] tcp client NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
@ -125,8 +116,7 @@ void UaBrowserObjectsTestTask(void* param)
|
|||
UA_ClientConfig_setDefault(config);
|
||||
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
||||
|
||||
if(ret != UA_STATUSCODE_GOOD)
|
||||
{
|
||||
if(ret != UA_STATUSCODE_GOOD) {
|
||||
ua_error("ua: [%s] connect failed %#x\n", __func__, ret);
|
||||
UA_Client_delete(client);
|
||||
return;
|
||||
|
@ -144,12 +134,9 @@ void UaBrowserObjectsTestTask(void* param)
|
|||
|
||||
static void* UaBrowserObjectsTest(int argc, char* argv[])
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
if(isdigit(argv[1][0]))
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
||||
{
|
||||
if(argc == 2) {
|
||||
if(isdigit(argv[1][0])) {
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||
lw_notice("input wrong ip\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -160,17 +147,14 @@ static void* UaBrowserObjectsTest(int argc, char* argv[])
|
|||
sys_thread_new("ua object", UaBrowserObjectsTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
UaObject, UaBrowserObjectsTest, UaObject [IP]);
|
||||
PRIV_SHELL_CMD_FUNCTION(UaBrowserObjectsTest, a opcua object sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
void UaGetInfoTestTask(void* param)
|
||||
{
|
||||
UA_Client* client = UA_Client_new();
|
||||
ua_notice("--- Get OPUCA objects ---\n", __func__);
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
if(client == NULL) {
|
||||
ua_error("ua: [%s] tcp client null\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
@ -179,8 +163,7 @@ void UaGetInfoTestTask(void* param)
|
|||
UA_ClientConfig_setDefault(config);
|
||||
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
||||
|
||||
if(ret != UA_STATUSCODE_GOOD)
|
||||
{
|
||||
if(ret != UA_STATUSCODE_GOOD) {
|
||||
ua_error("ua: [%s] connect failed %#x\n", __func__, ret);
|
||||
UA_Client_delete(client);
|
||||
return;
|
||||
|
@ -192,14 +175,11 @@ void UaGetInfoTestTask(void* param)
|
|||
UA_Client_delete(client); /* Disconnects the client internally */
|
||||
}
|
||||
|
||||
void* UaGetInfoTest(int argc, char* argv[])
|
||||
void *UaGetInfoTest(int argc, char* argv[])
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
if(isdigit(argv[1][0]))
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
||||
{
|
||||
if(argc == 2) {
|
||||
if(isdigit(argv[1][0])) {
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||
lw_notice("input wrong ip\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -210,17 +190,14 @@ void* UaGetInfoTest(int argc, char* argv[])
|
|||
sys_thread_new("ua info", UaGetInfoTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
UaInfo, UaGetInfoTest, UaInfo [IP]);
|
||||
PRIV_SHELL_CMD_FUNCTION(UaGetInfoTest, a opcua info sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
void UaAddNodesTask(void* param)
|
||||
{
|
||||
UA_Client* client = UA_Client_new();
|
||||
ua_notice("ua: [%s] start ...\n", __func__);
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
if(client == NULL) {
|
||||
ua_error("ua: [%s] client null\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
@ -229,8 +206,7 @@ void UaAddNodesTask(void* param)
|
|||
UA_ClientConfig_setDefault(config);
|
||||
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
||||
|
||||
if(ret != UA_STATUSCODE_GOOD)
|
||||
{
|
||||
if(ret != UA_STATUSCODE_GOOD) {
|
||||
ua_print("ua: [%s] connect failed %#x\n", __func__, ret);
|
||||
UA_Client_delete(client);
|
||||
return;
|
||||
|
@ -242,14 +218,11 @@ void UaAddNodesTask(void* param)
|
|||
UA_Client_delete(client); /* Disconnects the client internally */
|
||||
}
|
||||
|
||||
void* UaAddNodesTest(int argc, char* argv[])
|
||||
void *UaAddNodesTest(int argc, char* argv[])
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
if(isdigit(argv[1][0]))
|
||||
{
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
||||
{
|
||||
if(argc == 2){
|
||||
if(isdigit(argv[1][0])) {
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||
lw_notice("input wrong ip\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -260,7 +233,4 @@ void* UaAddNodesTest(int argc, char* argv[])
|
|||
sys_thread_new("ua add nodes", UaAddNodesTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
UaAdd, UaAddNodesTest, UA Add Nodes);
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(UaAddNodesTest, a opcua add nodes sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(flashdb_app, flashdb test);
|
||||
#endif
|
||||
PRIV_SHELL_CMD_FUNCTION(flashdb_app, a flashdb test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -26,6 +26,3 @@ void mnist_app(void);
|
|||
int tfmnist(void) {
|
||||
mnist_app();
|
||||
}
|
||||
// #ifndef SEPARATE_COMPILE
|
||||
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, tfmnist, tfmnist, run mnist demo of tflite);
|
||||
// #endif
|
|
@ -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 <lv_port_indev_template.h>
|
||||
#include "lv_demo_calendar.h"
|
||||
|
@ -38,5 +59,4 @@ static int lvgl_demo_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_demo_init, lvgl_demo_init, lvgl_demo_init );
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(lvgl_demo_init, a littlevgl init sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -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 "lv_demo_calendar.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__
|
||||
#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>
|
||||
#define DBG_TAG "LVGL"
|
||||
#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"
|
||||
|
||||
static void draw_part_event_cb(lv_event_t* e) {
|
||||
|
@ -25,12 +46,11 @@ static void draw_part_event_cb(lv_event_t* e) {
|
|||
}
|
||||
}
|
||||
|
||||
char* Double2Str(char* buf, double value) {
|
||||
sprintf(buf,"%.8f",value);//保留8位小数,不够补0
|
||||
char *Double2Str(char* buf, double value) {
|
||||
sprintf(buf,"%.8f",value);//keep 8 bit float data
|
||||
int index = 0;
|
||||
int len = strlen(buf);
|
||||
for(int i = len-1;i>0;i--)
|
||||
{
|
||||
for(int i = len-1;i>0;i--) {
|
||||
if(buf[i] == '0')
|
||||
continue;
|
||||
else {
|
||||
|
@ -71,8 +91,7 @@ void lv_sensor_info(void) {
|
|||
for (uint32_t i = 0; i < 2 * NR_VAL_PERLINE; ++i) {
|
||||
if (i % 2 == 0) {
|
||||
lv_table_set_col_width(lv_ssr_tb, i, 75);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lv_table_set_col_width(lv_ssr_tb, i, 85);
|
||||
}
|
||||
}
|
||||
|
@ -100,12 +119,11 @@ void lv_sensor_info(void) {
|
|||
lv_obj_add_event_cb(lv_ssr_tb, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
||||
}
|
||||
|
||||
void* lvgl_thd_show_sensor_info(void *parameter)
|
||||
void *lvgl_thd_show_sensor_info(void *parameter)
|
||||
{
|
||||
lv_sensor_info();
|
||||
PrivMutexCreate(&ssr_val_lock, 0);
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
lv_task_handler();
|
||||
|
||||
sensor_update_table();
|
||||
|
@ -123,5 +141,4 @@ static int lvgl_show_sensor_info(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_show_sensor_info, lvgl_show_sensor_info, lvgl_show_sensor_info );
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(lvgl_show_sensor_info, a littlevgl sensor info show sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: lv_sensor_info.h
|
||||
* @brief: a sensor info application using littleVgl
|
||||
* @version: 2.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/9/26
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LVGL_SENSOR_INFO_H__
|
||||
#define __LVGL_SENSOR_INFO_H__
|
||||
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: lv_sensor_info_update_demo.c
|
||||
* @brief: a sensor info update application using littleVgl
|
||||
* @version: 2.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/9/26
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lv_sensor_info.h"
|
||||
|
||||
void* lvgl_thd_sensor_info_update_demo(void *parameter)
|
||||
|
@ -28,5 +49,4 @@ static int lvgl_sensor_info_update_demo(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_sensor_info_update_demo, lvgl_sensor_info_update_demo, lvgl_sensor_info_update_demo );
|
||||
|
||||
PRIV_SHELL_CMD_FUNCTION(lvgl_sensor_info_update_demo, a littlevgl sensor infor update sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: lv_sensor_update_info.c
|
||||
* @brief: a sensor update info application using littleVgl
|
||||
* @version: 2.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2022/9/26
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lv_sensor_info.h"
|
||||
|
||||
uint32_t lv_ssr_map_idx(enum sensor_type st) {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <transform.h>
|
||||
|
||||
|
||||
|
||||
extern int FrameworkInit();
|
||||
extern void ApplicationOtaTaskInit(void);
|
||||
int main(void)
|
||||
|
|
|
@ -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 <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* @date 2021.12.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
* @date 2021.12.10
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
* @date 2021.12.23
|
||||
*/
|
||||
//
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,12 +18,8 @@
|
|||
* @date 2021.12.15
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
|
||||
/**
|
||||
* @description: Read a hcho
|
||||
* @return 0
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
@ -31,7 +27,7 @@
|
|||
void HumiHs300x(void)
|
||||
{
|
||||
int i = 0;
|
||||
int32 humidity;
|
||||
int32_t humidity;
|
||||
struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI);
|
||||
SensorQuantityOpen(humi);
|
||||
for (i = 0; i < 100; i ++) {
|
||||
|
|
|
@ -18,18 +18,8 @@
|
|||
* @date 2021.12.14
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#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
|
||||
* @return 0
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
* @date 2021.12.28
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
@ -31,7 +27,7 @@
|
|||
void TempHs300x(void)
|
||||
{
|
||||
int i = 0;
|
||||
int32 temperature;
|
||||
int32_t temperature;
|
||||
struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP);
|
||||
SensorQuantityOpen(temp);
|
||||
for (i = 0; i < 100; i ++) {
|
||||
|
|
|
@ -18,12 +18,8 @@
|
|||
* @date 2021.12.15
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
|
||||
/**
|
||||
* @description: Read a tvoc
|
||||
* @return 0
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
@ -30,7 +29,7 @@ void VoiceD124(void)
|
|||
struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE);
|
||||
SensorQuantityOpen(voice);
|
||||
PrivTaskDelay(2000);
|
||||
uint16 result = SensorQuantityReadValue(voice);
|
||||
uint16_t result = SensorQuantityReadValue(voice);
|
||||
printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places));
|
||||
SensorQuantityClose(voice);
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
* @date 2021.12.14
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
@ -30,11 +29,7 @@ void WindDirectionQsFx(void)
|
|||
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
|
||||
SensorQuantityOpen(wind_direction);
|
||||
PrivTaskDelay(2000);
|
||||
uint16 result = SensorQuantityReadValue(wind_direction);
|
||||
uint16_t result = SensorQuantityReadValue(wind_direction);
|
||||
printf("wind direction : %d degree\n", result);
|
||||
SensorQuantityClose(wind_direction);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindDirectionQsFx, WindDirectionQsFx, WindDirectionQsFx function);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* @date 2021.12.14
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
@ -30,11 +29,7 @@ void WindSpeedQsFs(void)
|
|||
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
|
||||
SensorQuantityOpen(wind_speed);
|
||||
PrivTaskDelay(2000);
|
||||
uint16 result = SensorQuantityReadValue(wind_speed);
|
||||
uint16_t result = SensorQuantityReadValue(wind_speed);
|
||||
printf("wind speed : %d.%d m/s\n", result/10, result%10);
|
||||
SensorQuantityClose(wind_speed);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindSpeedQsFs, WindSpeedQsFs, WindSpeedQsFs function);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,5 +20,9 @@ ifeq ($(CONFIG_CRYPTO),y)
|
|||
SRC_DIR += security
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MBEDTLS), y)
|
||||
SRC_DIR += security
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
|
|
|
@ -110,10 +110,4 @@ int Adapter4GTest(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ADD_RTTHREAD_FETURES
|
||||
MSH_CMD_EXPORT(Adapter4GTest,a EC200T adpter sample);
|
||||
#endif
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, Adapter4GTest, Adapter4GTest, show adapter 4G information);
|
||||
#endif
|
||||
PRIV_SHELL_CMD_FUNCTION(Adapter4GTest, a EC200T adpter sample, PRIV_SHELL_CMD_FUNC_ATTR);
|
||||
|
|
|
@ -8,11 +8,11 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
|||
bool "Using connection framework debug log function"
|
||||
default y
|
||||
|
||||
menuconfig CONNECTION_INDUSTRIAL_ETHERNET
|
||||
bool "Using industrial ethernet"
|
||||
menuconfig CONNECTION_INDUSTRIAL_NETWORK
|
||||
bool "Using industrial network"
|
||||
default n
|
||||
if CONNECTION_INDUSTRIAL_ETHERNET
|
||||
source "$APP_DIR/Framework/connection/industrial_ethernet/Kconfig"
|
||||
if CONNECTION_INDUSTRIAL_NETWORK
|
||||
source "$APP_DIR/Framework/connection/industrial_network/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig CONNECTION_INDUSTRIAL_FIELDBUS
|
||||
|
|
|
@ -9,8 +9,8 @@ endif
|
|||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := adapter.c adapter_agent.c
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_ETHERNET),y)
|
||||
SRC_DIR += industrial_ethernet
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_NETWORK),y)
|
||||
SRC_DIR += industrial_network
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y)
|
||||
|
|
|
@ -111,9 +111,4 @@ int AdapterBlueToothTest(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#ifdef ADD_RTTHREAD_FETURES
|
||||
MSH_CMD_EXPORT(AdapterBlueToothTest,a bt adpter sample);
|
||||
#endif
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter bluetooth information);
|
||||
#endif
|
||||
PRIV_SHELL_CMD_FUNCTION(AdapterBlueToothTest, a bluetooth test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -122,8 +122,4 @@ int AdapterEthernetTest(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#ifdef ADD_RTTHREAD_FETURES
|
||||
MSH_CMD_EXPORT(AdapterEthernetTest,a ethernet adpter sample);
|
||||
#elif definded ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterEthernetTest, AdapterEthernetTest, show adapter ethernet information);
|
||||
#endif
|
||||
PRIV_SHELL_CMD_FUNCTION(AdapterEthernetTest, a ethernet test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue