forked from xuos/xiuos
Merge pull request 'merge code' (#1) from develop into prepare_for_master
This commit is contained in:
commit
2ce43f3a1b
|
@ -2,6 +2,7 @@
|
||||||
# APP_Framework/Applications/Make.defs
|
# APP_Framework/Applications/Make.defs
|
||||||
############################################################################
|
############################################################################
|
||||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
|
||||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
|
||||||
|
|
||||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)
|
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)
|
||||||
|
|
|
@ -4,10 +4,6 @@ menu "test app"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
if USER_TEST
|
if USER_TEST
|
||||||
config USER_TEST_SPI_FLASH
|
|
||||||
bool "Config test spi flash"
|
|
||||||
default n
|
|
||||||
|
|
||||||
menuconfig USER_TEST_ADC
|
menuconfig USER_TEST_ADC
|
||||||
bool "Config test adc"
|
bool "Config test adc"
|
||||||
default n
|
default n
|
||||||
|
@ -29,5 +25,13 @@ menu "test app"
|
||||||
default "/dev/dac_dev"
|
default "/dev/dac_dev"
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
config USER_TEST_SEMC
|
||||||
|
bool "Config test semc sdram"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config USER_TEST_LCD
|
||||||
|
bool "Config test lcd device"
|
||||||
|
default n
|
||||||
endif
|
endif
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
############################################################################
|
||||||
|
# APP_Framework/Applications/app_test/Make.defs
|
||||||
|
############################################################################
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
|
||||||
|
|
||||||
|
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/app_test/*/Make.defs)
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
SRC_FILES :=
|
SRC_FILES := test_shell.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y)
|
|
||||||
SRC_FILES += test_spi_flash.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_USER_TEST_ADC),y)
|
ifeq ($(CONFIG_USER_TEST_ADC),y)
|
||||||
SRC_FILES += test_adc.c
|
SRC_FILES += test_adc.c
|
||||||
|
@ -12,4 +8,22 @@ ifeq ($(CONFIG_USER_TEST_DAC),y)
|
||||||
SRC_FILES += test_dac.c
|
SRC_FILES += test_dac.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USER_TEST_SEMC),y)
|
||||||
|
SRC_FILES += test_extsram.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USER_TEST_LCD),y)
|
||||||
|
SRC_FILES +=
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/.config
|
||||||
|
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
CSRCS += test_extsram.c test_lcd.c
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import os
|
||||||
|
from building import *
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
DEPENDS = [""]
|
||||||
|
|
||||||
|
SOURCES = ['test_shell.c']
|
||||||
|
path = [cwd]
|
||||||
|
objs = DefineGroup('app_test', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||||
|
Return("objs")
|
|
@ -22,7 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <transform.h>
|
#include <transform.h>
|
||||||
|
|
||||||
void test_adc()
|
void TestAdc(void)
|
||||||
{
|
{
|
||||||
int adc_fd;
|
int adc_fd;
|
||||||
uint8 adc_channel = 0x0;
|
uint8 adc_channel = 0x0;
|
||||||
|
@ -56,6 +56,4 @@ void test_adc()
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
|
||||||
adc, test_adc, read 3.3 voltage data from adc);
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <transform.h>
|
#include <transform.h>
|
||||||
|
|
||||||
void test_dac()
|
void TestDac(void)
|
||||||
{
|
{
|
||||||
int dac_fd;
|
int dac_fd;
|
||||||
uint16 dac_set_value = 800;
|
uint16 dac_set_value = 800;
|
||||||
|
@ -56,5 +56,4 @@ void test_dac()
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
test_dac, test_dac, set digital data to dac);
|
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: test_extsram.c
|
||||||
|
* @brief: a extsram test application
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <transform.h>
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
/* parameters for sram peripheral */
|
||||||
|
// /* stm32f4 Bank3:0X68000000 */
|
||||||
|
// #define SRAM_BANK_ADDR ((uint32_t)0X68000000)
|
||||||
|
|
||||||
|
/* OK-1052 semc:0X80000000 */
|
||||||
|
#define SRAM_BANK_ADDR ((uint32_t)0X80000000)
|
||||||
|
|
||||||
|
/* data width: 8, 16, 32 */
|
||||||
|
#define SRAM_DATA_WIDTH 16
|
||||||
|
|
||||||
|
/* sram size */
|
||||||
|
#define SRAM_SIZE ((uint32_t)0x2000000)
|
||||||
|
|
||||||
|
#define TICK_PER_SECOND 100
|
||||||
|
|
||||||
|
int ExtsramTest(void)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
uint32_t start_time = 0, time_cast = 0;
|
||||||
|
#if SRAM_DATA_WIDTH == 8
|
||||||
|
char data_width = 1;
|
||||||
|
uint8_t data = 0;
|
||||||
|
#elif SRAM_DATA_WIDTH == 16
|
||||||
|
char data_width = 2;
|
||||||
|
uint16_t data = 0;
|
||||||
|
#else
|
||||||
|
char data_width = 4;
|
||||||
|
uint32_t data = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* write data */
|
||||||
|
printf("Writing the %ld bytes data, waiting....\n", SRAM_SIZE);
|
||||||
|
start_time = PrivGetTickTime();
|
||||||
|
for (i = 0; i < SRAM_SIZE / data_width; i++)
|
||||||
|
{
|
||||||
|
#if SRAM_DATA_WIDTH == 8
|
||||||
|
*(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width) = (uint8_t)0x55;
|
||||||
|
#elif SRAM_DATA_WIDTH == 16
|
||||||
|
*(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width) = (uint16_t)0x5555;
|
||||||
|
#else
|
||||||
|
*(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width) = (uint32_t)0x55555555;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
time_cast = PrivGetTickTime() - start_time;
|
||||||
|
printf("Write data success, total time: %ld.%03ldS.\n", time_cast / TICK_PER_SECOND,
|
||||||
|
time_cast % TICK_PER_SECOND / ((TICK_PER_SECOND * 1 + 999) / 1000));
|
||||||
|
|
||||||
|
/* read data */
|
||||||
|
printf("start Reading and verifying data, waiting....\n");
|
||||||
|
for (i = 0; i < SRAM_SIZE / data_width; i++)
|
||||||
|
{
|
||||||
|
#if SRAM_DATA_WIDTH == 8
|
||||||
|
data = *(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||||
|
if (data != 0x55)
|
||||||
|
{
|
||||||
|
printf("SRAM test failed!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#elif SRAM_DATA_WIDTH == 16
|
||||||
|
data = *(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||||
|
if (data != 0x5555)
|
||||||
|
{
|
||||||
|
printf("SRAM test failed! data = 0x%x\n",data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
data = *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||||
|
if (data != 0x55555555)
|
||||||
|
{
|
||||||
|
printf("SRAM test failed!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= SRAM_SIZE / data_width)
|
||||||
|
{
|
||||||
|
printf("SRAM test success!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(ExtsramTest, a extsram test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
|
@ -0,0 +1,522 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* apps/examples/fb/fb_main.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
|
||||||
|
#ifdef CONFIG_K210_LCD
|
||||||
|
|
||||||
|
#include "nuttx/arch.h"
|
||||||
|
#include "nuttx/lcd/lt768.h"
|
||||||
|
#include "nuttx/lcd/lt768_lib.h"
|
||||||
|
#include "nuttx/lcd/k210_lcd.h"
|
||||||
|
|
||||||
|
void LcdDemo(void)
|
||||||
|
{
|
||||||
|
int x1 = 50, y1 = 50, x2 = LCD_XSIZE_TFT - 50, y2 = LCD_YSIZE_TFT - 50;
|
||||||
|
|
||||||
|
Main_Image_Start_Address(LCD_START_ADDR);
|
||||||
|
Main_Image_Width(LCD_XSIZE_TFT);
|
||||||
|
Main_Window_Start_XY(0, 0);
|
||||||
|
Canvas_Image_Start_address(LCD_START_ADDR);
|
||||||
|
Canvas_image_width(LCD_XSIZE_TFT);
|
||||||
|
Active_Window_XY(0, 0);
|
||||||
|
Active_Window_WH(LCD_XSIZE_TFT, LCD_YSIZE_TFT);
|
||||||
|
up_mdelay(10);
|
||||||
|
Canvas_Image_Start_address(LCD_START_ADDR);
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
x1 = 50;
|
||||||
|
y1 = 50;
|
||||||
|
x2 = LCD_XSIZE_TFT - 50;
|
||||||
|
y2 = LCD_YSIZE_TFT - 50;
|
||||||
|
syslog(LOG_NOTICE, "Disp_demo %d (%d,%d - %d,%d)\n", i, x1, y1, x2, y2);
|
||||||
|
LT768_DrawSquare_Fill(x1, y1, x2, y2, Red);
|
||||||
|
up_mdelay(2000);
|
||||||
|
x1 += 20;
|
||||||
|
y1 += 20;
|
||||||
|
x2 -= 20;
|
||||||
|
y2 -= 20;
|
||||||
|
LT768_DrawSquare_Fill(x1, y1, x2, y2, Green);
|
||||||
|
up_mdelay(2000);
|
||||||
|
x1 += 20;
|
||||||
|
y1 += 20;
|
||||||
|
x2 -= 20;
|
||||||
|
y2 -= 20;
|
||||||
|
LT768_DrawSquare_Fill(x1, y1, x2, y2, Blue);
|
||||||
|
up_mdelay(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/video/fb.h>
|
||||||
|
#include <nuttx/video/rgbcolors.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Preprocessor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define NCOLORS 6
|
||||||
|
#define TEST_FB_DEV "/dev/fb0"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct fb_state_s
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
struct fb_videoinfo_s vinfo;
|
||||||
|
struct fb_planeinfo_s pinfo;
|
||||||
|
#ifdef CONFIG_FB_OVERLAY
|
||||||
|
struct fb_overlayinfo_s oinfo;
|
||||||
|
#endif
|
||||||
|
FAR void *fbmem;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static const char g_default_fbdev[] = TEST_FB_DEV;
|
||||||
|
|
||||||
|
/* Violet-Blue-Green-Yellow-Orange-Red */
|
||||||
|
|
||||||
|
static const uint32_t g_rgb24[NCOLORS] =
|
||||||
|
{
|
||||||
|
RGB24_VIOLET, RGB24_BLUE, RGB24_GREEN,
|
||||||
|
RGB24_YELLOW, RGB24_ORANGE, RGB24_RED
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint16_t g_rgb16[NCOLORS] =
|
||||||
|
{
|
||||||
|
RGB16_VIOLET, RGB16_BLUE, RGB16_GREEN,
|
||||||
|
RGB16_YELLOW, RGB16_ORANGE, RGB16_RED
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t g_rgb8[NCOLORS] =
|
||||||
|
{
|
||||||
|
RGB8_VIOLET, RGB8_BLUE, RGB8_GREEN,
|
||||||
|
RGB8_YELLOW, RGB8_ORANGE, RGB8_RED
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* draw_rect
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void draw_rect32(FAR struct fb_state_s *state,
|
||||||
|
FAR struct fb_area_s *area, int color)
|
||||||
|
{
|
||||||
|
FAR uint32_t *dest;
|
||||||
|
FAR uint8_t *row;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y;
|
||||||
|
for (y = 0; y < area->h; y++)
|
||||||
|
{
|
||||||
|
dest = ((FAR uint32_t *)row) + area->x;
|
||||||
|
for (x = 0; x < area->w; x++)
|
||||||
|
{
|
||||||
|
*dest++ = g_rgb24[color];
|
||||||
|
}
|
||||||
|
|
||||||
|
row += state->pinfo.stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_rect16(FAR struct fb_state_s *state,
|
||||||
|
FAR struct fb_area_s *area, int color)
|
||||||
|
{
|
||||||
|
FAR uint16_t *dest;
|
||||||
|
FAR uint8_t *row;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y;
|
||||||
|
for (y = 0; y < area->h; y++)
|
||||||
|
{
|
||||||
|
dest = ((FAR uint16_t *)row) + area->x;
|
||||||
|
for (x = 0; x < area->w; x++)
|
||||||
|
{
|
||||||
|
*dest++ = g_rgb16[color];
|
||||||
|
}
|
||||||
|
|
||||||
|
row += state->pinfo.stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_rect8(FAR struct fb_state_s *state,
|
||||||
|
FAR struct fb_area_s *area, int color)
|
||||||
|
{
|
||||||
|
FAR uint8_t *dest;
|
||||||
|
FAR uint8_t *row;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y;
|
||||||
|
for (y = 0; y < area->h; y++)
|
||||||
|
{
|
||||||
|
dest = row + area->x;
|
||||||
|
for (x = 0; x < area->w; x++)
|
||||||
|
{
|
||||||
|
*dest++ = g_rgb8[color];
|
||||||
|
}
|
||||||
|
|
||||||
|
row += state->pinfo.stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_rect1(FAR struct fb_state_s *state,
|
||||||
|
FAR struct fb_area_s *area, int color)
|
||||||
|
{
|
||||||
|
FAR uint8_t *pixel;
|
||||||
|
FAR uint8_t *row;
|
||||||
|
uint8_t color8 = (color & 1) == 0 ? 0 : 0xff;
|
||||||
|
uint8_t lmask;
|
||||||
|
uint8_t rmask;
|
||||||
|
int startx;
|
||||||
|
int endx;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
/* Calculate the framebuffer address of the first row to draw on */
|
||||||
|
|
||||||
|
row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y;
|
||||||
|
|
||||||
|
/* Calculate the start byte position rounding down so that we get the
|
||||||
|
* first byte containing any part of the pixel sequence. Then calculate
|
||||||
|
* the last byte position with a ceil() operation so it includes any final
|
||||||
|
* final pixels of the sequence.
|
||||||
|
*/
|
||||||
|
|
||||||
|
startx = (area->x >> 3);
|
||||||
|
endx = ((area->x + area->w + 6) >> 3);
|
||||||
|
|
||||||
|
/* Calculate a mask on the first and last bytes of the sequence that may
|
||||||
|
* not be completely filled with pixel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
lmask = 0xff << (8 - (area->x & 7));
|
||||||
|
rmask = 0xff >> ((area->x + area->w - 1) & 7);
|
||||||
|
|
||||||
|
/* Now draw each row, one-at-a-time */
|
||||||
|
|
||||||
|
for (y = 0; y < area->h; y++)
|
||||||
|
{
|
||||||
|
/* 'pixel' points to the 1st pixel the next row */
|
||||||
|
|
||||||
|
pixel = row + startx;
|
||||||
|
|
||||||
|
/* Special case: The row is less no more than one byte wide */
|
||||||
|
|
||||||
|
if (startx == endx)
|
||||||
|
{
|
||||||
|
uint8_t mask = lmask | rmask;
|
||||||
|
|
||||||
|
*pixel = (*pixel & mask) | (color8 & ~mask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Special case the first byte of the row */
|
||||||
|
|
||||||
|
*pixel = (*pixel & lmask) | (color8 & ~lmask);
|
||||||
|
pixel++;
|
||||||
|
|
||||||
|
/* Handle all middle bytes in the row */
|
||||||
|
|
||||||
|
for (x = startx + 1; x < endx; x++)
|
||||||
|
{
|
||||||
|
*pixel++ = color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the final byte of the row */
|
||||||
|
|
||||||
|
*pixel = (*pixel & rmask) | (color8 & ~rmask);
|
||||||
|
}
|
||||||
|
|
||||||
|
row += state->pinfo.stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_rect(FAR struct fb_state_s *state,
|
||||||
|
FAR struct fb_area_s *area, int color)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_FB_UPDATE
|
||||||
|
int ret;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (state->pinfo.bpp)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
draw_rect32(state, area, color);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
draw_rect16(state, area, color);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
default:
|
||||||
|
draw_rect8(state, area, color);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
draw_rect1(state, area, color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_FB_UPDATE
|
||||||
|
ret = ioctl(state->fd, FBIO_UPDATE,
|
||||||
|
(unsigned long)((uintptr_t)area));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: ioctl(FBIO_UPDATE) failed: %d\n",
|
||||||
|
errcode);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* fb_main
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int test_lcd(int argc, FAR char *argv[])
|
||||||
|
{
|
||||||
|
FAR const char *fbdev = g_default_fbdev;
|
||||||
|
struct fb_state_s state;
|
||||||
|
struct fb_area_s area;
|
||||||
|
int nsteps;
|
||||||
|
int xstep;
|
||||||
|
int ystep;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int color;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* There is a single required argument: The path to the framebuffer
|
||||||
|
* driver.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
fbdev = argv[1];
|
||||||
|
}
|
||||||
|
else if (argc != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Single argument required\n");
|
||||||
|
fprintf(stderr, "USAGE: %s [<fb-driver-path>]\n", argv[0]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the framebuffer driver */
|
||||||
|
|
||||||
|
state.fd = open(fbdev, O_RDWR);
|
||||||
|
if (state.fd < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: Failed to open %s: %d\n", fbdev, errcode);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the characteristics of the framebuffer */
|
||||||
|
|
||||||
|
ret = ioctl(state.fd, FBIOGET_VIDEOINFO,
|
||||||
|
(unsigned long)((uintptr_t)&state.vinfo));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: ioctl(FBIOGET_VIDEOINFO) failed: %d\n",
|
||||||
|
errcode);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
printf("2022-10-14 Mr. Wang commit LCD\n");
|
||||||
|
printf("VideoInfo:\n");
|
||||||
|
printf(" fmt: %u\n", state.vinfo.fmt);
|
||||||
|
printf(" xres: %u\n", state.vinfo.xres);
|
||||||
|
printf(" yres: %u\n", state.vinfo.yres);
|
||||||
|
printf(" nplanes: %u\n", state.vinfo.nplanes);
|
||||||
|
|
||||||
|
#ifdef CONFIG_FB_OVERLAY
|
||||||
|
printf("noverlays: %u\n", state.vinfo.noverlays);
|
||||||
|
|
||||||
|
/* Select the first overlay, which should be the composed framebuffer */
|
||||||
|
|
||||||
|
ret = ioctl(state.fd, FBIO_SELECT_OVERLAY, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: ioctl(FBIO_SELECT_OVERLAY) failed: %d\n",
|
||||||
|
errcode);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the first overlay information */
|
||||||
|
|
||||||
|
state.oinfo.overlay = 0;
|
||||||
|
ret = ioctl(state.fd, FBIOGET_OVERLAYINFO,
|
||||||
|
(unsigned long)((uintptr_t)&state.oinfo));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: ioctl(FBIOGET_OVERLAYINFO) failed: %d\n",
|
||||||
|
errcode);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("OverlayInfo (overlay 0):\n");
|
||||||
|
printf(" fbmem: %p\n", state.oinfo.fbmem);
|
||||||
|
printf(" fblen: %lu\n", (unsigned long)state.oinfo.fblen);
|
||||||
|
printf(" stride: %u\n", state.oinfo.stride);
|
||||||
|
printf(" overlay: %u\n", state.oinfo.overlay);
|
||||||
|
printf(" bpp: %u\n", state.oinfo.bpp);
|
||||||
|
printf(" blank: %u\n", state.oinfo.blank);
|
||||||
|
printf("chromakey: 0x%08" PRIx32 "\n", state.oinfo.chromakey);
|
||||||
|
printf(" color: 0x%08" PRIx32 "\n", state.oinfo.color);
|
||||||
|
printf(" transp: 0x%02x\n", state.oinfo.transp.transp);
|
||||||
|
printf(" mode: %u\n", state.oinfo.transp.transp_mode);
|
||||||
|
printf(" area: (%u,%u) => (%u,%u)\n",
|
||||||
|
state.oinfo.sarea.x, state.oinfo.sarea.y,
|
||||||
|
state.oinfo.sarea.w, state.oinfo.sarea.h);
|
||||||
|
printf(" accl: %" PRIu32 "\n", state.oinfo.accl);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = ioctl(state.fd, FBIOGET_PLANEINFO,
|
||||||
|
(unsigned long)((uintptr_t)&state.pinfo));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n",
|
||||||
|
errcode);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("PlaneInfo (plane 0):\n");
|
||||||
|
printf(" fbmem: %p\n", state.pinfo.fbmem);
|
||||||
|
printf(" fblen: %lu\n", (unsigned long)state.pinfo.fblen);
|
||||||
|
printf(" stride: %u\n", state.pinfo.stride);
|
||||||
|
printf(" display: %u\n", state.pinfo.display);
|
||||||
|
printf(" bpp: %u\n", state.pinfo.bpp);
|
||||||
|
|
||||||
|
/* Only these pixel depths are supported. viinfo.fmt is ignored, only
|
||||||
|
* certain color formats are supported.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (state.pinfo.bpp != 32 && state.pinfo.bpp != 16 &&
|
||||||
|
state.pinfo.bpp != 8 && state.pinfo.bpp != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: bpp=%u not supported\n", state.pinfo.bpp);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mmap() the framebuffer.
|
||||||
|
*
|
||||||
|
* NOTE: In the FLAT build the frame buffer address returned by the
|
||||||
|
* FBIOGET_PLANEINFO IOCTL command will be the same as the framebuffer
|
||||||
|
* address. mmap(), however, is the preferred way to get the framebuffer
|
||||||
|
* address because in the KERNEL build, it will perform the necessary
|
||||||
|
* address mapping to make the memory accessible to the application.
|
||||||
|
*/
|
||||||
|
|
||||||
|
state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED | MAP_FILE, state.fd, 0);
|
||||||
|
if (state.fbmem == MAP_FAILED)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n",
|
||||||
|
errcode);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Mapped FB: %p\n", state.fbmem);
|
||||||
|
|
||||||
|
/* Draw some rectangles */
|
||||||
|
|
||||||
|
nsteps = 2 * (NCOLORS - 1) + 1;
|
||||||
|
xstep = state.vinfo.xres / nsteps;
|
||||||
|
ystep = state.vinfo.yres / nsteps;
|
||||||
|
width = state.vinfo.xres;
|
||||||
|
height = state.vinfo.yres;
|
||||||
|
|
||||||
|
for (x = 0, y = 0, color = 0;
|
||||||
|
color < NCOLORS;
|
||||||
|
x += xstep, y += ystep, color++)
|
||||||
|
{
|
||||||
|
area.x = x;
|
||||||
|
area.y = y;
|
||||||
|
area.w = width;
|
||||||
|
area.h = height;
|
||||||
|
|
||||||
|
printf("%2d: (%3d,%3d) (%3d,%3d)\n",
|
||||||
|
color, area.x, area.y, area.w, area.h);
|
||||||
|
|
||||||
|
draw_rect(&state, &area, color);
|
||||||
|
usleep(500 * 1000);
|
||||||
|
|
||||||
|
width -= (2 * xstep);
|
||||||
|
height -= (2 * ystep);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Test finished\n");
|
||||||
|
munmap(state.fbmem, state.pinfo.fblen);
|
||||||
|
close(state.fd);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LcdDemo(void)
|
||||||
|
{
|
||||||
|
test_lcd(1, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: test_shell.c
|
||||||
|
* @brief: a application of shell function
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <transform.h>
|
||||||
|
|
||||||
|
void TestShellMain(int argc, char *agrv[])
|
||||||
|
{
|
||||||
|
printf("%dparameter(s)\r\n", argc);
|
||||||
|
for (char i = 1; i < argc; i++) {
|
||||||
|
printf("%s\r\n", agrv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(TestShellMain, a shell main sample 1, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
|
void TestShellMainVoid(void)
|
||||||
|
{
|
||||||
|
printf("XiUOS test_shell_main_void\r\n");
|
||||||
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(TestShellMainVoid, a shell main sample 2, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
|
void TestShellFunc(int i, char ch, char *str)
|
||||||
|
{
|
||||||
|
printf("input int: %d, char: %c, string: %s\r\n", i, ch, str);
|
||||||
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(TestShellFunc, a shell func sample, PRIV_SHELL_CMD_FUNC_ATTR);
|
|
@ -3,5 +3,11 @@ menu "connection app"
|
||||||
menuconfig APPLICATION_CONNECTION
|
menuconfig APPLICATION_CONNECTION
|
||||||
bool "Using connection apps"
|
bool "Using connection apps"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
if APPLICATION_CONNECTION
|
||||||
|
menuconfig SOCKET_DEMO
|
||||||
|
bool "Config test socket demo"
|
||||||
|
default n
|
||||||
|
endif
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
############################################################################
|
||||||
|
# APP_Framework/Application/connection_app/Make.defs
|
||||||
|
############################################################################
|
||||||
|
ifneq ($(CONFIG_APPLICATION_CONNECTION),)
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo
|
||||||
|
endif
|
|
@ -1,7 +1,20 @@
|
||||||
SRC_DIR :=
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
ifeq ($(CONFIG_SOCKET_DEMO),y)
|
||||||
SRC_DIR += socket_demo
|
|
||||||
|
include $(KERNEL_ROOT)/.config
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
||||||
|
SRC_DIR += socket_demo
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
############################################################################
|
||||||
|
# APP_Framework/Application/connection_app/socket_demo/Make.defs
|
||||||
|
############################################################################
|
||||||
|
ifneq ($(CONFIG_SOCKET_DEMO),)
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo/*/Make.defs
|
||||||
|
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo/*/Make.defs)
|
||||||
|
endif
|
|
@ -1,3 +1,12 @@
|
||||||
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
|
SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/.config
|
||||||
|
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
CSRCS += lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
|
@ -19,18 +19,71 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <transform.h>
|
#include <transform.h>
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
#include "sys_arch.h"
|
#include "sys_arch.h"
|
||||||
#include <lwip/sockets.h>
|
#include <lwip/sockets.h>
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
#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
|
||||||
|
|
||||||
char tcp_socket_ip[] = {192, 168, 250, 252};
|
char tcp_socket_ip[] = {192, 168, 250, 252};
|
||||||
u16_t tcp_socket_port = LWIP_TARGET_PORT;
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
#define lw_print printf
|
||||||
|
#define lw_notice printf
|
||||||
|
#define lw_error printf
|
||||||
|
|
||||||
|
#define LWIP_DEMO_TIMES 3
|
||||||
|
#define LWIP_TARGET_PORT 4840
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
|
||||||
|
char tcp_ip_str[128] = {0};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
void TcpSocketConfigParam(char *ip_str)
|
||||||
|
{
|
||||||
|
int ip1, ip2, ip3, ip4, port = 0;
|
||||||
|
|
||||||
static void TCPSocketRecvTask(void *arg)
|
if(ip_str == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
int fd = -1, clientfd;
|
int fd = -1, clientfd;
|
||||||
int recv_len;
|
int recv_len;
|
||||||
|
@ -63,19 +116,19 @@ static void TCPSocketRecvTask(void *arg)
|
||||||
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");
|
lw_error("Unable to bind\n");
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
free(recv_buf);
|
free(recv_buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_print("tcp bind success, start to receive.\n");
|
lw_print("tcp bind success, start to receive.\n");
|
||||||
lw_notice("\n\nLocal Port:%d\n\n", tcp_socket_port);
|
lw_notice("\nLocal Port:%d\n", tcp_socket_port);
|
||||||
|
|
||||||
// setup socket fd as listening mode
|
// setup socket fd as listening mode
|
||||||
if (listen(fd, 5) != 0 )
|
if (listen(fd, 5) != 0 )
|
||||||
{
|
{
|
||||||
lw_error("Unable to listen\n");
|
lw_error("Unable to listen\n");
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
free(recv_buf);
|
free(recv_buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +140,8 @@ static void TCPSocketRecvTask(void *arg)
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
memset(recv_buf, 0, TCP_DEMO_BUF_SIZE);
|
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);
|
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 from : %s\n", inet_ntoa(tcp_addr.sin_addr));
|
||||||
|
@ -97,36 +151,37 @@ static void TCPSocketRecvTask(void *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
free(recv_buf);
|
free(recv_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPSocketRecvTest(int argc, char *argv[])
|
void TcpSocketRecvTest(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
if(argc >= 2)
|
if(argc >= 2)
|
||||||
{
|
{
|
||||||
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == EOK)
|
TcpSocketConfigParam(argv[1]);
|
||||||
{
|
|
||||||
sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||||
sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
TcpSocketRecvTask(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(TcpSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
static void TcpSocketSendTask(void *arg)
|
||||||
TCPSocketRecv, TCPSocketRecvTest, TCP recv echo);
|
|
||||||
|
|
||||||
static void TCPSocketSendTask(void *arg)
|
|
||||||
{
|
{
|
||||||
int cnt = LWIP_DEMO_TIMES;
|
int cnt = LWIP_DEMO_TIMES;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
int ret;
|
||||||
char send_msg[128];
|
char send_msg[128];
|
||||||
|
|
||||||
|
lw_print("2022-10-14 Mr. Wang commit TCP\n");
|
||||||
lw_print("%s start\n", __func__);
|
lw_print("%s start\n", __func__);
|
||||||
|
|
||||||
memset(send_msg, 0, sizeof(send_msg));
|
memset(send_msg, 0, sizeof(send_msg));
|
||||||
|
@ -140,47 +195,48 @@ static void TCPSocketSendTask(void *arg)
|
||||||
struct sockaddr_in tcp_sock;
|
struct sockaddr_in tcp_sock;
|
||||||
tcp_sock.sin_family = AF_INET;
|
tcp_sock.sin_family = AF_INET;
|
||||||
tcp_sock.sin_port = htons(tcp_socket_port);
|
tcp_sock.sin_port = htons(tcp_socket_port);
|
||||||
tcp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(tcp_socket_ip[0], tcp_socket_ip[1], tcp_socket_ip[2], tcp_socket_ip[3]));
|
tcp_sock.sin_addr.s_addr = inet_addr(tcp_ip_str);
|
||||||
|
|
||||||
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
|
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr)))
|
ret = connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr));
|
||||||
|
if (ret)
|
||||||
{
|
{
|
||||||
lw_print("Unable to connect\n");
|
lw_print("Unable to connect %s = %d\n", tcp_ip_str, ret);
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_notice("\n\nTarget Port:%d\n\n", tcp_socket_port);
|
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");
|
lw_print("Lwip client is running.\n");
|
||||||
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
|
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
|
||||||
sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr));
|
send(fd, send_msg, strlen(send_msg), 0);
|
||||||
lw_notice("Send tcp msg: %s ", send_msg);
|
lw_notice("Send tcp msg: %s ", send_msg);
|
||||||
MdelayKTask(1000);
|
PrivTaskDelay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TcpSocketSendTest(int argc, char *argv[])
|
||||||
void TCPSocketSendTest(int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
if(argc >= 2)
|
if(argc >= 2)
|
||||||
{
|
{
|
||||||
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == EOK)
|
TcpSocketConfigParam(argv[1]);
|
||||||
{
|
|
||||||
sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||||
sys_thread_new("TCP Socket Send", TCPSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
sys_thread_new("Tcp Socket Send", TcpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
|
#endif
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
TcpSocketSendTask(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(TcpSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
|
||||||
TCPSocketSend, TCPSocketSendTest, TCP send demo);
|
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,65 @@
|
||||||
* @date 2022-03-21
|
* @date 2022-03-21
|
||||||
*/
|
*/
|
||||||
#include <transform.h>
|
#include <transform.h>
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
#include "sys_arch.h"
|
#include "sys_arch.h"
|
||||||
#include "lwip/sockets.h"
|
#include "lwip/sockets.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define LWIP_DEMO_TIMES 3
|
||||||
|
#define LWIP_LOCAL_PORT 4840
|
||||||
|
|
||||||
|
#define lw_error printf
|
||||||
|
#define lw_notice printf
|
||||||
|
#define lw_print printf
|
||||||
|
#endif
|
||||||
|
|
||||||
#define UDP_BUF_SIZE 65536
|
#define UDP_BUF_SIZE 65536
|
||||||
|
|
||||||
char udp_socket_ip[] = {192, 168, 250, 252};
|
char udp_socket_ip[] = {192, 168, 250, 252};
|
||||||
u16_t udp_socket_port = LWIP_LOCAL_PORT;
|
char udp_ip_str[128] = {0};
|
||||||
|
uint16_t udp_socket_port = LWIP_LOCAL_PORT;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +84,6 @@ static void UdpSocketRecvTask(void *arg)
|
||||||
char *recv_buf;
|
char *recv_buf;
|
||||||
struct sockaddr_in udp_addr, server_addr;
|
struct sockaddr_in udp_addr, server_addr;
|
||||||
int recv_len;
|
int recv_len;
|
||||||
socklen_t addr_len;
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
@ -61,27 +110,27 @@ static void UdpSocketRecvTask(void *arg)
|
||||||
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");
|
lw_error("Unable to bind\n");
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
free(recv_buf);
|
free(recv_buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_notice("UDP bind sucess, start to receive.\n");
|
lw_notice("UDP bind success, start to receive.\n");
|
||||||
lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port);
|
lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port);
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
memset(recv_buf, 0, UDP_BUF_SIZE);
|
memset(recv_buf, 0, UDP_BUF_SIZE);
|
||||||
recv_len = recvfrom(fd, recv_buf, UDP_BUF_SIZE, 0, (struct sockaddr *)&server_addr, &addr_len);
|
recv_len = recv(fd, recv_buf, UDP_BUF_SIZE, 0);
|
||||||
if(recv_len > 0)
|
if(recv_len > 0)
|
||||||
{
|
{
|
||||||
lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
|
lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
|
||||||
lw_notice("Receive data : %s\n\n", recv_buf);
|
lw_notice("Receive data : %s\n\n", recv_buf);
|
||||||
}
|
}
|
||||||
sendto(fd, recv_buf, recv_len, 0, (struct sockaddr*)&server_addr, addr_len);
|
send(fd, recv_buf, recv_len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
free(recv_buf);
|
free(recv_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,18 +140,19 @@ void UdpSocketRecvTest(int argc, char *argv[])
|
||||||
if(argc >= 2)
|
if(argc >= 2)
|
||||||
{
|
{
|
||||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == EOK)
|
UdpSocketConfigParam(argv[1]);
|
||||||
{
|
|
||||||
sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||||
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL,
|
||||||
|
LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
|
#endif
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
UdpSocketRecvTask(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
UDPSocketRecv, UdpSocketRecvTest, UDP Receive DEMO);
|
|
||||||
|
|
||||||
static void UdpSocketSendTask(void *arg)
|
static void UdpSocketSendTask(void *arg)
|
||||||
{
|
{
|
||||||
|
@ -122,28 +172,29 @@ static void UdpSocketSendTask(void *arg)
|
||||||
struct sockaddr_in udp_sock;
|
struct sockaddr_in udp_sock;
|
||||||
udp_sock.sin_family = AF_INET;
|
udp_sock.sin_family = AF_INET;
|
||||||
udp_sock.sin_port = htons(udp_socket_port);
|
udp_sock.sin_port = htons(udp_socket_port);
|
||||||
udp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(udp_socket_ip[0], udp_socket_ip[1], udp_socket_ip[2], udp_socket_ip[3]));
|
udp_sock.sin_addr.s_addr = inet_addr(udp_ip_str);
|
||||||
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
|
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
|
||||||
|
|
||||||
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
|
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
|
||||||
{
|
{
|
||||||
lw_error("Unable to connect\n");
|
lw_error("Unable to connect\n");
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_print("UDP connect success, start to send.\n");
|
lw_print("UDP connect %s:%d success, start to send.\n",
|
||||||
lw_notice("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
|
udp_ip_str,
|
||||||
|
udp_socket_port);
|
||||||
|
|
||||||
while (cnt --)
|
while(cnt --)
|
||||||
{
|
{
|
||||||
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
|
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
|
||||||
sendto(fd, send_str, strlen(send_str), 0, (struct sockaddr*)&udp_sock, sizeof(struct sockaddr));
|
send(fd, send_str, strlen(send_str), 0);
|
||||||
lw_notice("Send UDP msg: %s ", send_str);
|
lw_notice("Send UDP msg: %s ", send_str);
|
||||||
MdelayKTask(1000);
|
PrivTaskDelay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
closesocket(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,16 +203,17 @@ void UdpSocketSendTest(int argc, char *argv[])
|
||||||
if(argc >= 2)
|
if(argc >= 2)
|
||||||
{
|
{
|
||||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == EOK)
|
UdpSocketConfigParam(argv[1]);
|
||||||
{
|
|
||||||
sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||||
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE,
|
||||||
|
LWIP_DEMO_TASK_PRIO);
|
||||||
|
#endif
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
UdpSocketSendTask(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
UDPSocketSend, UdpSocketSendTest, UDP send echo);
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
SRC_DIR :=
|
SRC_DIR := plc_demo
|
||||||
|
|
||||||
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
ifeq ($(CONFIG_RESOURCES_LWIP),y)
|
||||||
|
|
||||||
ifeq ($(CONFIG_USING_CONTROL_PLC_OPCUA), y)
|
ifeq ($(CONFIG_USING_CONTROL_PLC_OPCUA), y)
|
||||||
SRC_DIR += opcua_demo plc_demo
|
SRC_DIR += opcua_demo
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
|
|
||||||
#include <list.h>
|
#include <list.h>
|
||||||
#include <transform.h>
|
#include <transform.h>
|
||||||
#include "board.h"
|
#include <open62541.h>
|
||||||
#include "open62541.h"
|
#include <ua_api.h>
|
||||||
#include "ua_api.h"
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
|
@ -58,8 +57,7 @@ static void UaConnectTestTask(void* arg)
|
||||||
|
|
||||||
UA_Client* client = UA_Client_new();
|
UA_Client* client = UA_Client_new();
|
||||||
|
|
||||||
if(client == NULL)
|
if(client == NULL) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] tcp client null\n", __func__);
|
ua_error("ua: [%s] tcp client null\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,8 +74,7 @@ static void UaConnectTestTask(void* arg)
|
||||||
|
|
||||||
ret = UA_Client_connect(client, url);
|
ret = UA_Client_connect(client, url);
|
||||||
|
|
||||||
if(ret != UA_STATUSCODE_GOOD)
|
if(ret != UA_STATUSCODE_GOOD) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] connected failed %x\n", __func__, ret);
|
ua_error("ua: [%s] connected failed %x\n", __func__, ret);
|
||||||
UA_Client_delete(client);
|
UA_Client_delete(client);
|
||||||
fail_cnt++;
|
fail_cnt++;
|
||||||
|
@ -90,12 +87,9 @@ static void UaConnectTestTask(void* arg)
|
||||||
|
|
||||||
static void UaConnectTest(int argc, char *argv[])
|
static void UaConnectTest(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if(argc == 2)
|
if(argc == 2) {
|
||||||
{
|
if(isdigit(argv[1][0])) {
|
||||||
if(isdigit(argv[1][0]))
|
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||||
{
|
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
|
||||||
{
|
|
||||||
lw_notice("input wrong ip\n");
|
lw_notice("input wrong ip\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -105,9 +99,7 @@ static void UaConnectTest(int argc, char *argv[])
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip);
|
||||||
sys_thread_new("ua test", UaConnectTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
sys_thread_new("ua test", UaConnectTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(UaConnectTest, a opcua connect sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
|
||||||
UaConnect, UaConnectTest, Test Opc UA connection);
|
|
||||||
|
|
||||||
void UaBrowserObjectsTestTask(void* param)
|
void UaBrowserObjectsTestTask(void* param)
|
||||||
{
|
{
|
||||||
|
@ -115,8 +107,7 @@ void UaBrowserObjectsTestTask(void* param)
|
||||||
|
|
||||||
UA_Client* client = UA_Client_new();
|
UA_Client* client = UA_Client_new();
|
||||||
|
|
||||||
if(client == NULL)
|
if(client == NULL) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] tcp client NULL\n", __func__);
|
ua_error("ua: [%s] tcp client NULL\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -125,8 +116,7 @@ void UaBrowserObjectsTestTask(void* param)
|
||||||
UA_ClientConfig_setDefault(config);
|
UA_ClientConfig_setDefault(config);
|
||||||
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
||||||
|
|
||||||
if(ret != UA_STATUSCODE_GOOD)
|
if(ret != UA_STATUSCODE_GOOD) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] connect failed %#x\n", __func__, ret);
|
ua_error("ua: [%s] connect failed %#x\n", __func__, ret);
|
||||||
UA_Client_delete(client);
|
UA_Client_delete(client);
|
||||||
return;
|
return;
|
||||||
|
@ -144,12 +134,9 @@ void UaBrowserObjectsTestTask(void* param)
|
||||||
|
|
||||||
static void* UaBrowserObjectsTest(int argc, char* argv[])
|
static void* UaBrowserObjectsTest(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if(argc == 2)
|
if(argc == 2) {
|
||||||
{
|
if(isdigit(argv[1][0])) {
|
||||||
if(isdigit(argv[1][0]))
|
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||||
{
|
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
|
||||||
{
|
|
||||||
lw_notice("input wrong ip\n");
|
lw_notice("input wrong ip\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -160,17 +147,14 @@ static void* UaBrowserObjectsTest(int argc, char* argv[])
|
||||||
sys_thread_new("ua object", UaBrowserObjectsTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
sys_thread_new("ua object", UaBrowserObjectsTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(UaBrowserObjectsTest, a opcua object sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
UaObject, UaBrowserObjectsTest, UaObject [IP]);
|
|
||||||
|
|
||||||
void UaGetInfoTestTask(void* param)
|
void UaGetInfoTestTask(void* param)
|
||||||
{
|
{
|
||||||
UA_Client* client = UA_Client_new();
|
UA_Client* client = UA_Client_new();
|
||||||
ua_notice("--- Get OPUCA objects ---\n", __func__);
|
ua_notice("--- Get OPUCA objects ---\n", __func__);
|
||||||
|
|
||||||
if(client == NULL)
|
if(client == NULL) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] tcp client null\n", __func__);
|
ua_error("ua: [%s] tcp client null\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -179,8 +163,7 @@ void UaGetInfoTestTask(void* param)
|
||||||
UA_ClientConfig_setDefault(config);
|
UA_ClientConfig_setDefault(config);
|
||||||
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
||||||
|
|
||||||
if(ret != UA_STATUSCODE_GOOD)
|
if(ret != UA_STATUSCODE_GOOD) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] connect failed %#x\n", __func__, ret);
|
ua_error("ua: [%s] connect failed %#x\n", __func__, ret);
|
||||||
UA_Client_delete(client);
|
UA_Client_delete(client);
|
||||||
return;
|
return;
|
||||||
|
@ -192,14 +175,11 @@ void UaGetInfoTestTask(void* param)
|
||||||
UA_Client_delete(client); /* Disconnects the client internally */
|
UA_Client_delete(client); /* Disconnects the client internally */
|
||||||
}
|
}
|
||||||
|
|
||||||
void* UaGetInfoTest(int argc, char* argv[])
|
void *UaGetInfoTest(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if(argc == 2)
|
if(argc == 2) {
|
||||||
{
|
if(isdigit(argv[1][0])) {
|
||||||
if(isdigit(argv[1][0]))
|
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||||
{
|
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
|
||||||
{
|
|
||||||
lw_notice("input wrong ip\n");
|
lw_notice("input wrong ip\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -210,17 +190,14 @@ void* UaGetInfoTest(int argc, char* argv[])
|
||||||
sys_thread_new("ua info", UaGetInfoTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
sys_thread_new("ua info", UaGetInfoTestTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(UaGetInfoTest, a opcua info sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
UaInfo, UaGetInfoTest, UaInfo [IP]);
|
|
||||||
|
|
||||||
void UaAddNodesTask(void* param)
|
void UaAddNodesTask(void* param)
|
||||||
{
|
{
|
||||||
UA_Client* client = UA_Client_new();
|
UA_Client* client = UA_Client_new();
|
||||||
ua_notice("ua: [%s] start ...\n", __func__);
|
ua_notice("ua: [%s] start ...\n", __func__);
|
||||||
|
|
||||||
if(client == NULL)
|
if(client == NULL) {
|
||||||
{
|
|
||||||
ua_error("ua: [%s] client null\n", __func__);
|
ua_error("ua: [%s] client null\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -229,8 +206,7 @@ void UaAddNodesTask(void* param)
|
||||||
UA_ClientConfig_setDefault(config);
|
UA_ClientConfig_setDefault(config);
|
||||||
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
UA_StatusCode ret = UA_Client_connect(client, opc_server_url);
|
||||||
|
|
||||||
if(ret != UA_STATUSCODE_GOOD)
|
if(ret != UA_STATUSCODE_GOOD) {
|
||||||
{
|
|
||||||
ua_print("ua: [%s] connect failed %#x\n", __func__, ret);
|
ua_print("ua: [%s] connect failed %#x\n", __func__, ret);
|
||||||
UA_Client_delete(client);
|
UA_Client_delete(client);
|
||||||
return;
|
return;
|
||||||
|
@ -242,14 +218,11 @@ void UaAddNodesTask(void* param)
|
||||||
UA_Client_delete(client); /* Disconnects the client internally */
|
UA_Client_delete(client); /* Disconnects the client internally */
|
||||||
}
|
}
|
||||||
|
|
||||||
void* UaAddNodesTest(int argc, char* argv[])
|
void *UaAddNodesTest(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if(argc == 2)
|
if(argc == 2){
|
||||||
{
|
if(isdigit(argv[1][0])) {
|
||||||
if(isdigit(argv[1][0]))
|
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == -1) {
|
||||||
{
|
|
||||||
if(sscanf(argv[1], "%d.%d.%d.%d", &test_ua_ip[0], &test_ua_ip[1], &test_ua_ip[2], &test_ua_ip[3]) == EOF)
|
|
||||||
{
|
|
||||||
lw_notice("input wrong ip\n");
|
lw_notice("input wrong ip\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +233,4 @@ void* UaAddNodesTest(int argc, char* argv[])
|
||||||
sys_thread_new("ua add nodes", UaAddNodesTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
sys_thread_new("ua add nodes", UaAddNodesTask, NULL, UA_STACK_SIZE, UA_TASK_PRIO);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(UaAddNodesTest, a opcua add nodes sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
UaAdd, UaAddNodesTest, UA Add Nodes);
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
SRC_FILES := plc_show_demo.c plc_control_demo.c
|
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
# PLC DEMO README
|
|
||||||
|
|
||||||
## 文件说明
|
|
||||||
|
|
||||||
用于PLC设备相关测试命令演示,目前支持OPCUA协议对PLC进行远程控制,该命令基于LWIP和OPCUA,需要开启相关开关。
|
|
||||||
|
|
||||||
多个PLC设备可以组成一个channel,用于一条相关业务线控制。
|
|
||||||
|
|
||||||
### 命令行
|
|
||||||
|
|
||||||
ShowChannel
|
|
||||||
|
|
||||||
显示注册到channel上的PLC设备,范例如下:
|
|
||||||
|
|
||||||
ch_type ch_name drv_name dev_name cnt
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
PLC_Channel PLC OPCUA PLC Demo 4 1
|
|
||||||
PLC Demo 3 2
|
|
||||||
PLC Demo 2 3
|
|
||||||
PLC Demo 1 4
|
|
||||||
PLC Demo 0 5
|
|
||||||
|
|
||||||
ShowPLC
|
|
||||||
|
|
||||||
用于显示PLC,范例如下:
|
|
||||||
|
|
||||||
device vendor model product id
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
PLC Demo 4 B&R X20 X20 CP1381 5
|
|
||||||
PLC Demo 3 B&R X20 X20 CP1586 4
|
|
||||||
PLC Demo 2 SIEMSNS S7-200 CPU SR60 3
|
|
||||||
PLC Demo 1 SIEMENS S7-1200 CPU 1215C 2
|
|
||||||
PLC Demo 0 SIEMENS S7-1500 CPU 1512SP-1PN 1
|
|
||||||
|
|
||||||
PlcRead [NodeID]
|
|
||||||
|
|
||||||
用于读取PLC节点信息
|
|
||||||
|
|
||||||
- [NodeID]: 如n4,1, 其中4代表namespace,1代表节点号
|
|
||||||
|
|
||||||
|
|
||||||
PlcWrite
|
|
||||||
|
|
||||||
用于写入PLC节点数值
|
|
||||||
|
|
||||||
- [NodeID]: 如n4,1, 其中4代表namespace,1代表节点号
|
|
||||||
|
|
||||||
- [value]: 为写入数值,目前支持bool类型,和int类型。bool型应为0b(代表false), 1b(代表true)
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := advantech_ark_2250.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file beckhoff_c6920.c
|
||||||
|
* @brief PLC BECKHOFF C6920 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := beckhoff_c6920.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file advantech_ark_2250.c
|
||||||
|
* @brief PLC ADVANTECH ARK-2250 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file br_x20cp0410.c
|
||||||
|
* @brief PLC B&R X20CP0410 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file br_x20cp1381.c
|
||||||
|
* @brief PLC B&R X20CP1381 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file br_x20cp1586.c
|
||||||
|
* @brief PLC B&R X20CP1586 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := delta_as228t.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file delta_as228t.c
|
||||||
|
* @brief PLC DELTA AS228T app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file delta_as332t.c
|
||||||
|
* @brief PLC DELTA AS332T app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file mitsubishi_fx3u.c
|
||||||
|
* @brief PLC MITSUBISHI FX3U app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file mitsubishi_fx5u.c
|
||||||
|
* @brief PLC MITSUBISHI FX5U app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file omron_cj2m.c
|
||||||
|
* @brief PLC OMRON CJ2M app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file omron_nj501.c
|
||||||
|
* @brief PLC OMRON NJ501 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file omron_nx102.c
|
||||||
|
* @brief PLC OMRON NX102 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,354 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2022 AIIT XUOS Lab
|
|
||||||
* XiUOS is licensed under Mulan PSL v2.
|
|
||||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
||||||
* You may obtain a copy of Mulan PSL v2 at:
|
|
||||||
* http://license.coscl.org.cn/MulanPSL2
|
|
||||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
||||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the Mulan PSL v2 for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file plc_control_demo.c
|
|
||||||
* @brief Demo for PLC control
|
|
||||||
* @version 1.0
|
|
||||||
* @author AIIT XUOS Lab
|
|
||||||
* @date 2022.2.22
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "transform.h"
|
|
||||||
#include "open62541.h"
|
|
||||||
#include "ua_api.h"
|
|
||||||
#include "sys_arch.h"
|
|
||||||
#include "plc_demo.h"
|
|
||||||
|
|
||||||
#define PLC_NS_FORMAT "n%d,%s"
|
|
||||||
|
|
||||||
struct PlcChannel plc_demo_ch;
|
|
||||||
struct PlcDriver plc_demo_drv;
|
|
||||||
struct PlcDevice plc_demo_dev;
|
|
||||||
|
|
||||||
int plc_test_flag = 0;
|
|
||||||
|
|
||||||
PlcCtrlParamType plc_ctrl_param;
|
|
||||||
|
|
||||||
UA_NodeId test_nodeid = {4, UA_NODEIDTYPE_NUMERIC, 5};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
void PlcDelay(int sec)
|
|
||||||
{
|
|
||||||
volatile uint32_t i = 0;
|
|
||||||
for (i = 0; i < 100000000 * sec; ++i)
|
|
||||||
{
|
|
||||||
__asm("NOP"); /* delay */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get NodeId from str
|
|
||||||
void PlcGetTestNodeId(char *str, UA_NodeId *id)
|
|
||||||
{
|
|
||||||
static char node_str[UA_NODE_LEN];
|
|
||||||
memset(node_str, 0, sizeof(node_str));
|
|
||||||
|
|
||||||
plc_print("plc: arg %s\n", str);
|
|
||||||
|
|
||||||
if(sscanf(str, PLC_NS_FORMAT, &id->namespaceIndex, node_str) != EOF)
|
|
||||||
{
|
|
||||||
if(isdigit(node_str[0]))
|
|
||||||
{
|
|
||||||
id->identifierType = UA_NODEIDTYPE_NUMERIC;
|
|
||||||
id->identifier.numeric = atoi(node_str);
|
|
||||||
plc_print("ns %d num %d\n", id->namespaceIndex, id->identifier.numeric);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id->identifierType = UA_NODEIDTYPE_STRING;
|
|
||||||
id->identifier.string.length = strlen(node_str);
|
|
||||||
id->identifier.string.data = node_str;
|
|
||||||
plc_print("ns %d str %s\n", id->namespaceIndex, id->identifier.string.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlcDemoChannelDrvInit(void)
|
|
||||||
{
|
|
||||||
static uint8_t init_flag = 0;
|
|
||||||
if(init_flag)
|
|
||||||
return;
|
|
||||||
init_flag = 1;
|
|
||||||
|
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, test_ua_ip);
|
|
||||||
PlcChannelInit(&plc_demo_ch, PLC_CH_NAME);
|
|
||||||
if(PlcDriverInit(&plc_demo_drv, PLC_DRV_NAME) == EOK)
|
|
||||||
{
|
|
||||||
PlcDriverAttachToChannel(PLC_DRV_NAME, PLC_CH_NAME);
|
|
||||||
}
|
|
||||||
memset(&plc_demo_dev, 0, sizeof(plc_demo_dev));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PlcGetDemoDev(PlcDeviceType *dev, UA_NodeId *id)
|
|
||||||
{
|
|
||||||
// register plc device
|
|
||||||
dev->state = CHDEV_INIT;
|
|
||||||
strcpy(dev->name, "UA Demo");
|
|
||||||
dev->info.product = "CPU 1215C";
|
|
||||||
dev->info.vendor = "SIEMENS";
|
|
||||||
dev->info.model = "S7-1200";
|
|
||||||
dev->info.id = 123;
|
|
||||||
dev->net = PLC_IND_ENET_OPCUA;
|
|
||||||
|
|
||||||
// register UA parameter
|
|
||||||
if(!dev->priv_data)
|
|
||||||
{
|
|
||||||
dev->priv_data = (UaParamType*)malloc(sizeof(UaParamType));
|
|
||||||
}
|
|
||||||
UaParamType* ua_ptr = dev->priv_data;
|
|
||||||
memset(ua_ptr, 0, sizeof(UaParamType));
|
|
||||||
strcpy(ua_ptr->ua_remote_ip, opc_server_url);
|
|
||||||
ua_ptr->act = UA_ACT_ATTR;
|
|
||||||
memcpy(&ua_ptr->ua_id, id, sizeof(*id));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PlcCtrlDemoInit(void)
|
|
||||||
{
|
|
||||||
static uint8_t init_flag = 0;
|
|
||||||
|
|
||||||
PlcDemoChannelDrvInit();
|
|
||||||
|
|
||||||
// register plc device
|
|
||||||
PlcGetDemoDev(&plc_demo_dev, &test_nodeid);
|
|
||||||
|
|
||||||
if(init_flag)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
init_flag = 1;
|
|
||||||
|
|
||||||
if(PlcDevRegister(&plc_demo_dev, NULL, plc_demo_dev.name) != EOK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PlcDeviceAttachToChannel(plc_demo_dev.name, PLC_CH_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlcReadUATask(void* arg)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
struct PlcOps* ops = NULL;
|
|
||||||
char buf[PLC_BUF_SIZE];
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
PlcCtrlDemoInit();
|
|
||||||
ops = plc_demo_dev.ops;
|
|
||||||
ret = ops->open(&plc_demo_dev);
|
|
||||||
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] open failed %#x\n", __func__, ret);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ops->read(&plc_demo_dev, buf, PLC_BUF_SIZE);
|
|
||||||
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] read failed %x\n", __func__, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
ops->close(&plc_demo_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlcReadTestShell(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
static char node_str[UA_NODE_LEN];
|
|
||||||
memset(node_str, 0, sizeof(node_str));
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
{
|
|
||||||
PlcGetTestNodeId(argv[1], &test_nodeid);
|
|
||||||
}
|
|
||||||
|
|
||||||
sys_thread_new("plc read", PlcReadUATask, NULL, PLC_STACK_SIZE, PLC_TASK_PRIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
PlcRead, PlcReadTestShell, Read PLC);
|
|
||||||
|
|
||||||
void PlcWriteUATask(void* arg)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
struct PlcOps* ops = NULL;
|
|
||||||
char buf[PLC_BUF_SIZE];
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
|
|
||||||
PlcCtrlDemoInit();
|
|
||||||
ops = plc_demo_dev.ops;
|
|
||||||
ret = ops->open(&plc_demo_dev);
|
|
||||||
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] open failed %#x\n", __func__, ret);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ops->write(&plc_demo_dev, arg, PLC_BUF_SIZE);
|
|
||||||
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] write failed\n", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
ops->close(&plc_demo_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlcWriteTestShell(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
static char node_str[UA_NODE_LEN];
|
|
||||||
static char val_param[UA_NODE_LEN];
|
|
||||||
memset(node_str, 0, sizeof(node_str));
|
|
||||||
memset(val_param, 0, sizeof(val_param));
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
{
|
|
||||||
PlcGetTestNodeId(argv[1], &test_nodeid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(argc > 2)
|
|
||||||
{
|
|
||||||
strcpy(val_param, argv[2]);
|
|
||||||
plc_print("write value %s\n", val_param);
|
|
||||||
}
|
|
||||||
|
|
||||||
sys_thread_new("plc write", PlcWriteUATask, val_param, PLC_STACK_SIZE, PLC_TASK_PRIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
PlcWrite, PlcWriteTestShell, Read PLC);
|
|
||||||
|
|
||||||
// test motor
|
|
||||||
// clear parameter
|
|
||||||
// PlcWrite n4,2 0b
|
|
||||||
// PlcWrite n4,3 0b
|
|
||||||
// PlcWrite n4,4 0b
|
|
||||||
// PlcWrite n4,5 0b
|
|
||||||
//
|
|
||||||
// enable
|
|
||||||
// PlcWrite n4,2 1b
|
|
||||||
//
|
|
||||||
// set rotate speed
|
|
||||||
// PlcWrite n4,3 50
|
|
||||||
//
|
|
||||||
// positive turn
|
|
||||||
// PlcWrite n4,4 1b
|
|
||||||
//
|
|
||||||
// reversal turn
|
|
||||||
// PlcWrite n4,5 1b
|
|
||||||
|
|
||||||
static int plc_test_speed = 50;
|
|
||||||
static int plc_test_dir = 1; // direction positive: 1 reversal: 0
|
|
||||||
|
|
||||||
void PlcMotorTestTask(void* arg)
|
|
||||||
{
|
|
||||||
//support node id
|
|
||||||
char *test_nodeid[] = {"n4,2", "n4,3", "n4,4", "n4,5", "n4,7"};
|
|
||||||
// enable -> speed -> positive dir or inversal dir -> stop -> enable
|
|
||||||
char test_sort[] = {0, 4, 2, 1, 0};
|
|
||||||
char test_cmd[][4] = {"1b", "50", "1b", "1b", "0b"};
|
|
||||||
char *test_notice[] = {"Enable Motor", "Set Speed", "Set Forward", "Set Reverse", "Stop Motor"};
|
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
struct PlcOps* ops = NULL;
|
|
||||||
char buf[PLC_BUF_SIZE];
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
|
|
||||||
PlcCtrlDemoInit();
|
|
||||||
ops = plc_demo_dev.ops;
|
|
||||||
ret = ops->open(&plc_demo_dev);
|
|
||||||
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] open failed %#x\n", __func__, ret);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UaParamType* ua_ptr = plc_demo_dev.priv_data;
|
|
||||||
|
|
||||||
// initialize step
|
|
||||||
for(int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
plc_print("###\n### Clear %s\n###\n", test_notice[i]);
|
|
||||||
PlcGetTestNodeId(test_nodeid[i], &ua_ptr->ua_id);
|
|
||||||
ret = ops->write(&plc_demo_dev, "0b", PLC_BUF_SIZE);
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] %d write failed\n", __func__, __LINE__);
|
|
||||||
}
|
|
||||||
PlcDelay(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plc_test_speed != 50)
|
|
||||||
{
|
|
||||||
snprintf(test_cmd[1], 4, "%d", plc_test_speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plc_test_dir == 0) // if not postive, next running
|
|
||||||
test_sort[2] = 3;
|
|
||||||
|
|
||||||
for(int i = 0; i < sizeof(test_sort)/sizeof(test_sort[0]); i++)
|
|
||||||
{
|
|
||||||
PlcGetTestNodeId(test_nodeid[test_sort[i]], &ua_ptr->ua_id);
|
|
||||||
plc_print("###\n### %s\n###\n", test_notice[i]);
|
|
||||||
ret = ops->write(&plc_demo_dev, test_cmd[i], PLC_BUF_SIZE);
|
|
||||||
if(EOK != ret)
|
|
||||||
{
|
|
||||||
plc_print("plc: [%s] %d write failed\n", __func__, __LINE__);
|
|
||||||
}
|
|
||||||
PlcDelay(1);
|
|
||||||
if(i == 2) // postive
|
|
||||||
{
|
|
||||||
PlcDelay(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ops->close(&plc_demo_dev);
|
|
||||||
plc_test_flag = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get parameter from
|
|
||||||
void PlcGetMotorParam(char *str)
|
|
||||||
{
|
|
||||||
static char node_str[UA_NODE_LEN];
|
|
||||||
memset(node_str, 0, sizeof(node_str));
|
|
||||||
|
|
||||||
plc_print("plc: arg %s\n", str);
|
|
||||||
|
|
||||||
sscanf(str, "speed=%d", &plc_test_speed);
|
|
||||||
sscanf(str, "dir=%d", &plc_test_dir);
|
|
||||||
plc_print("speed is %d\n", plc_test_speed);
|
|
||||||
plc_print("dir is %d\n", plc_test_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlcMotorTestShell(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
if(plc_test_flag)
|
|
||||||
{
|
|
||||||
plc_print("PLC Motor testing!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plc_test_flag = 1;
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < argc; i++)
|
|
||||||
{
|
|
||||||
PlcGetMotorParam(argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sys_thread_new("plc motor", PlcMotorTestTask, NULL, PLC_STACK_SIZE, PLC_TASK_PRIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
PlcMotorTest, PlcMotorTestShell, Run motor);
|
|
||||||
|
|
|
@ -1,257 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2022 AIIT XUOS Lab
|
|
||||||
* XiUOS is licensed under Mulan PSL v2.
|
|
||||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
||||||
* You may obtain a copy of Mulan PSL v2 at:
|
|
||||||
* http://license.coscl.org.cn/MulanPSL2
|
|
||||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
||||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the Mulan PSL v2 for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file plc_show_demo.c
|
|
||||||
* @brief Demo for PLC information show
|
|
||||||
* @version 1.0
|
|
||||||
* @author AIIT XUOS Lab
|
|
||||||
* @date 2022.02.24
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "transform.h"
|
|
||||||
#include "list.h"
|
|
||||||
|
|
||||||
#include "open62541.h"
|
|
||||||
#include "ua_api.h"
|
|
||||||
#include "sys_arch.h"
|
|
||||||
#include "plc_demo.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define PLC_DEMO_NUM 5
|
|
||||||
|
|
||||||
struct PlcDevice plc_demo_array[PLC_DEMO_NUM];
|
|
||||||
|
|
||||||
typedef struct PlcShowParam
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
char* vector;
|
|
||||||
char* model;
|
|
||||||
char* product;
|
|
||||||
} PlcShowParamType;
|
|
||||||
|
|
||||||
PlcShowParamType plc_demo_param[PLC_NAME_SIZE] =
|
|
||||||
{
|
|
||||||
{1, "SIEMENS", "S7-1500", "CPU 1512SP-1PN"},
|
|
||||||
{2, "SIEMENS", "S7-1200", "CPU 1215C"},
|
|
||||||
{3, "SIEMSNS", "S7-200", "CPU SR60"},
|
|
||||||
{4, "B&R", "X20", "X20 CP1586"},
|
|
||||||
{5, "B&R", "X20", "X20 CP1381"}
|
|
||||||
};
|
|
||||||
|
|
||||||
static char* const channel_type_str[] =
|
|
||||||
{
|
|
||||||
"PLC_Channel",
|
|
||||||
"Unknown"
|
|
||||||
};
|
|
||||||
|
|
||||||
extern DoublelistType plcdev_list;
|
|
||||||
extern DoublelistType ch_linklist;
|
|
||||||
|
|
||||||
/**********************************************************************************************************************/
|
|
||||||
|
|
||||||
void PlcShowTitle(const char* item_array[])
|
|
||||||
{
|
|
||||||
int i = 0, max_len = 65;
|
|
||||||
KPrintf(" %-15s%-15s%-15s%-15s%-20s\n", item_array[0], item_array[1], item_array[2], item_array[3], item_array[4]);
|
|
||||||
|
|
||||||
while(i < max_len)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if(max_len == i)
|
|
||||||
{
|
|
||||||
KPrintf("-\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KPrintf("-");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChDrvType ShowChannelFindDriver(struct Channel* ch)
|
|
||||||
{
|
|
||||||
struct ChDrv* driver = NONE;
|
|
||||||
DoublelistType* node = NONE;
|
|
||||||
DoublelistType* head = &ch->ch_drvlink;
|
|
||||||
|
|
||||||
for(node = head->node_next; node != head; node = node->node_next)
|
|
||||||
{
|
|
||||||
driver = DOUBLE_LIST_ENTRY(node, struct ChDrv, driver_link);
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PlcShowDemoInit(void)
|
|
||||||
{
|
|
||||||
static uint8_t init_flag = 0;
|
|
||||||
int i;
|
|
||||||
PlcDemoChannelDrvInit();
|
|
||||||
|
|
||||||
for(i = 0; i < PLC_DEMO_NUM; i++)
|
|
||||||
{
|
|
||||||
// register plc device
|
|
||||||
plc_demo_array[i].state = CHDEV_INIT;
|
|
||||||
snprintf(plc_demo_array[i].name, PLC_NAME_SIZE, "PLC Demo %d", i);
|
|
||||||
plc_demo_array[i].info.vendor = plc_demo_param[i].vector;
|
|
||||||
plc_demo_array[i].info.model = plc_demo_param[i].model;
|
|
||||||
plc_demo_array[i].info.id = plc_demo_param[i].id;
|
|
||||||
plc_demo_array[i].info.product = plc_demo_param[i].product;
|
|
||||||
plc_demo_array[i].net = PLC_IND_ENET_OPCUA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(init_flag)
|
|
||||||
return;
|
|
||||||
init_flag = 1;
|
|
||||||
|
|
||||||
for(i = 0; i < PLC_DEMO_NUM; i++)
|
|
||||||
{
|
|
||||||
if(PlcDevRegister(&plc_demo_array[i], NULL, plc_demo_array[i].name) == EOK)
|
|
||||||
{
|
|
||||||
PlcDeviceAttachToChannel(plc_demo_array[i].name, PLC_CH_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlcShowChannel(void)
|
|
||||||
{
|
|
||||||
ChannelType ch;
|
|
||||||
ChDrvType driver;
|
|
||||||
ChDevType device;
|
|
||||||
int dev_cnt;
|
|
||||||
DoublelistType* ch_node = NONE;
|
|
||||||
DoublelistType* ch_head = &ch_linklist;
|
|
||||||
const char* item_array[] = {"ch_type", "ch_name", "drv_name", "dev_name", "cnt"};
|
|
||||||
PlcShowDemoInit();
|
|
||||||
PlcShowTitle(item_array);
|
|
||||||
ch_node = ch_head->node_next;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ch = DOUBLE_LIST_ENTRY(ch_node, struct Channel, ch_link);
|
|
||||||
|
|
||||||
if((ch) && (ch->ch_type == CH_PLC_TYPE))
|
|
||||||
{
|
|
||||||
KPrintf("%s", " ");
|
|
||||||
KPrintf("%-15s%-15s",
|
|
||||||
channel_type_str[ch->ch_type],
|
|
||||||
ch->ch_name);
|
|
||||||
|
|
||||||
driver = ShowChannelFindDriver(ch);
|
|
||||||
|
|
||||||
if(driver)
|
|
||||||
{
|
|
||||||
KPrintf("%-15s", driver->drv_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KPrintf("%-15s", "nil");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ch->haldev_cnt)
|
|
||||||
{
|
|
||||||
DoublelistType* dev_node = NONE;
|
|
||||||
DoublelistType* dev_head = &ch->ch_devlink;
|
|
||||||
dev_node = dev_head->node_next;
|
|
||||||
dev_cnt = 1;
|
|
||||||
|
|
||||||
while(dev_node != dev_head)
|
|
||||||
{
|
|
||||||
device = DOUBLE_LIST_ENTRY(dev_node, struct ChDev, dev_link);
|
|
||||||
|
|
||||||
if(1 == dev_cnt)
|
|
||||||
{
|
|
||||||
if(device)
|
|
||||||
{
|
|
||||||
KPrintf("%-16s%-4d\n", device->dev_name, dev_cnt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KPrintf("%-16s%-4d\n", "nil", dev_cnt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KPrintf("%46s", " ");
|
|
||||||
|
|
||||||
if(device)
|
|
||||||
{
|
|
||||||
KPrintf("%-16s%-4d\n", device->dev_name, dev_cnt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KPrintf("%-16s%-4d\n", "nil", dev_cnt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_cnt++;
|
|
||||||
dev_node = dev_node->node_next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KPrintf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ch_node = ch_node->node_next;
|
|
||||||
}
|
|
||||||
while(ch_node != ch_head);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
ShowChannel, PlcShowChannel, Show PLC information);
|
|
||||||
|
|
||||||
void PlcShowDev(void)
|
|
||||||
{
|
|
||||||
PlcDeviceType* plc_dev;
|
|
||||||
ChDrvType driver;
|
|
||||||
ChDevType device;
|
|
||||||
DoublelistType* plc_node = NONE;
|
|
||||||
DoublelistType* plc_head = &plcdev_list;
|
|
||||||
const char* item_array[] = {"device", "vendor", "model", "product", "id"};
|
|
||||||
PlcShowDemoInit();
|
|
||||||
PlcShowTitle(item_array);
|
|
||||||
plc_node = plc_head->node_next;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
plc_dev = DOUBLE_LIST_ENTRY(plc_node, struct PlcDevice, link);
|
|
||||||
|
|
||||||
if(plc_dev)
|
|
||||||
{
|
|
||||||
KPrintf("%s", " ");
|
|
||||||
KPrintf("%-15s%-15s%-15s%-15s%-20d",
|
|
||||||
plc_dev->name,
|
|
||||||
plc_dev->info.vendor,
|
|
||||||
plc_dev->info.model,
|
|
||||||
plc_dev->info.product,
|
|
||||||
plc_dev->info.id);
|
|
||||||
KPrintf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
plc_node = plc_node->node_next;
|
|
||||||
}
|
|
||||||
while(plc_node != plc_head);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
|
||||||
ShowPlc, PlcShowDev, Show PLC information);
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := schneider_m241.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file schneider_m241.c
|
||||||
|
* @brief PLC SCHNEIDER M241 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := siemens_s7_200_cn.c siemens_s7_200_smart.c siemens_s7_300.c siemens_s7_1200.c siemens_s7_1500.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file siemens_s7_1200.c
|
||||||
|
* @brief PLC SIEMENS S7-1200 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file siemens_s7_1500.c
|
||||||
|
* @brief PLC SIEMENS S7-1500 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file siemens_s7_200_cn.c
|
||||||
|
* @brief PLC SIEMENS S7-200CN app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file siemens_s7_200_smart.c
|
||||||
|
* @brief PLC SIEMENS S7-200 SMART app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file siemens_s7_300.c
|
||||||
|
* @brief PLC SIEMENS S7-300 app
|
||||||
|
* @version 3.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2022.9.27
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,4 @@ int flashdb_app(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(flashdb_app, a flashdb test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
#ifdef __RT_THREAD_H__
|
|
||||||
MSH_CMD_EXPORT(flashdb_app, flashdb test);
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -26,6 +26,3 @@ void mnist_app(void);
|
||||||
int tfmnist(void) {
|
int tfmnist(void) {
|
||||||
mnist_app();
|
mnist_app();
|
||||||
}
|
}
|
||||||
// #ifndef SEPARATE_COMPILE
|
|
||||||
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, tfmnist, tfmnist, run mnist demo of tflite);
|
|
||||||
// #endif
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_demo.c
|
||||||
|
* @brief: a application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#include <lv_port_indev_template.h>
|
#include <lv_port_indev_template.h>
|
||||||
#include "lv_demo_calendar.h"
|
#include "lv_demo_calendar.h"
|
||||||
|
@ -38,5 +59,4 @@ static int lvgl_demo_init(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_demo_init, lvgl_demo_init, lvgl_demo_init );
|
PRIV_SHELL_CMD_FUNCTION(lvgl_demo_init, a littlevgl init sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_demo_calendar.c
|
||||||
|
* @brief: a calendar application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#include "lv_demo_calendar.h"
|
#include "lv_demo_calendar.h"
|
||||||
// #include <drv_lcd.h>
|
// #include <drv_lcd.h>
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_demo_calendar.h
|
||||||
|
* @brief: a calendar application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __LV_DEMO_CALENDAR_H__
|
#ifndef __LV_DEMO_CALENDAR_H__
|
||||||
#define __LV_DEMO_CALENDAR_H__
|
#define __LV_DEMO_CALENDAR_H__
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_init.c
|
||||||
|
* @brief: init littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#define DBG_TAG "LVGL"
|
#define DBG_TAG "LVGL"
|
||||||
#define DBG_LVL DBG_INFO
|
#define DBG_LVL DBG_INFO
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_sensor_info.c
|
||||||
|
* @brief: a sensor info application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "lv_sensor_info.h"
|
#include "lv_sensor_info.h"
|
||||||
|
|
||||||
static void draw_part_event_cb(lv_event_t* e) {
|
static void draw_part_event_cb(lv_event_t* e) {
|
||||||
|
@ -25,12 +46,11 @@ static void draw_part_event_cb(lv_event_t* e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Double2Str(char* buf, double value) {
|
char *Double2Str(char* buf, double value) {
|
||||||
sprintf(buf,"%.8f",value);//保留8位小数,不够补0
|
sprintf(buf,"%.8f",value);//keep 8 bit float data
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int len = strlen(buf);
|
int len = strlen(buf);
|
||||||
for(int i = len-1;i>0;i--)
|
for(int i = len-1;i>0;i--) {
|
||||||
{
|
|
||||||
if(buf[i] == '0')
|
if(buf[i] == '0')
|
||||||
continue;
|
continue;
|
||||||
else {
|
else {
|
||||||
|
@ -71,8 +91,7 @@ void lv_sensor_info(void) {
|
||||||
for (uint32_t i = 0; i < 2 * NR_VAL_PERLINE; ++i) {
|
for (uint32_t i = 0; i < 2 * NR_VAL_PERLINE; ++i) {
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
lv_table_set_col_width(lv_ssr_tb, i, 75);
|
lv_table_set_col_width(lv_ssr_tb, i, 75);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lv_table_set_col_width(lv_ssr_tb, i, 85);
|
lv_table_set_col_width(lv_ssr_tb, i, 85);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,12 +119,11 @@ void lv_sensor_info(void) {
|
||||||
lv_obj_add_event_cb(lv_ssr_tb, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
lv_obj_add_event_cb(lv_ssr_tb, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* lvgl_thd_show_sensor_info(void *parameter)
|
void *lvgl_thd_show_sensor_info(void *parameter)
|
||||||
{
|
{
|
||||||
lv_sensor_info();
|
lv_sensor_info();
|
||||||
PrivMutexCreate(&ssr_val_lock, 0);
|
PrivMutexCreate(&ssr_val_lock, 0);
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
|
|
||||||
sensor_update_table();
|
sensor_update_table();
|
||||||
|
@ -123,5 +141,4 @@ static int lvgl_show_sensor_info(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_show_sensor_info, lvgl_show_sensor_info, lvgl_show_sensor_info );
|
PRIV_SHELL_CMD_FUNCTION(lvgl_show_sensor_info, a littlevgl sensor info show sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_sensor_info.h
|
||||||
|
* @brief: a sensor info application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __LVGL_SENSOR_INFO_H__
|
#ifndef __LVGL_SENSOR_INFO_H__
|
||||||
#define __LVGL_SENSOR_INFO_H__
|
#define __LVGL_SENSOR_INFO_H__
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_sensor_info_update_demo.c
|
||||||
|
* @brief: a sensor info update application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "lv_sensor_info.h"
|
#include "lv_sensor_info.h"
|
||||||
|
|
||||||
void* lvgl_thd_sensor_info_update_demo(void *parameter)
|
void* lvgl_thd_sensor_info_update_demo(void *parameter)
|
||||||
|
@ -28,5 +49,4 @@ static int lvgl_sensor_info_update_demo(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_sensor_info_update_demo, lvgl_sensor_info_update_demo, lvgl_sensor_info_update_demo );
|
PRIV_SHELL_CMD_FUNCTION(lvgl_sensor_info_update_demo, a littlevgl sensor infor update sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: lv_sensor_update_info.c
|
||||||
|
* @brief: a sensor update info application using littleVgl
|
||||||
|
* @version: 2.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2022/9/26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "lv_sensor_info.h"
|
#include "lv_sensor_info.h"
|
||||||
|
|
||||||
uint32_t lv_ssr_map_idx(enum sensor_type st) {
|
uint32_t lv_ssr_map_idx(enum sensor_type st) {
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <transform.h>
|
#include <transform.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int FrameworkInit();
|
extern int FrameworkInit();
|
||||||
extern void ApplicationOtaTaskInit(void);
|
extern void ApplicationOtaTaskInit(void);
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file: ota_server.c
|
||||||
|
* @brief: a application ota task of system running in Linux
|
||||||
|
* @version: 1.0
|
||||||
|
* @author: AIIT XUOS Lab
|
||||||
|
* @date: 2021/11/3
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
* @date 2021.12.23
|
* @date 2021.12.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <user_api.h>
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
* @date 2021.12.10
|
* @date 2021.12.10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
* @date 2021.12.23
|
* @date 2021.12.23
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,12 +18,8 @@
|
||||||
* @date 2021.12.15
|
* @date 2021.12.15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Read a hcho
|
* @description: Read a hcho
|
||||||
* @return 0
|
* @return 0
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +27,7 @@
|
||||||
void HumiHs300x(void)
|
void HumiHs300x(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int32 humidity;
|
int32_t humidity;
|
||||||
struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI);
|
struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI);
|
||||||
SensorQuantityOpen(humi);
|
SensorQuantityOpen(humi);
|
||||||
for (i = 0; i < 100; i ++) {
|
for (i = 0; i < 100; i ++) {
|
||||||
|
|
|
@ -18,18 +18,8 @@
|
||||||
* @date 2021.12.14
|
* @date 2021.12.14
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
// struct iaq_data {
|
|
||||||
// uint16_t gas;
|
|
||||||
// uint8_t TH;
|
|
||||||
// uint8_t TL;
|
|
||||||
// uint8_t RhH;
|
|
||||||
// uint8_t RhL;
|
|
||||||
// };
|
|
||||||
/**
|
/**
|
||||||
* @description: Read a iaq
|
* @description: Read a iaq
|
||||||
* @return 0
|
* @return 0
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
* @date 2021.12.28
|
* @date 2021.12.28
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +27,7 @@
|
||||||
void TempHs300x(void)
|
void TempHs300x(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int32 temperature;
|
int32_t temperature;
|
||||||
struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP);
|
struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP);
|
||||||
SensorQuantityOpen(temp);
|
SensorQuantityOpen(temp);
|
||||||
for (i = 0; i < 100; i ++) {
|
for (i = 0; i < 100; i ++) {
|
||||||
|
|
|
@ -18,12 +18,8 @@
|
||||||
* @date 2021.12.15
|
* @date 2021.12.15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
# include <user_api.h>
|
|
||||||
#endif
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Read a tvoc
|
* @description: Read a tvoc
|
||||||
* @return 0
|
* @return 0
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
* @date 2021.04.23
|
* @date 2021.04.23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <transform.h>
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +29,7 @@ void VoiceD124(void)
|
||||||
struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE);
|
struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE);
|
||||||
SensorQuantityOpen(voice);
|
SensorQuantityOpen(voice);
|
||||||
PrivTaskDelay(2000);
|
PrivTaskDelay(2000);
|
||||||
uint16 result = SensorQuantityReadValue(voice);
|
uint16_t result = SensorQuantityReadValue(voice);
|
||||||
printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places));
|
printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places));
|
||||||
SensorQuantityClose(voice);
|
SensorQuantityClose(voice);
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@
|
||||||
* @date 2021.12.14
|
* @date 2021.12.14
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <transform.h>
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,11 +29,7 @@ void WindDirectionQsFx(void)
|
||||||
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
|
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
|
||||||
SensorQuantityOpen(wind_direction);
|
SensorQuantityOpen(wind_direction);
|
||||||
PrivTaskDelay(2000);
|
PrivTaskDelay(2000);
|
||||||
uint16 result = SensorQuantityReadValue(wind_direction);
|
uint16_t result = SensorQuantityReadValue(wind_direction);
|
||||||
printf("wind direction : %d degree\n", result);
|
printf("wind direction : %d degree\n", result);
|
||||||
SensorQuantityClose(wind_direction);
|
SensorQuantityClose(wind_direction);
|
||||||
}
|
}
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindDirectionQsFx, WindDirectionQsFx, WindDirectionQsFx function);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
* @date 2021.12.14
|
* @date 2021.12.14
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <transform.h>
|
|
||||||
#include <sensor.h>
|
#include <sensor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,11 +29,7 @@ void WindSpeedQsFs(void)
|
||||||
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
|
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
|
||||||
SensorQuantityOpen(wind_speed);
|
SensorQuantityOpen(wind_speed);
|
||||||
PrivTaskDelay(2000);
|
PrivTaskDelay(2000);
|
||||||
uint16 result = SensorQuantityReadValue(wind_speed);
|
uint16_t result = SensorQuantityReadValue(wind_speed);
|
||||||
printf("wind speed : %d.%d m/s\n", result/10, result%10);
|
printf("wind speed : %d.%d m/s\n", result/10, result%10);
|
||||||
SensorQuantityClose(wind_speed);
|
SensorQuantityClose(wind_speed);
|
||||||
}
|
}
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindSpeedQsFs, WindSpeedQsFs, WindSpeedQsFs function);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -20,5 +20,9 @@ ifeq ($(CONFIG_CRYPTO),y)
|
||||||
SRC_DIR += security
|
SRC_DIR += security
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_MBEDTLS), y)
|
||||||
|
SRC_DIR += security
|
||||||
|
endif
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,4 @@ int Adapter4GTest(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
PRIV_SHELL_CMD_FUNCTION(Adapter4GTest, a EC200T adpter sample, PRIV_SHELL_CMD_FUNC_ATTR);
|
||||||
#ifdef ADD_RTTHREAD_FETURES
|
|
||||||
MSH_CMD_EXPORT(Adapter4GTest,a EC200T adpter sample);
|
|
||||||
#endif
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, Adapter4GTest, Adapter4GTest, show adapter 4G information);
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
||||||
bool "Using connection framework debug log function"
|
bool "Using connection framework debug log function"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
menuconfig CONNECTION_INDUSTRIAL_ETHERNET
|
menuconfig CONNECTION_INDUSTRIAL_NETWORK
|
||||||
bool "Using industrial ethernet"
|
bool "Using industrial network"
|
||||||
default n
|
default n
|
||||||
if CONNECTION_INDUSTRIAL_ETHERNET
|
if CONNECTION_INDUSTRIAL_NETWORK
|
||||||
source "$APP_DIR/Framework/connection/industrial_ethernet/Kconfig"
|
source "$APP_DIR/Framework/connection/industrial_network/Kconfig"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
menuconfig CONNECTION_INDUSTRIAL_FIELDBUS
|
menuconfig CONNECTION_INDUSTRIAL_FIELDBUS
|
||||||
|
|
|
@ -9,8 +9,8 @@ endif
|
||||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
SRC_FILES := adapter.c adapter_agent.c
|
SRC_FILES := adapter.c adapter_agent.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_ETHERNET),y)
|
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_NETWORK),y)
|
||||||
SRC_DIR += industrial_ethernet
|
SRC_DIR += industrial_network
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y)
|
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y)
|
||||||
|
|
|
@ -169,7 +169,7 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
||||||
|
|
||||||
result = priv_done->open(adapter);
|
result = priv_done->open(adapter);
|
||||||
if (0 == result) {
|
if (0 == result) {
|
||||||
printf("Device %s open success.\n", adapter->name);
|
printf("Device %s %p open success.\n", adapter->name, adapter->adapter_param);
|
||||||
adapter->adapter_status = INSTALL;
|
adapter->adapter_status = INSTALL;
|
||||||
} else {
|
} else {
|
||||||
if (adapter->fd) {
|
if (adapter->fd) {
|
||||||
|
@ -187,7 +187,7 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
||||||
|
|
||||||
result = ip_done->open(adapter);
|
result = ip_done->open(adapter);
|
||||||
if (0 == result) {
|
if (0 == result) {
|
||||||
printf("Device %s open success.\n", adapter->name);
|
printf("Device %s param %p open success.\n", adapter->name, adapter->adapter_param);
|
||||||
adapter->adapter_status = INSTALL;
|
adapter->adapter_status = INSTALL;
|
||||||
} else {
|
} else {
|
||||||
if (adapter->fd) {
|
if (adapter->fd) {
|
||||||
|
|
|
@ -139,9 +139,9 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const
|
||||||
|
|
||||||
abstime.tv_sec = timeout_s;
|
abstime.tv_sec = timeout_s;
|
||||||
|
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
agent->receive_mode = AT_MODE;
|
agent->receive_mode = AT_MODE;
|
||||||
|
|
||||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const
|
||||||
const char *cmd = NULL;
|
const char *cmd = NULL;
|
||||||
|
|
||||||
agent->reply = reply;
|
agent->reply = reply;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
|
||||||
if(agent->reply != NULL) {
|
if(agent->reply != NULL) {
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
reply->reply_len = 0;
|
reply->reply_len = 0;
|
||||||
|
@ -211,8 +211,7 @@ int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
printf("[reply result :\n");
|
printf("[reply result: %s]\n", result);
|
||||||
printf("%s]\n", result);
|
|
||||||
if(!strstr(result, check)) {
|
if(!strstr(result, check)) {
|
||||||
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -230,7 +229,7 @@ char *GetReplyText(ATReplyType reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||||
{
|
{
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +240,7 @@ int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||||
{
|
{
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +252,7 @@ int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
||||||
{
|
{
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -292,18 +291,18 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
abstime.tv_sec = timeout_s;
|
abstime.tv_sec = timeout_s;
|
||||||
if(buffer_len > ENTM_RECV_MAX){
|
if(buffer_len > ENTM_RECV_MAX){
|
||||||
printf("read length more then max length[%d] Bytes",ENTM_RECV_MAX);
|
printf("read length more then max length[%d] Bytes",ENTM_RECV_MAX);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
agent->receive_mode = ENTM_MODE;
|
agent->receive_mode = ENTM_MODE;
|
||||||
agent->read_len = buffer_len;
|
agent->read_len = buffer_len;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
//PrivTaskDelay(1000);
|
//PrivTaskDelay(1000);
|
||||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||||
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
|
|
||||||
printf("EntmRecv once len %d.\n", agent->entm_recv_len);
|
printf("EntmRecv once len %d.\n", agent->entm_recv_len);
|
||||||
|
|
||||||
|
@ -312,7 +311,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
||||||
agent->entm_recv_len = 0;
|
agent->entm_recv_len = 0;
|
||||||
agent->read_len = 0;
|
agent->read_len = 0;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
|
||||||
return buffer_len;
|
return buffer_len;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +322,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
char ch = 0, last_ch = 0;
|
char ch = 0, last_ch = 0;
|
||||||
bool is_full = false;
|
bool is_full = false;
|
||||||
|
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
|
|
||||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
|
@ -331,7 +330,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
memset(agent->entm_recv_buf, 0x00, 256);
|
memset(agent->entm_recv_buf, 0x00, 256);
|
||||||
agent->entm_recv_len = 0;
|
agent->entm_recv_len = 0;
|
||||||
|
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
PrivRead(agent->fd, &ch, 1);
|
PrivRead(agent->fd, &ch, 1);
|
||||||
|
@ -359,7 +358,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
} else {
|
} else {
|
||||||
printf("entm_recv_buf is_full ...\n");
|
printf("entm_recv_buf is_full ...\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (agent->receive_mode == AT_MODE) {
|
else if (agent->receive_mode == AT_MODE) {
|
||||||
if (read_len < agent->maintain_max) {
|
if (read_len < agent->maintain_max) {
|
||||||
if(ch != 0) { ///< if the char is null then do not save it to the buff
|
if(ch != 0) { ///< if the char is null then do not save it to the buff
|
||||||
|
@ -367,13 +366,14 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
read_len++;
|
read_len++;
|
||||||
agent->maintain_len = read_len;
|
agent->maintain_len = read_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("maintain_len is_full ...\n");
|
printf("maintain_len is_full %d ...\n", read_len);
|
||||||
is_full = true;
|
is_full = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
|
if (((ch == '\n') && (agent->reply_lr_end)) ||
|
||||||
|
((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
|
||||||
((ch == agent->reply_end_char) && (agent->reply_end_char) &&
|
((ch == agent->reply_end_char) && (agent->reply_end_char) &&
|
||||||
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
||||||
((read_len == agent->reply_char_num) && (agent->reply_char_num))) {
|
((read_len == agent->reply_char_num) && (agent->reply_char_num))) {
|
||||||
|
@ -384,7 +384,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("GetCompleteATReply done\n");
|
printf("GetCompleteATReply done\n");
|
||||||
agent->receive_mode = DEFAULT_MODE;
|
agent->receive_mode = DEFAULT_MODE;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
@ -418,7 +418,7 @@ int DeleteATAgent(ATAgentType agent)
|
||||||
if(agent->at_handler > 0){
|
if(agent->at_handler > 0){
|
||||||
PrivTaskDelete(agent->at_handler, 0);
|
PrivTaskDelete(agent->at_handler, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->fd > 0) {
|
if (agent->fd > 0) {
|
||||||
printf("close agent fd = %d\n",agent->fd);
|
printf("close agent fd = %d\n",agent->fd);
|
||||||
PrivClose(agent->fd);
|
PrivClose(agent->fd);
|
||||||
|
@ -464,7 +464,7 @@ static void *ATAgentReceiveProcess(void *param)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (GetCompleteATReply(agent) > 0) {
|
if (GetCompleteATReply(agent) > 0) {
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
if (agent->reply != NULL) {
|
if (agent->reply != NULL) {
|
||||||
ATReplyType reply = agent->reply;
|
ATReplyType reply = agent->reply;
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ static int ATAgentInit(ATAgentType agent)
|
||||||
#ifdef ADD_NUTTX_FETURES
|
#ifdef ADD_NUTTX_FETURES
|
||||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||||
attr.priority = 18;
|
attr.priority = 18;
|
||||||
attr.stacksize = 4096;
|
attr.stacksize = 8192;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
|
@ -550,7 +550,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||||
if (GetATAgent(agent_name) != NULL) {
|
if (GetATAgent(agent_name) != NULL) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < AT_AGENT_MAX && at_agent_table[i].fd > 0) {
|
while (i < AT_AGENT_MAX && at_agent_table[i].fd > 0) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,4 @@ int AdapterBlueToothTest(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef ADD_RTTHREAD_FETURES
|
PRIV_SHELL_CMD_FUNCTION(AdapterBlueToothTest, a bluetooth test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
MSH_CMD_EXPORT(AdapterBlueToothTest,a bt adpter sample);
|
|
||||||
#endif
|
|
||||||
#ifdef ADD_XIZI_FETURES
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter bluetooth information);
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -122,8 +122,4 @@ int AdapterEthernetTest(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef ADD_RTTHREAD_FETURES
|
PRIV_SHELL_CMD_FUNCTION(AdapterEthernetTest, a ethernet test sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
MSH_CMD_EXPORT(AdapterEthernetTest,a ethernet adpter sample);
|
|
||||||
#elif definded ADD_XIZI_FETURES
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterEthernetTest, AdapterEthernetTest, show adapter ethernet information);
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
config CONNECTION_ADAPTER_ETHERCAT
|
|
||||||
bool "Using ethercat on industrial_ethernet adapter device"
|
|
||||||
default n
|
|
||||||
|
|
||||||
if CONNECTION_ADAPTER_ETHERCAT
|
|
||||||
source "$APP_DIR/Framework/connection/industrial_ethernet/ethercat/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
menuconfig POWERLINK_MN
|
|
||||||
bool "Using powerlink MN"
|
|
||||||
default n
|
|
||||||
|
|
||||||
menuconfig POWERLINK_CN
|
|
||||||
bool "Using powerlink CN"
|
|
||||||
default n
|
|
|
@ -1,28 +0,0 @@
|
||||||
#include <xizi.h>
|
|
||||||
#include <xsconfig.h>
|
|
||||||
|
|
||||||
#ifdef POWERLINK_MN
|
|
||||||
extern int OplkDemoMnConsole(int argc, char *argv[]);
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(
|
|
||||||
SHELL_CMD_PERMISSION(0) |
|
|
||||||
SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
|
|
||||||
SHELL_CMD_PARAM_NUM(0) |
|
|
||||||
SHELL_CMD_DISABLE_RETURN,
|
|
||||||
OplkDemoMnConsole,
|
|
||||||
OplkDemoMnConsole,
|
|
||||||
openPOWERLINK demo MN (console version));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef POWERLINK_CN
|
|
||||||
extern int OplkDemoCnConsole(int argc, char *argv[]);
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(
|
|
||||||
SHELL_CMD_PERMISSION(0) |
|
|
||||||
SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
|
|
||||||
SHELL_CMD_PARAM_NUM(0) |
|
|
||||||
SHELL_CMD_DISABLE_RETURN,
|
|
||||||
OplkDemoCnConsole,
|
|
||||||
OplkDemoCnConsole,
|
|
||||||
openPOWERLINK demo CN (console version));
|
|
||||||
#endif
|
|
|
@ -1,2 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR :=
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue