Merge branch '2023_open_source_contest' of https://gitlink.org.cn/xuos/xiuos into pr2
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
@@ -110,7 +110,7 @@ menu "test app"
|
||||
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"
|
||||
@@ -125,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"
|
||||
@@ -137,7 +137,7 @@ 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"
|
||||
@@ -149,7 +149,7 @@ menu "test app"
|
||||
bool "Config test touch"
|
||||
default n
|
||||
if USER_TEST_TOUCH
|
||||
if ADD_XIZI_FETURES
|
||||
if ADD_XIZI_FEATURES
|
||||
config TOUCH_DEV_DRIVER
|
||||
string "Set touch dev path"
|
||||
default "/dev/touch_dev"
|
||||
@@ -164,7 +164,7 @@ menu "test app"
|
||||
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"
|
||||
@@ -176,7 +176,7 @@ menu "test app"
|
||||
bool "Config test can"
|
||||
default n
|
||||
if USER_TEST_CAN
|
||||
if ADD_XIZI_FETURES
|
||||
if ADD_XIZI_FEATURES
|
||||
config CAN_DEV_DRIVER
|
||||
string "Set can dev path"
|
||||
default "/dev/can2_dev1"
|
||||
@@ -189,7 +189,7 @@ menu "test app"
|
||||
bool "Config test camera with lcd"
|
||||
default n
|
||||
if USER_TEST_CAMERA
|
||||
if ADD_XIZI_FETURES
|
||||
if ADD_XIZI_FEATURES
|
||||
config CAMERA_DEV_DRIVER
|
||||
string "Set camera dev path"
|
||||
default "/dev/camera_dev"
|
||||
@@ -211,7 +211,7 @@ menu "test app"
|
||||
bool "Config test ethernet only for edu-riscv64"
|
||||
default n
|
||||
if USER_TEST_ETHERNET
|
||||
if ADD_XIZI_FETURES
|
||||
if ADD_XIZI_FEATURES
|
||||
choice
|
||||
prompt "set ethernet role as client or server"
|
||||
default ETHERNET_AS_SERVER
|
||||
@@ -229,7 +229,7 @@ menu "test app"
|
||||
bool "Config test w25q128 device"
|
||||
default n
|
||||
if USER_TEST_FLASH
|
||||
if ADD_XIZI_FETURES
|
||||
if ADD_XIZI_FEATURES
|
||||
config FLASH_DEV_DRIVER
|
||||
string "Set flash dev path"
|
||||
default "/dev/qspi_W25Q128"
|
||||
|
||||
@@ -1,6 +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)
|
||||
@@ -23,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
|
||||
SRC_FILES += test_hash.c
|
||||
ifeq ($(CONFIG_USER_TEST_ADC),y)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
void TestAdc(void)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
static uint16_t image_buff[384000];
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
|
||||
void TestCAN(void)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
void TestDac(void)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#include <socket.h>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
void TestFlash(void)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#define MAX_READ_LENGTH 1000
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#ifdef BOARD_EDU_RISCV64_EVB
|
||||
#define BSP_LED_PIN 29
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#define BSP_LED_PIN 134
|
||||
#define NULL_PARAMETER 0
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#define I2C_SLAVE_ADDRESS 0x0012U
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef ADD_NUTTX_FEATURES
|
||||
|
||||
#ifdef CONFIG_K210_LCD
|
||||
void LcdDemo(void)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#define GRAPHIC_CTRL_RECT_UPDATE 0x00
|
||||
#define LCD_STRING_TYPE 0
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#define NULL_PARAMETER 0
|
||||
#define E220_CFG_LENGTH
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef ADD_NUTTX_FEATURES
|
||||
|
||||
#if defined(CONFIG_MUSL_LIBC) && defined(CONFIG_FS_AUTOMOUNTER)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
#define BSP_485_DIR_PIN 24
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
void TestRTC(int argc,char *argv[])
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef ADD_NUTTX_FEATURES
|
||||
|
||||
#ifdef CONFIG_BSP_USING_TOUCH
|
||||
void TestTouch(void)
|
||||
@@ -48,7 +48,7 @@ void TestTouch(void)
|
||||
#define LCD_DOT_TYPE 1
|
||||
#define LCD_SIZE 320
|
||||
|
||||
#elif defined ADD_XIZI_FETURES
|
||||
#elif defined ADD_XIZI_FEATURES
|
||||
|
||||
void TestTouch(void)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
|
||||
void TestWDT(int argc, char *agrv[])
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#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>
|
||||
@@ -45,7 +45,7 @@ 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_FETURES
|
||||
#ifdef ADD_NUTTX_FEATURES
|
||||
#define lw_print printf
|
||||
#define lw_notice printf
|
||||
#define lw_error printf
|
||||
@@ -151,7 +151,7 @@ void TcpSocketRecvTest(int argc, char *argv[])
|
||||
TcpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
|
||||
|
||||
pthread_attr_t attr;
|
||||
@@ -159,7 +159,7 @@ void TcpSocketRecvTest(int argc, char *argv[])
|
||||
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#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;
|
||||
@@ -222,14 +222,14 @@ void TcpSocketSendTest(int argc, char *argv[])
|
||||
TcpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#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
|
||||
#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;
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
*/
|
||||
#include <transform.h>
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#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>
|
||||
@@ -133,14 +133,14 @@ void UdpSocketRecvTest(int argc, char *argv[])
|
||||
UdpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#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
|
||||
#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;
|
||||
@@ -199,14 +199,14 @@ void UdpSocketSendTest(int argc, char *argv[])
|
||||
UdpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#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
|
||||
#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;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance
|
||||
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
SRC_FILES := inovance_am401_cpu1608tn_ethernet.c
|
||||
SRC_FILES := inovance_am401_cpu1608tn_ethernet.c inovance_am401_cpu1608tn_uart.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
+64
@@ -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);
|
||||
|
||||
|
||||
+80
@@ -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
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
SRC_FILES := kv_8000.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,22 @@
|
||||
# KEYENCE 通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 网口
|
||||
|
||||
*Mosbus TCP协议,IP:192.168.250.40,Port:502
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区ZF区。
|
||||
|
||||
## 通信测试
|
||||
|
||||
(1)共测试INT16类型数据。
|
||||
|
||||
(2)测试ZF区数据。
|
||||
|
||||
(3)D区数据测试,用功能码03和06,以字为单位读写。如读写ZF1,则配方文件中起始地址则直接写1即可。
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# SCHNEIDER M241通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 串口
|
||||
* M241支持2路485串口,本次采用的是serial2。波特率:9600,数据位:8位,停止位:1位,校验:偶校验
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区MW区。
|
||||
|
||||
## 通信测试
|
||||
|
||||
(1)共测试INT16共1种类型数据。
|
||||
|
||||
(2)测试MW区数据。
|
||||
|
||||
(3)MW区数据测试,用功能码03,以字为单位读取。如读MW100,则配方文件中起始地址则直接写100即可。
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# XINJIE 通信测试
|
||||
|
||||
[TOC]
|
||||
|
||||
## 通信接线及参数设置
|
||||
|
||||
* 网口
|
||||
|
||||
*Mosbus TCP协议,IP:192.168.250.32,Port:502
|
||||
|
||||
## 存储区
|
||||
|
||||
- 存储区M、D区。
|
||||
|
||||
## 通信测试
|
||||
|
||||
(1)共测试BOOL,INT16共2种类型数据。
|
||||
|
||||
(2)测试M区及D区数据。
|
||||
|
||||
(3)D区数据测试,用功能码03和06,以字为单位读写。如读写D500,则配方文件中起始地址则直接写500即可。
|
||||
|
||||
(4)M区数据测试,用功能码01和05,以位为单位读写。如读写M19,则配方文件中起始地址则直接写19即可。
|
||||
@@ -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 += circular_area_app.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
|
||||
SRC_FILES := circular_area_app.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -71,7 +71,7 @@ void mnist_nnom(int argc, char **argv)
|
||||
printf("Predicted label: %d\n", predic_label);
|
||||
printf("Probability: %d%%\n", (int)(prob * 100));
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
#ifdef ADD_XIZI_FEATURES
|
||||
PRIV_SHELL_CMD_FUNCTION(mnist_nnom, a mnist_nnom test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
#endif
|
||||
#ifdef __RT_THREAD_H__
|
||||
|
||||
@@ -108,7 +108,7 @@ menu "sensor app"
|
||||
bool "Using sensor HS300x apps"
|
||||
default n
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
if ADD_NUTTX_FEATURES
|
||||
endif
|
||||
|
||||
endif
|
||||
@@ -122,7 +122,7 @@ menu "sensor app"
|
||||
bool "Using sensor HS300x apps"
|
||||
default n
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
if ADD_NUTTX_FEATURES
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
@@ -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_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
|
||||
@@ -64,7 +64,7 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
|
||||
SRC_FILES :=
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
|
||||
|
||||
Reference in New Issue
Block a user