Commit 38ab750c authored by Vincent Wei's avatar Vincent Wei
Browse files

debug

parent 40419611
......@@ -139,7 +139,7 @@ static struct _demo_info {
char* const exe_file;
char* const def_mode;
} _demo_list [] = {
{"mguxdemo", "/usr/local/bin/", "/usr/local/bin/mguxdemo", "480x640-16bpp"},
{"mguxdemo", "/usr/local/bin/", "/usr/local/bin/mguxdemo", "360x480-16bpp"},
{"cbplusui", "/usr/local/bin/", "/usr/local/bin/cbplusui", "240x240-16bpp"},
};
......@@ -199,7 +199,6 @@ int us_on_connected (USClient* us_client)
/* read info of virtual frame buffer */
n = read (us_client->fd, &header, sizeof (struct _frame_header));
if (n < sizeof (struct _frame_header) || header.type != FT_VFBINFO) {
printf ("us_on_connected: frame header info: %ld, %d.\n", n, header.type);
retval = 1;
goto error;
}
......@@ -272,7 +271,6 @@ int us_on_client_data (USClient* us_client)
}
if (n < sizeof (struct _frame_header)) {
printf ("us_on_client_data: read bytes %ld\n", n);
return 1;
}
......
......@@ -168,20 +168,6 @@ onmessage (WSClient * client)
WSMessage **msg = &client->message;
printf ("INFO: got a message from client (%d): %s\n", client->listener, (*msg)->payload);
uint32_t hsize = sizeof (uint32_t) * 3;
char *hdr = NULL, *ptr = NULL;
hdr = calloc (hsize, sizeof (char));
ptr = hdr;
ptr += pack_uint32 (ptr, client->listener);
ptr += pack_uint32 (ptr, (*msg)->opcode);
ptr += pack_uint32 (ptr, (*msg)->payloadsz);
//ws_write_fifo (pipeout, hdr, hsize);
//ws_write_fifo (pipeout, (*msg)->payload, (*msg)->payloadsz);
free (hdr);
return 0;
}
......
......@@ -2204,9 +2204,14 @@ handle_ws_writes (int conn, WSServer * server)
*
* On success, the number size of uint32_t is returned. */
size_t
pack_uint32 (void *buf, uint32_t val)
pack_uint32 (void *buf, uint32_t val, int convert)
{
uint32_t v32 = htonl (val);
uint32_t v32;
if (convert)
v32 = htonl (val);
else
v32 = val;
memcpy (buf, &v32, sizeof (uint32_t));
return sizeof (uint32_t);
......@@ -2216,11 +2221,14 @@ pack_uint32 (void *buf, uint32_t val)
*
* On success, the number size of uint32_t is returned. */
size_t
unpack_uint32 (const void *buf, uint32_t * val)
unpack_uint32 (const void *buf, uint32_t * val, int convert)
{
uint32_t v32 = 0;
memcpy (&v32, buf, sizeof (uint32_t));
*val = ntohl (v32);
if (convert)
*val = ntohl (v32);
else
*val = v32;
return sizeof (uint32_t);
}
......@@ -2401,14 +2409,19 @@ ws_send_dirty_pixels (WSClient* ws_client, const RECT* rc_dirty, const char* png
goto error;
}
LOG (("Trying send content of file %s (size: %u) to client\n", png_path, my_stat.st_size));
p = xmalloc (sizeof (RECT) + my_stat.st_size);
//LOG (("Trying send content of file %s (size: %u) to client\n", png_path, my_stat.st_size));
p = xmalloc (sizeof (uint32_t) * 4 + my_stat.st_size);
if (p == NULL) {
retval = 3;
goto error;
}
memcpy (p, rc_dirty, sizeof (RECT));
char* ptr;
ptr = p;
ptr += pack_uint32 (ptr, (uint32_t)rc_dirty->left, 0);
ptr += pack_uint32 (ptr, (uint32_t)rc_dirty->top, 0);
ptr += pack_uint32 (ptr, (uint32_t)rc_dirty->right, 0);
ptr += pack_uint32 (ptr, (uint32_t)rc_dirty->bottom, 0);
fp = fopen (png_path, "r");
if (fp == NULL) {
......@@ -2416,13 +2429,13 @@ ws_send_dirty_pixels (WSClient* ws_client, const RECT* rc_dirty, const char* png
goto error;
}
size = fread (p + sizeof (RECT), sizeof (char), my_stat.st_size, fp);
size = fread (ptr, sizeof (char), my_stat.st_size, fp);
if (size < my_stat.st_size) {
retval = 5;
goto error;
}
retval = ws_send_data (ws_client, WS_OPCODE_BIN, p, sizeof (RECT) + my_stat.st_size);
retval = ws_send_data (ws_client, WS_OPCODE_BIN, p, sizeof (uint32_t) * 4 + my_stat.st_size);
error:
if (p)
......@@ -2446,8 +2459,7 @@ check_dirty_pixels (WSServer* server)
int retval;
char png_path [20];
printf ("check_dirty_pixels: UnixSocket Client #%d has dirty pixels (%d, %d, %d, %d) to send.\n",
us_client->pid, us_client->rc_dirty.left, us_client->rc_dirty.top, us_client->rc_dirty.right, us_client->rc_dirty.bottom);
//LOG (("check_dirty_pixels: UnixSocket Client #%d has dirty pixels (%d, %d, %d, %d) to send.\n", us_client->pid, us_client->rc_dirty.left, us_client->rc_dirty.top, us_client->rc_dirty.right, us_client->rc_dirty.bottom));
sprintf (png_path, "/tmp/wds-%d.png", us_client->pid);
if ((retval = save_dirty_pixels_to_png (png_path, us_client))) {
......
......@@ -292,11 +292,12 @@ typedef struct WSServer_
#endif
} WSServer;
size_t pack_uint32 (void *buf, uint32_t val, int convert);
size_t unpack_uint32 (const void *buf, uint32_t * val, int convert);
int ws_send_data (WSClient * client, WSOpcode opcode, const char *p, int sz);
int ws_setfifo (const char *pipename);
int ws_validate_string (const char *str, int len);
size_t pack_uint32 (void *buf, uint32_t val);
size_t unpack_uint32 (const void *buf, uint32_t * val);
void set_nonblocking (int listener);
void ws_set_config_accesslog (const char *accesslog);
void ws_set_config_echomode (int echomode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment