project_files/frontlib/ipc/ipcconn.c
changeset 7182 076aba32abd3
parent 7179 f84805e6df03
child 7224 5143861c83bd
--- a/project_files/frontlib/ipc/ipcconn.c	Sat Jun 09 03:28:38 2012 +0200
+++ b/project_files/frontlib/ipc/ipcconn.c	Mon Jun 11 00:02:17 2012 +0200
@@ -155,6 +155,22 @@
 	}
 }
 
+static void logSentMsg(const uint8_t *data, size_t len) {
+	if(flib_log_getLevel() > FLIB_LOGLEVEL_DEBUG) {
+		size_t msgStart = 0;
+		while(msgStart < len) {
+			uint8_t msglen = data[msgStart];
+			if(msgStart+msglen < len) {
+				flib_log_d("[IPC OUT][%03u]%*.*s",(unsigned)msglen, (unsigned)msglen, (unsigned)msglen, data+msgStart+1);
+			} else {
+				uint8_t msglen2 = len-msgStart-1;
+				flib_log_d("[IPC OUT][%03u/%03u]%*.*s",(unsigned)msglen2, (unsigned)msglen, (unsigned)msglen2, (unsigned)msglen2, data+msgStart+1);
+			}
+			msgStart += (uint8_t)data[msgStart]+1;
+		}
+	}
+}
+
 int flib_ipcconn_send_raw(flib_ipcconn ipc, const void *data, size_t len) {
 	if(!ipc || (!data && len>0)) {
 		flib_log_e("Call to flib_ipcconn_send_raw with ipc==null or data==null");
@@ -166,6 +182,7 @@
 	}
 
 	if(flib_socket_send(ipc->sock, data, len) == len) {
+		logSentMsg(data, len);
 		if(ipc->demoBuffer) {
 			if(flib_demo_record_to_engine(ipc->demoBuffer, data, len) < 0) {
 				flib_log_w("Stopping demo recording due to an error.");
@@ -189,7 +206,6 @@
 	uint8_t sendbuf[256];
 	sendbuf[0] = len;
 	memcpy(sendbuf+1, data, len);
-
 	return flib_ipcconn_send_raw(ipc, sendbuf, len+1);
 }