examples/udp: Fixe registration as a built-in program; Change some naming to make room for a second target. Current one endpoint is the target and one is the host. This will (eventually) allow two targets to be both endpoints of the test.
This commit is contained in:
parent
a73060ae64
commit
bb95584aed
@ -12,9 +12,28 @@ config EXAMPLES_UDP
|
||||
|
||||
if EXAMPLES_UDP
|
||||
|
||||
config EXAMPLES_UDP_SERVER
|
||||
bool "Target is the server"
|
||||
config EXAMPLES_UDP_SERVER1
|
||||
bool "Target1 is the server"
|
||||
default n
|
||||
---help---
|
||||
By default Target1 is the client and the host PC is the server
|
||||
|
||||
config EXAMPLES_UDP_PROGNAME1
|
||||
string "Target1 program name"
|
||||
default "udpserver" if EXAMPLES_UDP_SERVER1
|
||||
default "udpclient" if !EXAMPLES_UDP_SERVER1
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the name of the Target1 program that will be use when the
|
||||
NSH ELF program is installed.
|
||||
|
||||
config EXAMPLES_UDP_PRIORITY1
|
||||
int "Target1 task priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_UDP_STACKSIZE1
|
||||
int "Target1 stack size"
|
||||
default 2048
|
||||
|
||||
config EXAMPLES_UDP_DEVNAME
|
||||
string "Network device"
|
||||
@ -55,7 +74,7 @@ if EXAMPLES_UDP_IPv4
|
||||
|
||||
comment "IPv4 addresses"
|
||||
|
||||
if !EXAMPLES_UDP_NETINIT
|
||||
if EXAMPLES_UDP_NETINIT
|
||||
|
||||
config EXAMPLES_UDP_IPADDR
|
||||
hex "Target IP address"
|
||||
@ -73,8 +92,8 @@ endif # !EXAMPLES_UDP_NETINIT
|
||||
|
||||
config EXAMPLES_UDP_SERVERIP
|
||||
hex "Server IP address"
|
||||
default 0x0a000001 if !EXAMPLES_UDP_SERVER
|
||||
default 0x0a000002 if EXAMPLES_UDP_SERVER
|
||||
default 0x0a000001 if !EXAMPLES_UDP_SERVER1
|
||||
default 0x0a000002 if EXAMPLES_UDP_SERVER1
|
||||
|
||||
endif # EXAMPLES_UDP_IPv4
|
||||
|
||||
@ -445,8 +464,8 @@ config EXAMPLES_UDP_SERVERIPv6ADDR_7
|
||||
|
||||
config EXAMPLES_UDP_SERVERIPv6ADDR_8
|
||||
hex "[7]"
|
||||
default 0x0001 if !EXAMPLES_UDP_SERVER
|
||||
default 0x0002 if EXAMPLES_UDP_SERVER
|
||||
default 0x0001 if !EXAMPLES_UDP_SERVER1
|
||||
default 0x0002 if EXAMPLES_UDP_SERVER1
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the server. If the target is the server, then
|
||||
|
@ -42,7 +42,7 @@ include $(APPDIR)/Make.defs
|
||||
TARG_ASRCS =
|
||||
|
||||
TARG_CSRCS =
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER),y)
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y)
|
||||
TARG_CSRCS += udp_server.c
|
||||
else
|
||||
TARG_CSRCS += udp_client.c
|
||||
@ -51,7 +51,7 @@ ifeq ($(CONFIG_EXAMPLES_UDP_NETINIT),y)
|
||||
TARG_CSRCS += target_netinit.c
|
||||
endif
|
||||
|
||||
TARG_MAINSRC = target.c
|
||||
TARG_MAINSRC = target1.c
|
||||
|
||||
TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT))
|
||||
TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT))
|
||||
@ -77,7 +77,7 @@ endif
|
||||
HOSTCFLAGS += -DEXAMPLES_UDP_HOST=1
|
||||
|
||||
HOST_SRCS = host.c
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER),y)
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y)
|
||||
HOST_SRCS += udp_client.c
|
||||
else
|
||||
HOST_SRCS += udp_server.c
|
||||
@ -92,8 +92,25 @@ else
|
||||
INSTALL_DIR = $(BIN_DIR)
|
||||
endif
|
||||
|
||||
CONFIG_XYZ_PROGNAME ?= udp$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_XYZ_PROGNAME)
|
||||
ifeq ($(EXAMPLES_UDP_SERVER1),y)
|
||||
CONFIG_EXAMPLES_UDP_PROGNAME1 ?= udpserver$(EXEEXT)
|
||||
APPNAME1 = udpserver
|
||||
else
|
||||
CONFIG_EXAMPLES_UDP_PROGNAME1 ?= udpclient$(EXEEXT)
|
||||
APPNAME1 = udpclient
|
||||
endif
|
||||
CONFIG_EXAMPLES_UDP_PRIORITY1 ?= 100
|
||||
CONFIG_EXAMPLES_UDP_STACKSIZE1 ?= 2048
|
||||
|
||||
PROGNAME1 = $(CONFIG_EXAMPLES_UDP_PROGNAME1)
|
||||
PRIORITY1 = $(CONFIG_EXAMPLES_UDP_PRIORITY1)
|
||||
STACKSIZE1 = $(CONFIG_EXAMPLES_UDP_STACKSIZE1)
|
||||
|
||||
ifeq ($(EXAMPLES_UDP_TARGET2),y)
|
||||
MAINNAME1 = udp1_main
|
||||
else
|
||||
MAINNAME1 = udp_main
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
@ -128,19 +145,26 @@ $(HOST_BIN): config.h $(HOST_OBJS)
|
||||
$(Q) touch .built
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ)
|
||||
@echo "LD: $(PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(TARG_MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME1): $(OBJS) $(TARG_MAINOBJ)
|
||||
@echo "LD: $(PROGNAME1)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME1) $(ARCHCRT0OBJ) $(TARG_MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME1)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME1)
|
||||
|
||||
else
|
||||
install:
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(MAINNAME1))
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile config.h $(TARG_SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER1
|
||||
send_client();
|
||||
#else
|
||||
recv_server();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/target.c
|
||||
* examples/udp/target1.c
|
||||
*
|
||||
* Copyright (C) 2007, 2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -45,11 +45,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* udp_main
|
||||
* udp1_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
#if defined(CONFIG_BUILD_KERNEL)
|
||||
int main(int argc, FAR char *argv[])
|
||||
#elif defined(CONFIG_EXAMPLES_UDP_TARGET2)
|
||||
int udp1_main(int argc, char *argv[])
|
||||
#else
|
||||
int udp_main(int argc, char *argv[])
|
||||
#endif
|
||||
@ -62,7 +64,7 @@ int udp_main(int argc, char *argv[])
|
||||
|
||||
/* Run the server or client, depending upon how we are configured */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER1
|
||||
recv_server();
|
||||
#else
|
||||
send_client();
|
Loading…
Reference in New Issue
Block a user