mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
POSIX: Added sleep command
The baro was not fully initialized when the sensors module tried to open it. Added a sleep command and a sleep 2 to rc.S so the baro is initialized by the time the sensors module tried to read it. Fixed other noisy errors Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -48,6 +48,7 @@ print """
|
|||||||
|
|
||||||
#include <px4_tasks.h>
|
#include <px4_tasks.h>
|
||||||
#include <px4_posix.h>
|
#include <px4_posix.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ static int list_tasks_main(int argc, char *argv[]);
|
|||||||
static int list_files_main(int argc, char *argv[]);
|
static int list_files_main(int argc, char *argv[]);
|
||||||
static int list_devices_main(int argc, char *argv[]);
|
static int list_devices_main(int argc, char *argv[]);
|
||||||
static int list_topics_main(int argc, char *argv[]);
|
static int list_topics_main(int argc, char *argv[]);
|
||||||
|
static int sleep_main(int argc, char *argv[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ print '\tapps["list_tasks"] = list_tasks_main;'
|
|||||||
print '\tapps["list_files"] = list_files_main;'
|
print '\tapps["list_files"] = list_files_main;'
|
||||||
print '\tapps["list_devices"] = list_devices_main;'
|
print '\tapps["list_devices"] = list_devices_main;'
|
||||||
print '\tapps["list_topics"] = list_topics_main;'
|
print '\tapps["list_topics"] = list_topics_main;'
|
||||||
|
print '\tapps["sleep"] = sleep_main;'
|
||||||
print """
|
print """
|
||||||
return apps;
|
return apps;
|
||||||
}
|
}
|
||||||
@@ -122,5 +125,14 @@ static int list_files_main(int argc, char *argv[])
|
|||||||
px4_show_files();
|
px4_show_files();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int sleep_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc != 2) {
|
||||||
|
cout << "Usage: sleep <seconds>" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sleep(atoi(argv[1]));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#
|
#
|
||||||
MODULES += drivers/device
|
MODULES += drivers/device
|
||||||
MODULES += drivers/blinkm
|
MODULES += drivers/blinkm
|
||||||
|
MODULES += drivers/buzzer
|
||||||
MODULES += drivers/hil
|
MODULES += drivers/hil
|
||||||
MODULES += drivers/rgbled
|
MODULES += drivers/rgbled
|
||||||
MODULES += drivers/led
|
MODULES += drivers/led
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
uorb start
|
uorb start
|
||||||
simulator start -s
|
simulator start -s
|
||||||
|
sleep 2
|
||||||
barosim start
|
barosim start
|
||||||
adcsim start
|
adcsim start
|
||||||
accelsim start
|
accelsim start
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ I2C::I2C(const char *name,
|
|||||||
_address(address),
|
_address(address),
|
||||||
_fd(-1)
|
_fd(-1)
|
||||||
{
|
{
|
||||||
warnx("I2C::I2C name = %s devname = %s", name, devname);
|
//warnx("I2C::I2C name = %s devname = %s", name, devname);
|
||||||
// fill in _device_id fields for a I2C device
|
// fill in _device_id fields for a I2C device
|
||||||
_device_id.devid_s.bus_type = DeviceBusType_I2C;
|
_device_id.devid_s.bus_type = DeviceBusType_I2C;
|
||||||
_device_id.devid_s.bus = bus;
|
_device_id.devid_s.bus = bus;
|
||||||
|
|||||||
@@ -868,7 +868,7 @@ Sensors::parameters_update()
|
|||||||
barofd = px4_open(BARO0_DEVICE_PATH, 0);
|
barofd = px4_open(BARO0_DEVICE_PATH, 0);
|
||||||
|
|
||||||
if (barofd < 0) {
|
if (barofd < 0) {
|
||||||
warnx("ERROR: no barometer foundon %s", BARO0_DEVICE_PATH);
|
warnx("ERROR: no barometer found on %s", BARO0_DEVICE_PATH);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -774,7 +774,7 @@ ACCELSIM::mag_ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
unsigned period = 1000000 / arg;
|
unsigned period = 1000000 / arg;
|
||||||
|
|
||||||
/* check against maximum sane rate (1ms) */
|
/* check against maximum sane rate (1ms) */
|
||||||
if (period < 1000)
|
if (period < 10000)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* update interval for next measurement */
|
/* update interval for next measurement */
|
||||||
@@ -961,11 +961,10 @@ ACCELSIM::start()
|
|||||||
//PX4_INFO("ACCELSIM::start accel %u", _call_accel_interval);
|
//PX4_INFO("ACCELSIM::start accel %u", _call_accel_interval);
|
||||||
hrt_call_every(&_accel_call, 1000, _call_accel_interval, (hrt_callout)&ACCELSIM::measure_trampoline, this);
|
hrt_call_every(&_accel_call, 1000, _call_accel_interval, (hrt_callout)&ACCELSIM::measure_trampoline, this);
|
||||||
|
|
||||||
|
// There is a race here where SENSORIOCSPOLLRATE on the accel starts polling of mag but _call_mag_interval is 0
|
||||||
// There is a race here where SENSORIOCSPOLLRATE on the accel starts polling of mag but mag period is set to 0
|
|
||||||
if (_call_mag_interval == 0) {
|
if (_call_mag_interval == 0) {
|
||||||
PX4_ERR("_call_mag_interval uninitilized - would have set period delay of 0");
|
//PX4_INFO("_call_mag_interval uninitilized - would have set period delay of 0");
|
||||||
_call_mag_interval = 1000;
|
_call_mag_interval = 10000; // Max 100Hz
|
||||||
}
|
}
|
||||||
|
|
||||||
//PX4_INFO("ACCELSIM::start mag %u", _call_mag_interval);
|
//PX4_INFO("ACCELSIM::start mag %u", _call_mag_interval);
|
||||||
|
|||||||
@@ -466,6 +466,9 @@ GYROSIM::GYROSIM(const char *path_accel, const char *path_gyro, enum Rotation ro
|
|||||||
// disable debug() calls
|
// disable debug() calls
|
||||||
_debug_enabled = false;
|
_debug_enabled = false;
|
||||||
|
|
||||||
|
// Don't publish until initialized
|
||||||
|
_pub_blocked = true;
|
||||||
|
|
||||||
_device_id.devid_s.devtype = DRV_ACC_DEVTYPE_GYROSIM;
|
_device_id.devid_s.devtype = DRV_ACC_DEVTYPE_GYROSIM;
|
||||||
|
|
||||||
/* Prime _gyro with parents devid. */
|
/* Prime _gyro with parents devid. */
|
||||||
@@ -588,6 +591,9 @@ GYROSIM::init()
|
|||||||
if (_accel_topic == nullptr) {
|
if (_accel_topic == nullptr) {
|
||||||
PX4_WARN("ADVERT FAIL");
|
PX4_WARN("ADVERT FAIL");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
_pub_blocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* advertise sensor topic, measure manually to initialize valid report */
|
/* advertise sensor topic, measure manually to initialize valid report */
|
||||||
|
|||||||
Reference in New Issue
Block a user