changed demo task name with hump style

This commit is contained in:
wlyu
2022-02-15 16:12:49 +08:00
parent 338f4ad41a
commit a101e994ff
10 changed files with 65 additions and 98 deletions
@@ -40,7 +40,6 @@
#include <transform.h>
#include <sys_arch.h>
#include "connect_ethernet.h"
#include "lwip_demo.h"
/*******************************************************************************
* Definitions
@@ -58,12 +57,12 @@
* Code
******************************************************************************/
static void *lwip_config_test(void *param)
static void *LwipSetIPTask(void *param)
{
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
}
void lwip_setip_thread(int argc, char *argv[])
void LwipSetIPTest(int argc, char *argv[])
{
int result = 0;
pthread_t th_id;
@@ -85,19 +84,19 @@ void lwip_setip_thread(int argc, char *argv[])
sscanf(argv[1], "%d.%d.%d.%d", &lwip_ipaddr[0], &lwip_ipaddr[1], &lwip_ipaddr[2], &lwip_ipaddr[3]);
}
result = pthread_create(&th_id, &attr, lwip_config_test, NULL);
result = pthread_create(&th_id, &attr, LwipSetIPTask, NULL);
if (0 == result) {
lw_print("lwip_config_test %d successfully!\n", th_id);
lw_print("lw: [%s] thread %d successfully!\n", __func__, th_id);
} else {
lw_print("lwip_config_test failed! error code is %d\n", result);
lw_print("lw: [%s] failed! error code is %d\n", __func__, result);
}
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
setip, lwip_setip_thread, SetIp [IP] [Netmask] [Gateway]);
setip, LwipSetIPTest, SetIp [IP] [Netmask] [Gateway]);
void lwip_showip_thread(int argc, char *argv[])
void LwipShowIPTask(int argc, char *argv[])
{
char mac_addr[] = configMAC_ADDR;
@@ -116,6 +115,6 @@ void lwip_showip_thread(int argc, char *argv[])
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
showip, lwip_showip_thread, GetIp [IP] [Netmask] [Gateway]);
showip, LwipShowIPTask, GetIp [IP] [Netmask] [Gateway]);
#endif
@@ -1,27 +0,0 @@
/*
* Copyright (c) 2021 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 lwip_demo.h
* @brief lwip demo header
* @version 1.0
* @author AIIT XUOS Lab
* @date 2022.1.18
*/
#ifndef __LWIP_DEMO_H__
#define __LWIP_DEMO_H__
#define LWIP_TEST_STACK_SIZE 4096
#define LWIP_TEST_TASK_PRIO 20
#endif /* __LWIP_DEMO_H__ */
@@ -62,7 +62,7 @@
*
* @param netif network interface structure
*/
int print_dhcp_state(struct netif *netif)
int LwipPrintDHCP(struct netif *netif)
{
static u8_t dhcp_last_state = DHCP_STATE_OFF;
struct dhcp *dhcp = netif_dhcp_data(netif);
@@ -132,7 +132,7 @@ int print_dhcp_state(struct netif *netif)
/*!
* @brief Main function.
*/
void lwip_dhcp_test(void)
void LwipDHCPTest(void)
{
u32_t dhcp_time;
static int flag = 0;
@@ -158,7 +158,7 @@ void lwip_dhcp_test(void)
sys_check_timeouts();
/* Print DHCP progress */
if(print_dhcp_state(&gnetif))
if(LwipPrintDHCP(&gnetif))
{
sscanf(ipaddr_ntoa(&gnetif.ip_addr), "%d.%d.%d.%d", &lwip_ipaddr[0], &lwip_ipaddr[1],
&lwip_ipaddr[2], &lwip_ipaddr[3]);
@@ -178,6 +178,6 @@ void lwip_dhcp_test(void)
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
getdynip, lwip_dhcp_test, DHCP_Test);
getdynip, LwipDHCPTest, DHCP_Test);
#endif
@@ -60,7 +60,7 @@ ip4_addr_t ping_addr;
* Code
******************************************************************************/
void lwip_ping_thread(int argc, char *argv[])
void LwipPingTest(int argc, char *argv[])
{
int result = 0;
@@ -99,6 +99,6 @@ void lwip_ping_thread(int argc, char *argv[])
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
ping, lwip_ping_thread, ping [IP] 3 times);
ping, LwipPingTest, ping [IP] 3 times);
#endif
@@ -46,9 +46,9 @@ char tcp_target[] = {192, 168, 250, 252};
* Code
******************************************************************************/
static void lwip_tcp_send_thread(void *arg)
static void LwipTcpSendTask(void *arg)
{
lw_print("lwip_tcp_send_thread start.\n");
lw_print("LwipTcpSendTask start.\n");
int fd = -1;
fd = socket(AF_INET, SOCK_STREAM, 0);
@@ -84,7 +84,7 @@ __exit:
return;
}
void lwip_tcp_send_run(int argc, char *argv[])
void LwipTcpSendTest(int argc, char *argv[])
{
memset(tcp_send_msg, 0, MSG_SIZE);
if(argc >= 2)
@@ -103,18 +103,18 @@ void lwip_tcp_send_run(int argc, char *argv[])
}
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
sys_thread_new("tcp send", lwip_tcp_send_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
sys_thread_new("tcp send", LwipTcpSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
TCPSend, lwip_tcp_send_run, TCP Send message);
TCPSend, LwipTcpSendTest, TCP Send message);
void lwip_tcp_recv_run(void)
void LwipTcpRecvTest(void)
{
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
tcpecho_raw_init();
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
TCPRecv, lwip_tcp_recv_run, TCP Recv message);
TCPRecv, LwipTcpRecvTest, TCP Recv message);
@@ -50,7 +50,7 @@ char udp_send_msg[] = "\n\nThis one is UDP pkg. Congratulations on you.\n\n";
* Code
******************************************************************************/
static void lwip_udp_send(void *arg)
static void LwipUDPSendTask(void *arg)
{
int cnt = LWIP_DEMO_TIMES;
@@ -91,7 +91,7 @@ __exit:
return;
}
void *lwip_udp_send_run(int argc, char *argv[])
void *LwipUdpSendTest(int argc, char *argv[])
{
int result = 0;
sys_thread_t th_id;
@@ -115,13 +115,13 @@ void *lwip_udp_send_run(int argc, char *argv[])
lw_print("lw: [%s] gw %d.%d.%d.%d\n", __func__, udp_target[0], udp_target[1], udp_target[2], udp_target[3]);
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
sys_thread_new("udp socket send", lwip_udp_send, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
sys_thread_new("udp socket send", LwipUDPSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
UDPSend, lwip_udp_send_run, UDP send echo);
UDPSend, LwipUdpSendTest, UDP send echo);
static void udpecho_raw_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
static void LwipUdpRecvTask(void *arg, struct udp_pcb *upcb, struct pbuf *p,
const ip_addr_t *addr, u16_t port)
{
int udp_len;
@@ -156,10 +156,11 @@ static void udpecho_raw_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
pbuf_free(udp_buf);
}
void udpecho_raw_init(void)
void LwipUdpRecvTest(void)
{
err_t err;
lw_print("udpecho_raw_init\r\n");
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
udpecho_raw_pcb = udp_new_ip_type(IPADDR_TYPE_ANY);
if (udpecho_raw_pcb == NULL)
@@ -170,16 +171,10 @@ void udpecho_raw_init(void)
err = udp_bind(udpecho_raw_pcb, IP_ANY_TYPE, LWIP_LOCAL_PORT);
if (err == ERR_OK)
{
udp_recv(udpecho_raw_pcb, udpecho_raw_recv, NULL);
udp_recv(udpecho_raw_pcb, LwipUdpRecvTask, NULL);
}
}
void lwip_udp_server(void)
{
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
udpecho_raw_init();
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
UDPRecv, lwip_udp_server, UDP server echo);
UDPRecv, LwipUdpRecvTest, UDP server echo);