Date
1 - 4 of 4
system call
Henry Zhang
Hi folks,
I have a problem understanding how system call work. For example, system call
/*fetch sensor samples */
rc=sensor_sample_fetch(dev);
rc=sensor_sample_fetch(dev);
But I only see definition:
__syscall int sensor_sample_fetch(const struct device *dev);
__syscall int sensor_sample_fetch(const struct device *dev);
I could not see how sensor_sample_fetch(dev) handles the argument dev.
Any hint?
Thanks
----henry
Bolivar, Marti
toggle quoted message
Show quoted text
On Wed, Feb 08 2023, Henry Zhang via lists zephyrproject org wrote:
Hi folks,
I have a problem understanding how system call work. For example, system call
/*fetch sensor samples */
rc=sensor_sample_fetch(dev);
But I only see definition:
__syscall int sensor_sample_fetch(const struct device *dev);
I could not see how sensor_sample_fetch(dev) handles the argument dev.
Any hint?
Thanks
----henry
Hi Henry:
If you are just trying to understand how the sensor_sample_fetch() call works you can look at an example program that works with a sensor
https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/sensor/bmi270/src/main.c
In this example, after the sensor has been setup with the appropriate ranges and sample rates then the call to sensor_sample_fetch(dev) does all of the work of 'fetching' the samples from the sensor and bringing the sample data into the processor. This could take some time, and the call doesn't return until the data is ready (typically this takes a few milliseconds for several I2C or SPI transactions). This blocks the task that called sensor_sample_fetch() but all of the other tasks on the processor are running so your system isn't halted.
Once the sensor data is in the processor you can then call sensor_sample_get() to get the data that you just fetched into your task. sensor_sample_get() usually returns very quickly.
Hope this helps....
If you are just trying to understand how the sensor_sample_fetch() call works you can look at an example program that works with a sensor
https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/sensor/bmi270/src/main.c
In this example, after the sensor has been setup with the appropriate ranges and sample rates then the call to sensor_sample_fetch(dev) does all of the work of 'fetching' the samples from the sensor and bringing the sample data into the processor. This could take some time, and the call doesn't return until the data is ready (typically this takes a few milliseconds for several I2C or SPI transactions). This blocks the task that called sensor_sample_fetch() but all of the other tasks on the processor are running so your system isn't halted.
Once the sensor data is in the processor you can then call sensor_sample_get() to get the data that you just fetched into your task. sensor_sample_get() usually returns very quickly.
Hope this helps....
Henry Zhang
After compile sample,
west build -b esp32s2_saola samples/sensor/esp32_temp_sensor
it will create include/generated/sensor.h with detailed definition of sensor_sample_fetch().
See attached
---henry
On Thu, Feb 9, 2023 at 12:26 PM Lawrence King <lawrencek52@...> wrote:
Hi Henry:
If you are just trying to understand how the sensor_sample_fetch() call works you can look at an example program that works with a sensor
https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/sensor/bmi270/src/main.c
In this example, after the sensor has been setup with the appropriate ranges and sample rates then the call to sensor_sample_fetch(dev) does all of the work of 'fetching' the samples from the sensor and bringing the sample data into the processor. This could take some time, and the call doesn't return until the data is ready (typically this takes a few milliseconds for several I2C or SPI transactions). This blocks the task that called sensor_sample_fetch() but all of the other tasks on the processor are running so your system isn't halted.
Once the sensor data is in the processor you can then call sensor_sample_get() to get the data that you just fetched into your task. sensor_sample_get() usually returns very quickly.
Hope this helps....