summaryrefslogtreecommitdiff
path: root/logs.cpp
diff options
context:
space:
mode:
authorOlivier Gayot <og@satcom1.com>2016-04-09 10:28:03 +0200
committerOlivier Gayot <og@satcom1.com>2016-04-09 10:28:03 +0200
commite55eca19ef0e0c03832e8195ec3a11ff4e3903ce (patch)
tree98195abd377f02d4cf5208c0cd2d501147367da7 /logs.cpp
initial commit - read the raw values and send them
Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'logs.cpp')
-rw-r--r--logs.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/logs.cpp b/logs.cpp
new file mode 100644
index 0000000..901fd25
--- /dev/null
+++ b/logs.cpp
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <Arduino.h>
+
+int serial_write(uint8_t val)
+{
+ Serial.write(&val, 1);
+}
+
+int serial_put_string(const char *str)
+{
+ while (*str) {
+ serial_write(*str++);
+ }
+
+ return 0;
+}
+
+int serial_puts(const char *str)
+{
+ serial_put_string(str);
+
+ serial_write('\n');
+
+ return 0;
+}
+
+int serial_printf(const char *fmt, ...)
+{
+ va_list ap;
+
+ static char buf[256];
+
+ va_start(ap, fmt);
+
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+
+ serial_put_string(buf);
+
+ va_end(ap);
+
+ return 0;
+}
+
+#if 0
+int serial_print_dec(uint8_t opcode, int32_t integer)
+{
+ Serial.write(&opcode, 1);
+ Serial.println(integer, DEC);
+ return 0;
+}
+
+int serial_print_hex(uint8_t opcode, int32_t integer)
+{
+ Serial.write(&opcode, 1);
+ Serial.println(integer, HEX);
+ return 0;
+}
+#endif
+
+
+