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

Gas sensor firmware update #733

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

divkam
Copy link
Contributor

@divkam divkam commented Feb 2, 2017

  • added commands to read gas sensor firmware version, status register, error register
  • command line support to test firmware update
  • periodic upload of gas sensor firmware version as part of periodic protobuf (Fields for gas sensor fw update proto#145)


assert(xSemaphoreTakeRecursive(i2c_smphr, 30000));

(I2C_IF_Write(tvoc_i2c_addr, i2c_payload, 9, 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

use the number of bytes read in, in case it's less than the i2c payload size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the payload size has to be 9 though. if the bytes read is less, it breaks out of the loop


res = hello_fs_read(&fp,&i2c_payload[1],bytes_to_read, &bytes_read);
}
LOGI("TV: program done. Bytes read: %d, res:%d\n", bytes_read, res);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe LOGE if bytes_read != bytes_to_read

(I2C_IF_Write(tvoc_i2c_addr, erase_cmd, 5, 1));
xSemaphoreGiveRecursive(i2c_smphr);

vTaskDelay(500);
Copy link
Contributor

Choose a reason for hiding this comment

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

How much margin does this give?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

500ms delay is as recommended in the datasheet. The entire programming takes 3-5 seconds.

LOGI("TVOC FW Filename:%s\n",bin_file);

// reset CCS811
if(_tvoc_reset()){
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be better to get the I2C semaphore here and hold it for the entire process. The lock can still be left within the private functions in case they are called independently.

What happens if it is acquired for one step but not others?

bool tvoc_wa = false;
uint8_t tvoc_i2c_addr = 0x5A;
int init_tvoc(int measmode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a check here in case the device has been put into a bad state by the update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, will do. thanks

- removed status register read before boot since the register contents
are garbage
- added check for app valid. if sensor is in a bad state after a fw
update, the status register read after boot will indicate the same
- use Uartprintf instead of LOGI because init_tvoc is called before uart
logger init
@divkam divkam changed the title Gas sensor version periodic upload Gas sensor firmware update Feb 6, 2017
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.

2 participants