42 #include <px4_platform_common/px4_config.h> 44 #include <sys/types.h> 52 #include <px4_platform_common/getopt.h> 65 #include <board_config.h> 67 #include <isl29501/isl29501.hpp> 98 int _publish(
struct range_sensor_data &
data);
109 ISL29501(ISL_DEVICE_PATH),
110 _range_topic(nullptr),
111 _orb_class_instance(-1)
125 PX4_ERR(
"ISL init fail: %d", ret);
132 PX4_ERR(
"ISL start fail: %d", ret);
145 PX4_ERR(
"ISL stop fail: %d", ret);
156 memset(&d, 0,
sizeof(d));
166 d.
type = distance_sensor_s::MAV_DISTANCE_SENSOR_LASER;
203 if (g_dev ==
nullptr) {
204 PX4_ERR(
"failed instantiating DfISL29501Wrapper object");
208 int ret = g_dev->
start();
211 PX4_ERR(
"DfISL29501Wrapper start failed");
217 DevMgr::getHandle(ISL_DEVICE_PATH, h);
220 DF_LOG_INFO(
"Error: unable to obtain a valid handle for the receiver at: %s (%d)",
221 ISL_DEVICE_PATH, h.getError());
225 DevMgr::releaseHandle(h);
232 if (g_dev ==
nullptr) {
233 PX4_ERR(
"driver not running");
237 int ret = g_dev->
stop();
240 PX4_ERR(
"driver could not be stopped");
255 if (g_dev ==
nullptr) {
256 PX4_ERR(
"driver not running");
260 PX4_DEBUG(
"state @ %p", g_dev);
273 if (g_dev ==
nullptr) {
277 PX4_ERR(
"Failed to start");
282 ret = g_dev->probe();
285 PX4_ERR(
"Failed to probe");
289 PX4_DEBUG(
"state @ %p", g_dev);
306 if (g_dev ==
nullptr) {
310 PX4_ERR(
"Failed to start");
315 ret = g_dev->calibration();
318 PX4_ERR(
"Failed to calibrate");
322 PX4_DEBUG(
"state @ %p", g_dev);
331 PX4_WARN(
"Usage: df_isl_wrapper 'start', 'info', 'stop', 'calib', 'probe'");
348 const char *verb = argv[myoptind];
351 if (!strcmp(verb,
"start")) {
355 else if (!strcmp(verb,
"stop")) {
359 else if (!strcmp(verb,
"info")) {
363 else if (!strcmp(verb,
"probe")) {
367 else if (!strcmp(verb,
"calib")) {
API for the uORB lightweight object broker.
void usage(const char *reason)
Print the correct usage.
int _publish(struct range_sensor_data &data)
int stop()
Stop the driver.
High-resolution timer with callouts and timekeeping.
__EXPORT int df_isl29501_wrapper_main(int argc, char *argv[])
void usage()
Prints info about the driver argument usage.
orb_advert_t _range_topic
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
int calibration()
Calibration runs calibration routine for ISL29501 TODO: implement calibration user interface and para...
void init()
Activates/configures the hardware registers.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
int stop()
Stop automatic measurement.
int start()
Attempt to start driver on all available I2C busses.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
DfISL29501Wrapper * g_dev
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
int start()
Start automatic measurement.
int info()
Print a little info about the driver.
orb_advert_t orb_advertise_multi(const struct orb_metadata *meta, const void *data, int *instance, int priority)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
Performance measuring tools.