LWIP support for the uGFXnet driver.
This commit is contained in:
parent
54a3288320
commit
1ae42d93c1
1 changed files with 24 additions and 5 deletions
|
@ -54,7 +54,7 @@
|
||||||
atexit(StopSockets);
|
atexit(StopSockets);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#elif GFX_USE_OS_LINUX || GFX_USE_OS_OSX
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -67,6 +67,21 @@
|
||||||
#ifndef SOCKET
|
#ifndef SOCKET
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
extern void StartSockets(void); // Where the application does the lwip stack setup
|
||||||
|
|
||||||
|
#define LWIP_COMPAT_SOCKETS TRUE
|
||||||
|
#include <lwip/sockets.h>
|
||||||
|
#if !LWIP_SOCKET
|
||||||
|
#error "GDISP: uGFXnet - LWIP_SOCKETS must be defined in your lwipopts.h file"
|
||||||
|
#endif
|
||||||
|
#if !LWIP_COMPAT_SOCKETS
|
||||||
|
#error "GDISP: uGFXnet - LWIP_COMPAT_SOCKETS must be defined in your lwipopts.h file"
|
||||||
|
#endif
|
||||||
|
#ifndef SOCKET
|
||||||
|
#define SOCKET int
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GDISP_FLG_HASMOUSE (GDISP_FLG_DRIVER<<0)
|
#define GDISP_FLG_HASMOUSE (GDISP_FLG_DRIVER<<0)
|
||||||
|
@ -93,7 +108,10 @@ typedef struct netPriv {
|
||||||
} netPriv;
|
} netPriv;
|
||||||
|
|
||||||
static gfxThreadHandle hThread;
|
static gfxThreadHandle hThread;
|
||||||
static GDisplay * mouseDisplay;
|
|
||||||
|
#if GINPUT_NEED_MOUSE
|
||||||
|
static GDisplay * mouseDisplay;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a whole packet of data.
|
* Send a whole packet of data.
|
||||||
|
@ -116,7 +134,8 @@ static bool_t sendpkt(SOCKET netfd, uint16_t *pkt, int len) {
|
||||||
static DECLARE_THREAD_STACK(waNetThread, 512);
|
static DECLARE_THREAD_STACK(waNetThread, 512);
|
||||||
static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
||||||
SOCKET listenfd, fdmax, i, clientfd;
|
SOCKET listenfd, fdmax, i, clientfd;
|
||||||
int len;
|
socklen_t len;
|
||||||
|
int leni;
|
||||||
unsigned disp;
|
unsigned disp;
|
||||||
fd_set master, read_fds;
|
fd_set master, read_fds;
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
@ -248,7 +267,7 @@ static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle data from a client */
|
/* handle data from a client */
|
||||||
if ((len = recv(i, ((char *)priv->data)+priv->databytes, sizeof(priv->data)-priv->databytes, 0)) <= 0) {
|
if ((leni = recv(i, ((char *)priv->data)+priv->databytes, sizeof(priv->data)-priv->databytes, 0)) <= 0) {
|
||||||
// Socket closed or in error state
|
// Socket closed or in error state
|
||||||
g->flags &= ~GDISP_FLG_CONNECTED;
|
g->flags &= ~GDISP_FLG_CONNECTED;
|
||||||
memset(priv, 0, sizeof(netPriv));
|
memset(priv, 0, sizeof(netPriv));
|
||||||
|
@ -258,7 +277,7 @@ static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we have a full reply yet
|
// Do we have a full reply yet
|
||||||
priv->databytes += len;
|
priv->databytes += leni;
|
||||||
if (priv->databytes < sizeof(priv->data))
|
if (priv->databytes < sizeof(priv->data))
|
||||||
continue;
|
continue;
|
||||||
priv->databytes = 0;
|
priv->databytes = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue