36 #include <mathlib/mathlib.h> 37 #include <px4_platform_common/getopt.h> 82 unsigned num_control_groups_updated)
86 return num_control_groups_updated > 0;
135 *(uint32_t *)arg = 9999;
139 *(uint32_t *)arg = 9999;
143 *(uint32_t *)arg = 0;
205 *(uint32_t *)arg = (1 << channel);
218 const char *buf = (
const char *)arg;
219 unsigned buflen = strlen(buf);
238 bool hil_mode =
false;
242 const char *myoptarg =
nullptr;
244 while ((ch = px4_getopt(argc, argv,
"m:", &myoptind, &myoptarg)) != EOF) {
247 hil_mode = strcmp(myoptarg,
"hil") == 0;
258 PX4_ERR(
"alloc failed");
262 _object.store(instance);
263 _task_id = task_id_is_work_queue;
264 instance->ScheduleNow();
282 PX4_WARN(
"%s\n", reason);
285 PRINT_MODULE_DESCRIPTION(
288 Driver for simulated PWM outputs. 290 Its only function is to take `actuator_control` uORB messages, 291 mix them with any loaded mixer and output the result to the 292 `actuator_output` uORB topic. 294 It is used in SITL and HITL. 298 PRINT_MODULE_USAGE_NAME("pwm_out_sim",
"driver");
299 PRINT_MODULE_USAGE_COMMAND_DESCR(
"start",
"Start the module");
300 PRINT_MODULE_USAGE_PARAM_STRING(
'm',
"sim",
"hil|sim",
"Mode",
true);
301 PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
#define PWM_SERVO_GET_SELECT_UPDATE_RATE
check the selected update rates
#define MIXERIOCLOADBUF
Add mixer(s) from the buffer in (const char *)arg.
static constexpr uint16_t PWM_SIM_PWM_MIN_MAGIC
#define PWM_SERVO_GET_COUNT
get the number of servos in *(unsigned *)arg
#define PWM_SERVO_ARM
arm all servo outputs handle by this driver
static int print_usage(const char *reason=nullptr)
int main(int argc, char **argv)
void lock()
Take the driver lock.
PWMSim(bool hil_mode_enabled)
int ioctl(device::file_t *filp, int cmd, unsigned long arg) override
Perform an ioctl operation on the device.
#define PWM_SERVO_GET_UPDATE_RATE
get alternate servo update rate
#define PWM_SERVO_GET_DISARMED_PWM
get the PWM value when disarmed
bool update()
Call this regularly from Run().
__EXPORT int pwm_out_sim_main(int argc, char *argv[])
static constexpr uint16_t PWM_SIM_PWM_MAX_MAGIC
bool updateSubscriptions(bool allow_wq_switch)
Check for subscription updates (e.g.
#define PWM_SERVO_SET_SELECT_UPDATE_RATE
selects servo update rates, one bit per servo.
static constexpr int MAX_ACTUATORS
void setIgnoreLockdown(bool ignore_lockdown)
static int custom_command(int argc, char *argv[])
static constexpr uint16_t PWM_SIM_DISARMED_MAGIC
#define PWM_SERVO_GET_DEFAULT_UPDATE_RATE
get default servo update rate
#define PWM_OUTPUT0_DEVICE_PATH
uint16_t values[PWM_OUTPUT_MAX_CHANNELS]
uint16_t & maxValue(int index)
void init()
Activates/configures the hardware registers.
MixingOutput _mixing_output
static int task_spawn(int argc, char *argv[])
int print_status() override
void setAllFailsafeValues(uint16_t value)
void resetMixerThreadSafe()
Reset (unload) the complete mixer, called from another thread.
#define PWM_SERVO_GET_TRIM_PWM
get the TRIM value the output will send
#define PWM_OUTPUT_MAX_CHANNELS
bool updated()
Check if there is a new update.
Base class for an output module.
#define PWM_SERVO_GET_RATEGROUP(_n)
get the _n'th rate group's channels; *(uint32_t *)arg returns a bitmap of channels whose update rates...
int loadMixerThreadSafe(const char *buf, unsigned len)
Load (append) a new mixer from a buffer, called from another thread.
#define PWM_SERVO_SET_MIN_PWM
set the minimum PWM value the output will send
uORB::Subscription _parameter_update_sub
#define MIXERIOCRESET
reset (clear) the mixer configuration
bool updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], unsigned num_outputs, unsigned num_control_groups_updated) override
Callback to update the (physical) actuator outputs in the driver.
void setAllMaxValues(uint16_t value)
#define PWM_SERVO_SET_MAX_PWM
set the maximum PWM value the output will send
uint16_t & disarmedValue(int index)
Disarmed values: disarmedValue < minValue needs to hold.
#define PWM_SERVO_GET_MIN_PWM
get the minimum PWM value the output will send
void setAllDisarmedValues(uint16_t value)
uint16_t & minValue(int index)
static constexpr uint16_t PWM_SIM_FAILSAFE_MAGIC
void unregister()
unregister uORB subscription callbacks
void unlock()
Release the driver lock.
#define PWM_SERVO_GET_FAILSAFE_PWM
get the PWM value for failsafe
bool copy(void *dst)
Copy the struct.
#define PWM_SERVO_DISARM
disarm all servo outputs (stop generating pulses)
uint16_t & failsafeValue(int index)
#define PWM_SERVO_GET_MAX_PWM
get the maximum PWM value the output will send
#define PWM_SERVO_SET_UPDATE_RATE
set alternate servo update rate
void setAllMinValues(uint16_t value)