Generic communication interface between the wireless board (mote) and the sensor board. Any kind of sensor board can be connected to the mote using this specification given it provides a SPI peripheral, one input pin with interrupt capability and one digital output. The sensor board must implement a special register set from which all required information can be retrieved. Protocol: http://is.gd/wuQorh Github: http://is.gd/ySj1L9

Dependencies:   mbed-src

Revision:
1:acdf490d94a7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sens_itf/sens_util.c	Tue Apr 08 16:34:20 2014 +0000
@@ -0,0 +1,81 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "sens_util.h"
+
+#define MAX_LOG_BUF 256
+static char buffer[MAX_LOG_BUF];
+
+static volatile int sens_util_log_started = 0;
+
+void sens_util_assert(int cond)
+{
+    assert(cond);
+}
+
+const uint8_t *sens_util_strip_path(const uint8_t *filename)
+{
+	int pos;
+
+	pos = strlen(filename) - 1; // avoiding null terminator
+
+	while( (filename[pos] != '\\') && (pos > 0) ) 
+		pos--;
+
+	if(pos != 0) 
+		pos++; // removing "\"
+	
+	return &filename[pos];
+}
+
+void sens_util_log(int cond, const uint8_t *line, ...)
+{
+	va_list argp;
+   
+    if((!cond) || (!sens_util_log_started))
+		return;
+
+	va_start(argp, line);
+    vsnprintf(buffer,MAX_LOG_BUF,line, argp);
+    va_end(argp);
+    
+    buffer[MAX_LOG_BUF-1] = '\0';
+
+	// TODO
+	// define destination for this buffer: ethernet, serial, console, syslog ...
+	// 
+    printf("%s",buffer);
+}
+
+void sens_util_dump_frame(const uint8_t * const data, int len)
+{
+	int i, j, k;
+	uint8_t buf[50];
+
+	for(k = 0 ; k < len ; k += 16)
+	{
+		for(i = k, j = 0 ; ( i< (k+16) ) && ( i < len ) ; i++, j+=3 )
+			sprintf((char *)&buf[j],"%02X ",data[i]);
+		buf[j] = '\0';
+		sens_util_log(1,"%s",buf);
+	}
+}
+
+int sens_util_log_stop(void)
+{
+	if(sens_util_log_started)
+        sens_util_log_started  = 0;
+
+	return 0;
+}
+
+int sens_util_log_start(void)
+{
+	if(!sens_util_log_started)
+        sens_util_log_started  = 1;
+
+	return 0;
+}