Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug/general fixes #221

Merged
merged 3 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions radsat-sk/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@
<listOptionValue builtIn="false" value="../operation/subsystems/camera"/>
<listOptionValue builtIn="false" value="../operation/utility"/>
<listOptionValue builtIn="false" value="../src/tasks"/>
<listOptionValue builtIn="false" value="../testing"/>
<listOptionValue builtIn="false" value="../testing/unit"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs.663972223" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="sdram"/>
Expand Down Expand Up @@ -156,7 +154,7 @@
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="framework"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="operation"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
<entry excluding="RTestSuite.c|RTestSuite.h" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="testing"/>
<entry excluding="*|**" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="testing"/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down Expand Up @@ -238,6 +236,7 @@
<listOptionValue builtIn="false" value="../operation/message/crypt"/>
<listOptionValue builtIn="false" value="../operation/services"/>
<listOptionValue builtIn="false" value="../operation/subsystems"/>
<listOptionValue builtIn="false" value="../operation/subsystems/camera"/>
<listOptionValue builtIn="false" value="../operation/utility"/>
<listOptionValue builtIn="false" value="../src/tasks"/>
</option>
Expand Down Expand Up @@ -399,10 +398,10 @@
<listOptionValue builtIn="false" value="../operation/message/crypt"/>
<listOptionValue builtIn="false" value="../operation/services"/>
<listOptionValue builtIn="false" value="../operation/subsystems"/>
<listOptionValue builtIn="false" value="../operation/subsystems/camera"/>
<listOptionValue builtIn="false" value="../operation/utility"/>
<listOptionValue builtIn="false" value="../testing/unit"/>
<listOptionValue builtIn="false" value="../testing"/>
<listOptionValue builtIn="false" value="../src/tasks"/>
<listOptionValue builtIn="false" value="../testing"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs.1971370393" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="sdram"/>
Expand Down Expand Up @@ -466,7 +465,7 @@
</folderInfo>
<fileInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139.1724570827.555085295" name="RTestSuite.c" rcbsApplicability="disable" resourcePath="testing/RTestSuite.c" toolsToInvoke="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.926867254.1416169741">
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.926867254.1416169741" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.926867254">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs.846178328" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs" valueType="definedSymbols">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs.846178328" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs" valueType="definedSymbols">
<listOptionValue builtIn="false" value="sdram"/>
<listOptionValue builtIn="false" value="at91sam9g20"/>
<listOptionValue builtIn="false" value="TRACE_LEVEL=5"/>
Expand All @@ -476,7 +475,7 @@
<listOptionValue builtIn="false" value="'BASE_REVISION_HASH=$(REVHASH)'"/>
<listOptionValue builtIn="false" value="TEST=1"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.33493194" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" valueType="includePath">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.33493194" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/radsat-sk/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${external-dependencies}/hal/freertos/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${external-dependencies}/hal/at91/include&quot;"/>
Expand Down Expand Up @@ -535,10 +534,10 @@
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.894727219;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.821686405">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2034562181;ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2034562181.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.2123396632;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.556885632">
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139.1724570827;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139.1724570827.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.926867254;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1887967793">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139.1724570827;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.853133139.1724570827.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.926867254;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1887967793">
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2034562181;ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2034562181.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.2123396632;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.556885632">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
Expand Down
2 changes: 1 addition & 1 deletion radsat-sk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/Release
/docs
/.settings
/Test
/Test
32 changes: 16 additions & 16 deletions radsat-sk/operation/services/RFileTransferService.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,31 @@ typedef struct _fram_frame_t {
uint8_t fileTransferNextFrame(uint8_t* frame) {
// get the read cursor from FRAM
uint16_t frameReadCursor = 0;
framRead(&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);
framRead((uint8_t*)&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);

// ensure that there is a valid frame ahead
uint16_t nextFrameReadCursor = frameReadCursor + 1;
if (nextFrameReadCursor == MAX_FRAME_COUNT)
nextFrameReadCursor = 0;

fram_frame_t fram_frame = {0};
void* framDataAddr = FRAM_DATA_START_ADDR + (nextFrameReadCursor * FRAM_DATA_FRAME_SIZE);
framRead(&fram_frame, framDataAddr, FRAM_DATA_FRAME_SIZE);
uint32_t framDataAddr = FRAM_DATA_START_ADDR + (nextFrameReadCursor * FRAM_DATA_FRAME_SIZE);
framRead((uint8_t*)&fram_frame, framDataAddr, FRAM_DATA_FRAME_SIZE);

if (fram_frame.size == 0)
return SUCCESS;

// invalidate the current (now previous frame)
fram_frame_t emptyFrame = {0};
framDataAddr = FRAM_DATA_START_ADDR + (frameReadCursor * FRAM_DATA_FRAME_SIZE);
framWrite(&emptyFrame, framDataAddr, FRAM_DATA_FRAME_SIZE);
framWrite((uint8_t*)&emptyFrame, framDataAddr, FRAM_DATA_FRAME_SIZE);

// increment the read cursor
frameReadCursor++;
if (frameReadCursor == MAX_FRAME_COUNT)
frameReadCursor = 0;
// save read cursor value in FRAM
framWrite(&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);
framWrite((uint8_t*)&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);

// transfer the new (now current) frame into the provided buffer
memcpy(frame, fram_frame.data, fram_frame.size);
Expand All @@ -99,12 +99,12 @@ uint8_t fileTransferNextFrame(uint8_t* frame) {
uint8_t fileTransferCurrentFrame(uint8_t* frame) {
// get the read cursor from FRAM
uint16_t frameReadCursor = 0;
framRead(&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);
framRead((uint8_t*)&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);

// read current frame from FRAM
fram_frame_t fram_frame = {0};
void* framDataAddr = FRAM_DATA_START_ADDR + (frameReadCursor * FRAM_DATA_FRAME_SIZE);
framRead(&fram_frame, framDataAddr, FRAM_DATA_FRAME_SIZE);
uint32_t framDataAddr = FRAM_DATA_START_ADDR + (frameReadCursor * FRAM_DATA_FRAME_SIZE);
framRead((uint8_t*)&fram_frame, framDataAddr, FRAM_DATA_FRAME_SIZE);

sqrt(1);
// only provide a frame if the cursor is pointing at a valid frame
Expand Down Expand Up @@ -138,8 +138,8 @@ int fileTransferAddMessage(const void* message, uint8_t size, uint16_t messageTa
// get the write & read cursors from FRAM
uint16_t frameWriteCursor = 0;
uint16_t frameReadCursor = 0;
framRead(&frameWriteCursor, FRAM_WRITE_CURSOR_ADDR, 2);
framRead(&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);
framRead((uint8_t*)&frameWriteCursor, FRAM_WRITE_CURSOR_ADDR, 2);
framRead((uint8_t*)&frameReadCursor, FRAM_READ_CURSOR_ADDR, 2);

// ensure we are not about to overwrite frames that have not been read
if (frameWriteCursor == frameReadCursor)
Expand All @@ -162,8 +162,8 @@ int fileTransferAddMessage(const void* message, uint8_t size, uint16_t messageTa
fram_frame.size = messageWrap(&newMessage, fram_frame.data);

// write data in FRAM
void* framDataAddr = FRAM_DATA_START_ADDR + (frameWriteCursor * FRAM_DATA_FRAME_SIZE);
framWrite(&fram_frame, framDataAddr, FRAM_DATA_FRAME_SIZE);
uint32_t framDataAddr = FRAM_DATA_START_ADDR + (frameWriteCursor * FRAM_DATA_FRAME_SIZE);
framWrite((uint8_t*)&fram_frame, framDataAddr, FRAM_DATA_FRAME_SIZE);

// return error if message wrapping failed
if (fram_frame.size == 0)
Expand All @@ -174,7 +174,7 @@ int fileTransferAddMessage(const void* message, uint8_t size, uint16_t messageTa
if (frameWriteCursor == MAX_FRAME_COUNT)
frameWriteCursor = 0;
// save write cursor value in FRAM
framWrite(&frameWriteCursor, FRAM_WRITE_CURSOR_ADDR, 2);
framWrite((uint8_t*)&frameWriteCursor, FRAM_WRITE_CURSOR_ADDR, 2);

// return success
return SUCCESS;
Expand All @@ -190,12 +190,12 @@ int fileTransferAddMessage(const void* message, uint8_t size, uint16_t messageTa
void fileTransferReset(void) {
// reset the cursors to their default values
uint16_t defaultCursors[2] = {1,0};
framWrite(&defaultCursors, FRAM_WRITE_CURSOR_ADDR, 4);
framWrite((uint8_t*)&defaultCursors, FRAM_WRITE_CURSOR_ADDR, 4);

// reset all data frames to zero
fram_frame_t emptyFrame = {0};
for(int i=0; i<MAX_FRAME_COUNT; i++) {
void* framDataAddr = FRAM_DATA_START_ADDR + (i * FRAM_DATA_FRAME_SIZE);
framWrite(&emptyFrame, framDataAddr, FRAM_DATA_FRAME_SIZE);
uint32_t framDataAddr = FRAM_DATA_START_ADDR + (i * FRAM_DATA_FRAME_SIZE);
framWrite((uint8_t*)&emptyFrame, framDataAddr, FRAM_DATA_FRAME_SIZE);
}
}
1 change: 0 additions & 1 deletion radsat-sk/operation/services/RTelecommandService.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* @return The tag of the processed telecommand (0 on failure).
*/
uint8_t telecommandHandle(uint8_t* wrappedMessage, uint8_t size) {
int error;

// ensure the input pointer is not NULL
if (wrappedMessage == 0)
Expand Down
21 changes: 14 additions & 7 deletions radsat-sk/operation/subsystems/RBattery.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ static int checkSafeFlag(uint8_t* safeFlag);
int batteryTelemetry(battery_status_t* dataStorage) {

// Create temporary variables for sending and receiving I2C data
uint8_t command[BATTERY_TELEM_COMMAND_LENGTH] = {0};
uint8_t response[BATTERY_RESPONSE_LENGTH] = {0};
uint8_t command[BATTERY_TELEM_COMMAND_LENGTH] = { 0 };
uint8_t response[BATTERY_RESPONSE_LENGTH] = { 0 };

// Create a temporary array for calculated voltage and current before transferring into the battery_status_t structure
float storedData[NUMBER_OF_CURRENT_COMMANDS] = {0};
float storedData[NUMBER_OF_CURRENT_COMMANDS] = { 0 };

// Create a temporary array for calculated temperatures before transferring into the battery_status_t structure
float storedTemperatureData[NUMBER_OF_TEMP_COMMANDS] = {0};
float storedTemperatureData[NUMBER_OF_TEMP_COMMANDS] = { 0 };


// Send 3 commands to get ADC output voltage readings from the Battery
Expand All @@ -153,7 +153,9 @@ int batteryTelemetry(battery_status_t* dataStorage) {
int error = batteryTalk(command, response);

if (error != SUCCESS){
return error;
debugPrint("Error = %d\n", error);
continue;
//return error;
}
memset(&storedData[i], 0, sizeof(storedData[i]));
memcpy(&storedData[i], response, BATTERY_RESPONSE_LENGTH);
Expand All @@ -175,7 +177,9 @@ int batteryTelemetry(battery_status_t* dataStorage) {
int error = batteryTalk(command, response);

if (error != SUCCESS) {
return error;
debugPrint("Error = %d\n", error);
continue;
//return error;
}

memset(&storedData[i], 0, sizeof(&storedData[i]));
Expand Down Expand Up @@ -205,8 +209,11 @@ int batteryTelemetry(battery_status_t* dataStorage) {
int error = batteryTalk(command, response);

if (error != SUCCESS) {
return error;
debugPrint("Error = %d\n", error);
continue;
//return error;
}
debugPrint("GTG\n");

memset(&storedTemperatureData[i], 0, sizeof(storedTemperatureData[i]));
memcpy(&storedTemperatureData[i], response, BATTERY_RESPONSE_LENGTH);
Expand Down
32 changes: 16 additions & 16 deletions radsat-sk/operation/subsystems/RDosimeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,24 @@ int16_t dosimeterTemperature(dosimeterBoard_t board) {

void printDosimeterData(dosimeter_data* data){

debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelZero );
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelOne );
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelTwo );
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelThree);
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelFour );
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelFive );
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelSix );
debugPrint("Dosimeter Voltage = %f\n", data->boardOne.channelSeven);
debugPrint("Board 1 Channel 1 = %f mv\n", data->boardOne.channelZero );
debugPrint("Board 1 Channel 2 = %f mv\n", data->boardOne.channelOne );
debugPrint("Board 1 Channel 3 = %f mv\n", data->boardOne.channelTwo );
debugPrint("Board 1 Channel 4 = %f mv\n", data->boardOne.channelThree);
debugPrint("Board 1 Channel 5 = %f mv\n", data->boardOne.channelFour );
debugPrint("Board 1 Channel 6 = %f mv\n", data->boardOne.channelFive );
debugPrint("Board 1 Channel 7 = %f mv\n", data->boardOne.channelSix );
debugPrint("Board 1 Channel 8 = %f C\n", data->boardOne.channelSeven);

// board two
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelZero );
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelOne );
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelTwo );
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelThree);
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelFour );
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelFive );
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelSix );
debugPrint("Dosimeter Voltage = %f\n", data->boardTwo.channelSeven);
debugPrint("Board 2 Channel 1 = %f mV\n", data->boardTwo.channelZero );
debugPrint("Board 2 Channel 2 = %f mV\n", data->boardTwo.channelOne );
debugPrint("Board 2 Channel 3 = %f mV\n", data->boardTwo.channelTwo );
debugPrint("Board 2 Channel 4 = %f mV\n", data->boardTwo.channelThree);
debugPrint("Board 2 Channel 5 = %f mV\n", data->boardTwo.channelFour );
debugPrint("Board 2 Channel 6 = %f mV\n", data->boardTwo.channelFive );
debugPrint("Board 2 Channel 7 = %f mV\n", data->boardTwo.channelSix );
debugPrint("Board 2 Channel 8 = %f C\n", data->boardTwo.channelSeven);
}


Expand Down
1 change: 1 addition & 0 deletions radsat-sk/operation/utility/RDebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void debugPrint(const char* stringFormat, ...) {
extern unsigned char debugReadIntMinMax(unsigned int *pValue, unsigned int min, unsigned int max) {
// input variable
char ascii_char;
*pValue = 0;

do {
// If there is a char waiting to get read from the debug uart buffer
Expand Down
Loading