-
Notifications
You must be signed in to change notification settings - Fork 89
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
1-wire: add 1-wire bus driver #171
1-wire: add 1-wire bus driver #171
Conversation
ESP_RETURN_ON_FALSE(onewire_crc8(0, iter->rom_number, 7) == iter->rom_number[7], ESP_ERR_INVALID_CRC, TAG, "bad device crc"); | ||
|
||
// save the ROM number as the device address | ||
memcpy(&dev->address, iter->rom_number, sizeof(onewire_device_address_t)); |
Check warning
Code scanning / clang-tidy
Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
|
||
// transmit one bits to generate read clock | ||
uint8_t tx_buffer[rx_buf_size]; | ||
memset(tx_buffer, 0xFF, rx_buf_size); |
Check warning
Code scanning / clang-tidy
Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left few question/comments, otherwise LGTM!
You also mentioned setting up a runner in espressif/esp-idf#10790 (comment) , do you plan to connect the runner to esp-idf or in idf-extra-components?
9e35247
to
1fd3156
Compare
onewire_bus_rmt_obj_t *bus_rmt = __containerof(bus, onewire_bus_rmt_obj_t, base); | ||
esp_err_t ret = ESP_OK; | ||
ESP_RETURN_ON_FALSE(rx_buf_size <= bus_rmt->max_rx_bytes, ESP_ERR_INVALID_ARG, TAG, "rx_buf_size too large for buffer to hold"); | ||
memset(rx_buf, 0, rx_buf_size); |
Check warning
Code scanning / clang-tidy
Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
Added onewire_bus library based on RMT peripheral driver. Previously this library was located in the esp-idf's example: https://github.com/espressif/esp-idf/tree/master/examples/peripherals/rmt/onewire_ds18b20/components/onewire_bus
Now I have refactored that, and split it into multiple parts: bus, device and other helper functions (e.g. CRC).
As the one-wire bus implementation can be various, so added an interface to abstract the bus behavior. Easy to extend with other backend peripherals.
Fixed an issue that reported in espressif/esp-idf#10790
examples and doc will be added in the later PR(s).
device driver like "ds18b20" will go into esp-bsp repo, after this PR got merged.