xiaoxiang781216 commented on a change in pull request #2369: URL: https://github.com/apache/incubator-nuttx/pull/2369#discussion_r528356173
########## File path: drivers/sensors/sensor.c ########## @@ -651,22 +682,22 @@ int sensor_register(FAR struct sensor_lowerhalf_s *lower, int devno) { if (!lower->buffer_size) { - lower->buffer_size = g_sensor_info[lower->type].esize; + lower->buffer_size = esize; + } + else + { + lower->buffer_size = ROUNDUP(lower->buffer_size, esize); } lower->push_event = sensor_push_event; } else { lower->notify_event = sensor_notify_event; + lower->buffer_size = 0; Review comment: The buffer size(buffer_size) is different from the element size(esize) since the sensor lower half normally generate the structural data stream. For examples, the custom sensor could define: ``` struct custem_event_s { uint64_t timestamp; int16_t adc[8]; }; struct sensor_lowerhalf_s g_lower = { .buffer_size = 1024, }; sensor_custom_register(lower, "/dev/sensor/custom0", sizeof(struct custem_event_s)); ``` So buffer_size is 1024B and esize is 16B. Of course, the custom driver could pass 1 as esize if the driver generate the pure byte stream or variable size structural data. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org