GDP group 24 node core

Dependencies:   EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue

Files at this revision

API Documentation at this revision

Comitter:
jakehodges
Date:
Tue Jan 13 23:43:09 2015 +0000
Parent:
17:215899ba8b8e
Parent:
19:70c911d35e67
Child:
22:835a6c6dcfbb
Commit message:
Merge master branch

Changed in this revision

sensorinterface.cpp Show annotated file Show diff for this revision Revisions of this file
sensorinterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/sdcard.cpp	Tue Jan 13 23:38:44 2015 +0000
+++ b/sdcard.cpp	Tue Jan 13 23:43:09 2015 +0000
@@ -3,11 +3,7 @@
 #include <map>
 
 sdcard::sdcard(): sd(p5, p6, p7, p8, "sd")
-{
-    typeLookup[0x00] = "soil_con";
-    typeLookup[0x01] = "soil_temp";
-    typeLookup[0x02] = "amb_temp";
-    
+{   
     //first write sometimes fails, let's ensure the first write isn't real data
     FILE *fp = fopen("/sd/boot", "w");
     fprintf(fp, "boot");
@@ -21,9 +17,7 @@
     string sd_location ="";
     char time_s[64];
  
-    string l_type = typeLookup[data.type];
- 
-    sd_location = sd_name + l_type;
+    sd_location = sd_name + data.type;
     mkdir(sd_location.c_str(), 0777);
     
     sprintf(time_s, "%d", time);
--- a/sdcard.h	Tue Jan 13 23:38:44 2015 +0000
+++ b/sdcard.h	Tue Jan 13 23:43:09 2015 +0000
@@ -7,6 +7,5 @@
         sdcard(); // MOSI, MISO, CKL, CS -> PINS 2, 7, 5, 1, ON SD CARD WITH 4=VCC, 6=GND, 8,9=NC
         int write(long int time_holder, d_reply data);
     private:
-        map<char,string> typeLookup;
         SDFileSystem sd;
 };
\ No newline at end of file
--- a/sensorinterface.cpp	Tue Jan 13 23:38:44 2015 +0000
+++ b/sensorinterface.cpp	Tue Jan 13 23:43:09 2015 +0000
@@ -148,7 +148,7 @@
  
 int sensorinterface::sendRequest(char address)
 {
-    char cmd[1] = {'R'};
+    char cmd[1] = {I2C_REQUEST_HEADER};
  
     this->i2c.write(address, cmd, 1);
     
@@ -161,7 +161,7 @@
         printf("[SIF] Reading data from current device (0x%.2X)\r\n", currentSensor->first);
     #endif
     char address = currentSensor->first;
-    char cmd[1] = {'D'};
+    char cmd[1] = {I2C_DATA_HEADER};
     char bufSize = currentSensor->second.packetSize + 2;
     char buffer[bufSize];
     this->i2c.write(address, cmd, 1);
@@ -183,7 +183,7 @@
         reply.readings.push_back(r);
     }
  
-    if (buffer[0] != 'D')
+    if (buffer[0] != I2C_DATA_HEADER)
     {
         //if it doesn't send the correct header bit, something has gone wrong
         #ifdef DEBUG
--- a/sensorinterface.h	Tue Jan 13 23:38:44 2015 +0000
+++ b/sensorinterface.h	Tue Jan 13 23:43:09 2015 +0000
@@ -7,8 +7,8 @@
 #include <vector>
 
 #define I2C_TYPE_HEADER     'T'
-#define I2C_TYPE_REQUEST    'R'
-#define I2C_TYPE_DATA       'D'
+#define I2C_REQUEST_HEADER  'R'
+#define I2C_DATA_HEADER     'D'
 #define I2C_TYPE_PACKET_SIZE    4
 
 #define DEBUG