diff --git a/graphics/vnc/server/vnc_fbdev.c b/graphics/vnc/server/vnc_fbdev.c index 89a976c2c3..87fb91b84d 100644 --- a/graphics/vnc/server/vnc_fbdev.c +++ b/graphics/vnc/server/vnc_fbdev.c @@ -445,6 +445,18 @@ static inline int vnc_wait_server(int display) result = g_fbstartup[display].result; if (result != -EBUSY) { +#ifdef CONFIG_DEBUG + if (result < 0) + { + DEBUGASSERT(g_vnc_sessions[display] == NULL); + gdbg("ERROR: VNC server startup failed: %d\n", result); + } + else + { + DEBUGASSERT(g_vnc_sessions[display] != NULL && + g_vnc_sessions[display]->state == VNCSERVER_RUNNING); + } +#endif return result; } } diff --git a/graphics/vnc/server/vnc_negotiate.c b/graphics/vnc/server/vnc_negotiate.c index d6c1a9a2f7..7c229814cb 100644 --- a/graphics/vnc/server/vnc_negotiate.c +++ b/graphics/vnc/server/vnc_negotiate.c @@ -94,6 +94,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) /* Inform the client of the VNC protocol version */ + gvdbg("Send protocol version: %s\n", g_vncproto); + len = strlen(g_vncproto); nsent = psock_send(&session->connect, g_vncproto, len, 0); if (nsent < 0) @@ -108,6 +110,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) /* Receive the echo of the protocol string */ + gvdbg("Receive echo from VNC client\n"); + nrecvd = psock_recv(&session->connect, session->inbuf, len, 0); if (nrecvd < 0) { @@ -125,6 +129,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) * word:" */ + gvdbg("Send security type (None)\n"); + sectype = (FAR struct rfb_sectype_s *)session->outbuf; rfb_putbe32(sectype->type, RFB_SECTYPE_NONE); @@ -150,6 +156,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) * In this implementation, the sharing flag is ignored. */ + gvdbg("Receive ClientInit\n"); + nrecvd = psock_recv(&session->connect, session->inbuf, sizeof(struct rfb_clientinit_s), 0); if (nrecvd < 0) @@ -162,13 +170,15 @@ int vnc_negotiate(FAR struct vnc_session_s *session) DEBUGASSERT(nrecvd == sizeof(struct rfb_clientinit_s)); - /* Send the ClientInit message + /* Send the ServerInit message * * "After receiving the ClientInit message, the server sends a ServerInit * message. This tells the client the width and height of the server’s * framebuffer, its pixel format and the name associated with the desktop: */ + gvdbg("Receive ServerInit\n"); + serverinit = (FAR struct rfb_serverinit_s *)session->outbuf; rfb_putbe16(serverinit->width, CONFIG_VNCSERVER_SCREENWIDTH); @@ -204,6 +214,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) * This may override some of our framebuffer settings. */ + gvdbg("Receive SetPixelFormat\n"); + setformat = (FAR struct rfb_setpixelformat_s *)session->inbuf; nrecvd = psock_recv(&session->connect, setformat, @@ -273,6 +285,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) * we will do only raw format. */ + gvdbg("Receive encoding types\n"); + (void)psock_recv(&session->connect, session->inbuf, CONFIG_VNCSERVER_INBUFFER_SIZE, 0); diff --git a/graphics/vnc/server/vnc_receiver.c b/graphics/vnc/server/vnc_receiver.c index 8715ee69a8..9b9fc0d1d2 100644 --- a/graphics/vnc/server/vnc_receiver.c +++ b/graphics/vnc/server/vnc_receiver.c @@ -119,6 +119,9 @@ int vnc_receiver(FAR struct vnc_session_s *session) int errcode; int ret; + DEBUGASSERT(session); + gvdbg("Receiver running for Display %d\n", session->display); + /* Loop until the client disconnects or an unhandled error occurs */ for (; ; ) diff --git a/graphics/vnc/server/vnc_server.c b/graphics/vnc/server/vnc_server.c index b83ebe6b9e..653e2bc3ac 100644 --- a/graphics/vnc/server/vnc_server.c +++ b/graphics/vnc/server/vnc_server.c @@ -57,10 +57,6 @@ #include "vnc_server.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Public Data ****************************************************************************/ @@ -92,7 +88,7 @@ FAR struct vnc_session_s *g_vnc_sessions[RFB_MAX_DISPLAYS]; ****************************************************************************/ static void vnc_reset_session(FAR struct vnc_session_s *session, - FAR uint8_t *fb) + FAR uint8_t *fb, int display) { FAR struct vnc_fbupdate_s *curr; FAR struct vnc_fbupdate_s *next; @@ -136,8 +132,9 @@ static void vnc_reset_session(FAR struct vnc_session_s *session, sem_reset(&session->freesem, CONFIG_VNCSERVER_NUPDATES); sem_reset(&session->queuesem, 0); - session->fb = fb; - session->state = VNCSERVER_INITIALIZED; + session->fb = fb; + session->display = display; + session->state = VNCSERVER_INITIALIZED; } /**************************************************************************** @@ -160,6 +157,8 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port) struct sockaddr_in addr; int ret; + gvdbg("Connecting display %d\n", session->display); + /* Create a listening socket */ addr.sin_family = AF_INET; @@ -194,6 +193,8 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port) /* Connect to the client */ + gvdbg("Acception connection for display %d\n", session->display); + ret = psock_accept(&session->listen, NULL, NULL, &session->connect); if (ret < 0) { @@ -201,6 +202,7 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port) goto errout_with_listener; } + gvdbg("Display %d connected\n", session->display); session->state = VNCSERVER_CONNECTED; return OK; @@ -234,6 +236,7 @@ int vnc_server(int argc, FAR char *argv[]) int display; int ret; + gvdbg("Server Started\n"); DEBUGASSERT(session != NULL); /* A single argument is expected: A diplay port number in ASCII form */ @@ -253,6 +256,8 @@ int vnc_server(int argc, FAR char *argv[]) goto errout_with_post; } + gvdbg("Display %d\n", display); + /* Allocate the framebuffer memory. We rely on the fact that * the KMM allocator will align memory to 32-bits or better. */ @@ -290,7 +295,7 @@ int vnc_server(int argc, FAR char *argv[]) * for the next connection. */ - vnc_reset_session(session, fb); + vnc_reset_session(session, fb, display); g_fbstartup[display].result = -EBUSY; sem_reset(&g_fbstartup[display].fbsem, 0); diff --git a/graphics/vnc/server/vnc_server.h b/graphics/vnc/server/vnc_server.h index 41acacd822..c4bd08ac38 100644 --- a/graphics/vnc/server/vnc_server.h +++ b/graphics/vnc/server/vnc_server.h @@ -207,6 +207,7 @@ struct vnc_session_s /* Display geometry and color characteristics */ + uint8_t display; /* Display number (for debug) */ uint8_t colorfmt; /* Remote color format (See include/nuttx/fb.h) */ uint8_t bpp; /* Remote bits per pixel */ FAR uint8_t *fb; /* Allocated local frame buffer */ diff --git a/graphics/vnc/server/vnc_updater.c b/graphics/vnc/server/vnc_updater.c index 1a76c17665..01e1046a96 100644 --- a/graphics/vnc/server/vnc_updater.c +++ b/graphics/vnc/server/vnc_updater.c @@ -544,9 +544,11 @@ static FAR void *vnc_updater(FAR void *arg) } convert; bool color32 = false; + DEBUGASSERT(session != NULL); + gvdbg("Updater running for Display %d\n", session->display); + /* Set up some constant pointers and values */ - DEBUGASSERT(session != NULL); update = (FAR struct rfb_framebufferupdate_s *)session->outbuf; destrect = update->rect; @@ -743,6 +745,8 @@ int vnc_start_updater(FAR struct vnc_session_s *session) struct sched_param param; int status; + gvdbg("Starting updater for Display %d\n", session->display); + /* Create thread that is gonna send rectangles to the client */ session->state = VNCSERVER_RUNNING; diff --git a/sched/task/task_create.c b/sched/task/task_create.c index 1cc59793cc..c8dc768d5a 100644 --- a/sched/task/task_create.c +++ b/sched/task/task_create.c @@ -117,12 +117,14 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, #endif #if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 +#if 0 /* No... there are side effects */ /* Associate file descriptors with the new task. Exclude kernel threads; * kernel threads do not have file or socket descriptors. They must use * SYSLOG for output and the low-level psock interfaces for network I/O. */ if (ttype != TCB_FLAG_TTYPE_KERNEL) +#endif { ret = group_setuptaskfiles(tcb); if (ret < OK)