Dependents:   communication

Revision:
1:36cd04f61e68
Parent:
0:964bbeb0a1d3
Child:
2:27ac6b5ec2d1
diff -r 964bbeb0a1d3 -r 36cd04f61e68 serial_communication.cpp
--- a/serial_communication.cpp	Thu Mar 31 04:42:48 2016 +0000
+++ b/serial_communication.cpp	Sun Apr 03 06:30:35 2016 +0000
@@ -1,6 +1,7 @@
 #include "serial_communication.hpp"
 #include "mbed.h"
 #include "SimpleMapDeSerializer.hpp"
+#include "communication.hpp"
 #include <map>
 
 serial_communication* serial_communication::instance_ = NULL;
@@ -8,17 +9,21 @@
 serial_communication::serial_communication() : serial_(USBTX, USBRX),
                                                semaphore_(true),
                                                is_new_data_existing_(false) {
+    // 基準値で初期化
+    map_["stkLX"] = communication::velocity_offset_;
+    map_["stkLY"] = communication::velocity_offset_;
+    /*
     serial_.baud(115200);
     serial_.format(7, RawSerial::None, 1);
     serial_.attach(this, &serial_communication::receive);
+    */
 }
 
 serial_communication::~serial_communication() {
     delete instance_;
 }
 
-int serial_communication::get_data(string key) {
-    //while (!semaphore_) {}
+int serial_communication::get(string key) {
     return map_[key];
 }
 
@@ -32,18 +37,11 @@
     return false;
 }
 
-I2C i2c(I2C_SDA, I2C_SCL);
-
 void serial_communication::receive() {
     char c = serial_.getc();
     
     switch (c) {
         case '\n':
-            /*
-            semaphore_ = false;
-            SimpleMapSerialization::simpleMapDeSerializer(buffer_, ',', map_);
-            semaphore_ = true;
-            */
             data_ = buffer_;
             buffer_.erase();
             buffer_ += "a,0,";