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

Completed Onboarding Challenge #103

Closed
wants to merge 13 commits into from

Conversation

SeanZhang425
Copy link

Purpose

Onboarding

New Changes

Implemented temperature sensor driver function, thermal management task, and OS handler.

Testing

Passed all unit and integration tests

Copy link
Contributor

@Navtajh04 Navtajh04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of changes

lm75bd/lm75bd.c Outdated
Comment on lines 34 to 35
errCode = i2cSendTo(devAddr, writeBuf, 1);
RETURN_IF_ERROR_CODE(errCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines can be combined to just be RETURN_IF_ERROR_CODE(i2cSendTo(devAddr, writeBuf, 1);

lm75bd/lm75bd.c Outdated
// read temperature from sensor
uint8_t readBuf[2] = {0};
errCode = i2cReceiveFrom(devAddr, readBuf, 2);
RETURN_IF_ERROR_CODE(errCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

lm75bd/lm75bd.c Outdated

// set pointer register to 'temperature sensor'
uint8_t writeBuf[] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you know this should only be 1 uint8_t long, its best to explicitly initialize it to that size for readability

@@ -42,19 +42,43 @@ void initThermalSystemManager(lm75bd_config_t *config) {
}

error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) {
/* Send an event to the thermal manager queue */
if (event != NULL) {
if (xQueueSend(thermalMgrQueueHandle, (void *) event, (TickType_t) 0) == pdPASS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure that the queue has already been created



float temp;
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receive and check the event first before reading temp, since right now even if you don't receive a measure temp command you'll be reading the temperature

}

static void thermalMgr(void *pvParameters) {
/* Implement this task */
thermal_mgr_event_t eventBuf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general try to limit the scope of your variables to the smallest scope possible, so move this into the while block

Copy link
Contributor

@Navtajh04 Navtajh04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just 2 more quick changes

if (xQueueReceive(thermalMgrQueueHandle, &eventBuf, 10) == pdPASS) {
if (eventBuf.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) {
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp);
if (errCode == ERR_CODE_SUCCESS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to log the error if it was no successful

addTemperatureTelemetry(temp);
}
else if (eventBuf.type == THERMAL_MGR_EVENT_INTERRUPT_CMD) {
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if the function call was successful or not

Copy link
Contributor

@Navtajh04 Navtajh04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more quick change other than that looks good


return ERR_CODE_SUCCESS;
return ERR_CODE_INVALID_QUEUE_MSG;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the thermal mgr queue handle is null, then it makes more sense to return ERR_CODE_INVALID_STATE instead since we are in a state where we have not intitialized the queue yet and it's not related to the queue msg itself


return ERR_CODE_SUCCESS;
return ERR_CODE_INVALID_QUEUE_MSG;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note that when your doing multiple errror checks like this it's a lot cleaner to just use multiple if statements with early returns rather than a bunch of nested if statements. For example something like ```

if(errCodeCondition){
return ERR_CODE
}
if(otherPossibleError){
return OTHER_ERROR
}
// continue with the rest of the function knowing everything before was success without need an else statement

Copy link
Contributor

@Navtajh04 Navtajh04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a quick change

@@ -0,0 +1 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your integration test run looks wrong

@@ -42,19 +42,50 @@ void initThermalSystemManager(lm75bd_config_t *config) {
}

error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) {
/* Send an event to the thermal manager queue */

if (&thermalMgrQueueHandle != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be == NULL instead of !=, same for below

I don't know how this slipped sorry
Copy link
Contributor

@Navtajh04 Navtajh04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, ill add you to the github and then you can send me your email you I can add you to the notion and you can take a look through the FW task board and let me know a couple of tasks that interest you

@dgobalak dgobalak closed this Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants