Merge branches 'prepare_for_master' and 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into prepare_for_master

This commit is contained in:
涂煜洋 2023-07-21 14:55:20 +08:00
commit 4b48a8d908
957 changed files with 626612 additions and 7752 deletions

22
.gitmodules vendored
View File

@ -1,24 +1,34 @@
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/rt-thread"]
path = Ubiquitous/RT-Thread_Fusion_XiUOS/rt-thread
url = https://code.gitlink.org.cn/chunyexixiaoyu/rt-thread.git
url = https://www.gitlink.org.cn/chunyexixiaoyu/rt-thread.git
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/kendryte-sdk/kendryte-sdk-source"]
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/kendryte-sdk/kendryte-sdk-source
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
url = https://www.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/kendryte-sdk/kendryte-sdk-source"]
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/kendryte-sdk/kendryte-sdk-source
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
url = https://www.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
[submodule "Ubiquitous/XiZi/fs/lwext4/lwext4_submodule"]
path = Ubiquitous/XiZi/fs/lwext4/lwext4_submodule
url = https://gitlink.org.cn/xuos/lwext4_filesystem_support_XiUOS.git
[submodule "Ubiquitous/Nuttx_Fusion_XiUOS/nuttx"]
path = Ubiquitous/Nuttx_Fusion_XiUOS/nuttx
url = https://code.gitlink.org.cn/wgzAIIT/incubator-nuttx.git
url = https://www.gitlink.org.cn/wgzAIIT/incubator-nuttx.git
[submodule "Ubiquitous/Nuttx_Fusion_XiUOS/apps"]
path = Ubiquitous/Nuttx_Fusion_XiUOS/apps
url = https://code.gitlink.org.cn/wgzAIIT/incubator-nuttx-apps.git
url = https://www.gitlink.org.cn/wgzAIIT/incubator-nuttx-apps.git
[submodule "APP_Framework/Applications/webnet/WebNet_XiUOS"]
path = APP_Framework/Applications/webnet/WebNet_XiUOS
url = https://gitlink.org.cn/xuos/WebNet_XiUOS.git
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/kendryte-sdk/kendryte-sdk-source"]
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/kendryte-sdk/kendryte-sdk-source
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
url = https://www.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
[submodule "APP_Framework/lib/lorawan/lora_radio_driver"]
path = APP_Framework/lib/lorawan/lora_radio_driver
url = https://gitlink.org.cn/IACU/lora_radio_driver.git
[submodule "APP_Framework/lib/lorawan/lorawan_devicenode"]
path = APP_Framework/lib/lorawan/lorawan_devicenode
url = https://gitlink.org.cn/IACU/lorawan_devicenode.git
branch = master
[submodule "APP_Framework/lib/lorawan/lorawan_gateway_single_channel"]
path = APP_Framework/lib/lorawan/lorawan_gateway_single_channel
url = https://gitlink.org.cn/IACU/lorawan_gateway_single_channel.git

View File

@ -1,17 +1,19 @@
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
CSRCS += framework_init.c
CSRCS +=
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
SRC_DIR := general_functions app_test
SRC_FILES := main.c framework_init.c
SRC_FILES := main.c
ifeq ($(CONFIG_LIB_LV),y)
SRC_DIR += lv_app
SRC_DIR += tinyttf_app
endif
ifeq ($(CONFIG_APPLICATION_OTA),y)

View File

@ -8,7 +8,7 @@ menu "test app"
bool "Config test adc"
default n
if USER_TEST_ADC
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config ADC_DEV_DRIVER
string "Set ADC dev path"
default "/dev/adc1_dev"
@ -19,7 +19,7 @@ menu "test app"
bool "Config test dac"
default n
if USER_TEST_DAC
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config DAC_DEV_DRIVER
string "Set DAC dev path"
default "/dev/dac_dev"
@ -30,7 +30,7 @@ menu "test app"
bool "Config test fs with sd or usb"
default n
if USER_TEST_FS
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config FPATH
string "Set test file path"
default "/test_file"
@ -46,7 +46,7 @@ menu "test app"
bool "Config test gpio with led and key"
default n
if USER_TEST_GPIO
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config GPIO_DEV_DRIVER
string "Set gpio dev path"
default "/dev/pin_dev"
@ -62,7 +62,7 @@ menu "test app"
bool "Config test uart(loraE220)"
default n
if USER_TEST_LORA
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config LORA_UART_DEV_DRIVER
string "Set uart dev path"
default "/dev/uart2_dev2"
@ -80,7 +80,7 @@ menu "test app"
bool "Config test uart(RS485)"
default n
if USER_TEST_RS485
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config RS485_UART_DEV_DRIVER
string "Set uart dev path"
default "/dev/uart1_dev1"
@ -95,7 +95,7 @@ menu "test app"
bool "Config test rtc"
default n
if USER_TEST_RTC
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config RTC_DEV_DRIVER
string "Set rtc dev path"
default "/dev/rtc_dev"
@ -105,10 +105,15 @@ menu "test app"
menuconfig USER_TEST_HWTIMER
select BSP_USING_HWTIMER
select BSP_USING_GPIO
select RESOURCES_PIN
select BSP_USING_LED
bool "Config test hwtimer"
default n
if USER_TEST_HWTIMER
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config HWTIMER_TIMER_DEV_DRIVER
string "Set pin dev path"
default "/dev/timer0_dev0"
config HWTIMER_PIN_DEV_DRIVER
string "Set pin dev path"
default "/dev/pin_dev"
@ -120,7 +125,7 @@ menu "test app"
bool "Config test watchdog"
default n
if USER_TEST_WDT
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config WDT0_DEV_DRIVER
string "Set wdt dev path"
default "/dev/wdt0_dev0"
@ -132,25 +137,68 @@ menu "test app"
bool "Config test lcd in PrivOpen"
default n
if USER_TEST_LCD_EDU
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config EDU_LCD_DEV_DRIVER
string "Set lcd dev path"
default "/dev/lcd_dev"
endif
endif
menuconfig USER_TEST_TOUCH
select BSP_USING_TOUCH
bool "Config test touch"
default n
if USER_TEST_TOUCH
if ADD_XIZI_FEATURES
config TOUCH_DEV_DRIVER
string "Set touch dev path"
default "/dev/touch_dev"
config TOUCH_LCD_DEV_DRIVER
string "Set lcd dev path"
default "/dev/lcd_dev"
endif
endif
menuconfig USER_TEST_I2C
select BSP_USING_I2C
bool "Config test i2c"
default n
if USER_TEST_I2C
if ADD_XIZI_FETURES
if ADD_XIZI_FEATURES
config I2C_DEV_DRIVER
string "Set i2c dev path"
default "/dev/i2c1_dev0"
endif
endif
menuconfig USER_TEST_CAN
select BSP_USING_CAN
bool "Config test can"
default n
if USER_TEST_CAN
if ADD_XIZI_FEATURES
config CAN_DEV_DRIVER
string "Set can dev path"
default "/dev/can2_dev1"
endif
endif
menuconfig USER_TEST_CAMERA
select BSP_USING_CAMERA
select BSP_USING_LCD
bool "Config test camera with lcd"
default n
if USER_TEST_CAMERA
if ADD_XIZI_FEATURES
config CAMERA_DEV_DRIVER
string "Set camera dev path"
default "/dev/camera_dev"
config CAMERA_LCD_DEV_DRIVER
string "Set lcd dev path"
default "/dev/lcd_dev"
endif
endif
config USER_TEST_SEMC
bool "Config test semc sdram"
default n
@ -159,6 +207,38 @@ menu "test app"
bool "Config test lcd device"
default n
menuconfig USER_TEST_ETHERNET
bool "Config test ethernet only for edu-riscv64"
default n
if USER_TEST_ETHERNET
if ADD_XIZI_FEATURES
choice
prompt "set ethernet role as client or server"
default ETHERNET_AS_SERVER
config ETHERNET_AS_SERVER
bool "test as server"
config ETHERNET_AS_CLIENT
bool "test as client"
endchoice
endif
endif
menuconfig USER_TEST_FLASH
bool "Config test w25q128 device"
default n
if USER_TEST_FLASH
if ADD_XIZI_FEATURES
config FLASH_DEV_DRIVER
string "Set flash dev path"
default "/dev/qspi_W25Q128"
endif
endif
menuconfig USER_TEST_TIMER
bool "Config test soft timer"
default n
endif
endmenu

View File

