/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NVSENSOR_H #define NVSENSOR_H #include "NvsLog.h" #include "NvsClient.h" #include "NvsChInf.h" #include SENSORS_INCLUDE class NvSensor: public NvsLog { NvsClient *mNvsClnt; public: NvSensor(); virtual ~NvSensor(); /** * getSensors: Returns list of available sensors. * @ snsrs: pointer for the pointer to the sensor list * * Returns number of sensors in list on success or a negative * error code. * * It's the caller's responsibility to delete the sensor list returned. * If snsrs is NULL then just the sensor count is returned. */ int getSensors(struct sensor_t **snsrs); /** * clientOpen: Open a session with NVS. * @ clnts: pointer for the client handle * * Returns 0 on success or a negative error code. * The possible error codes: * -EINVAL = No nvsc pointer. * -EPERM = Fatal error. NVS is toast. * -EAGAIN = NVS is still initializing. * -EBUSY = NVS is encountering errors. This isn't good but it is possible * that another attempt at a later time may work. * -ENOMEM = There are system resource errors. * * The client handle placed at nvsc will be used on all subsequent function * calls with NVS. */ int clientOpen(void **clnts); /** * setSensorBatch: set sensor rate and timeout. * @ clnt: client handle * @ handle: sensor handle * @ nsPeriod: sensor period rate in nanoseconds * @ nsTimeout: sensor event timeout in nanoseconds * * Returns 0 on success or a negative error code. */ int setSensorBatch(void *clnt, int handle, int64_t nsPeriod, int64_t nsTimeout); /** * setSensorAble: EnAble/DisAble a sensor * @ clnt: client handle * @ handle: sensor handle * @ enable: TODO * * Returns 0 on success or a negative error code. */ int setSensorAble(void *clnt, int handle, int64_t enable); /** * setSensorFlush: Flush sensor events. * @ clnt: client handle * @ handle: sensor handle * * Returns 0 on success or a negative error code. */ int setSensorFlush(void *clnt, int handle); /** * getSensorEvent: polls for sensor events. * @ clnt: client handle * @ evnt: pointer to data buffer * @ nEvnt: number of events buffer can hold * @ msPoll: timeout in milliseconds call will return * * Returns number of events in data buffer on success or a * negative error code. */ int getSensorEvent(void *clnt, struct sensors_event_t *evnt, int nEvnt, int msPoll); /** * clientClose: Closes an open session with NVS. * @ clnt: client handle * * NOTE: clnt may be NULL for efficient code. */ void clientClose(void *clnt); /** * getChannelInfo: Returns list of sensor's data channels. * @ chInfs: pointer for the pointer to the channel list * * Returns number of data channels in list on success or a negative * error code. * * It's the caller's responsibility to delete the channel list returned. * If chInfs is NULL then just the channel count is returned. */ int getChannelInfo(struct NvsChannelInfo **chInfs, int handle); }; #endif /* NVSENSOR_H */