summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorArda <[email protected]>2014-11-24 11:57:31 +0800
committerArda <[email protected]>2014-11-24 11:57:31 +0800
commit143d3b82244b977735649e7d7c201d2affe67460 (patch)
tree61503d3a150cef8d8184c858efc139b146b50cf6 /examples
parentbc2a890ab08d163ccea323f7e719c4fdf53050cd (diff)
parent9ecd18411fc1344e3d080d844b60c7070c3fb4d8 (diff)
Merge pull request #2 from RT-Thread/master
update from official source
Diffstat (limited to 'examples')
-rw-r--r--examples/network/tcpclient.c2
-rw-r--r--examples/network/tcpserver.c2
-rw-r--r--examples/test/net_test.c36
-rw-r--r--examples/ymodem/echo.c4
-rw-r--r--examples/ymodem/null.c4
-rw-r--r--examples/ymodem/tofile.c8
6 files changed, 37 insertions, 19 deletions
diff --git a/examples/network/tcpclient.c b/examples/network/tcpclient.c
index 088206fdb1..7a0d4b5365 100644
--- a/examples/network/tcpclient.c
+++ b/examples/network/tcpclient.c
@@ -81,7 +81,7 @@ void tcpclient(const char* url, int port)
else
{
/* 在控制终端显示收到的数据 */
- rt_kprintf("\nRecieved data = %s " , recv_data);
+ rt_kprintf("\nReceived data = %s " , recv_data);
}
/* 发送数据到sock连接 */
diff --git a/examples/network/tcpserver.c b/examples/network/tcpserver.c
index 54b8c9301d..3f34bc2c29 100644
--- a/examples/network/tcpserver.c
+++ b/examples/network/tcpserver.c
@@ -101,7 +101,7 @@ void tcpserv(void* parameter)
else
{
/* 在控制终端显示收到的数据 */
- rt_kprintf("RECIEVED DATA = %s \n" , recv_data);
+ rt_kprintf("RECEIVED DATA = %s \n" , recv_data);
}
}
}
diff --git a/examples/test/net_test.c b/examples/test/net_test.c
index e4961622c7..53bd2836fa 100644
--- a/examples/test/net_test.c
+++ b/examples/test/net_test.c
@@ -5,6 +5,8 @@
#include <finsh.h>
#include <lwip/api.h>
#include <lwip/sockets.h>
+#include <lwip/init.h>
+
/*
* UDP echo server
*/
@@ -23,19 +25,28 @@ void udpecho_entry(void *parameter)
while(1)
{
/* received data to buffer */
+#if LWIP_VERSION_MINOR==3U
buf = netconn_recv(conn);
-
+#else
+ netconn_recv(conn, &buf);
+#endif
+
addr = netbuf_fromaddr(buf);
port = netbuf_fromport(buf);
- /* send the data to buffer */
+ /* send the data to buffer */
netconn_connect(conn, addr, port);
/* reset address, and send to client */
+#if LWIP_VERSION_MINOR==3U
buf->addr = RT_NULL;
+#else
+ buf->addr = *IP_ADDR_ANY;
+#endif
+
netconn_send(conn, buf);
-
- /* release buffer */
+
+ /* release buffer */
netbuf_delete(buf);
}
}
@@ -122,15 +133,23 @@ void tcpecho_entry(void *parameter)
while(1)
{
/* Grab new connection. */
+#if LWIP_VERSION_MINOR==3U
newconn = netconn_accept(conn);
- /* Process the new connection. */
if(newconn != NULL)
+#else
+ err = netconn_accept(conn, &newconn);
+ if(err == ERR_OK)
+#endif
+ /* Process the new connection. */
{
struct netbuf *buf;
void *data;
u16_t len;
-
+#if LWIP_VERSION_MINOR==3U
while((buf = netconn_recv(newconn)) != NULL)
+#else
+ while((err = netconn_recv(newconn, &buf)) == ERR_OK)
+#endif
{
do
{
@@ -214,9 +233,8 @@ void tcpecho_socket_entry(void *parameter)
bytes_received = recv(connected,recv_data, TCP_SOCKET_BUFFER_SIZE, 0);
if (bytes_received <= 0)
{
- rt_kprintf("close client connection, errno: %d, socket error: %d\n",
- rt_get_errno(),
- lwip_get_error());
+ rt_kprintf("close client connection, errno: %d\n",
+ rt_get_errno());
/* connection closed. */
lwip_close(connected);
break;
diff --git a/examples/ymodem/echo.c b/examples/ymodem/echo.c
index 5ffa5ff417..5cb807f519 100644
--- a/examples/ymodem/echo.c
+++ b/examples/ymodem/echo.c
@@ -25,8 +25,8 @@ rt_err_t rym_cat_to_dev(rt_device_t idev, rt_device_t odev)
rt_kprintf("open output device error: 0x%x", -res);
return res;
}
- res = rym_recv_on_device(&rctx, idev,
- RT_NULL, _rym_echo_data, RT_NULL, 1000);
+ res = rym_recv_on_device(&rctx, idev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
+ RT_NULL, _rym_echo_data, RT_NULL, 1000);
rt_device_close(_odev);
rt_kprintf("leaving RYM mode with code %X\n", res);
return res;
diff --git a/examples/ymodem/null.c b/examples/ymodem/null.c
index 5e3baa9870..c72ea064f8 100644
--- a/examples/ymodem/null.c
+++ b/examples/ymodem/null.c
@@ -20,8 +20,8 @@ rt_err_t rym_null(char *devname)
return -1;
}
- return rym_recv_on_device(&rctx, dev,
- RT_NULL, _rym_dummy_write, RT_NULL, 1000);
+ return rym_recv_on_device(&rctx, dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
+ RT_NULL, _rym_dummy_write, RT_NULL, 1000);
}
FINSH_FUNCTION_EXPORT(rym_null, dump data to null);
#endif
diff --git a/examples/ymodem/tofile.c b/examples/ymodem/tofile.c
index 2deef73c2c..4a3705ede7 100644
--- a/examples/ymodem/tofile.c
+++ b/examples/ymodem/tofile.c
@@ -21,7 +21,7 @@ static enum rym_code _rym_bg(
struct custom_ctx *cctx = (struct custom_ctx*)ctx;
cctx->fpath[0] = '/';
/* the buf should be the file name */
- strcpy(&(cctx->fpath[1]), buf);
+ strcpy(&(cctx->fpath[1]), (const char*)buf);
cctx->fd = open(cctx->fpath, O_CREAT | O_WRONLY | O_TRUNC, 0);
if (cctx->fd < 0)
{
@@ -31,7 +31,7 @@ static enum rym_code _rym_bg(
return RYM_CODE_CAN;
}
- cctx->flen = atoi(buf+strlen(buf)+1);
+ cctx->flen = atoi((const char*)buf+strlen((const char*)buf)+1);
if (cctx->flen == 0)
cctx->flen = -1;
return RYM_CODE_ACK;
@@ -80,8 +80,8 @@ rt_err_t rym_write_to_file(rt_device_t idev)
rt_kprintf("entering RYM mode\n");
- res = rym_recv_on_device(&ctx->parent, idev,
- _rym_bg, _rym_tof, _rym_end, 1000);
+ res = rym_recv_on_device(&ctx->parent, idev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
+ _rym_bg, _rym_tof, _rym_end, 1000);
/* there is no Ymodem traffic on the line so print out info. */
rt_kprintf("leaving RYM mode with code %d\n", res);