diff options
| author | liukangcc <[email protected]> | 2021-09-17 15:03:14 +0800 |
|---|---|---|
| committer | liukangcc <[email protected]> | 2021-09-17 15:03:14 +0800 |
| commit | 4b3df6010f7870aebcd1df20bbaabd5fe9212c6d (patch) | |
| tree | 95b0e12447425f803be46d16eaf6e7188c364fec /components/net | |
| parent | f07507a91310bc5696a08f5bbf6ab8679cfbcf73 (diff) | |
| parent | ef71de34f76d4403fcd2cddd21a17f3a53a40296 (diff) | |
Merge remote-tracking branch 'remotes/rtt_github/master'
Diffstat (limited to 'components/net')
23 files changed, 55 insertions, 41 deletions
diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 8215dd4417..96ea053f9c 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -19,7 +19,7 @@ #include <at_device.h> #ifdef SAL_USING_POSIX -#include <dfs_poll.h> +#include <poll.h> #endif #include <arpa/inet.h> diff --git a/components/net/at/include/at.h b/components/net/at/include/at.h index 0e93720ff0..0a385058a0 100644 --- a/components/net/at/include/at.h +++ b/components/net/at/include/at.h @@ -12,6 +12,7 @@ #ifndef __AT_H__ #define __AT_H__ +#include <stddef.h> #include <rtthread.h> #ifdef __cplusplus diff --git a/components/net/at/src/at_cli.c b/components/net/at/src/at_cli.c index 25fbb708f4..c589bb68a0 100644 --- a/components/net/at/src/at_cli.c +++ b/components/net/at/src/at_cli.c @@ -11,7 +11,7 @@ #include <at.h> #include <stdio.h> #include <string.h> - +#include <stdint.h> #include <rtthread.h> #include <rtdevice.h> #include <rthw.h> diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index 948020f4cf..845d8c0fa6 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -310,7 +310,6 @@ int at_obj_exec_cmd(at_client_t client, at_response_t resp, const char *cmd_expr rt_mutex_take(client->lock, RT_WAITING_FOREVER); client->resp_status = AT_RESP_OK; - client->resp = resp; if (resp != RT_NULL) { @@ -318,6 +317,9 @@ int at_obj_exec_cmd(at_client_t client, at_response_t resp, const char *cmd_expr resp->line_counts = 0; } + client->resp = resp; + rt_sem_control(client->resp_notice, RT_IPC_CMD_RESET, RT_NULL); + va_start(args, cmd_expr); at_vprintfln(client->device, cmd_expr, args); va_end(args); @@ -327,7 +329,7 @@ int at_obj_exec_cmd(at_client_t client, at_response_t resp, const char *cmd_expr if (rt_sem_take(client->resp_notice, resp->timeout) != RT_EOK) { cmd = at_get_last_cmd(&cmd_size); - LOG_D("execute command (%.*s) timeout (%d ticks)!", cmd_size, cmd, resp->timeout); + LOG_W("execute command (%.*s) timeout (%d ticks)!", cmd_size, cmd, resp->timeout); client->resp_status = AT_RESP_TIMEOUT; result = -RT_ETIMEOUT; goto __exit; @@ -381,6 +383,7 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout) rt_mutex_take(client->lock, RT_WAITING_FOREVER); client->resp = resp; + rt_sem_control(client->resp_notice, RT_IPC_CMD_RESET, RT_NULL); start_time = rt_tick_get(); @@ -426,6 +429,8 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout) */ rt_size_t at_client_obj_send(at_client_t client, const char *buf, rt_size_t size) { + rt_size_t len; + RT_ASSERT(buf); if (client == RT_NULL) @@ -440,7 +445,7 @@ rt_size_t at_client_obj_send(at_client_t client, const char *buf, rt_size_t size rt_mutex_take(client->lock, RT_WAITING_FOREVER); - rt_size_t len = at_utils_send(client->device, 0, buf, size); + len = at_utils_send(client->device, 0, buf, size); rt_mutex_release(client->lock); @@ -480,9 +485,7 @@ static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeo */ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size, rt_int32_t timeout) { - rt_size_t read_idx = 0; - rt_err_t result = RT_EOK; - char ch; + rt_size_t len = 0; RT_ASSERT(buf); @@ -494,28 +497,30 @@ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size, rt_i while (1) { - if (read_idx < size) + rt_size_t read_len; + + rt_sem_control(client->rx_notice, RT_IPC_CMD_RESET, RT_NULL); + + read_len = rt_device_read(client->device, 0, buf + len, size); + if(read_len > 0) { - result = at_client_getchar(client, &ch, timeout); - if (result != RT_EOK) - { - LOG_E("AT Client receive failed, uart device get data error(%d)", result); - return 0; - } + len += read_len; + size -= read_len; + if(size == 0) + break; - buf[read_idx++] = ch; + continue; } - else - { + + if(rt_sem_take(client->rx_notice, rt_tick_from_millisecond(timeout)) != RT_EOK) break; - } } #ifdef AT_PRINT_RAW_CMD - at_print_raw_cmd("urc_recv", buf, size); + at_print_raw_cmd("urc_recv", buf, len); #endif - return read_idx; + return len; } /** diff --git a/components/net/lwip-1.4.1/src/apps/ping/ping.c b/components/net/lwip-1.4.1/src/apps/ping/ping.c index 6d3cfe0fc3..6251504f59 100644 --- a/components/net/lwip-1.4.1/src/apps/ping/ping.c +++ b/components/net/lwip-1.4.1/src/apps/ping/ping.c @@ -236,7 +236,7 @@ int cmd_ping(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(cmd_ping, __cmd_ping, ping network host); +MSH_CMD_EXPORT_ALIAS(cmd_ping, ping, ping network host); #endif /* RT_USING_FINSH */ #endif /* RT_USING_NETDEV */ diff --git a/components/net/lwip-1.4.1/src/lwipopts.h b/components/net/lwip-1.4.1/src/lwipopts.h index 9148066d50..a5e035b53a 100644 --- a/components/net/lwip-1.4.1/src/lwipopts.h +++ b/components/net/lwip-1.4.1/src/lwipopts.h @@ -533,6 +533,7 @@ #ifndef LWIP_SOCKET #define LWIP_SOCKET 1 #endif +#include <fcntl.h> /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.0.2/src/apps/ping/ping.c b/components/net/lwip-2.0.2/src/apps/ping/ping.c index 6d3cfe0fc3..6251504f59 100644 --- a/components/net/lwip-2.0.2/src/apps/ping/ping.c +++ b/components/net/lwip-2.0.2/src/apps/ping/ping.c @@ -236,7 +236,7 @@ int cmd_ping(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(cmd_ping, __cmd_ping, ping network host); +MSH_CMD_EXPORT_ALIAS(cmd_ping, ping, ping network host); #endif /* RT_USING_FINSH */ #endif /* RT_USING_NETDEV */ diff --git a/components/net/lwip-2.0.2/src/lwipopts.h b/components/net/lwip-2.0.2/src/lwipopts.h index fdfe1437b2..fe6e2fef6f 100644 --- a/components/net/lwip-2.0.2/src/lwipopts.h +++ b/components/net/lwip-2.0.2/src/lwipopts.h @@ -572,6 +572,7 @@ #ifndef LWIP_SOCKET #define LWIP_SOCKET 1 #endif +#include <fcntl.h> /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.0.3/src/apps/ping/ping.c b/components/net/lwip-2.0.3/src/apps/ping/ping.c index 6d3cfe0fc3..6251504f59 100644 --- a/components/net/lwip-2.0.3/src/apps/ping/ping.c +++ b/components/net/lwip-2.0.3/src/apps/ping/ping.c @@ -236,7 +236,7 @@ int cmd_ping(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(cmd_ping, __cmd_ping, ping network host); +MSH_CMD_EXPORT_ALIAS(cmd_ping, ping, ping network host); #endif /* RT_USING_FINSH */ #endif /* RT_USING_NETDEV */ diff --git a/components/net/lwip-2.0.3/src/lwipopts.h b/components/net/lwip-2.0.3/src/lwipopts.h index fdfe1437b2..fe6e2fef6f 100644 --- a/components/net/lwip-2.0.3/src/lwipopts.h +++ b/components/net/lwip-2.0.3/src/lwipopts.h @@ -572,6 +572,7 @@ #ifndef LWIP_SOCKET #define LWIP_SOCKET 1 #endif +#include <fcntl.h> /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.1.2/src/apps/ping/ping.c b/components/net/lwip-2.1.2/src/apps/ping/ping.c index 6d3cfe0fc3..6251504f59 100644 --- a/components/net/lwip-2.1.2/src/apps/ping/ping.c +++ b/components/net/lwip-2.1.2/src/apps/ping/ping.c @@ -236,7 +236,7 @@ int cmd_ping(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(cmd_ping, __cmd_ping, ping network host); +MSH_CMD_EXPORT_ALIAS(cmd_ping, ping, ping network host); #endif /* RT_USING_FINSH */ #endif /* RT_USING_NETDEV */ diff --git a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h index 1459e3241d..6d5044b1b7 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h +++ b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h @@ -22,7 +22,6 @@ struct eth_device /* network interface for lwip */ struct netif *netif; - struct rt_semaphore tx_ack; rt_uint16_t flags; rt_uint8_t link_changed; diff --git a/components/net/lwip-2.1.2/src/lwipopts.h b/components/net/lwip-2.1.2/src/lwipopts.h index a964ab13ac..81409a9d0a 100644 --- a/components/net/lwip-2.1.2/src/lwipopts.h +++ b/components/net/lwip-2.1.2/src/lwipopts.h @@ -579,6 +579,7 @@ #ifndef LWIP_SOCKET #define LWIP_SOCKET 1 #endif +#include <fcntl.h> /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.1.2/src/netif/ethernetif.c b/components/net/lwip-2.1.2/src/netif/ethernetif.c index bd4db225ee..e9c2a20a15 100644 --- a/components/net/lwip-2.1.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.2/src/netif/ethernetif.c @@ -39,6 +39,7 @@ * 2013-02-28 aozima fixed list_tcps bug: ipaddr_ntoa isn't reentrant. * 2016-08-18 Bernard port to lwIP 2.0.0 * 2018-11-02 MurphyZhao port to lwIP 2.1.0 + * 2021-09-07 Grissiom fix eth_tx_msg ack bug */ #include "lwip/opt.h" @@ -58,6 +59,8 @@ #include "lwip/inet.h" +#include <ipc/completion.h> + #if LWIP_IPV6 #include "lwip/ethip6.h" #endif /* LWIP_IPV6 */ @@ -79,6 +82,7 @@ struct eth_tx_msg { struct netif *netif; struct pbuf *buf; + struct rt_completion ack; }; static struct rt_mailbox eth_tx_thread_mb; @@ -387,18 +391,17 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p) { #ifndef LWIP_NO_TX_THREAD struct eth_tx_msg msg; - struct eth_device* enetif; RT_ASSERT(netif != RT_NULL); - enetif = (struct eth_device*)netif->state; /* send a message to eth tx thread */ msg.netif = netif; msg.buf = p; + rt_completion_init(&msg.ack); if (rt_mb_send(ð_tx_thread_mb, (rt_uint32_t) &msg) == RT_EOK) { /* waiting for ack */ - rt_sem_take(&(enetif->tx_ack), RT_WAITING_FOREVER); + rt_completion_wait(&msg.ack, RT_WAITING_FOREVER); } #else struct eth_device* enetif; @@ -519,7 +522,6 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ dev->parent.type = RT_Device_Class_NetIf; /* register to RT-Thread device manager */ rt_device_register(&(dev->parent), name, RT_DEVICE_FLAG_RDWR); - rt_sem_init(&(dev->tx_ack), name, 0, RT_IPC_FLAG_FIFO); /* set name */ netif->name[0] = name[0]; @@ -595,7 +597,6 @@ void eth_device_deinit(struct eth_device *dev) #endif rt_device_close(&(dev->parent)); rt_device_unregister(&(dev->parent)); - rt_sem_detach(&(dev->tx_ack)); rt_free(netif); } @@ -673,7 +674,7 @@ static void eth_tx_thread_entry(void* parameter) } /* send ACK */ - rt_sem_release(&(enetif->tx_ack)); + rt_completion_done(&msg->ack); } } } diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index f722909cc8..4c5d524510 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -10,6 +10,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <rtthread.h> #include <rthw.h> @@ -1047,7 +1048,7 @@ int netdev_ifconfig(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(netdev_ifconfig, __cmd_ifconfig, list the information of all network interfaces); +MSH_CMD_EXPORT_ALIAS(netdev_ifconfig, ifconfig, list the information of all network interfaces); #endif /* NETDEV_USING_IFCONFIG */ #ifdef NETDEV_USING_PING @@ -1152,7 +1153,7 @@ int netdev_ping(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(netdev_ping, __cmd_ping, ping network host); +MSH_CMD_EXPORT_ALIAS(netdev_ping, ping, ping network host); #endif /* NETDEV_USING_IFCONFIG */ static void netdev_list_dns(void) @@ -1222,8 +1223,7 @@ int netdev_dns(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(netdev_dns, __cmd_dns, list and set the information of dns); - +MSH_CMD_EXPORT_ALIAS(netdev_dns, dns, list and set the information of dns); #ifdef NETDEV_USING_NETSTAT static void netdev_cmd_netstat(void) { @@ -1270,7 +1270,7 @@ int netdev_netstat(int argc, char **argv) return 0; } -FINSH_FUNCTION_EXPORT_ALIAS(netdev_netstat, __cmd_netstat, list the information of TCP / IP); +MSH_CMD_EXPORT_ALIAS(netdev_netstat, netstat, list the information of TCP / IP); #endif /* NETDEV_USING_NETSTAT */ #endif /* RT_USING_FINSH */ diff --git a/components/net/netdev/src/netdev_ipaddr.c b/components/net/netdev/src/netdev_ipaddr.c index 9abb41bd14..afb6d1d962 100644 --- a/components/net/netdev/src/netdev_ipaddr.c +++ b/components/net/netdev/src/netdev_ipaddr.c @@ -7,7 +7,7 @@ * Date Author Notes * 2018-05-18 ChenYong First version */ - +#include <stdlib.h> #include <rtthread.h> #include <netdev_ipaddr.h> diff --git a/components/net/sal_socket/impl/af_inet_at.c b/components/net/sal_socket/impl/af_inet_at.c index c85dfe9f06..07dff0018c 100644 --- a/components/net/sal_socket/impl/af_inet_at.c +++ b/components/net/sal_socket/impl/af_inet_at.c @@ -19,7 +19,7 @@ #include <netdev.h> #ifdef SAL_USING_POSIX -#include <dfs_poll.h> +#include <poll.h> #endif #ifdef SAL_USING_AT diff --git a/components/net/sal_socket/impl/af_inet_lwip.c b/components/net/sal_socket/impl/af_inet_lwip.c index 2e19275b5d..2cf0958ee4 100644 --- a/components/net/sal_socket/impl/af_inet_lwip.c +++ b/components/net/sal_socket/impl/af_inet_lwip.c @@ -17,7 +17,7 @@ #include <lwip/netif.h> #ifdef SAL_USING_POSIX -#include <dfs_poll.h> +#include <poll.h> #endif #include <sal.h> diff --git a/components/net/sal_socket/include/sal_netdb.h b/components/net/sal_socket/include/sal_netdb.h index 50064ce343..9b1421270f 100644 --- a/components/net/sal_socket/include/sal_netdb.h +++ b/components/net/sal_socket/include/sal_netdb.h @@ -10,6 +10,7 @@ #ifndef SAL_NETDB_H__ #define SAL_NETDB_H__ +#include <stddef.h> #include "sal_socket.h" #ifdef __cplusplus diff --git a/components/net/sal_socket/include/sal_socket.h b/components/net/sal_socket/include/sal_socket.h index 497be47e41..c479d21c62 100644 --- a/components/net/sal_socket/include/sal_socket.h +++ b/components/net/sal_socket/include/sal_socket.h @@ -11,6 +11,7 @@ #ifndef SAL_SOCKET_H__ #define SAL_SOCKET_H__ +#include <stddef.h> #include <arpa/inet.h> #ifdef __cplusplus diff --git a/components/net/sal_socket/include/socket/netdb.h b/components/net/sal_socket/include/socket/netdb.h index 9d54953681..8394fddea5 100644 --- a/components/net/sal_socket/include/socket/netdb.h +++ b/components/net/sal_socket/include/socket/netdb.h @@ -16,6 +16,7 @@ extern "C" { #endif +#include <stddef.h> #include <sal_netdb.h> struct hostent *gethostbyname(const char *name); diff --git a/components/net/sal_socket/socket/net_netdb.c b/components/net/sal_socket/socket/net_netdb.c index 03b995c68d..1eb84e1c32 100644 --- a/components/net/sal_socket/socket/net_netdb.c +++ b/components/net/sal_socket/socket/net_netdb.c @@ -9,6 +9,7 @@ * 2108-05-24 ChenYong Add socket abstraction layer */ +#include <stddef.h> #include <rtthread.h> #include <netdb.h> diff --git a/components/net/sal_socket/socket/net_sockets.c b/components/net/sal_socket/socket/net_sockets.c index 7d4db34327..1b6db50e6d 100644 --- a/components/net/sal_socket/socket/net_sockets.c +++ b/components/net/sal_socket/socket/net_sockets.c @@ -11,7 +11,7 @@ #include <dfs.h> #include <dfs_file.h> -#include <dfs_poll.h> +#include <poll.h> #include <dfs_net.h> #include <sys/errno.h> #include <sys/socket.h> |