@ -1,5 +1,5 @@
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_USER_TEST_SEMC),y)
@ -22,7 +22,7 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
SRC_FILES := test_shell.c
ifeq ($(CONFIG_USER_TEST_ADC),y)
@ -75,7 +75,31 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_USER_TEST_WDT),y)
SRC_FILES += test_wdt.c
endif
endif
ifeq ($(CONFIG_USER_TEST_TOUCH),y)
SRC_FILES += test_touch.c
endif
ifeq ($(CONFIG_USER_TEST_CAMERA),y)
SRC_FILES += test_camera.c
endif
ifeq ($(CONFIG_USER_TEST_ETHERNET),y)
SRC_FILES += test_ethernet.c
endif
ifeq ($(CONFIG_USER_TEST_FLASH),y)
SRC_FILES += test_flash.c
endif
ifeq ($(CONFIG_USER_TEST_CAN),y)
SRC_FILES += test_can.c
endif
ifeq ($(CONFIG_USER_TEST_TIMER),y)
SRC_FILES += test_timer.c
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
void TestAdc(void)
{
@ -56,4 +57,5 @@ void TestAdc(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,120 @@
/*
* 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_camera.c
* @brief: a application of camera function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/7
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
static uint16_t image_buff[384000];
void TestCamera(int argc, char *argv[])
{
int frame_counter = 10000;
if (argc > 1)
{
frame_counter = atoi(argv[1]);
}
printf("This test will refresh %d frames\n", frame_counter);
int camera_fd = PrivOpen(CAMERA_DEV_DRIVER, O_RDWR);
if (camera_fd < 0)
{
printf("open camera fd error:%d\n", camera_fd);
return;
}
int lcd_fd = PrivOpen(CAMERA_LCD_DEV_DRIVER, O_RDWR);
if (lcd_fd < 0)
{
printf("open lcd fd error:%d\n", lcd_fd);
return;
}
//configure the camera's output address
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = CAMERA_TYPE;
struct CameraCfg camera_cfg ={
.gain_manu_enable = 0,
.gain = 0xFF,
.window_w = 800,
.window_h = 600,
.output_w = IMAGE_WIDTH,
.output_h = IMAGE_HEIGHT,
.window_xoffset = 0,
.window_yoffset = 0
};
ioctl_cfg.args = &camera_cfg;
if (0 != PrivIoctl(camera_fd, OPE_CFG, &ioctl_cfg))
{
printf("camera pin fd error %d\n", camera_fd);
PrivClose(camera_fd);
return;
}
ioctl_cfg.args = (void *)image_buff;
if (0 != PrivRead(camera_fd, image_buff, NULL_PARAMETER))
{
printf("camera pin fd error %d\n", camera_fd);
PrivClose(camera_fd);
return;
}
printf("address buff is %x\n", image_buff);
LcdWriteParam graph_param;
graph_param.type = LCD_DOT_TYPE;
//clear the LCD
uint16_t back_color[LCD_SIZE];
memset(back_color,0,sizeof(back_color));
for (int i = 0; i < LCD_SIZE; i++)
{
graph_param.pixel_info.pixel_color = &back_color;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i;
graph_param.pixel_info.x_endpos = LCD_SIZE -1;
graph_param.pixel_info.y_endpos = i;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
//refresh the LCD using photo of camera
while (frame_counter--)
{
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
graph_param.pixel_info.pixel_color = image_buff + i * IMAGE_WIDTH;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i + (LCD_SIZE - IMAGE_HEIGHT) / 2;
graph_param.pixel_info.x_endpos = IMAGE_WIDTH - 1;
graph_param.pixel_info.y_endpos = i + (LCD_SIZE - IMAGE_HEIGHT) / 2;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
}
// close test
PrivClose(lcd_fd);
PrivClose(camera_fd);
printf("The camera test is finished successfully\n");
}
PRIV_SHELL_CMD_FUNCTION(TestCamera, a camera test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,87 @@
/*
* 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_can.c
* @brief: a application of can function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2023/2/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
void TestCAN(void)
{
// config CAN pin(SCL:34.SDA:35) in menuconfig
int can_fd = PrivOpen(CAN_DEV_DRIVER, O_RDWR);
if (can_fd < 0)
{
printf("open can_fd fd error:%d\n", can_fd);
return;
}
printf("CAN open successful!\n");
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = CAN_TYPE;
struct CanDriverConfigure can_config;
can_config.brp = 8U;
can_config.tbs1 = 1U + 8U;
can_config.tbs2 = 4U;
can_config.tsjw = 4U;
can_config.mode = 0U;
ioctl_cfg.args = (void *)&can_config;
if (0 != PrivIoctl(can_fd, OPE_INT, &ioctl_cfg))
{
printf("init can fd error %d\n", can_fd);
PrivClose(can_fd);
return;
}
printf("CAN configure successful!\n");
uint8_t data_buff[64u] = {1,2,3,4,4,3,2,1};
struct CanSendConfigure frame_send;
frame_send.ide=0;
frame_send.stdid = 0x55;
frame_send.rtr=0;
frame_send.data_lenth=8;
frame_send.data = data_buff;
struct CanSendConfigure frame_recv;
uint8_t recv_buff[65U] = {0};
frame_recv.data = recv_buff;
// CAN write
while (1)
{
PrivTaskDelay(500);
PrivWrite(can_fd, &frame_send, NONE);
PrivTaskDelay(500);
PrivRead(can_fd, &frame_recv, NONE);
// if any data has received,Then printf message
if(frame_recv.data_lenth > 0){
printf("ID %08x:%s\n",frame_recv.exdid,frame_recv.data);
}
}
PrivClose(can_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestCAN, a can test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -17,10 +17,10 @@
* @author: AIIT XUOS Lab
* @date: 2022/1/11
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
void TestDac(void)
{
@ -57,3 +57,4 @@ void TestDac(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,194 @@
/*
* 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_ethernet.c
* @brief: a application of ethernet function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#include <socket.h>
#define BUFF_SIZE 128
#define RECV_SIZE 16
#define TCP_PORT 12345
const static uint32_t sn = 0;
#ifdef ETHERNET_AS_SERVER
static int32_t wiz_server_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
uint16_t port, enum TCP_OPTION opt) {
int32_t ret = 0;
uint16_t size = 0, sentsize = 0;
switch (getSn_SR(sn)) {
case SOCK_ESTABLISHED:
if (getSn_IR(sn) & Sn_IR_CON) {
printf("%d:Connected\r\n", sn);
setSn_IR(sn, Sn_IR_CON);
}
if (opt == SEND_DATA) {
uint32_t sent_size = 0;
memset(buf,0,buf_size);
strcpy(buf,"The message has been recved");
ret = wiz_sock_send(sn, buf, buf_size);
if (ret < 0) {
wiz_sock_close(sn);
return ret;
}
} else if (opt == RECV_DATA) {
uint32_t size = 0;
if ((size = getSn_RX_RSR(sn)) > 0) {
if (size > buf_size) size = buf_size;
memset(buf,0,buf_size);
ret = wiz_sock_recv(sn, buf, size);
printf("Recv message: %s\n",buf);
return ret;
}
}
break;
case SOCK_CLOSE_WAIT:
printf("%d:CloseWait\r\n", sn);
if ((ret = wiz_sock_disconnect(sn)) != SOCK_OK) return ret;
printf("%d:Closed\r\n", sn);
break;
case SOCK_INIT:
printf("%d:Listen, port [%d]\r\n", sn, port);
if ((ret = wiz_sock_listen(sn)) != SOCK_OK) return ret;
break;
case SOCK_CLOSED:
printf("%d:LBTStart\r\n", sn);
if ((ret = wiz_socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret;
printf("%d:Opened\r\n", sn);
break;
default:
break;
}
return 0;
}
void TestSocketAsServer(int argc, char *argv[])
{
x_err_t ret;
uint8_t buf[BUFF_SIZE] = {0};
while (1) {
ret = wiz_server_op(0, buf, BUFF_SIZE, TCP_PORT, RECV_DATA);
if (ret > 0) {
wiz_server_op(0, buf, BUFF_SIZE, TCP_PORT, SEND_DATA);
};
}
return ;
}
PRIV_SHELL_CMD_FUNCTION(TestSocketAsServer, a w5500 server test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#elif defined ETHERNET_AS_CLIENT
static uint32_t wiz_client_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
uint8_t dst_ip[4], uint16_t dst_port,
enum TCP_OPTION opt) {
// assert(buf_size <= g_wiznet_buf_size);
int32_t ret;
switch (getSn_SR(sn)) {
case SOCK_CLOSE_WAIT:
wiz_sock_disconnect(sn);
break;
case SOCK_CLOSED:
wiz_socket(sn, Sn_MR_TCP, 5000, 0x00);
break;
case SOCK_INIT:
KPrintf("[SOCKET CLIENT] sock init.\n");
wiz_sock_connect(sn, dst_ip, dst_port);
break;
case SOCK_ESTABLISHED:
if (getSn_IR(sn) & Sn_IR_CON) {
printf("[SOCKET CLIENT] %d:Connected\r\n", sn);
setSn_IR(sn, Sn_IR_CON);
}
if (opt == SEND_DATA) {
uint32_t sent_size = 0;
ret = wiz_sock_send(sn, buf, buf_size);
if (ret < 0) {
wiz_sock_close(sn);
return ret;
}
} else if (opt == RECV_DATA) {
uint32_t size = 0;
if ((size = getSn_RX_RSR(sn)) > 0) {
if (size > buf_size) size = buf_size;
ret = wiz_sock_recv(sn, buf, size);
if (ret <= 0) return ret;
}
}
break;
default:
break;
}
}
void TestSocketAsClient(int argc, char *argv[])
{
x_err_t ret;
uint8_t buf[BUFF_SIZE] = {0};
uint32_t tmp_ip[4];
uint32_t port;
const uint8_t client_sock = 2;
if(argc<3){
printf("Please enter command like TestSocketAsClient ip:port msg\n");
}
sscanf(argv[1],"%d.%d.%d.%d:%d",tmp_ip,tmp_ip+1,tmp_ip+2,tmp_ip+3,&port);
printf("Client to %d.%d.%d.%d:%d\n",tmp_ip[0],tmp_ip[1],tmp_ip[2],tmp_ip[3],port);
uint8_t destination_ip[4]={0};
for(int i=0;i<4;i++){
destination_ip[i]=tmp_ip[i];
}
while(1){
ret = wiz_client_op(client_sock, argv[2], strlen(argv[2]), destination_ip, port,SEND_DATA);
printf("sizeof:%d\n",strlen(argv[2]));
PrivTaskDelay(1000);
if (ret > 0) {
ret=wiz_client_op(client_sock, buf, BUFF_SIZE, destination_ip, port, RECV_DATA);
printf("read ret is %d\n",ret);
if(ret>0){
printf("client recv msg successfully!\n");
printf("%s\n",buf);
}
};
PrivTaskDelay(1000);
}
return ;
}
PRIV_SHELL_CMD_FUNCTION(TestSocketAsClient, a w5500 client-ip-port-msg test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif
#endif

View File

@ -0,0 +1,56 @@
/*
* 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_flash.c
* @brief: a application of flash function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
void TestFlash(void)
{
int fd = open(FLASH_DEV_DRIVER,O_RDWR);
if(fd<0){
printf("fs fd open error:%d\n",fd);
return;
}
struct BusBlockWriteParam flash_writer;
uint8_t read_buff[8] = {1,2,3,4,5,6,7,8};
flash_writer.pos = 0x000000L;
flash_writer.size = 8;
flash_writer.buffer = read_buff;
struct BusBlockReadParam flash_reader;
flash_reader.pos = 0x000000L;
flash_reader.size = 8;
flash_reader.buffer = read_buff;
PrivRead(fd,&flash_reader,NONE);
printf("Read data is:");
for(int i=0;i<flash_writer.size;i++){
printf("%02x ",read_buff[i]);
read_buff[i]++;
}
printf("\n");
PrivWrite(fd,&flash_writer,NONE);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestFlash, a flash test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,6 +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.
*/
/**
* @file: test_fs.c
* @brief: a application of file_system function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/11/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define MAX_READ_LENGTH 1000
@ -59,4 +79,5 @@ void TestFs(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(TestFs, a sd or usb filesystem test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestFs, a sd or usb filesystem test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,15 +1,40 @@
/*
* 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_gpio.c
* @brief: a application of GPIO function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#ifdef BOARD_EDU_RISCV64_EVB
#define BSP_LED_PIN 29
#define BSP_KEY_PIN 31
#elif defined BOARD_HC32F4A0_EVB
#define BSP_LED_PIN 134
#define BSP_KEY_PIN 176
#endif
#define NULL_PARAMETER 0
void TestGpio(void)
{
int pin_fd = PrivOpen(GPIO_DEV_DRIVER, O_RDWR);
if(pin_fd<0){
if(pin_fd < 0) {
printf("open pin fd error:%d\n",pin_fd);
return;
}
@ -31,8 +56,8 @@ void TestGpio(void)
}
//config key pin in board
parameter.pin = BSP_KEY_PIN;
parameter.mode = GPIO_CFG_INPUT;
parameter.pin = BSP_KEY_PIN;
parameter.mode = GPIO_CFG_INPUT;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
@ -48,7 +73,7 @@ void TestGpio(void)
//recycle read pin and write pin until key break
while(1){
if(0>PrivRead(pin_fd,&pin_key,NULL_PARAMETER)){
if(0 > PrivRead(pin_fd, &pin_key, NULL_PARAMETER)) {
printf("read pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
@ -61,13 +86,13 @@ void TestGpio(void)
pin_led.val = GPIO_LOW;
}
if(0>PrivWrite(pin_fd,&pin_led,NULL_PARAMETER)){
printf("write pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
if(0 > PrivWrite(pin_fd, &pin_led, NULL_PARAMETER)) {
printf("write pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
}
}
PRIV_SHELL_CMD_FUNCTION(TestGpio, a gpio test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestGpio, a gpio test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,38 +1,56 @@
/*
* 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_hwtimer.c
* @brief: a application of hwtimer function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define BSP_LED_PIN 29
#define BSP_LED_PIN 134
#define NULL_PARAMETER 0
static uint16_t pinval=0;
static uint16_t pin_fd=0;
static struct PinStat pin_led;
void ledflip(void *parameter)
{
int tmp_fd = *(int*)parameter;
struct PinStat pin_led;
pin_led.pin = BSP_LED_PIN;
pin_led.val = !pinval;
pinval = !pinval;
PrivWrite(tmp_fd,&pin_led,NULL_PARAMETER);
printf("Timer has callback once\n");
pin_led.val = !pin_led.val;
PrivWrite(pin_fd,&pin_led,NULL_PARAMETER);
}
void TestHwTimer(int argc, char *argv[])
void TestHwTimer(void)
{
x_ticks_t period = 100;//uint:10ms
if(argc>1){
period = (x_ticks_t)atoi(argv[1]);
}
x_ticks_t period = 100000;
int pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR);
pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR);
if(pin_fd<0){
printf("open pin fd error:%d\n",pin_fd);
return;
}
int timer_fd = PrivOpen(HWTIMER_TIMER_DEV_DRIVER, O_RDWR);
if(timer_fd<0){
printf("open timer fd error:%d\n",timer_fd);
return;
}
//config led pin in board
struct PinParam parameter;
parameter.cmd = GPIO_CONFIG_MODE;
@ -49,14 +67,31 @@ void TestHwTimer(int argc, char *argv[])
return;
}
int32 timer_handle = KCreateTimer("LED on and off by 1s",&ledflip,&pin_fd,period,TIMER_TRIGGER_PERIODIC);
KTimerStartRun(timer_handle);
PrivTaskDelay(10000);
KTimerQuitRun(timer_handle);
KDeleteTimer(timer_handle);
ioctl_cfg.ioctl_driver_type = TIME_TYPE;
ioctl_cfg.args = (void *)&ledflip;
if (0 != PrivIoctl(timer_fd, OPE_INT, &ioctl_cfg)) {
printf("timer pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
ioctl_cfg.args = (void *)&period;
if (0 != PrivIoctl(timer_fd, OPE_CFG, &ioctl_cfg)) {
printf("timer pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
while(1){
}
// int32 timer_handle = KCreateTimer("LED on and off by 1s",&ledflip,&pin_fd,period,TIMER_TRIGGER_PERIODIC);
// KTimerStartRun(timer_handle);
PrivClose(pin_fd);
PrivClose(timer_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestHwTimer, a timer test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestHwTimer, a timer test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,6 +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.
*/
/**
* @file: test_i2c.c
* @brief: a application of i2c function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define I2C_SLAVE_ADDRESS 0x0012U
@ -48,3 +68,4 @@ void TestI2C(void)
}
PRIV_SHELL_CMD_FUNCTION(TestI2C, a iic test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -20,7 +20,7 @@
#include <transform.h>
#ifdef ADD_NUTTX_FETURES
#ifdef ADD_NUTTX_FEATURES
#ifdef CONFIG_K210_LCD
void LcdDemo(void)

View File

@ -1,6 +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.
*/
/**
* @file: test_lcd.c
* @brief: a application of lcd function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define GRAPHIC_CTRL_RECT_UPDATE 0x00
#define LCD_STRING_TYPE 0
@ -18,8 +38,21 @@ void TestLcd(void)
return;
}
// draw text
LcdWriteParam graph_param;
// black
uint16* color_select = malloc(sizeof(uint16) * 321 * 321);
memset(color_select, 0x00, sizeof(uint16) * 321 * 321);
graph_param.type = LCD_DOT_TYPE;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = 0;
graph_param.pixel_info.x_endpos = 320;
graph_param.pixel_info.y_endpos = 320;
graph_param.pixel_info.pixel_color = color_select;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
free(color_select);
// draw text
graph_param.type = LCD_STRING_TYPE;
graph_param.string_info.x_pos = 0;
graph_param.string_info.y_pos = 0;
@ -29,22 +62,28 @@ void TestLcd(void)
graph_param.string_info.back_color = 0xFFFF;
graph_param.string_info.font_color = 0x0000;
graph_param.string_info.addr = "hello_world!";
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
uint16 color_select = 0xF800;
for (int i = 0; i < 5; i++)
// draw line
color_select = malloc(sizeof(uint16) * 1 * 320);
for (int i = 0; i < 320; i++)
{
color_select[i] = 0xF800;
}
for (int i = 1; i <= 5; i++)
{
graph_param.type = LCD_DOT_TYPE;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = 50 * i;
graph_param.pixel_info.x_endpos = 320;
graph_param.pixel_info.y_endpos = 50 * i;
graph_param.pixel_info.pixel_color = &color_select;
graph_param.pixel_info.y_startpos = i * 50;
graph_param.pixel_info.x_endpos = 319;
graph_param.pixel_info.y_endpos = i * 50;
graph_param.pixel_info.pixel_color = color_select;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
free(color_select);
PrivClose(lcd_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestLcd, a lcd test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestLcd, a lcd test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,6 +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.
*/
/**
* @file: test_loraE220.c
* @brief: a application of loraE220 function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define NULL_PARAMETER 0
#define E220_CFG_LENGTH
@ -67,7 +87,6 @@ void TestLora(int argc, char *argv[])
printf("pin configure success\n");
struct SerialDataCfg uart_cfg;
memset(&uart_cfg, 0, sizeof(struct SerialDataCfg));
// loraE220 support only 9600bps with 8N1 during initializing
uart_cfg.serial_baud_rate = BAUD_RATE_9600;
@ -96,7 +115,8 @@ void TestLora(int argc, char *argv[])
printf("lora configure into sleep(configure) mode\n");
// send configure data, and receive the same length of data
char sendbuff[] = {0xC0, 0x00, 0x05, 0x19, 0x49, 0xE6, 0x00, 0x17}; // config as address 1949 CH17 36.8kps
// configure loraE220 as address 1949 CH17 36.8kps
char sendbuff[] = {0xC0, 0x00, 0x05, 0x19, 0x49, 0xE6, 0x00, 0x17};
PrivTaskDelay(2000);
@ -145,3 +165,4 @@ void TestLora(int argc, char *argv[])
}
PRIV_SHELL_CMD_FUNCTION(TestLora, a lora test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -20,7 +20,7 @@
#include <transform.h>
#ifdef ADD_NUTTX_FETURES
#ifdef ADD_NUTTX_FEATURES
#if defined(CONFIG_MUSL_LIBC) && defined(CONFIG_FS_AUTOMOUNTER)

View File

@ -1,6 +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.
*/
/**
* @file: test_rs485.c
* @brief: a application of rs485 function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define BSP_485_DIR_PIN 24
@ -83,4 +103,5 @@ void Test485(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(Test485, a RS485 test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(Test485, a RS485 test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,6 +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.
*/
/**
* @file: test_rtc.c
* @brief: a application of rtc function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
void TestRTC(int argc,char *argv[])
{
@ -11,16 +31,19 @@ void TestRTC(int argc,char *argv[])
}
if(argc>1){
int times = atoi(argv[1]);
printf("Time will be printf %d times\n",times);
struct RtcDrvConfigureParam rtc_para;
time_t my_time=0;
rtc_para.rtc_operation_cmd = OPER_RTC_SET_TIME;
*(rtc_para.time) = 0;
rtc_para.time = &my_time;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = RTC_TYPE;
ioctl_cfg.args = (void *)&rtc_para;
PrivIoctl(rtc_fd,0,&ioctl_cfg);
rtc_para.rtc_operation_cmd = OPER_RTC_GET_TIME;
@ -36,3 +59,4 @@ void TestRTC(int argc,char *argv[])
}
PRIV_SHELL_CMD_FUNCTION(TestRTC, a rtc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,67 @@
/*
* 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_timer.c
* @brief: a application of soft timer function
* @version: 3.0
* @author: AIIT XUOS Lab
* @date: 2023/03/09
*/
#include <transform.h>
void TimerFunction(union sigval sig_val)
{
static int cnt = 0;
printf("%s cnt %d\n", __func__, cnt++);
}
void TestTimer(void)
{
int ret = 0;
int timer_flags;
timer_t timer_id;
struct sigevent evp;
memset(&evp, 0, sizeof(struct sigevent));
timer_flags = TIMER_TRIGGER_PERIODIC;
evp.sigev_notify = SIGEV_THREAD;
evp.sigev_notify_function = TimerFunction;
evp.sigev_notify_attributes = &timer_flags;
ret = timer_create(CLOCK_REALTIME, &evp, &timer_id);
if (ret < 0) {
printf("%s create timer failed ret %d\n", __func__, ret);
return;
}
struct itimerspec value;
//active time interval
value.it_interval.tv_sec = 2;
value.it_interval.tv_nsec = 0;
//first timer set time
value.it_value.tv_sec = 2;
value.it_value.tv_nsec = 0;
ret = timer_settime(timer_id, 1, &value, NULL);
if (ret < 0) {
printf("%s set timer time failed ret %d\n", __func__, ret);
return;
}
printf("%s success\n", __func__);
}
PRIV_SHELL_CMD_FUNCTION(TestTimer, soft timer test, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -24,7 +24,7 @@
#include <transform.h>
#ifdef ADD_NUTTX_FETURES
#ifdef ADD_NUTTX_FEATURES
#ifdef CONFIG_BSP_USING_TOUCH
void TestTouch(void)
@ -40,4 +40,74 @@ void TestTouch(void)
}
#endif
#endif
#include <stdio.h>
#include <string.h>
#include <transform.h>
#define NULL_PARAMETER 0
#define LCD_DOT_TYPE 1
#define LCD_SIZE 320
#elif defined ADD_XIZI_FEATURES
void TestTouch(void)
{
int touch_fd = PrivOpen(TOUCH_DEV_DRIVER, O_RDWR);
if (touch_fd < 0)
{
printf("open touch fd error:%d\n", touch_fd);
return;
}
int lcd_fd = PrivOpen(TOUCH_LCD_DEV_DRIVER, O_RDWR);
if (lcd_fd < 0)
{
printf("open lcd fd error:%d\n", lcd_fd);
return;
}
// draw text
struct TouchDataStandard touch_pixel;
memset(&touch_pixel,0,sizeof(touch_pixel));
LcdWriteParam graph_param;
graph_param.type = LCD_DOT_TYPE;
uint16_t back_color[LCD_SIZE];
memset(back_color,0x00,sizeof(back_color));
for (int i = 0; i < LCD_SIZE; i++)
{
graph_param.pixel_info.pixel_color = &back_color;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i;
graph_param.pixel_info.x_endpos = LCD_SIZE -1;
graph_param.pixel_info.y_endpos = i;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
uint16 color_select[LCD_SIZE];
memset(color_select,0xff,sizeof(color_select));
graph_param.pixel_info.pixel_color = &color_select;
while(1){
if(0 > PrivRead(touch_fd, &touch_pixel, NULL_PARAMETER)){
printf("read touch error\n");
return;
}
printf("touch pixel position x:%d,y:%d\n",touch_pixel.x,touch_pixel.y);
graph_param.pixel_info.x_startpos = touch_pixel.x-10>0?touch_pixel.x-10:0;
graph_param.pixel_info.y_startpos = touch_pixel.y;
graph_param.pixel_info.x_endpos = touch_pixel.x+10;
graph_param.pixel_info.y_endpos = touch_pixel.y;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
graph_param.pixel_info.x_startpos = touch_pixel.x;
graph_param.pixel_info.y_startpos = touch_pixel.y-10>0?touch_pixel.y-10:0;
graph_param.pixel_info.x_endpos = touch_pixel.x;
graph_param.pixel_info.y_endpos = touch_pixel.y+10;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
PrivClose(lcd_fd);
PrivClose(touch_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestTouch, a touch test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,6 +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.
*/
/**
* @file: test_wdt.c
* @brief: a application of wdt function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
void TestWDT(int argc, char *agrv[])
{
@ -42,4 +62,5 @@ void TestWDT(int argc, char *agrv[])
return;
}
PRIV_SHELL_CMD_FUNCTION(TestWDT, a wdt test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestWDT, a wdt test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,133 @@
/*
* 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 4g_app.c
* @brief support get data from and send data to 4g server
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.12.12
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#include <adapter.h>
static uint8_t adapter_4g_status = 0;
static pthread_t recv_4g_heart_task;
struct Adapter *adapter_4g;
static const uint8_t server_addr[] = "xxx.xxx.xxx.xxx";
static const uint8_t server_port[] = "xxx";
#define ADAPTER_4G_HEART "HEART"
int Adapter4GConnectFunction(struct Adapter *adapter, uint8_t reconnect)
{
int ret = 0;
int baud_rate = BAUD_RATE_115200;
if (1 != reconnect) {
ret = AdapterDeviceOpen(adapter);
if (ret < 0) {
goto out;
}
ret = AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
if (ret < 0) {
goto out;
}
}
ret = AdapterDeviceConnect(adapter, CLIENT, server_addr, server_port, IPV4);
if (ret < 0) {
goto out;
}
out:
if (ret < 0) {
AdapterDeviceClose(adapter);
}
return ret;
}
void Adapter4gSend(uint8_t *send_data, size_t length)
{
if (adapter_4g_status) {
AdapterDeviceSend(adapter_4g, send_data, length);
}
}
static void *Receive4gHeartTask(void* parameter)
{
char recv_msg[16] = {0};
ssize_t recv_length = 0;
uint8_t net_status_cnt = 0;
while (1) {
SetTaskStatus(0x01);
if (net_status_cnt > 5) {
adapter_4g_status = 0;
while (Adapter4GConnectFunction(adapter_4g, 1) < 0) {
PrivTaskDelay(10000);
}
net_status_cnt = 0;
}
adapter_4g_status = 1;
recv_length = AdapterDeviceRecv(adapter_4g, recv_msg, 6);
if (recv_length > 0) {
//if (0 == strcmp(recv_msg, ADAPTER_4G_HEART)) {
net_status_cnt = 0;
//}
} else {
printf("4G recv heart error re-recv cnt %d\n", net_status_cnt);
net_status_cnt++;
}
memset(recv_msg, 0, sizeof(recv_msg));
}
}
int Adapter4GActive(void)
{
int ret = 0;
adapter_4g = AdapterDeviceFindByName(ADAPTER_4G_NAME);
#ifdef ADAPTER_EC200T
adapter_4g->socket.socket_id = 0;
ret = Adapter4GConnectFunction(adapter_4g, 0);
if (ret < 0) {
printf("Adapter4GConnect failed %d\n", ret);
}
adapter_4g_status = 1;
pthread_attr_t attr;
attr.schedparam.sched_priority = 22;
attr.stacksize = 2048;
PrivTaskCreate(&recv_4g_heart_task, &attr, &Receive4gHeartTask, NULL);
PrivTaskStartup(&recv_4g_heart_task);
#endif
return ret;
}

View File

@ -0,0 +1,3 @@
SRC_FILES := 4g_app.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,14 +1,15 @@
ifeq ($(CONFIG_SOCKET_DEMO),y)
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
SRC_DIR += 4g_app
endif
ifeq ($(CONFIG_RESOURCES_LWIP),y)
SRC_DIR += socket_demo
@ -17,4 +18,3 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
include $(KERNEL_ROOT)/compiler.mk
endif
endif

View File

@ -0,0 +1,141 @@
/*
* 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 modbus_rtu_app.c
* @brief support get data from and send data to Modbus rtu server
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.12.12
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#include <adapter.h>
#define ADAPTER_RTU_DATA_LENGTH 112
#define ADAPTER_RTU_TRANSFER_DATA_LENGTH ADAPTER_RTU_DATA_LENGTH + 16
uint8_t client_join_data[ADAPTER_RTU_TRANSFER_DATA_LENGTH];
/* ----------------------- Modbus includes ----------------------------------*/
#include "mb.h"
#include "mbport.h"
/* ----------------------- Defines ------------------------------------------*/
#define REG_INPUT_START 1000
#define REG_INPUT_NREGS 4
/* ----------------------- Static variables ---------------------------------*/
static USHORT usRegInputStart = REG_INPUT_START;
static USHORT usRegInputBuf[REG_INPUT_NREGS];
/* ----------------------- Start implementation -----------------------------*/
eMBErrorCode
eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )
{
eMBErrorCode eStatus = MB_ENOERR;
int iRegIndex;
if( ( usAddress >= REG_INPUT_START )
&& ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) )
{
iRegIndex = ( int )( usAddress - usRegInputStart );
while( usNRegs > 0 )
{
*pucRegBuffer++ =
( unsigned char )( usRegInputBuf[iRegIndex] >> 8 );
*pucRegBuffer++ =
( unsigned char )( usRegInputBuf[iRegIndex] & 0xFF );
iRegIndex++;
usNRegs--;
}
}
else
{
eStatus = MB_ENOREG;
}
return eStatus;
}
eMBErrorCode
eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs,
eMBRegisterMode eMode )
{
return MB_ENOREG;
}
eMBErrorCode
eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils,
eMBRegisterMode eMode )
{
return MB_ENOREG;
}
eMBErrorCode
eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )
{
return MB_ENOREG;
}
/******************Modbus RTU TEST*********************/
int AdapterModbusRtuTest(void)
{
const char *send_msg = "Adapter_Modbus_Rtu Test";
char recv_msg[256] = {0};
int baud_rate = BAUD_RATE_115200;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_MODBUS_RTU_NAME);
struct AdapterData priv_rtu_net;
priv_rtu_net.len = ADAPTER_RTU_TRANSFER_DATA_LENGTH;
priv_rtu_net.buffer = client_join_data;
AdapterDeviceOpen(adapter);
AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
AdapterDeviceJoin(adapter,(uint8_t *)&priv_rtu_net);
eMBErrorCode eStatus;
eStatus = eMBInit( MB_RTU, 0x0A, 0, 38400, MB_PAR_EVEN );
/* Enable the Modbus Protocol Stack. */
eStatus = eMBEnable( );
for( ;; )
{
( void )eMBPoll( );//判断事件的发生,并执行对应的回调函数
/* Here we simply count the number of poll cycles. */
usRegInputBuf[0]++;
}
// while (1) {
// AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
// AdapterDeviceRecv(adapter, recv_msg, 256);
// printf("4G recv msg %s\n", recv_msg);
// memset(recv_msg, 0, 256);
// }
return 0;
}
PRIV_SHELL_CMD_FUNCTION(AdapterModbusRtuTest, a Modbus Rtu adpter sample, PRIV_SHELL_CMD_FUNC_ATTR);

