support lcd test on xidatong-arm32 support wifi test on xidatong-arm32 support ethernet test on xidatong-arm32 on nuttx from Wang_linyu
it is OK
This commit is contained in:
commit
a11ff29402
|
@ -29,5 +29,9 @@ menu "test app"
|
|||
config USER_TEST_SEMC
|
||||
bool "Config test semc sdram"
|
||||
default n
|
||||
|
||||
config USER_TEST_LCD
|
||||
bool "Config test lcd device"
|
||||
default n
|
||||
endif
|
||||
endmenu
|
||||
|
|
|
@ -12,6 +12,10 @@ 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
|
||||
endif
|
||||
|
@ -19,7 +23,7 @@ endif
|
|||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += test_extsram.c
|
||||
CSRCS += test_extsram.c test_lcd.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <transform.h>
|
||||
#include "stdio.h"
|
||||
|
||||
/* parameters for sram peripheral */
|
||||
// /* stm32f4 Bank3:0X68000000 */
|
||||
|
@ -52,7 +53,7 @@ int ExtsramTest(void)
|
|||
#endif
|
||||
|
||||
/* write data */
|
||||
printf("Writing the %ld bytes data, waiting....", SRAM_SIZE);
|
||||
printf("Writing the %ld bytes data, waiting....\n", SRAM_SIZE);
|
||||
start_time = PrivGetTickTime();
|
||||
for (i = 0; i < SRAM_SIZE / data_width; i++)
|
||||
{
|
||||
|
@ -90,7 +91,7 @@ int ExtsramTest(void)
|
|||
data = *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width);
|
||||
if (data != 0x55555555)
|
||||
{
|
||||
printf("SRAM test failed!");
|
||||
printf("SRAM test failed!\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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
|
|
@ -29,6 +29,7 @@
|
|||
#ifdef ADD_NUTTX_FETURES
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "stdio.h"
|
||||
#endif
|
||||
|
||||
|
@ -42,21 +43,47 @@ char tcp_socket_ip[] = {192, 168, 250, 252};
|
|||
#define lw_error printf
|
||||
|
||||
#define LWIP_DEMO_TIMES 3
|
||||
|
||||
/** Create u32_t value from bytes */
|
||||
#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
|
||||
((uint32_t)((b) & 0xff) << 16) | \
|
||||
((uint32_t)((c) & 0xff) << 8) | \
|
||||
(uint32_t)((d) & 0xff))
|
||||
|
||||
#define PP_HTONL(x) ((uint32_t)(x))
|
||||
#define LWIP_TARGET_PORT 6000
|
||||
#define LWIP_TARGET_PORT 4840
|
||||
#endif
|
||||
|
||||
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
|
||||
char tcp_ip_str[128] = {0};
|
||||
|
||||
/******************************************************************************/
|
||||
static void TCPSocketRecvTask(void *arg)
|
||||
void TcpSocketConfigParam(char *ip_str)
|
||||
{
|
||||
int ip1, ip2, ip3, ip4, port = 0;
|
||||
|
||||
if(ip_str == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
|
||||
{
|
||||
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 recv_len;
|
||||
|
@ -64,15 +91,18 @@ static void TCPSocketRecvTask(void *arg)
|
|||
struct sockaddr_in tcp_addr;
|
||||
socklen_t addr_len;
|
||||
|
||||
while(1) {
|
||||
while(1)
|
||||
{
|
||||
recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE);
|
||||
if (recv_buf == NULL) {
|
||||
if (recv_buf == NULL)
|
||||
{
|
||||
lw_error("No memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
if (fd < 0)
|
||||
{
|
||||
lw_error("Socket error\n");
|
||||
free(recv_buf);
|
||||
continue;
|
||||
|
@ -83,7 +113,8 @@ static void TCPSocketRecvTask(void *arg)
|
|||
tcp_addr.sin_port = htons(tcp_socket_port);
|
||||
memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero));
|
||||
|
||||
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) {
|
||||
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
lw_error("Unable to bind\n");
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
|
@ -91,10 +122,11 @@ static void TCPSocketRecvTask(void *arg)
|
|||
}
|
||||
|
||||
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
|
||||
if (listen(fd, 5) != 0 ) {
|
||||
if (listen(fd, 5) != 0 )
|
||||
{
|
||||
lw_error("Unable to listen\n");
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
|
@ -105,10 +137,13 @@ static void TCPSocketRecvTask(void *arg)
|
|||
clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len);
|
||||
lw_notice("client %s connected\n", inet_ntoa(tcp_addr.sin_addr));
|
||||
|
||||
while(1) {
|
||||
while(1)
|
||||
{
|
||||
memset(recv_buf, 0, TCP_DEMO_BUF_SIZE);
|
||||
recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0, (struct sockaddr *)&tcp_addr, &addr_len);
|
||||
if(recv_len > 0) {
|
||||
recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0,
|
||||
(struct sockaddr *)&tcp_addr, &addr_len);
|
||||
if(recv_len > 0)
|
||||
{
|
||||
lw_notice("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr));
|
||||
lw_notice("Receive data : %d - %s\n\n", recv_len, recv_buf);
|
||||
}
|
||||
|
@ -120,35 +155,39 @@ static void TCPSocketRecvTask(void *arg)
|
|||
free(recv_buf);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
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]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0) {
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]);
|
||||
}
|
||||
TcpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||
sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TCPSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
#endif
|
||||
|
||||
static void TCPSocketSendTask(void *arg)
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
TcpSocketRecvTask(NULL);
|
||||
#endif
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TcpSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
static void TcpSocketSendTask(void *arg)
|
||||
{
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
int fd = -1;
|
||||
int ret;
|
||||
char send_msg[128];
|
||||
|
||||
lw_print("2022-10-14 Mr. Wang commit TCP\n");
|
||||
lw_print("%s start\n", __func__);
|
||||
|
||||
memset(send_msg, 0, sizeof(send_msg));
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
if (fd < 0)
|
||||
{
|
||||
lw_print("Socket error\n");
|
||||
return;
|
||||
}
|
||||
|
@ -156,21 +195,25 @@ static void TCPSocketSendTask(void *arg)
|
|||
struct sockaddr_in tcp_sock;
|
||||
tcp_sock.sin_family = AF_INET;
|
||||
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));
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr))) {
|
||||
lw_print("Unable to connect\n");
|
||||
ret = connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr));
|
||||
if (ret)
|
||||
{
|
||||
lw_print("Unable to connect %s = %d\n", tcp_ip_str, ret);
|
||||
close(fd);
|
||||
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");
|
||||
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);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
@ -179,32 +222,21 @@ static void TCPSocketSendTask(void *arg)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
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]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0)
|
||||
{
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]);
|
||||
}
|
||||
TcpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||
sys_thread_new("TCP Socket Send", TCPSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TCPSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
sys_thread_new("Tcp Socket Send", TcpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
void tcp_recv_demo(void)
|
||||
{
|
||||
TCPSocketRecvTask(NULL);
|
||||
}
|
||||
|
||||
void tcp_send_demo(void)
|
||||
{
|
||||
TCPSocketSendTask(NULL);
|
||||
}
|
||||
TcpSocketSendTask(NULL);
|
||||
#endif
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(TcpSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
|
|
|
@ -31,45 +31,72 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define LWIP_DEMO_TIMES 3
|
||||
#define LWIP_LOCAL_PORT 6000
|
||||
#define LWIP_LOCAL_PORT 4840
|
||||
|
||||
#define lw_error printf
|
||||
#define lw_notice printf
|
||||
#define lw_print printf
|
||||
|
||||
/** Create u32_t value from bytes */
|
||||
#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
|
||||
((uint32_t)((b) & 0xff) << 16) | \
|
||||
((uint32_t)((c) & 0xff) << 8) | \
|
||||
(uint32_t)((d) & 0xff))
|
||||
|
||||
#define PP_HTONL(x) ((uint32_t)(x))
|
||||
|
||||
#endif
|
||||
|
||||
#define UDP_BUF_SIZE 65536
|
||||
|
||||
char udp_socket_ip[] = {192, 168, 250, 252};
|
||||
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)
|
||||
{
|
||||
int fd = -1;
|
||||
char *recv_buf;
|
||||
struct sockaddr_in udp_addr, server_addr;
|
||||
int recv_len;
|
||||
socklen_t addr_len;
|
||||
|
||||
while(1) {
|
||||
while(1)
|
||||
{
|
||||
recv_buf = (char *)malloc(UDP_BUF_SIZE);
|
||||
if(recv_buf == NULL) {
|
||||
if(recv_buf == NULL)
|
||||
{
|
||||
lw_error("No memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0) {
|
||||
if(fd < 0)
|
||||
{
|
||||
lw_error("Socket error\n");
|
||||
free(recv_buf);
|
||||
continue;
|
||||
|
@ -80,25 +107,27 @@ static void UdpSocketRecvTask(void *arg)
|
|||
udp_addr.sin_port = htons(udp_socket_port);
|
||||
memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero));
|
||||
|
||||
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) {
|
||||
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
lw_error("Unable to bind\n");
|
||||
close(fd);
|
||||
free(recv_buf);
|
||||
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);
|
||||
|
||||
while(1) {
|
||||
while(1)
|
||||
{
|
||||
memset(recv_buf, 0, UDP_BUF_SIZE);
|
||||
recv_len = recvfrom(fd, recv_buf, UDP_BUF_SIZE, 0, (struct sockaddr *)&server_addr, &addr_len);
|
||||
recv_len = recv(fd, recv_buf, UDP_BUF_SIZE, 0);
|
||||
if(recv_len > 0)
|
||||
{
|
||||
lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
|
||||
lw_notice("Receive data : %s\n\n", recv_buf);
|
||||
}
|
||||
sendto(fd, recv_buf, recv_len, 0, (struct sockaddr*)&server_addr, addr_len);
|
||||
send(fd, recv_buf, recv_len, 0);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
@ -106,21 +135,24 @@ static void UdpSocketRecvTask(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
void UdpSocketRecvTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2) {
|
||||
if(argc >= 2)
|
||||
{
|
||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) {
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]);
|
||||
}
|
||||
UdpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
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);
|
||||
#endif
|
||||
|
||||
static void UdpSocketSendTask(void *arg)
|
||||
{
|
||||
|
@ -131,7 +163,8 @@ static void UdpSocketSendTask(void *arg)
|
|||
memset(send_str, 0, sizeof(send_str));
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0) {
|
||||
if(fd < 0)
|
||||
{
|
||||
lw_error("Socket error\n");
|
||||
return;
|
||||
}
|
||||
|
@ -139,21 +172,24 @@ static void UdpSocketSendTask(void *arg)
|
|||
struct sockaddr_in udp_sock;
|
||||
udp_sock.sin_family = AF_INET;
|
||||
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));
|
||||
|
||||
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");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
lw_print("UDP connect success, start to send.\n");
|
||||
lw_notice("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
|
||||
lw_print("UDP connect %s:%d success, start to send.\n",
|
||||
udp_ip_str,
|
||||
udp_socket_port);
|
||||
|
||||
while (cnt --) {
|
||||
while(cnt --)
|
||||
{
|
||||
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
|
||||
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);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
@ -162,30 +198,22 @@ static void UdpSocketSendTask(void *arg)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
void UdpSocketSendTest(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 2) {
|
||||
if(argc >= 2)
|
||||
{
|
||||
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
|
||||
if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) {
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]);
|
||||
}
|
||||
UdpSocketConfigParam(argv[1]);
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
|
||||
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
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);
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
void udp_recv_demo(void)
|
||||
{
|
||||
UdpSocketRecvTask(NULL);
|
||||
}
|
||||
|
||||
void udp_send_demo(void)
|
||||
{
|
||||
UdpSocketSendTask(NULL);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -169,7 +169,7 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
|||
|
||||
result = priv_done->open(adapter);
|
||||
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;
|
||||
} else {
|
||||
if (adapter->fd) {
|
||||
|
@ -187,7 +187,7 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
|||
|
||||
result = ip_done->open(adapter);
|
||||
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;
|
||||
} else {
|
||||
if (adapter->fd) {
|
||||
|
|
|
@ -139,9 +139,9 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const
|
|||
|
||||
abstime.tv_sec = timeout_s;
|
||||
|
||||
PrivMutexObtain(&agent->lock);
|
||||
PrivMutexObtain(&agent->lock);
|
||||
agent->receive_mode = AT_MODE;
|
||||
|
||||
|
||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
agent->maintain_len = 0;
|
||||
|
||||
|
@ -154,8 +154,8 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const
|
|||
const char *cmd = NULL;
|
||||
|
||||
agent->reply = reply;
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
if(agent->reply != NULL) {
|
||||
PrivMutexObtain(&agent->lock);
|
||||
reply->reply_len = 0;
|
||||
|
@ -211,8 +211,7 @@ int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
|||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
printf("[reply result :\n");
|
||||
printf("%s]\n", result);
|
||||
printf("[reply result: %s]\n", result);
|
||||
if(!strstr(result, check)) {
|
||||
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
||||
ret = -1;
|
||||
|
@ -230,7 +229,7 @@ char *GetReplyText(ATReplyType reply)
|
|||
}
|
||||
|
||||
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||
{
|
||||
{
|
||||
if (!agent) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -241,7 +240,7 @@ int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
|||
}
|
||||
|
||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||
{
|
||||
{
|
||||
if (!agent) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -253,7 +252,7 @@ int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
|||
}
|
||||
|
||||
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
||||
{
|
||||
{
|
||||
if (!agent) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -292,18 +291,18 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
|||
abstime.tv_sec = timeout_s;
|
||||
if(buffer_len > 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->read_len = buffer_len;
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
//PrivTaskDelay(1000);
|
||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
||||
return -1;
|
||||
}
|
||||
PrivMutexObtain(&agent->lock);
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
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);
|
||||
agent->entm_recv_len = 0;
|
||||
agent->read_len = 0;
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
return buffer_len;
|
||||
}
|
||||
|
@ -323,7 +322,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
char ch = 0, last_ch = 0;
|
||||
bool is_full = false;
|
||||
|
||||
PrivMutexObtain(&agent->lock);
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
agent->maintain_len = 0;
|
||||
|
@ -331,7 +330,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
memset(agent->entm_recv_buf, 0x00, 256);
|
||||
agent->entm_recv_len = 0;
|
||||
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
while (1) {
|
||||
PrivRead(agent->fd, &ch, 1);
|
||||
|
@ -359,7 +358,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
} else {
|
||||
printf("entm_recv_buf is_full ...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (agent->receive_mode == AT_MODE) {
|
||||
if (read_len < agent->maintain_max) {
|
||||
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++;
|
||||
agent->maintain_len = read_len;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
printf("maintain_len is_full ...\n");
|
||||
printf("maintain_len is_full %d ...\n", read_len);
|
||||
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) &&
|
||||
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
||||
((read_len == agent->reply_char_num) && (agent->reply_char_num))) {
|
||||
|
@ -384,7 +384,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
PrivMutexAbandon(&agent->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
printf("GetCompleteATReply done\n");
|
||||
agent->receive_mode = DEFAULT_MODE;
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
@ -418,7 +418,7 @@ int DeleteATAgent(ATAgentType agent)
|
|||
if(agent->at_handler > 0){
|
||||
PrivTaskDelete(agent->at_handler, 0);
|
||||
}
|
||||
|
||||
|
||||
if (agent->fd > 0) {
|
||||
printf("close agent fd = %d\n",agent->fd);
|
||||
PrivClose(agent->fd);
|
||||
|
@ -464,7 +464,7 @@ static void *ATAgentReceiveProcess(void *param)
|
|||
|
||||
while (1) {
|
||||
if (GetCompleteATReply(agent) > 0) {
|
||||
PrivMutexObtain(&agent->lock);
|
||||
PrivMutexObtain(&agent->lock);
|
||||
if (agent->reply != NULL) {
|
||||
ATReplyType reply = agent->reply;
|
||||
|
||||
|
@ -521,7 +521,7 @@ static int ATAgentInit(ATAgentType agent)
|
|||
#ifdef ADD_NUTTX_FETURES
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = 18;
|
||||
attr.stacksize = 4096;
|
||||
attr.stacksize = 8192;
|
||||
|
||||
#else
|
||||
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) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
while (i < AT_AGENT_MAX && at_agent_table[i].fd > 0) {
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ int AdapterWifiInit(void)
|
|||
/******************wifi TEST*********************/
|
||||
int AdapterWifiTest(void)
|
||||
{
|
||||
char cmd[64];
|
||||
int baud_rate = BAUD_RATE_57600;
|
||||
// char cmd[64];
|
||||
// int baud_rate = BAUD_RATE_57600;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
|
||||
|
@ -168,13 +168,13 @@ int AdapterWifiTest(void)
|
|||
|
||||
const char *wifi_msg = "Wifi Test";
|
||||
int len = strlen(wifi_msg);
|
||||
for(int i = 0;i < 10; ++i) {
|
||||
for(int i = 0; i < 10; ++i) {
|
||||
AdapterDeviceSend(adapter, wifi_msg, len);
|
||||
PrivTaskDelay(4000);
|
||||
}
|
||||
|
||||
char wifi_recv_msg[128];
|
||||
for(int j=0;j<10;++j){
|
||||
for(int j = 0; j < 10; ++j){
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ PRIV_SHELL_CMD_FUNCTION(WifiClose, a WiFi close sample, PRIV_SHELL_CMD_MAIN_ATTR
|
|||
int WifiSetup(int argc, char *argv[])
|
||||
{
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
struct WifiParam param;
|
||||
static struct WifiParam param;
|
||||
memset(¶m,0,sizeof(struct WifiParam));
|
||||
strncpy((char *)param.wifi_ssid, argv[1], strlen(argv[1]));
|
||||
strncpy((char *)param.wifi_pwd, argv[2], strlen(argv[2]));
|
||||
|
@ -292,7 +292,7 @@ enum
|
|||
APT_WIFI_PARAM_NUM
|
||||
};
|
||||
|
||||
#define APT_WIFI_PARAM_LEN 20
|
||||
#define APT_WIFI_PARAM_LEN 128
|
||||
|
||||
char wifi_param[APT_WIFI_PARAM_NUM][APT_WIFI_PARAM_LEN] = {0};
|
||||
|
||||
|
@ -301,6 +301,7 @@ ret = __func; \
|
|||
if(ret != 0){ \
|
||||
printf("%s %d failed\n", __func__, __LINE__); \
|
||||
AdapterDeviceClose(adapter); \
|
||||
free(adapter->adapter_param); \
|
||||
return ret; \
|
||||
};
|
||||
|
||||
|
@ -309,7 +310,16 @@ void AdapterWifiGetParam(int argc, char *argv[])
|
|||
int i, j;
|
||||
char *param_str[] = {"ip", "port", "ssid", "pwd", "gw", "server", "mask", "ping"};
|
||||
char *default_str[] =
|
||||
{"192.168.137.34", "12345", "test", "tttttttt", "192.168.137.71", "192.168.137.1", "255.255.255.0", "220.181.38.251"};
|
||||
{
|
||||
"192.168.137.34",
|
||||
"12345",
|
||||
"test",
|
||||
"tttttttt",
|
||||
"192.168.137.71",
|
||||
"192.168.137.1",
|
||||
"255.255.255.0",
|
||||
"220.181.38.251"
|
||||
};
|
||||
|
||||
for(i = 0; i < APT_WIFI_PARAM_NUM; i ++)
|
||||
{
|
||||
|
@ -338,21 +348,24 @@ void AdapterWifiGetParam(int argc, char *argv[])
|
|||
}
|
||||
|
||||
|
||||
int AdapterWifiTest(int argc, char *argv[])
|
||||
int AdapterWifiTestWithParam(int argc, char *argv[])
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
AdapterWifiGetParam(argc, argv);
|
||||
|
||||
enum NetRoleType net_role = CLIENT;
|
||||
enum IpType ip_type = IPV4;
|
||||
struct WifiParam param;
|
||||
memset(¶m, 0, sizeof(struct WifiParam));
|
||||
strncpy((char *)param.wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID], strlen(wifi_param[APT_WIFI_PARAM_SSID]));
|
||||
strncpy((char *)param.wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD], strlen(wifi_param[APT_WIFI_PARAM_PWD]));
|
||||
|
||||
adapter->adapter_param = ¶m;
|
||||
adapter->adapter_param = malloc(sizeof(struct WifiParam));
|
||||
memset(adapter->adapter_param, 0, sizeof(struct WifiParam));
|
||||
struct WifiParam *apt_param = (struct WifiParam *)adapter->adapter_param;
|
||||
strcpy(apt_param->wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID]);
|
||||
strcpy(apt_param->wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD]);
|
||||
|
||||
printf("2022-10-14 Mr. Wang commit Wifi\n");
|
||||
printf("apt %p ssid %p %s\n", apt_param, apt_param->wifi_ssid);
|
||||
|
||||
CHECK_RET(AdapterDeviceOpen(adapter));
|
||||
CHECK_RET(AdapterDeviceSetUp(adapter));
|
||||
|
@ -373,8 +386,9 @@ int AdapterWifiTest(int argc, char *argv[])
|
|||
PrivTaskDelay(4000);
|
||||
}
|
||||
|
||||
char wifi_recv_msg[128];
|
||||
for(i = 0; i < 10; i ++)
|
||||
char wifi_recv_msg[APT_WIFI_PARAM_LEN];
|
||||
memset(wifi_recv_msg, 0, APT_WIFI_PARAM_LEN);
|
||||
for(i = 0; i < APT_WIFI_PARAM_NUM; i ++)
|
||||
{
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
|
@ -385,6 +399,7 @@ int AdapterWifiTest(int argc, char *argv[])
|
|||
// CHECK_RET(AdapterDevicePing(adapter, wifi_param[APT_WIFI_PARAM_PING]));
|
||||
// AdapterDeviceDisconnect(adapter, NULL);
|
||||
ret = AdapterDeviceClose(adapter);
|
||||
free(adapter->adapter_param);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
|
||||
struct WifiParam
|
||||
{
|
||||
uint8_t wifi_ssid[128];
|
||||
uint8_t wifi_pwd[128];
|
||||
char wifi_ssid[128];
|
||||
char wifi_pwd[128];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -196,39 +196,59 @@ static int Esp07sWifiSetUp(struct Adapter *adapter)
|
|||
return -1;
|
||||
}
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
printf("%s check %d adapter %p wifi %p param %p\n", __func__, __LINE__, adapter, param,
|
||||
adapter->adapter_param);
|
||||
|
||||
/* config as softAP+station mode */
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CWMODE=3\r\n", "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[AT+CWMODE=3] config failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// printf("%s check %d pwd %s\n", __func__, __LINE__, param->wifi_pwd);
|
||||
|
||||
PrivTaskDelay(2000);
|
||||
/* connect the router */
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
strncpy(cmd,"AT+CWJAP=",strlen("AT+CWJAP="));
|
||||
strcpy(cmd,"AT+CWJAP=");//strlen("AT+CWJAP="));
|
||||
strncat(cmd,"\"",1);
|
||||
strncat(cmd,param->wifi_ssid,strlen(param->wifi_ssid));
|
||||
|
||||
// printf("%s check %d len %d\n", __func__, __LINE__, strlen(param->wifi_pwd));
|
||||
|
||||
strncat(cmd,param->wifi_ssid,128);
|
||||
|
||||
strncat(cmd,"\"",1);
|
||||
strncat(cmd,",",1);
|
||||
strncat(cmd,"\"",1);
|
||||
|
||||
// printf("%s check %d len %d\n", __func__, __LINE__, strlen(param->wifi_pwd));
|
||||
|
||||
strncat(cmd,param->wifi_pwd,strlen(param->wifi_pwd));
|
||||
|
||||
strncat(cmd,"\"",1);
|
||||
strcat(cmd,"\r\n");
|
||||
|
||||
printf("%s check %d\n", __func__, __LINE__);
|
||||
|
||||
ret = AtCmdConfigAndCheck(agent, cmd, "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] connect[%s] failed!\n",__func__,__LINE__,cmd,param->wifi_ssid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s check %d\n", __func__, __LINE__);
|
||||
|
||||
/* check the wifi ip address */
|
||||
ATReplyType reply = CreateATReply(256);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s check %d\n", __func__, __LINE__);
|
||||
|
||||
ret = ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+CIFSR\r\n");
|
||||
if(ret < 0){
|
||||
printf("%s %d ATOrderSend AT+CIFSR failed.\n",__func__,__LINE__);
|
||||
|
@ -238,7 +258,7 @@ static int Esp07sWifiSetUp(struct Adapter *adapter)
|
|||
|
||||
result = GetReplyText(reply);
|
||||
if (!result) {
|
||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
||||
printf("%s %d get reply failed.\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
@ -355,7 +375,7 @@ static int Esp07sWifiNetstat(struct Adapter *adapter)
|
|||
|
||||
result = GetReplyText(reply);
|
||||
if (!result) {
|
||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
||||
printf("%s %d get reply failed.\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
|
|
@ -47,14 +47,24 @@ if ADD_XIZI_FETURES
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
if ARCH_BOARD_XIDATONG_ARM32
|
||||
config ADAPTER_E18_MODEPIN
|
||||
int "E18 MODE pin number"
|
||||
default "61"
|
||||
|
||||
config ADAPTER_E18_PIN_DRIVER
|
||||
string "E18 device pin driver path"
|
||||
default "/dev/gpio0"
|
||||
endif
|
||||
if ARCH_BOARD_XIDATONG_ARM32
|
||||
config ADAPTER_E18_MODE_PATH
|
||||
string "E18 MODE pin device"
|
||||
default "/dev/gpio2"
|
||||
|
||||
endif
|
||||
config ADAPTER_E18_DRIVER_EXTUART
|
||||
bool "Using extra uart to support zigbee"
|
||||
default y
|
||||
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/ttyS1"
|
||||
|
|
|
@ -40,10 +40,35 @@ char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/
|
|||
#define E18_AS_HEX_MODE 0
|
||||
#define E18_AS_AT_MODE 1
|
||||
|
||||
|
||||
static int E18HardwareModeGet()
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
||||
pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
pin_stat.pin = ADAPTER_E18_MODEPIN;
|
||||
|
||||
ret = PrivRead(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
|
||||
if(pin_stat.val == GPIO_HIGH) {
|
||||
printf(" E18 as AT mode\n");
|
||||
return E18_AS_AT_MODE;
|
||||
} else {
|
||||
printf(" E18 as HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
#else
|
||||
return E18_AS_HEX_MODE;
|
||||
#endif
|
||||
#else
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
@ -66,7 +91,41 @@ static int E18HardwareModeGet()
|
|||
printf(" E18 as HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static int E18HardwareModeSet(void)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
||||
pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
pin_stat.pin = ADAPTER_E18_MODEPIN;
|
||||
pin_stat.val = GPIO_HIGH;
|
||||
|
||||
// ret = PrivWrite(pin_fd, &pin_stat, 1);
|
||||
|
||||
ioctl(pin_fd, GPIOC_WRITE, (unsigned long)0);
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
ret = PrivRead(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
|
||||
if(pin_stat.val == GPIO_HIGH) {
|
||||
printf(" E18 set AT mode\n");
|
||||
return E18_AS_AT_MODE;
|
||||
} else {
|
||||
printf(" E18 set HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static int E18UartOpen(struct Adapter *adapter)
|
||||
|
@ -186,6 +245,8 @@ static int E18NetRoleConfig(struct Adapter *adapter)
|
|||
int ret = 0;
|
||||
int mode = -1;
|
||||
|
||||
printf("start %s\n", __func__);
|
||||
// E18HardwareModeSet();
|
||||
|
||||
if (NULL == adapter) {
|
||||
printf("%s %d adapter is null!\n",__func__,__LINE__);
|
||||
|
|
|
@ -107,3 +107,6 @@ CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0
|
|||
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0"
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES=0
|
||||
|
||||
CONFIG_USER_TEST=y
|
||||
CONFIG_USER_TEST_LCD=y
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ CONFIG_BOARD_LOOPSPERMSEC=104926
|
|||
CONFIG_BUILTIN=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_ETH0_PHY_LAN8720=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IMXRT_ENET_PHYINIT=y
|
||||
CONFIG_IMXRT_GPIO_IRQ=y
|
||||
CONFIG_IMXRT_GPIO3_0_15_IRQ=y
|
||||
|
@ -72,8 +73,8 @@ CONFIG_READLINE_CMD_HISTORY=y
|
|||
CONFIG_READLINE_CMD_HISTORY_LEN=100
|
||||
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
|
||||
CONFIG_READLINE_TABCOMPLETION=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_NSH_ROMFSETC=y
|
||||
CONFIG_NSH_ARCHROMFS=y
|
||||
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_APPLICATION_CONNECTION=y
|
||||
CONFIG_SOCKET_DEMO=y
|
||||
|
|
|
@ -47,15 +47,17 @@ CONFIG_SYSTEM_NSH=y
|
|||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_READLINE_CMD_HISTORY_LEN=100
|
||||
|
||||
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
|
||||
CONFIG_READLINE_TABCOMPLETION=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_NSH_ROMFSETC=y
|
||||
CONFIG_NSH_ARCHROMFS=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_CONNECTION_FRAMEWORK_DEBUG=y
|
||||
CONFIG_CONNECTION_ADAPTER_WIFI=y
|
||||
CONFIG_ADAPTER_ESP07S_WIFI=y
|
||||
CONFIG_ADAPTER_WIFI_ESP07S="esp07s_wifi"
|
||||
CONFIG_ADAPTER_ESP07S_DRIVER="/dev/ttyS2"
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y
|
||||
|
||||
|
|
|
@ -62,4 +62,7 @@ CONFIG_K210_HAVE_LCD=y
|
|||
CONFIG_K210_LCD=y
|
||||
CONFIG_K210_LCD_BACKLIGHT=y
|
||||
CONFIG_LCD=y
|
||||
CONFIG_LCD_LT768=y
|
||||
CONFIG_LCD_LT768=y
|
||||
|
||||
CONFIG_USER_TEST=y
|
||||
CONFIG_USER_TEST_LCD=y
|
||||
|
|
|
@ -1454,7 +1454,7 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
|
|||
int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_K210_LCD) && !defined(CONFIG_NSH_DISABLE_LCD)
|
||||
#if defined(CONFIG_USER_TEST_LCD) && !defined(CONFIG_NSH_DISABLE_USER_TEST_LCD)
|
||||
int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
|
@ -1462,6 +1462,13 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
|
|||
int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOCKET_DEMO) && !defined(CONFIG_NSH_DISABLE_SOCKET_DEMO)
|
||||
int cmd_Udpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
int cmd_Udprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
int cmd_Tcpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
int cmd_Tcprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
|
||||
int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
|
|
@ -54,7 +54,7 @@ int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||
/****************************************************************************
|
||||
* Name: cmd_lcd
|
||||
****************************************************************************/
|
||||
#if defined(CONFIG_K210_LCD) && !defined(CONFIG_NSH_DISABLE_LCD)
|
||||
#if defined(CONFIG_USER_TEST_LCD) && !defined(CONFIG_NSH_DISABLE_USER_TEST_LCD)
|
||||
extern void LcdDemo(void);
|
||||
int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
|
@ -68,11 +68,48 @@ int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||
* Name: cmd_Extsram
|
||||
****************************************************************************/
|
||||
#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC)
|
||||
extern int extsram_test(void);
|
||||
extern int ExtsramTest(void);
|
||||
int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, extra sdram!\n");
|
||||
extsram_test();
|
||||
ExtsramTest();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: socket test
|
||||
****************************************************************************/
|
||||
#if defined(CONFIG_SOCKET_DEMO) && !defined(CONFIG_NSH_DISABLE_SOCKET_DEMO)
|
||||
void UdpSocketRecvTest(int argc, char *argv[]);
|
||||
int cmd_Udprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, UDP receive!\n");
|
||||
UdpSocketRecvTest(argc, argv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UdpSocketSendTest(int argc, char *argv[]);
|
||||
int cmd_Udpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, UDP send!\n");
|
||||
UdpSocketSendTest(argc, argv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TcpSocketRecvTest(int argc, char *argv[]);
|
||||
int cmd_Tcprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, TCP receive!\n");
|
||||
TcpSocketRecvTest(argc, argv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TcpSocketSendTest(int argc, char *argv[]);
|
||||
int cmd_Tcpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, TCP send!\n");
|
||||
TcpSocketSendTest(argc, argv);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
@ -293,46 +330,46 @@ int cmd_WindSpeedQsFs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_CONNECTION_ADAPTER_ZIGBEE) && !defined(CONFIG_NSH_DISABLE_OPENZIGBEE)
|
||||
extern int openzigbee(void);
|
||||
extern int OpenZigbee(void);
|
||||
int cmd_openzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, world!\n");
|
||||
FrameworkInit();
|
||||
openzigbee();
|
||||
OpenZigbee();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(CONFIG_CONNECTION_ADAPTER_ZIGBEE) && !defined(CONFIG_NSH_DISABLE_SENDZIGBEE)
|
||||
extern int sendzigbee(int argc, char *argv[]);
|
||||
extern int SendZigbee(int argc, char *argv[]);
|
||||
int cmd_sendzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, world!\n");
|
||||
FrameworkInit();
|
||||
sendzigbee(argc,argv);
|
||||
SendZigbee(argc,argv);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CONNECTION_ADAPTER_ZIGBEE) && !defined(CONFIG_NSH_DISABLE_RECVZIGBEE)
|
||||
extern int recvzigbee(void);
|
||||
extern int RecvZigbee(void);
|
||||
int cmd_recvzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, world!\n");
|
||||
FrameworkInit();
|
||||
recvzigbee();
|
||||
RecvZigbee();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ADAPTER_ESP07S_WIFI) && !defined(CONFIG_NSH_DISABLE_ADAPTER_WIFI_TEST)
|
||||
extern int AdapterWifiTest(int argc, char *argv[]);
|
||||
extern int AdapterWifiTestWithParam(int argc, char *argv[]);
|
||||
int cmd_AdapterWifiTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, world!\n");
|
||||
FrameworkInit();
|
||||
AdapterWifiTest(argc, argv);
|
||||
AdapterWifiTestWithParam(argc, argv);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -600,14 +600,21 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||
{ "ch438", cmd_Ch438, 1, 1, "[ch438 demo cmd.]" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_K210_LCD) && !defined(CONFIG_NSH_DISABLE_LCD)
|
||||
{ "lcd", cmd_Lcd, 1, 1, "[LCD demo cmd.]" },
|
||||
#if defined(CONFIG_USER_TEST_LCD) && !defined(CONFIG_NSH_DISABLE_USER_TEST_LCD)
|
||||
{ "lcd", cmd_Lcd, 1, 1, "[LCD demo cmd.]" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC)
|
||||
{ "sram", cmd_Extsram, 1, 1, "[Extra sdram demo cmd.]" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOCKET_DEMO) && !defined(CONFIG_NSH_DISABLE_SOCKET_DEMO)
|
||||
{ "udpsend", cmd_Udpsend, 1, 2, "[Udp send demo cmd.]" },
|
||||
{ "udprecv", cmd_Udprecv, 1, 2, "[Udp recv demo cmd.]" },
|
||||
{ "tcpsend", cmd_Tcpsend, 1, 2, "[Tcp send demo cmd.]" },
|
||||
{ "tcprecv", cmd_Tcprecv, 1, 2, "[Tcp recv demo cmd.]" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
|
||||
{ "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" },
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue