Component Test's Software to work with "Universal Controller Box" - Software is an interpreter or "compiler" for programs to be done with a .txt file and read off of the SD Card
Dependencies: BridgeDriver FrontPanelButtons MCP23017 SDFileSystem TextLCD mbed
Revision 15:c944ee3c8a5b, committed 2014-10-03
- Comitter:
- mehatfie
- Date:
- Fri Oct 03 17:31:04 2014 +0000
- Parent:
- 14:953820302fb7
- Child:
- 16:2482d226cf4d
- Commit message:
- - readded mkdir("\sd") line which seemed to have fixed an error in the system where the system could not find any files in the SD Card on power cycle. New SD Cards wouldn't have had this directory made for the "readfileNames()" function
Changed in this revision
--- a/Devices/CAN_Device.cpp Thu Oct 02 23:49:44 2014 +0000
+++ b/Devices/CAN_Device.cpp Fri Oct 03 17:31:04 2014 +0000
@@ -20,7 +20,18 @@
//
// //channel must be either CAN1 or CAN2
// if (tempChannel == 1 || tempChannel == 2){
-// this->selectedCAN = tempChannel;
+// if (tempChannel == 1){
+// this->pinRD = p30;
+// this->pinTD = p29;
+// }
+// else if (tempChannel == 2){
+// this->pinRD = p9;
+// this->pinTD = p10;
+// }
+//
+// this->selectedCAN = tempChannel;
+// }
+//
// else
// this->errorFlag = 1;
//
@@ -43,34 +54,60 @@
////A line consists of [ __(Local_Name)__ __(function)__ __(parameter1)__ __(parameter2)__ __(parameter3)__ ... and so on]
//int CAN_Device::CAN_Device(LineData &lineData){
//
+// //Initialize the CAN device
+// CAN canDevice(pinRD, pinTD);
+// canDevice.frequency(125000);
+//
// //Order of Line: Local_Name, Function_Name, Param1, Param2, Param3,.......
// string func = lineData.word[1];
//
// /******************************************************************************/
-// /*** <Func: enableBrake> ***/
+// /*** <Func: write> ***/
// /******************************************************************************/
// if (func.compare("write") == 0){
-// //line looks like: Local_Name, write, ID_val, byte
-// if (lineData.numWords > 5){
+// //line looks like: Local_Name, write, ID_val, length_val, data
+// if (lineData.numWords < 5){
// ErrorOut("Incorrect number of parameters", lineData.lineNumber);
// return -1;
// }
//
// //Initialize and Convert Parameters
-// string enable = lineData.word[2];
-// int enableValue = 0;
+// string _id = lineData.word[2];
+// string _length = lineData.word[3];
+// string _data = lineData.word[4];
+// int _idValue = 0;
+// char _lengthValue = 0;
+//
+// int numValuesFound = sscanf(_id.c_str(), "%d", &_idValue);
+// if (numValuesFound < 1){
+// ErrorOut("Parameter Unknown, id value can't be converted", lineData.lineNumber);
+// return -1;
+// }
//
-// int numValuesFound = sscanf(enable.c_str(), "%d", &enableValue);
+// int numValuesFound = sscanf(_length.c_str(), "%c", &_lengthValue);
// if (numValuesFound < 1){
-// ErrorOut("Parameter Unknown, enableBrake value can't be converted", lineData.lineNumber);
+// ErrorOut("Parameter Unknown, length value can't be converted", lineData.lineNumber);
// return -1;
// }
//
+// int numDataVals = numWords - 4; //number of data bytes present in the line
+// const char* dataBytes[numDataVals];
+// int i = 0;
+// for (i = 0; i < numDataVals; i++){
+// string thisDataByte = lineData.word[4 + i];
+// int numValuesFound = sscanf(thisDataByte.c_str(), "%c", &dataBytes[i]);
+// if (numValuesFound < 1){
+// ErrorOut("Parameter Unknown, a data byte %d can't be converted", (i + 1), lineData.lineNumber);
+// return -1;
+// }
+// }
+//
// //All syntax checking done by this point, if Dummy then return success in order to check the code, no need to perform functionality
// if (DummyMode)
// return 0; //Function operated successfully but doesn't return a value
//
-// bridges.enableBraking(getMotor(), enableValue);
+//
+// canDevice.write(CANMessage(_idValue, &dataBytes, _lengthValue));
// }
//
// /******************************************************************************/
--- a/Devices/CAN_Device.hpp Thu Oct 02 23:49:44 2014 +0000
+++ b/Devices/CAN_Device.hpp Fri Oct 03 17:31:04 2014 +0000
@@ -8,6 +8,8 @@
private:
int selectedCAN;
int freq;
+ PinName pinRD;
+ PinName pinTD;
vector<CANMessage> messages;
public:
--- a/main.cpp Thu Oct 02 23:49:44 2014 +0000
+++ b/main.cpp Fri Oct 03 17:31:04 2014 +0000
@@ -415,7 +415,7 @@
return -1;
}
- //Restart the timer for the next cycle
+ //Restart the timer for the cycle
cycleTimer.reset();
cycleTimer.start();
}
@@ -1045,6 +1045,7 @@
/*** <Get all the Potential Programs> ***/
/******************************************************************************/
int numTextFiles = 0;
+ mkdir("/sd", 0777);
vector<string> textFiles; //Assuming Maximum of 25 txt files will be on the SD Card
vector<string> filenames = readFileNames("/sd");
@@ -1178,11 +1179,13 @@
lcd.setAddress(0,2);
lcd.printf("To Restart...");
lcd.setAddress(0,3);
- lcd.printf("Press BACK");
-
- while(!buttons.readBack());
-
- rewind(selectedFile);
+ lcd.printf("Cycle Power");
+
+ fclose(selectedFile);
+ return 1;
+
+ /*while(!buttons.readBack());
+ rewind(selectedFile);*/
}
}