View File

@ -1,10 +1,10 @@
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_ADD_XIZI_FEATURES),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)
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
CSRCS += lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
include $(APPDIR)/Application.mk

View File

@ -20,24 +20,32 @@
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include "sys_arch.h"
#ifdef ADD_XIZI_FEATURES
#include <sys_arch.h>
#include <lwip/sockets.h>
#include "lwip/sys.h"
#endif
#ifdef ADD_NUTTX_FETURES
#ifdef ADD_NUTTX_FEATURES
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "stdio.h"
#endif
#define TCP_DEMO_BUF_SIZE 65535
#define TCP_DEMO_BUF_SIZE 65535
#define TCP_DEMO_SEND_TIMES 20
#define LWIP_TCP_DEMO_TASK_STACK_SIZE 4096
#define LWIP_TCP_DEMO_TASK_PRIO 20
char tcp_socket_ip[] = {192, 168, 250, 252};
static pthread_t tcp_client_task;
static pthread_t tcp_server_task;
#ifdef ADD_NUTTX_FETURES
static char tcp_demo_ipaddr[] = {192, 168, 131, 77};
static char tcp_demo_netmask[] = {255, 255, 254, 0};
static char tcp_demo_gwaddr[] = {192, 168, 131, 1};
#ifdef ADD_NUTTX_FEATURES
#define lw_print printf
#define lw_notice printf
#define lw_error printf
@ -46,8 +54,8 @@ char tcp_socket_ip[] = {192, 168, 250, 252};
#define LWIP_TARGET_PORT 4840
#endif
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
char tcp_ip_str[128] = {0};
static uint16_t tcp_socket_port = 8888;
static char tcp_ip_str[128] = {0};
/******************************************************************************/
void TcpSocketConfigParam(char *ip_str)
@ -55,35 +63,23 @@ void TcpSocketConfigParam(char *ip_str)
int ip1, ip2, ip3, ip4, port = 0;
if(ip_str == NULL)
{
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
{
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) {
printf("config ip %s port %d\n", ip_str, port);
strcpy(tcp_ip_str, ip_str);
tcp_socket_ip[0] = ip1;
tcp_socket_ip[1] = ip2;
tcp_socket_ip[2] = ip3;
tcp_socket_ip[3] = ip4;
if(port)
tcp_socket_port = port;
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4))
{
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) {
printf("config ip %s\n", ip_str);
tcp_socket_ip[0] = ip1;
tcp_socket_ip[1] = ip2;
tcp_socket_ip[2] = ip3;
tcp_socket_ip[3] = ip4;
strcpy(tcp_ip_str, ip_str);
}
}
static void TcpSocketRecvTask(void *arg)
static void *TcpSocketRecvTask(void *arg)
{
int fd = -1, clientfd;
int recv_len;
@ -91,18 +87,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;
@ -113,8 +106,7 @@ static void TcpSocketRecvTask(void *arg)
tcp_addr.sin_port = htons(tcp_socket_port);
memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero));
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1)
{
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) {
lw_error("Unable to bind\n");
close(fd);
free(recv_buf);
@ -125,8 +117,7 @@ static void TcpSocketRecvTask(void *arg)
lw_notice("\nLocal Port:%d\n", tcp_socket_port);
// setup socket fd as listening mode
if (listen(fd, 5) != 0 )
{
if (listen(fd, 5) != 0 ) {
lw_error("Unable to listen\n");
close(fd);
free(recv_buf);
@ -137,13 +128,11 @@ 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);
}
@ -157,26 +146,33 @@ static void TcpSocketRecvTask(void *arg)
void TcpSocketRecvTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
TcpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
#ifdef ADD_XIZI_FEATURES
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
TcpSocketRecvTask(NULL);
#ifdef ADD_NUTTX_FEATURES
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&tcp_server_task, &attr, &TcpSocketRecvTask, NULL);
PrivTaskStartup(&tcp_server_task);
}
PRIV_SHELL_CMD_FUNCTION(TcpSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
static void TcpSocketSendTask(void *arg)
static void *TcpSocketSendTask(void *arg)
{
int cnt = LWIP_DEMO_TIMES;
int cnt = TCP_DEMO_SEND_TIMES;
int fd = -1;
int ret;
char send_msg[128];
@ -186,10 +182,9 @@ 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;
return NULL;
}
struct sockaddr_in tcp_sock;
@ -200,17 +195,15 @@ static void TcpSocketSendTask(void *arg)
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
ret = connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr));
if (ret)
{
lw_print("Unable to connect %s = %d\n", tcp_ip_str, ret);
if (ret < 0) {
lw_print("Unable to connect %s:%d = %d\n", tcp_ip_str, tcp_socket_port, ret);
close(fd);
return;
return NULL;
}
lw_print("TCP connect %s:%d success, start to send.\n", tcp_ip_str, 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);
send(fd, send_msg, strlen(send_msg), 0);
@ -219,24 +212,31 @@ static void TcpSocketSendTask(void *arg)
}
close(fd);
return;
return NULL;
}
void TcpSocketSendTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
TcpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
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);
#ifdef ADD_XIZI_FEATURES
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
TcpSocketSendTask(NULL);
#ifdef ADD_NUTTX_FEATURES
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&tcp_client_task, &attr, &TcpSocketSendTask, NULL);
PrivTaskStartup(&tcp_client_task);
}
PRIV_SHELL_CMD_FUNCTION(TcpSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -19,12 +19,12 @@
*/
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include "sys_arch.h"
#ifdef ADD_XIZI_FEATURES
#include <sys_arch.h>
#include "lwip/sockets.h"
#endif
#ifdef ADD_NUTTX_FETURES
#ifdef ADD_NUTTX_FEATURES
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -38,11 +38,20 @@
#define lw_print printf
#endif
#define UDP_BUF_SIZE 65536
#define UDP_DEMO_BUF_SIZE 65535
#define UDP_DEMO_SEND_TIMES 20
#define LWIP_UDP_DEMO_TASK_STACK_SIZE 4096
#define LWIP_UDP_DEMO_TASK_PRIO 20
char udp_socket_ip[] = {192, 168, 250, 252};
char udp_ip_str[128] = {0};
uint16_t udp_socket_port = LWIP_LOCAL_PORT;
static pthread_t udp_client_task;
static pthread_t udp_server_task;
static char udp_demo_ipaddr[] = {192, 168, 131, 77};
static char udp_demo_netmask[] = {255, 255, 254, 0};
static char udp_demo_gwaddr[] = {192, 168, 131, 1};
static char udp_ip_str[128] = {0};
static uint16_t udp_socket_port = 8888;
/*****************************************************************************/
void UdpSocketConfigParam(char *ip_str)
@ -50,53 +59,38 @@ void UdpSocketConfigParam(char *ip_str)
int ip1, ip2, ip3, ip4, port = 0;
if(ip_str == NULL)
{
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
{
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) {
printf("config ip %s port %d\n", ip_str, port);
strcpy(udp_ip_str, ip_str);
udp_socket_ip[0] = ip1;
udp_socket_ip[1] = ip2;
udp_socket_ip[2] = ip3;
udp_socket_ip[3] = ip4;
if(port)
udp_socket_port = port;
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4))
{
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) {
printf("config ip %s\n", ip_str);
udp_socket_ip[0] = ip1;
udp_socket_ip[1] = ip2;
udp_socket_ip[2] = ip3;
udp_socket_ip[3] = ip4;
strcpy(udp_ip_str, ip_str);
}
}
static void UdpSocketRecvTask(void *arg)
static void *UdpSocketRecvTask(void *arg)
{
int fd = -1;
char *recv_buf;
struct sockaddr_in udp_addr, server_addr;
int recv_len;
while(1)
{
recv_buf = (char *)malloc(UDP_BUF_SIZE);
if(recv_buf == NULL)
{
while(1) {
recv_buf = (char *)PrivMalloc(UDP_DEMO_BUF_SIZE);
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;
@ -107,8 +101,7 @@ static void UdpSocketRecvTask(void *arg)
udp_addr.sin_port = htons(udp_socket_port);
memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero));
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1)
{
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) {
lw_error("Unable to bind\n");
close(fd);
free(recv_buf);
@ -118,12 +111,10 @@ static void UdpSocketRecvTask(void *arg)
lw_notice("UDP bind success, start to receive.\n");
lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port);
while(1)
{
memset(recv_buf, 0, UDP_BUF_SIZE);
recv_len = recv(fd, recv_buf, UDP_BUF_SIZE, 0);
if(recv_len > 0)
{
while(1) {
memset(recv_buf, 0, UDP_DEMO_BUF_SIZE);
recv_len = recv(fd, recv_buf, UDP_DEMO_BUF_SIZE, 0);
if(recv_len > 0) {
lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
lw_notice("Receive data : %s\n\n", recv_buf);
}
@ -137,36 +128,41 @@ static void UdpSocketRecvTask(void *arg)
void UdpSocketRecvTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
UdpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL,
LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
#ifdef ADD_XIZI_FEATURES
lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
UdpSocketRecvTask(NULL);
#ifdef ADD_NUTTX_FEATURES
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&udp_server_task, &attr, &UdpSocketRecvTask, NULL);
PrivTaskStartup(&udp_server_task);
}
PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
static void UdpSocketSendTask(void *arg)
static void *UdpSocketSendTask(void *arg)
{
int cnt = LWIP_DEMO_TIMES;
int cnt = UDP_DEMO_SEND_TIMES;
char send_str[128];
int fd = -1;
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;
return NULL;
}
struct sockaddr_in udp_sock;
@ -175,19 +171,17 @@ static void UdpSocketSendTask(void *arg)
udp_sock.sin_addr.s_addr = inet_addr(udp_ip_str);
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
{
lw_error("Unable to connect\n");
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)) < 0) {
lw_error("Unable to connect %s:%d\n", udp_ip_str, udp_socket_port);
close(fd);
return;
return NULL;
}
lw_print("UDP connect %s:%d success, start to send.\n",
udp_ip_str,
udp_socket_port);
while(cnt --)
{
while(cnt --) {
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
send(fd, send_str, strlen(send_str), 0);
lw_notice("Send UDP msg: %s ", send_str);
@ -195,25 +189,31 @@ static void UdpSocketSendTask(void *arg)
}
close(fd);
return;
return NULL;
}
void UdpSocketSendTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
UdpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE,
LWIP_DEMO_TASK_PRIO);
#ifdef ADD_XIZI_FEATURES
lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
UdpSocketSendTask(NULL);
#ifdef ADD_NUTTX_FEATURES
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&udp_client_task, &attr, &UdpSocketSendTask, NULL);
PrivTaskStartup(&udp_client_task);
}
PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -1,3 +1,3 @@
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,3 +1,3 @@
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c br_ppc2100.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,23 @@
# 贝加莱 PPC2100通信测试
[TOC]
## 通信接线及参数设置
* 网口
* 通过ETH1 RJ45 网口连接
* 网口参数IP192.168.250.26 Port502
* 测试的协议:Modbus TCP
## 存储区
- 贝加莱PLC与其他PLC不同没有明确类似MD等这样的存储区的概念Modbus地址取决于库函数中结构体变量索引。
## 通信测试
- 共测试BOOLINT16INT32FLOAT,DOUBLE 共五种类型数据。
- 测试BOOL型变量用功能码01测其他类型变量用功能码03。
-

