Plymouth ELEC351 Group T / Mbed OS ELEC351

Dependencies:   BME280 BMP280 TextLCD

Revision:
48:244d6d81bb52
Parent:
41:859b5e1e3d9a
Child:
49:d51f96a46cc3
--- a/sample_hardware.cpp	Mon Jan 08 21:53:40 2018 +0000
+++ b/sample_hardware.cpp	Tue Jan 09 00:37:01 2018 +0000
@@ -77,9 +77,43 @@
     
     //Network test (if BOTH switches are held down)
     //networktest();
-    
-    
-    puts("**********POST END**********");
+    NetworkWaitTime = NetworkWait;
+        //Initialise the SD card (this needs to move)
+    if ( sd.init() != 0) {
+        printf("SD Init failed \n");
+        LCD.Display_Clear();
+        LCD.Write_String("CANNOT INIT SD");        //Change me
+        errorCode(FATAL);
+    }
+    //Create a filing system for SD Card
+    FATFileSystem fs("sd", &sd);
+
+    //Open to WRITE
+    FILE* fp = fopen("/sd/test.csv","a");//test.csv is created in the SD Card
+    if (fp == NULL) {
+        error("Could not open file for write\n");
+        LCD.Display_Clear();
+        LCD.Write_String("CANNOT OPEN FILE");
+        errorCode(FATAL);
+    }
+    //Close File
+    fclose(fp);
+    int network_temp;
+    network_temp = Network_Init();
+    if(network_temp == 1)//Sets up the network and checks if the network cable is not pluged in
+    {
+        error("Could not access network");
+        LCD.Display_Clear();
+        LCD.Write_String("Could not access network");
+        errorCode(NETWORK_FATAL);   
+    }
+    //Last message before sampling begins
+    LCD.Display_Clear();
+    LCD.Write_String("READY     PLAYER");
+    LCD.DDRAM_Address(0x40);
+    LCD.Write_String("      One     ");
+    LCD.DDRAM_Address(0x00);
+    puts("**********POST END**********\n");
  
 }