View File

@ -0,0 +1,64 @@
/*
* 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_ppc2100.c
* @brief PLC BR PPC2100 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.5.8
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlBrTest_PPC2100(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlBrTest_PPC2100, Delta ppc2100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,93 @@
{
"device_id": 1,
"device_name": "BR_PPC2100",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.26",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "motorrun",
"value_type": 1,
"function_code": 2,
"start_address": 0,
"quantity": 1
},
{
"value_name": "motorstop",
"value_type": 1,
"function_code": 2,
"start_address": 1,
"quantity": 1
},
{
"value_name": "valueopen",
"value_type": 1,
"function_code": 1,
"start_address": 100,
"quantity": 1
},
{
"value_name": "valueclose",
"value_type": 1,
"function_code": 1,
"start_address": 101,
"quantity": 1
},
{
"value_name": "step",
"value_type": 3,
"function_code": 4,
"start_address": 100,
"quantity": 1
},
{
"value_name": "temperature",
"value_type": 9,
"function_code": 4,
"start_address": 101,
"quantity": 2
},
{
"value_name": "status",
"value_type": 4,
"function_code": 4,
"start_address": 103,
"quantity": 2
},
{
"value_name": "mode",
"value_type": 3,
"function_code": 3,
"start_address": 200,
"quantity": 1
},
{
"value_name": "setTemperature",
"value_type": 9,
"function_code": 3,
"start_address": 201,
"quantity": 2
},
{
"value_name": "setConuter",
"value_type": 4,
"function_code": 3,
"start_address": 203,
"quantity": 2
},
{
"value_name": "LrealTest",
"value_type": 8,
"function_code": 3,
"start_address": 205,
"quantity": 4
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := delta_as228t.c
SRC_FILES := delta_as228t.c delta_as332t.c delta_dvp.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,22 @@
# 台达 DVP通信测试
[TOC]
## 通信接线及参数设置
* 网口
* 通过自带 RJ45 网口连接
* 网口参数IP192.168.250.27 Port502
* 测试的协议:Modbus TCP
## 存储区
- 含MDXY。台达PLC中 各存储区地址和Modbus地址有明确的对应表详见台达DVP协议解析测试文档。
## 通信测试
- 共测试BOOLINT16INT32FLOAT 共四种类型数据。
- 测试D区M区和Y区。

View File

@ -0,0 +1,64 @@
/*
* 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_dvp.c
* @brief PLC DELTA DVP app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlDeltadvpTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlDeltadvpTest, Delta dvp Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,80 @@
{
"device_id": 1,
"device_name": "DELTA_DVP",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.27",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "M20",
"value_type": 1,
"function_code": 1,
"start_address": 2068,
"quantity": 1
},
{
"value_name": "M100",
"value_type": 1,
"function_code": 1,
"start_address":2148,
"quantity": 1
},
{
"value_name": "Y10",
"value_type": 1,
"function_code": 1,
"start_address": 1288,
"quantity": 1
},
{
"value_name": "D200",
"value_type": 3,
"function_code": 3,
"start_address":4296,
"quantity": 1
},
{
"value_name": "D201",
"value_type": 3,
"function_code": 3,
"start_address": 4297,
"quantity": 1
},
{
"value_name": "D220",
"value_type": 4,
"function_code": 3,
"start_address": 4316,
"quantity": 2
},
{
"value_name": "D222",
"value_type": 4,
"function_code": 3,
"start_address": 4318,
"quantity": 2
},
{
"value_name": "D300",
"value_type": 9,
"function_code": 3,
"start_address": 4396,
"quantity": 2
},
{
"value_name": "D302",
"value_type": 9,
"function_code": 3,
"start_address": 4398,
"quantity": 2
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := ge_versamax001.c ge_cpe100.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,57 @@
---
typora-copy-images-to: upload
---
# 艾默生原GE 通信测试
[TOC]
## 小型VersaMAX CPU001测试
### 通信接线及参数设置
* 串口
* COM2为15孔D型 RS485。波特率19200数据位8位停止位1位校验偶校验。接线按下图典型双线接法。
![ge_versamax_serial](./img/ge_versamax_serial.png)
### 存储区
- 存储区 IQAIR区。其他内存区如MAQ不能直接访问要通过程序转换访问。
### 通信测试
- 共测试BOOLINT16FLOAT共三种类型数据。
- 测试R区及Q区数据。
- R区数据测试用功能码03以字为单位读取。配方中start_address字段为PLC地址直接减1。
- Q区数据测试用功能码01以位为单位读取。配方中start_address字段为PLC地址直接减1。
## 中型PLC CPE100通信测试
### 通信接线及参数设置
- 网口
- 网口RJ45参数 IP192.168.250.28 端口号502
### 存储区
- 存储区 IQAIR区。其他内存区如MAQ不能直接访问要通过程序转换访问。
### 通信测试
- 共测试BOOLINT16INT32FLOATDOUBLE共五种类型数据。
- 测试R区及Q区数据。
- R区数据测试用功能码03以字为单位读取。配方中start_address字段为PLC地址直接减1。
- Q区数据测试用功能码01以位为单位读取。配方中start_address字段为PLC地址直接减1。

View File

@ -0,0 +1,64 @@
/*
* 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 ge_cpe100.c
* @brief PLC GE Versamax app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlGecpe100Test(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlGecpe100Test, ge cpe100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,64 @@
/*
* 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 ge_versamax001.c
* @brief PLC GE Versamax app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlGeversamaxTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
if (NULL == modbus_rtu_protocol) {
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
return;
}
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
ControlProtocolOpen(modbus_rtu_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_rtu_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlGeversamaxTest, ge versamax001 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -0,0 +1,73 @@
{
"device_id": 1,
"device_name": "GE_CPE100_TCP",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.28",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "Q001",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "Q010",
"value_type": 1,
"function_code": 1,
"start_address":9,
"quantity": 1
},
{
"value_name": "Q066",
"value_type": 1,
"function_code": 1,
"start_address": 65,
"quantity": 1
},
{
"value_name": "Q100",
"value_type": 1,
"function_code": 1,
"start_address":99,
"quantity": 1
},
{
"value_name": "R11",
"value_type": 3,
"function_code": 3,
"start_address": 10,
"quantity": 1
},
{
"value_name": "R12",
"value_type": 9,
"function_code": 3,
"start_address": 11,
"quantity": 2
},
{
"value_name": "R14",
"value_type": 8,
"function_code": 3,
"start_address": 13,
"quantity": 4
},
{
"value_name": "R18",
"value_type": 4,
"function_code": 3,
"start_address": 17,
"quantity": 2
}
]
}

View File

@ -0,0 +1,58 @@
{
"device_id": 1,
"device_name": "GE_VersaMAX_RTU",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 19200,
"data_bits": 8,
"stop_bits": 1,
"check_mode": 2
},
"protocol_type": 3,
"read_period": 2000,
"read_item_list": [
{
"value_name": "Q001",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "Q010",
"value_type": 1,
"function_code": 1,
"start_address": 9,
"quantity": 1
},
{
"value_name": "Q066",
"value_type": 1,
"function_code": 1,
"start_address": 65,
"quantity": 1
},
{
"value_name": "Q100",
"value_type": 1,
"function_code": 1,
"start_address": 99,
"quantity": 1
},
{
"value_name": "R11",
"value_type": 3,
"function_code": 3,
"start_address": 10,
"quantity": 1
},
{
"value_name": "R12",
"value_type": 9,
"function_code": 3,
"start_address": 11,
"quantity": 2
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := inovance_am401_cpu1608tn_ethernet.c inovance_am401_cpu1608tn_uart.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,26 @@
# INOVANCE AM4011608TN通信测试
[TOC]
## 通信接线及参数设置
* 网口
* CN3 EtherNET,Mosbus TCP协议IP192.168.250.50Port502
* 串口
* CN1 RS485AM401只支持一路串口AM600可支持两路串口。AM401接线pin1:485-pin2:485+。波特率9600数据位8位停止位1位校验偶校验
## 存储区
- 存储区 IQM区。
## 通信测试
1共测试BOOLINT16INT32FLOAT共四种类型数据。
2测试M区及Q区数据。
3M区数据测试用功能码03以字为单位读取。如读MX0.3,则读取MW0然后按位拆解。如读MW100则配方文件中起始地址则直接写100即可。如读MDx则配方文件中起始地址应为2*x这是汇川的地址编码规则决定如MD200则对应400。
4Q区数据测试用功能码01以位为单位读取。如读QX.Y则配方文件中起始地址为X*8+Y如读QWQD等则需按位进行读取后然后组合得到。

View File

@ -0,0 +1,64 @@
/*
* 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 inovance_am401_cpu1608tn_ethernet.c
* @brief PLC inovance am401 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.25
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlInovanceam401EthernetTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlInovanceam401EthernetTest, inovance am401 ethernet Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,64 @@
/*
* 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 inovance_am401_cpu1608tn_ethernet.c
* @brief PLC inovance am401 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.5.15
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlInovanceam401UartTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
if (NULL == modbus_rtu_protocol) {
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
return;
}
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
ControlProtocolOpen(modbus_rtu_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_rtu_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlInovanceam401UartTest, inovance am401 uart Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,80 @@
{
"device_id": 1,
"device_name": "INOVANCE_AM401_TCP",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.50",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "q00",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "q01",
"value_type": 1,
"function_code": 1,
"start_address":1,
"quantity": 1
},
{
"value_name": "q10",
"value_type": 1,
"function_code": 1,
"start_address": 8,
"quantity": 1
},
{
"value_name": "mw100",
"value_type": 3,
"function_code": 3,
"start_address": 100,
"quantity": 1
},
{
"value_name": "mw101",
"value_type": 3,
"function_code": 3,
"start_address": 101,
"quantity": 1
},
{
"value_name": "md200",
"value_type": 4,
"function_code": 3,
"start_address": 400,
"quantity": 2
},
{
"value_name": "md201",
"value_type": 4,
"function_code": 3,
"start_address": 402,
"quantity": 2
},
{
"value_name": "md300",
"value_type": 9,
"function_code": 3,
"start_address": 600,
"quantity": 2
},
{
"value_name": "md301",
"value_type": 9,
"function_code": 3,
"start_address": 602,
"quantity": 2
}
]
}

View File

@ -0,0 +1,80 @@
{
"device_id": 1,
"device_name": "INOVANCE_am401_RTU",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 9600,
"data_bits": 8,
"stop_bits": 1,
"check_mode":3
},
"protocol_type": 3,
"read_period": 2000,
"read_item_list": [
{
"value_name": "q00",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "q01",
"value_type": 1,
"function_code": 1,
"start_address":1,
"quantity": 1
},
{
"value_name": "q10",
"value_type": 1,
"function_code": 1,
"start_address": 8,
"quantity": 1
},
{
"value_name": "mw100",
"value_type": 3,
"function_code": 3,
"start_address": 100,
"quantity": 1
},
{
"value_name": "mw101",
"value_type": 3,
"function_code": 3,
"start_address": 101,
"quantity": 1
},
{
"value_name": "md200",
"value_type": 4,
"function_code": 3,
"start_address": 400,
"quantity": 2
},
{
"value_name": "md201",
"value_type": 4,
"function_code": 3,
"start_address": 402,
"quantity": 2
},
{
"value_name": "md300",
"value_type": 9,
"function_code": 3,
"start_address": 600,
"quantity": 2
},
{
"value_name": "md301",
"value_type": 9,
"function_code": 3,
"start_address": 602,
"quantity": 2
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := kv_8000.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,22 @@
# KEYENCE 通信测试
[TOC]
## 通信接线及参数设置
* 网口
*Mosbus TCP协议IP192.168.250.40Port502
## 存储区
- 存储区ZF区。
## 通信测试
1共测试INT16类型数据。
2测试ZF区数据。
3D区数据测试用功能码03和06以字为单位读写。如读写ZF1则配方文件中起始地址则直接写1即可。

View File

@ -0,0 +1,53 @@
/*
* 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 kv_8000.c
* @brief PLC KEYENCE KV-8000 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.12
*/
#include <control.h>
void ControlKV8000Test(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlKV8000Test, KEYENCE Plc KV_8000 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,37 @@
{
"device_id": 1,
"device_name": "GJ2",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.40",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "ZF0",
"value_type": 3,
"function_code": 3,
"start_address": 0,
"quantity": 1
},
{
"value_name": "ZF1",
"value_type": 3,
"function_code": 3,
"start_address": 1,
"quantity": 1
},
{
"value_name": "ZF2",
"value_type": 3,
"function_code": 3,
"start_address": 2,
"quantity": 1
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c mitsubishi_fx2n.c mitsubishi_q02u.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,24 @@
# 三菱 FX2N通信测试
[TOC]
## 通信接线及参数设置
* 串口
* FX2N自带8针圆口422用于程序的下载。全系列不支持网口且需购买串口拓展模块FX2N-485-BD用于通信测试。
* 接线RDA和SDA短接引出ARDB与SDB短接引出B。
* 串口模块支持MC-1C协议通信速率9600数据位7bit停止位1bit校验偶校验
## 存储区
- 存储区 IQMD区。
## 通信测试
- 共测试BOOLINT16FLOAT共三种类型数据。
- 测试M区及D区数据。

View File

@ -0,0 +1,64 @@
/*
* 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_fx2n.c
* @brief PLC MITSUBISHI FX2N app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlFx2nTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType melsec_1c_protocol = ControlProtocolFind();
if (NULL == melsec_1c_protocol) {
printf("%s get melsec 1c protocol %p failed\n", __func__, melsec_1c_protocol);
return;
}
printf("%s get melsec 1c protocol %p successfull\n", __func__, melsec_1c_protocol);
if (CONTROL_REGISTERED == melsec_1c_protocol->protocol_status) {
ControlProtocolOpen(melsec_1c_protocol);
for (;;) {
read_data_length = ControlProtocolRead(melsec_1c_protocol, read_data, sizeof(read_data));
printf("%s read [%d] melsec 1c data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(melsec_1c_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlFx2nTest, Mitsubishi FX2N Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -18,6 +18,47 @@
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlFx3uTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType melsec_1e_protocol = ControlProtocolFind();
if (NULL == melsec_1e_protocol) {
printf("%s get melsec 1e protocol %p failed\n", __func__, melsec_1e_protocol);
return;
}
printf("%s get melsec 1e protocol %p successfull\n", __func__, melsec_1e_protocol);
if (CONTROL_REGISTERED == melsec_1e_protocol->protocol_status) {
ControlProtocolOpen(melsec_1e_protocol);
for (;;) {
read_data_length = ControlProtocolRead(melsec_1e_protocol, read_data, sizeof(read_data));
printf("%s read [%d] melsec 1e data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlFx3uTest, Mitsubishi fx3u Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,64 @@
/*
* 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_q02u.c
* @brief PLC MITSUBISHI Q02U app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlQ02uTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType melsec_3e_protocol = ControlProtocolFind();
if (NULL == melsec_3e_protocol) {
printf("%s get melsec 3e protocol %p failed\n", __func__, melsec_3e_protocol);
return;
}
printf("%s get melsec 3e protocol %p successfull\n", __func__, melsec_3e_protocol);
if (CONTROL_REGISTERED == melsec_3e_protocol->protocol_status) {
ControlProtocolOpen(melsec_3e_protocol);
for (;;) {
read_data_length = ControlProtocolRead(melsec_3e_protocol, read_data, sizeof(read_data));
printf("%s read [%d] melsec 3c data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(melsec_3c_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlQ02uTest, Mitsubishi Q02U Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,331 @@
{
"device_id": 769,
"device_name": "S01",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 9600,
"data_bits": 7,
"stop_bits": 1,
"check_mode": 3
},
"protocol_type": 9,
"read_period": 1000,
"read_item_list": [
{
"value_name": "启动",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "0",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "停止",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "1",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "使能",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "2",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "回零",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "3",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "急停",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "4",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "正限位",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "5",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "负限位",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "6",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "自动运行中",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "20",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "故障",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "21",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "待机",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "22",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "手动模式",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "23",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "自动模式",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "24",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "运行方向",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "25",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "复位",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "26",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "备用1",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "27",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "产量",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "0",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型1",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "1",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型2",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "2",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型3",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "3",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型4",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "4",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型5",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "5",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型6",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "50",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型7",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "51",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型8",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "52",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型9",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "53",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "速度",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "200",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "加速度",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "202",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "减速度",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "204",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "起始位置",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "206",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "终点位置",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "208",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "张力值",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "300",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型1",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "302",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型2",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "304",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型3",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "306",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型4",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "308",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c omron_cp1h.c omron_cp1l.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,70 @@
# OMRON_CP1L通信测试
[TOC]
## 通信接线及参数设置
* 本体无接口增加CP1W-CIF41网络板卡
* FINS协议PLC IP192.168.250.31Port9600
## 存储区
- 存储区 WD区。
## JSON配方设计
* 共测试BOOLINT16共2种类型数据,以下为JSON文件解释。
- ```json
{
"device_id": 1, //设备ID默认是1此参数无效
"device_name": "CP1L", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.31", //PLC的IP地址
"local_ip": "192.168.250.233", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port": 9600 //端口号设定
},
"protocol_type": 5, //通讯协议5代表FINS协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "停止", //变量名称,自定义
"value_type": 1, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area_char": "W", //变量功能块
"data_type": 0, //数据传输类型BOOL = 0,WORD = 1
"start_address": 100, //起始地址
"bit_address": 1, //BOOL地址偏移位采集变量地址是W100.1
"data_length": 1 //BOOL长度默认是1代表读取1个BOOL长度
},
{
"value_name": "转速", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area_char": "D", //变量功能块
"data_type": 1, //数据传输类型BOOL = 0,WORD = 1
"start_address": 101, //起始地址
"bit_address": 0, //以WORD采集方式时此参数无效采集变量地址是D101
"data_length": 1 //WORD长度默认是1代表读取1个WORD长度2个字节
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为omron_cp1l.c
(2) 复制样例代码程序到omron_cp1l.c文件中
(3) void **ControlOmronCP1LTest**(void) 更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlOmronCP1LTest**, **Omron Plc Cp1l Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽达通中,重启后完成测试。

View File

@ -18,6 +18,32 @@
* @date 2022.9.27
*/
#include <control.h>
void ControlOmronTest(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(100000);
}
//ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronTest, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,49 @@
/*
* 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_cp1h.c
* @brief PLC OMRON CP1H app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.1
*/
#include <control.h>
void ControlOmronCP1HTest(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(100000);
}
//ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronCP1HTest, Omron Plc Cp1h Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,48 @@
/*
* 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_.cp1l.c
* @brief PLC OMRON CP1L app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.2.10
*/
#include <control.h>
void ControlOmronCP1LTest(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(100000);
}
//ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronCP1LTest, Omron Plc Cp1l Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -18,6 +18,34 @@
* @date 2022.9.27
*/
#include <control.h>
void ControlOmronNX102Test(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(10000);
}
// ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronNX102Test, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,70 @@
{
"device_id": 1,
"device_name": "CP1H",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.46",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 9600
},
"protocol_type": 5,
"read_period": 100,
"read_item_list": [
{
"value_name": "启动",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 10,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "停止",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 10,
"bit_address": 1,
"data_length": 1
},
{
"value_name": "暂停",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 10,
"bit_address": 2,
"data_length": 1
},
{
"value_name": "整型1",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 100,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "整型2",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 101,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "浮点",
"value_type": 9,
"area_char": "D",
"data_type": 1,
"start_address": 110,
"bit_address": 0,
"data_length": 2
}
]
}

View File

@ -0,0 +1,52 @@
{
"device_id": 1,
"device_name": "CP1L",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.31",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 9600
},
"protocol_type": 5,
"read_period": 100,
"read_item_list": [
{
"value_name": "启动",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 100,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "停止",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 100,
"bit_address": 1,
"data_length": 1
},
{
"value_name": "转速",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 101,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "产量",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 102,
"bit_address": 0,
"data_length": 1
}
]
}

View File

@ -0,0 +1,21 @@
# SCHNEIDER M241通信测试
[TOC]
## 通信接线及参数设置
* 串口
* M241支持2路485串口本次采用的是serial2。波特率9600数据位8位停止位1位校验偶校验
## 存储区
- 存储区MW区。
## 通信测试
1共测试INT16共1种类型数据。
2测试MW区数据。
3MW区数据测试用功能码03以字为单位读取。如读MW100则配方文件中起始地址则直接写100即可。

View File

@ -0,0 +1,30 @@
{
"device_id": 1,
"device_name": "m241",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 9600,
"data_bits": 8,
"stop_bits": 1,
"check_mode": 3
},
"protocol_type": 3,
"read_period": 100,
"read_item_list": [
{
"value_name": "MW0",
"value_type": 3,
"function_code": 3,
"start_address": 0,
"quantity": 1
},
{
"value_name": "MW1",
"value_type": 3,
"function_code": 3,
"start_address": 1,
"quantity": 1
}
]
}

View File

@ -15,9 +15,47 @@
* @brief PLC SCHNEIDER M241 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.2.1
*/
#include <control.h>
void ControlM241Test(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
if (NULL == modbus_rtu_protocol) {
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
return;
}
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
ControlProtocolOpen(modbus_rtu_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_rtu_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlM241Test, Schneider M241 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,79 @@
# SIEMENS - S7-1512通信测试
[TOC]
## 通信接线及参数设置
* 本体以太网口
* S7协议PLC IP192.168.250.2Port102
## 存储区
- 存储区 QDB区。
## JSON配方设计
* 共测试BOOLINT16共2种类型数据,以下为JSON文件解释。
- ```json
{
"device_id": 1, //设备ID默认是1此参数无效
"device_name": "S7-1512", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.2", //PLC的IP地址
"local_ip": "192.168.250.233", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port": 102 //端口号设定
},
"protocol_type": 1, //通讯协议5代表FINS协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "布尔1", //变量名称,自定义
"value_type": 1, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area": "Q", //变量功能块
"wordlen": "Bit", //变量字长类型,有Bit Byte Word DWord Real Counter Timer
"db_number": 1, //如为DB区填写对应的DB块编号,如不是DB区无效
"start": 1, //BOOL地址偏移位采集变量地址是Q0.1
"amount": 1 //BOOL长度默认是1代表读取1个BOOL长度
},
{
"value_name": "整型", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area": "DB", //变量功能块
"wordlen": "Word", //变量字长类型,有Bit Byte Word DWord Real Counter Timer
"db_number": 18, //如为DB区即DB18块
"start": 2, //Word地址偏移位采集变量地址是DB18.DBW2
"amount": 1 //Word长度默认是1代表读取1个WORD长度2个字节
},
{
"value_name": "浮点数", //变量名称,自定义
"value_type": 9, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area": "DB", //变量功能块
"wordlen": "Real", //变量字长类型,有Bit Byte Word DWord Real Counter Timer
"db_number": 18, //如为DB区即DB18块
"start": 18, //Real地址偏移位采集变量地址是DB18.DBD18
"amount": 1 //Real长度默认是1代表读取1个Real长度4个字节
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为simens_s7_1500.c
(2) 复制样例代码程序到simens_s7_1500.c文件中
(3) void **ControlS71500Test**(void)更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlS71500Test, Siemens Plc S7_1512 Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽达通中,重启后完成测试。

View File

@ -15,9 +15,6 @@
* @brief PLC SIEMENS S7-1200 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/

View File

@ -15,9 +15,31 @@
* @brief PLC SIEMENS S7-1500 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/
#include <control.h>
void ControlS71500Test(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType s7_protocol = ControlProtocolFind();
if (NULL == s7_protocol) {
printf("%s get s7 protocol %p failed\n", __func__, s7_protocol);
return;
}
printf("%s get s7 protocol %p successfull\n", __func__, s7_protocol);
if (CONTROL_REGISTERED == s7_protocol->protocol_status) {
ControlProtocolOpen(s7_protocol);
for (;;) {
read_data_length = ControlProtocolRead(s7_protocol, read_data, sizeof(read_data));
printf("%s read [%d] s7 data %d using receipe file\n", __func__, i, read_data_length);
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
}
}
PRIV_SHELL_CMD_FUNCTION(ControlS71500Test, Siemens Plc S7_1512 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -11,13 +11,10 @@
*/
/**
* @file siemens_s7_200_smart.c
* @brief PLC SIEMENS S7-200 SMART app
* @file siemens_s7_200 smart.c
* @brief PLC SIEMENS S7-200 smart app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/

View File

@ -15,9 +15,6 @@
* @brief PLC SIEMENS S7-300 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/

View File

@ -0,0 +1,70 @@
{
"device_id": 1,
"device_name": "S7-1512",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.2",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.252",
"netmask": "255.255.255.0",
"port": 102
},
"protocol_type": 1,
"read_period": 100,
"read_item_list": [
{
"value_name": "布尔1",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 1,
"amount": 1
},
{
"value_name": "布尔2",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 2,
"amount": 1
},
{
"value_name": "布尔3",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 3,
"amount": 1
},
{
"value_name": "布尔4",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 4,
"amount": 1
},
{
"value_name": "整型",
"value_type": 3,
"area": "DB",
"wordlen": "Word",
"db_number": 18,
"start": 2,
"amount": 1
},
{
"value_name": "浮点数",
"value_type": 9,
"area": "DB",
"wordlen": "Real",
"db_number": 18,
"start": 18,
"amount": 1
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := xdh_60t4_e.c xsdh_60a32_e.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,23 @@
# XINJIE 通信测试
[TOC]
## 通信接线及参数设置
* 网口
*Mosbus TCP协议IP192.168.250.32Port502
## 存储区
- 存储区M、D区。
## 通信测试
1共测试BOOLINT16共2种类型数据。
2测试M区及D区数据。
3D区数据测试用功能码03和06以字为单位读写。如读写D500则配方文件中起始地址则直接写500即可。
4M区数据测试用功能码01和05以位为单位读写。如读写M19则配方文件中起始地址则直接写19即可。

View File

@ -0,0 +1,184 @@
{
"device_id": 1,
"device_name": "OP01",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.32",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "M19",
"value_type": 1,
"function_code": 5,
"start_address": 19,
"quantity": 1
},
{
"value_name": "M20",
"value_type": 1,
"function_code": 5,
"start_address":20,
"quantity": 1
},
{
"value_name": "D500",
"value_type": 4,
"function_code": 6,
"start_address": 500,
"quantity": 1
},
{
"value_name": "D501",
"value_type": 4,
"function_code": 6,
"start_address": 501,
"quantity": 1
},
{
"value_name": "D502",
"value_type": 4,
"function_code": 6,
"start_address": 502,
"quantity": 1
},
{
"value_name": "D503",
"value_type": 4,
"function_code": 6,
"start_address": 503,
"quantity": 1
},
{
"value_name": "D504",
"value_type": 4,
"function_code": 6,
"start_address": 504,
"quantity": 1
},
{
"value_name": "M22",
"value_type": 1,
"function_code": 5,
"start_address": 22,
"quantity": 1
},
{
"value_name": "D505",
"value_type": 4,
"function_code": 6,
"start_address": 505,
"quantity": 1
},
{
"value_name": "D506",
"value_type": 4,
"function_code": 6,
"start_address": 506,
"quantity": 1
},
{
"value_name": "D507",
"value_type": 4,
"function_code": 6,
"start_address": 507,
"quantity": 1
},
{
"value_name": "D508",
"value_type": 4,
"function_code": 6,
"start_address": 508,
"quantity": 1
},
{
"value_name": "D509",
"value_type": 4,
"function_code": 6,
"start_address": 509,
"quantity": 1
},
{
"value_name": "D510",
"value_type": 4,
"function_code": 6,
"start_address": 510,
"quantity": 1
},
{
"value_name": "D511",
"value_type": 4,
"function_code": 6,
"start_address": 511,
"quantity": 1
},
{
"value_name": "M23",
"value_type": 1,
"function_code": 5,
"start_address": 23,
"quantity": 1
},
{
"value_name": "M24",
"value_type": 1,
"function_code": 5,
"start_address":24,
"quantity": 1
},
{
"value_name": "M25",
"value_type": 1,
"function_code": 5,
"start_address": 25,
"quantity": 1
},
{
"value_name": "M26",
"value_type": 1,
"function_code": 5,
"start_address": 26,
"quantity": 1
},
{
"value_name": "M29",
"value_type": 1,
"function_code": 5,
"start_address": 29,
"quantity": 1
},
{
"value_name": "D513",
"value_type": 4,
"function_code": 3,
"start_address": 513,
"quantity": 1
},
{
"value_name": "D515",
"value_type": 4,
"function_code": 3,
"start_address": 515,
"quantity": 1
},
{
"value_name": "M27",
"value_type": 1,
"function_code": 1,
"start_address":27,
"quantity": 1
},
{
"value_name": "M28",
"value_type": 1,
"function_code": 1,
"start_address":28,
"quantity": 1
}
]
}

View File

@ -0,0 +1,93 @@
{
"device_id": 255,
"device_name": "GJ2",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.45",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "QX40.0",
"value_type": 1,
"function_code": 1,
"start_address":0,
"quantity": 1
},
{
"value_name": "QX40.1",
"value_type": 1,
"function_code": 1,
"start_address": 1,
"quantity": 1
},
{
"value_name": "QX40.2",
"value_type": 1,
"function_code": 1,
"start_address": 2,
"quantity": 1
},
{
"value_name": "QX40.3",
"value_type": 1,
"function_code": 1,
"start_address":3,
"quantity": 1
},
{
"value_name": "QX40.4",
"value_type": 1,
"function_code": 1,
"start_address": 4,
"quantity": 1
},
{
"value_name": "QW0",
"value_type": 3,
"function_code": 3,
"start_address": 0,
"quantity": 2
},
{
"value_name": "QW1",
"value_type": 3,
"function_code": 3,
"start_address": 1,
"quantity": 2
},
{
"value_name": "QW2",
"value_type": 3,
"function_code": 3,
"start_address": 2,
"quantity": 2
},
{
"value_name": "QW3",
"value_type": 3,
"function_code": 3,
"start_address": 3,
"quantity": 2
},
{
"value_name": "QW10",
"value_type": 3,
"function_code": 4,
"start_address": 0,
"quantity": 2
},
{
"value_name": "QW11",
"value_type": 3,
"function_code": 4,
"start_address": 1,
"quantity": 2
}
]
}

View File

@ -0,0 +1,52 @@
/*
* 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 xdh-60t4-e.c
* @brief PLC XINJE XDH-60T4-E app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.5
*/
#include <control.h>
void ControlXDHTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlXDHTest, Xinje Plc XDH_60T4_E Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,53 @@
/*
* 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 xsdh-60a32-e.c
* @brief PLC XINJE XSDH-60A32-E app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.3.28
*/
#include <control.h>
void ControlXSDHTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlXSDHTest, Xinje Plc XSDH_60A32_E Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -1,3 +1,3 @@
SRC_DIR := list
SRC_DIR := list circular_area
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,11 @@
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
CSRCS += circular_area_app.c
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
SRC_FILES := circular_area_app.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -0,0 +1,11 @@
import os
from building import *
Import('RTT_ROOT')
Import('rtconfig')
cwd = GetCurrentDir()
DEPENDS = [""]
SOURCES = ['circular_area_app.c']
path = [cwd]
objs = DefineGroup('circular_area', src = SOURCES, depend = DEPENDS,CPPPATH = path)
Return("objs")

View File

@ -0,0 +1,281 @@
/*
* 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: circular_area_app.c
* @brief: circular area file for applications
* @version: 3.0
* @author: AIIT XUOS Lab
* @date: 2022/11/21
*
*/
#include "circular_area_app.h"
/**
* This function will return whether the circular_area is full or not
*
* @param circular_area CircularAreaApp descriptor
*/
int CircularAreaAppIsFull(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
if((circular_area->readidx == circular_area->writeidx) && (circular_area->b_status)) {
printf("the circular area is full\n");
return 1;
} else {
return 0;
}
}
/**
* This function will return whether the circular_area is empty or not
*
* @param circular_area CircularAreaApp descriptor
*/
int CircularAreaAppIsEmpty(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
if((circular_area->readidx == circular_area->writeidx) && (!circular_area->b_status)) {
//printf("the circular area is empty\n");
return 1;
} else {
return 0;
}
}
/**
* This function will reset the circular_area and set the descriptor to default
*
* @param circular_area CircularAreaApp descriptor
*/
void CircularAreaAppReset(CircularAreaAppType circular_area)
{
circular_area->writeidx = 0;
circular_area->readidx = 0;
circular_area->b_status = 0;
}
/**
* This function will release the circular_area descriptor and free the memory
*
* @param circular_area CircularAreaApp descriptor
*/
void CircularAreaAppRelease(CircularAreaAppType circular_area)
{
circular_area->readidx = 0;
circular_area->writeidx = 0;
circular_area->p_head = NULL;
circular_area->p_tail = NULL;
circular_area->b_status = 0;
circular_area->area_length = 0;
PrivFree(circular_area->data_buffer);
PrivFree(circular_area);
}
/**
* This function will get the circual_area max length
*
* @param circular_area CircularAreaApp descriptor
*/
uint32_t CircularAreaAppGetMaxLength(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
return circular_area->area_length;
}
/**
* This function will get the data length of the circular_area
*
* @param circular_area CircularAreaApp descriptor
*/
uint32_t CircularAreaAppGetDataLength(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
if(CircularAreaAppIsFull(circular_area)) {
return circular_area->area_length;
} else {
return (circular_area->writeidx - circular_area->readidx + circular_area->area_length) % circular_area->area_length;
}
}
/**
* This function will return whether it is need to divide the read data into two parts or not
*
* @param circular_area CircularAreaApp descriptor
* @param data_length output data length
*/
static uint32_t CircularAreaAppDivideRdData(CircularAreaAppType circular_area, uint32_t data_length)
{
CA_PARAM_CHECK(circular_area);
if(circular_area->readidx + data_length <= circular_area->area_length) {
return 0;
} else {
return 1;
}
}
/**
* This function will return whether it is need to divide the write data into two parts or not
*
* @param circular_area CircularAreaApp descriptor
* @param data_length input data length
*/
static uint32_t CircularAreaAppDivideWrData(CircularAreaAppType circular_area, uint32_t data_length)
{
CA_PARAM_CHECK(circular_area);
if(circular_area->writeidx + data_length <= circular_area->area_length) {
return 0;
} else {
return 1;
}
}
/**
* This function will read data from the circular_area
*
* @param circular_area CircularAreaApp descriptor
* @param output_buffer output data buffer poniter
* @param data_length output data length
*/
int CircularAreaAppRead(CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length)
{
CA_PARAM_CHECK(circular_area);
CA_PARAM_CHECK(output_buffer);
CA_CHECK(data_length > 0);
if(CircularAreaAppIsEmpty(circular_area)) {
return -1;
}
int read_length = (data_length > CircularAreaAppGetDataLength(circular_area)) ? CircularAreaAppGetDataLength(circular_area) : data_length;
// if (data_length > CircularAreaAppGetDataLength(circular_area)) {
// return -1;
// }
if(CircularAreaAppDivideRdData(circular_area, read_length)) {
uint32_t read_len_up = circular_area->area_length - circular_area->readidx;
uint32_t read_len_down = read_length - read_len_up;
memcpy(output_buffer, &circular_area->data_buffer[circular_area->readidx], read_len_up);
memcpy(output_buffer + read_len_up, circular_area->p_head, read_len_down);
circular_area->readidx = read_len_down;
} else {
memcpy(output_buffer, &circular_area->data_buffer[circular_area->readidx], read_length);
circular_area->readidx = (circular_area->readidx + read_length) % circular_area->area_length;
}
circular_area->b_status = 0;
return read_length;
}
/**
* This function will write data to the circular_area
*
* @param circular_area CircularAreaApp descriptor
* @param input_buffer input data buffer poniter
* @param data_length input data length
* @param b_force whether to force to write data disregard the length limit
*/
int CircularAreaAppWrite(CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force)
{
CA_PARAM_CHECK(circular_area);
CA_PARAM_CHECK(input_buffer);
CA_CHECK(data_length > 0);
if(CircularAreaAppIsFull(circular_area) && (!b_force)) {
return -1;
}
uint32_t write_data_length = circular_area->area_length - CircularAreaAppGetDataLength(circular_area);
//data_length = (data_length > write_data_length) ? write_data_length : data_length;
if (data_length > write_data_length) {
return -1;
}
if(CircularAreaAppDivideWrData(circular_area, data_length)) {
uint32_t write_len_up = circular_area->area_length - circular_area->writeidx;
uint32_t write_len_down = data_length - write_len_up;
memcpy(&circular_area->data_buffer[circular_area->writeidx], input_buffer, write_len_up);
memcpy(circular_area->p_head, input_buffer + write_len_up, write_len_down);
circular_area->writeidx = write_len_down;
} else {
memcpy(&circular_area->data_buffer[circular_area->writeidx], input_buffer, data_length);
circular_area->writeidx = (circular_area->writeidx + data_length) % circular_area->area_length;
}
circular_area->b_status = 1;
if(b_force) {
circular_area->readidx = circular_area->writeidx;
}
return 0;
}
static struct CircularAreaAppOps CircularAreaAppOperations =
{
CircularAreaAppRead,
CircularAreaAppWrite,
CircularAreaAppRelease,
CircularAreaAppReset,
};
/**
* This function will initialize the circular_area
*
* @param circular_area_length circular_area length
*/
CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length)
{
CA_CHECK(circular_area_length > 0);
circular_area_length = CA_ALIGN_DOWN(circular_area_length, 8);
CircularAreaAppType circular_area = PrivMalloc(sizeof(struct CircularAreaApp));
if(NULL == circular_area) {
printf("CircularAreaAppInit malloc struct circular_area failed\n");
PrivFree(circular_area);
return NULL;
}
CircularAreaAppReset(circular_area);
circular_area->data_buffer = PrivMalloc(circular_area_length);
if(NULL == circular_area->data_buffer) {
printf("CircularAreaAppInit malloc circular_area data_buffer failed\n");
PrivFree(circular_area->data_buffer);
return NULL;
}
circular_area->p_head = circular_area->data_buffer;
circular_area->p_tail = circular_area->data_buffer + circular_area_length;
circular_area->area_length = circular_area_length;
printf("CircularAreaAppInit done p_head %8p p_tail %8p length %u\n",
circular_area->p_head, circular_area->p_tail, circular_area->area_length);
circular_area->CircularAreaAppOperations = &CircularAreaAppOperations;
return circular_area;
}

View File

@ -0,0 +1,109 @@
/*
* 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: circular_area_app.h
* @brief: function declaration and structure defintion of circular area for applications
* @version: 3.0
* @author: AIIT XUOS Lab
* @date: 2022/11/21
*
*/
#ifndef CIRCULAR_AREA_APP_H
#define CIRCULAR_AREA_APP_H
#include <string.h>
#include <transform.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CA_CHECK(TRUE_CONDITION) \
do \
{ \
if(!(TRUE_CONDITION)) { \
printf("%s CHECK condition is false at line[%d] of [%s] func.\n", #TRUE_CONDITION, __LINE__, __func__);\
while(1); \
} \
}while (0)
#define CA_PARAM_CHECK(param) \
do \
{ \
if(param == NULL) { \
printf("PARAM CHECK FAILED ...%s %d %s is NULL.\n", __func__, __LINE__, #param); \
while(1); \
} \
}while (0)
#define CA_ALIGN_DOWN(size, align) ((size)/(align)*(align))
typedef struct CircularAreaApp *CircularAreaAppType;
struct CircularAreaAppOps
{
int (*read) (CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length);
int (*write) (CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force);
void (*release) (CircularAreaAppType circular_area);
void (*reset) (CircularAreaAppType circular_area);
};
struct CircularAreaApp
{
uint8_t *data_buffer;
uint32_t readidx;
uint32_t writeidx;
uint8_t *p_head;
uint8_t *p_tail;
uint32_t area_length;
int b_status;
struct CircularAreaAppOps *CircularAreaAppOperations;
};
/*This function will return whether the circular_area is full or not*/
int CircularAreaAppIsFull(CircularAreaAppType circular_area);
/*This function will return whether the circular_area is empty or not*/
int CircularAreaAppIsEmpty(CircularAreaAppType circular_area);
/*This function will reset the circular_area and set the descriptor to default*/
void CircularAreaAppReset(CircularAreaAppType circular_area);
/*This function will release the circular_area descriptor and free the memory*/
void CircularAreaAppRelease(CircularAreaAppType circular_area);
/*This function will read data from the circular_area*/
int CircularAreaAppRead(CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length);
/*This function will write data to the circular_area*/
int CircularAreaAppWrite(CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force);
/*This function will get the circual_area max length*/
uint32_t CircularAreaAppGetMaxLength(CircularAreaAppType circular_area);
/*This function will get the data length of the circular_area*/
uint32_t CircularAreaAppGetDataLength(CircularAreaAppType circular_area);
/*This function will initialize the circular_area*/
CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,11 +1,11 @@
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
CSRCS += double_list.c single_list.c
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
SRC_FILES := double_list.c single_list.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -1,3 +1,15 @@
SRC_DIR := mnist
SRC_DIR :=
ifeq ($(CONFIG_APP_MNIST),y)
SRC_DIR += mnist
endif
ifeq ($(CONFIG_USING_NNOM_DEMOAPP),y)
SRC_DIR += nnom_demo
endif
ifeq ($(CONFIG_USING_CMSIS_5_DEMOAPP),y)
SRC_DIR += cmsis_5_demo
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,11 @@
SRC_DIR :=
ifeq ($(CONFIG_USING_CMSIS_5_NN_DEMOAPP),y)
SRC_DIR += cmsisnn-cifar10
endif
ifeq ($(CONFIG_USING_CMSIS_5_NN_DEMOAPP_VEG_CLASSIFY),y)
SRC_DIR += cmsisnn_vegetable_classify
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := demo/cmsisnn_demo.c demo/tjpgd.c model/m4/nn.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
# ISSUE
Code in Lib `tjpgd` might be redefined in RT-thread(which has not been tested). if occurs, please try to temporarily delete `tjpgd.c` in dir and `tjpgd.h` in ../model/m4/.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
/*----------------------------------------------------------------------------/
/ TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2019
/----------------------------------------------------------------------------*/
#ifndef DEF_TJPGDEC
#define DEF_TJPGDEC
/*---------------------------------------------------------------------------*/
/* System Configurations */
#define JD_SZBUF 512 /* Size of stream input buffer */
#define JD_FORMAT 1 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */
#define JD_USE_SCALE 1 /* Use descaling feature for output */
#define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
#define JD_SCALE 2 /* 0:1/1 1:1/2 2:1/4 3:1/8 */
/*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) /* Main development platform */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned long uint32_t;
typedef long int32_t;
#else
#include "stdint.h"
#endif
/* Error code */
typedef enum
{
JDR_OK = 0, /* 0: Succeeded */
JDR_INTR, /* 1: Interrupted by output function */
JDR_INP, /* 2: Device error or wrong termination of input stream */
JDR_MEM1, /* 3: Insufficient memory pool for the image */
JDR_MEM2, /* 4: Insufficient stream input buffer */
JDR_PAR, /* 5: Parameter error */
JDR_FMT1, /* 6: Data format error (may be damaged data) */
JDR_FMT2, /* 7: Right format but not supported */
JDR_FMT3 /* 8: Not supported JPEG standard */
} JRESULT;
/* Rectangular structure */
typedef struct
{
uint16_t left, right, top, bottom;
} JRECT;
/* Decompressor object structure */
typedef struct JDEC JDEC;
struct JDEC
{
uint16_t dctr; /* Number of bytes available in the input buffer */
uint8_t *dptr; /* Current data read ptr */
uint8_t *inbuf; /* Bit stream input buffer */
uint8_t dmsk; /* Current bit in the current read byte */
uint8_t scale; /* Output scaling ratio */
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
uint8_t qtid[3]; /* Quantization table ID of each component */
int16_t dcv[3]; /* Previous DC element of each component */
uint16_t nrst; /* Restart inverval */
uint16_t width, height; /* Size of the input image (pixel) */
uint8_t *huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t *huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t *huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t *qttbl[4]; /* Dequantizer tables [id] */
void *workbuf; /* Working buffer for IDCT and RGB output */
uint8_t *mcubuf; /* Working buffer for the MCU */
void *pool; /* Pointer to available memory pool */
uint16_t sz_pool; /* Size of momory pool (bytes available) */
uint16_t (*infunc)(JDEC *, uint8_t *, uint16_t); /* Pointer to jpeg stream input function */
void *device; /* Pointer to I/O device identifiler for the session */
};
/* TJpgDec API functions */
JRESULT jd_prepare (JDEC *, uint16_t(*)(JDEC *, uint8_t *, uint16_t), void *, uint16_t, void *);
JRESULT jd_decomp (JDEC *, uint16_t(*)(JDEC *, void *, JRECT *), uint8_t);
#ifdef __cplusplus
}
#endif
#endif /* _TJPGDEC */

View File

@ -0,0 +1,3 @@
SRC_FILES := cmsisnn_vegetable_classify.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,6 +1,6 @@
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_K210_FFT_TEST), y)

View File

@ -155,7 +155,7 @@ void k210_fft_test(void)
cycle[FFT_SOFT][FFT_DIR_BACKWARD]/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000));
}
#ifdef ADD_NUTTX_FETURES
#ifdef ADD_NUTTX_FEATURES
void nuttx_k210_fft_test(void)
{
pthread_t thread;

Some files were not shown because too many files have changed in this diff Show More