rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_cmd.h File Reference

A command of the SERVO screen as the panel's servo link takes it (servo_link.h), and what the link reports back: the frame rate's state, a pause let go of and where a sweep started. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  servo_cmd_t
 A command of the SERVO screen, as the servo link takes it. More...
struct  servo_pause_end_t
 A pause the panel has let go of, for servo_cmd_stale(). More...

Enumerations

enum  servo_cmd_kind_t {
  SERVO_CMD_NONE = 0 , SERVO_CMD_POSITION , SERVO_CMD_CENTRE , SERVO_CMD_RELEASE ,
  SERVO_CMD_ARM , SERVO_CMD_DISARM , SERVO_CMD_SWEEP , SERVO_CMD_HOLD
}
 The kind of a command of the SERVO screen. More...
enum  servo_rate_state_t {
  SERVO_RATE_UNSENT = 0 , SERVO_RATE_IN_FORCE , SERVO_RATE_REFUSED , SERVO_RATE_UNSUPPORTED ,
  SERVO_RATE_IN_FORCE_SURFACES
}
 What became of a frame rate the panel wrote to the SERVO page. More...
enum  servo_sweep_from_t { SERVO_SWEEP_FROM_REST , SERVO_SWEEP_FROM_HERE , SERVO_SWEEP_FROM_FROZEN , SERVO_SWEEP_RESUMED }
 Where the IOmcu's output was when it started a sweep. More...

Functions

servo_rate_state_t servo_rate_in_force (uint16_t minor)
 The state an acknowledged rate is shown in, by the IOmcu's protocol minor minor: SERVO_RATE_IN_FORCE from LINK_MINOR_SERVO_TARGET_RATE (4.19), where the rate reaches the PWM TARGET alone, and SERVO_RATE_IN_FORCE_SURFACES below it.
bool servo_cmd_survives_link_loss (const servo_cmd_t *c)
 Whether a command kept to be said again may still be said after the link has gone and come back.
uint16_t servo_cmd_pause_root (const servo_cmd_t *c)
 The pause a HOLD c ends when the panel lets it go: the pause its chain rests on (from_pause) when it was posted before an earlier pause's resume was acknowledged, and otherwise its own.
bool servo_cmd_stale (servo_pause_end_t *e, const servo_cmd_t *c)
 Whether the drive command c (a position, a centre, a sweep or a hold) was asked during the pause e records as let go of, so is stale and is not to be sent: the screen has ended that pause, and the command would hold or move the servo somewhere it no longer shows.

Detailed Description

A command of the SERVO screen as the panel's servo link takes it (servo_link.h), and what the link reports back: the frame rate's state, a pause let go of and where a sweep started.

Below the screen, so the link module in shared/outputs takes the types without the screen's header. servo_screen.h includes it.

SPDX-License-Identifier: MIT

Enumeration Type Documentation

◆ servo_cmd_kind_t

The kind of a command of the SERVO screen.

Enumerator
SERVO_CMD_NONE 

no command

SERVO_CMD_POSITION 

value is the pulse width in microseconds

SERVO_CMD_CENTRE 

centre the surfaces

SERVO_CMD_RELEASE 

Let go of the output: the surfaces the bench drives return to centre, which is where a surface rests. The pins stay bound to what the OUTPUTS screen bound them to; this screen commands channels and owns no wiring of its own.

SERVO_CMD_ARM 

the two-second hold, as on MOTOR & ESC

SERVO_CMD_DISARM 

Let go of the output and disarm.

One command rather than two, because leaving the screen has to do both and a screen that can only post one of them would leave a pin bound behind a bench it had just disarmed.

SERVO_CMD_SWEEP 

Drive the surfaces through the curve in sweep_*, on the IOmcu. Repeated while it runs, which keeps it running; any other command stops it.

SERVO_CMD_HOLD 

Stop a sweep and hold every surface where its output is, which only the IOmcu knows exactly. Repeated while held; any other command ends it.

◆ servo_rate_state_t

What became of a frame rate the panel wrote to the SERVO page.

Enumerator
SERVO_RATE_UNSENT 

not written yet: it goes with a position

SERVO_RATE_IN_FORCE 

the target the IOmcu holds runs at it (servo_in_force_note())

SERVO_RATE_REFUSED 

a pulse longer than the frame, or a pin sharing a PWM slice with an output at another rate; the pins kept theirs

SERVO_RATE_UNSUPPORTED 

the IOmcu has no SERVO page: protocol 4.0 runs each slot at its binding's rate

SERVO_RATE_IN_FORCE_SURFACES 

every PWM surface runs at it, whatever the target: protocol 4.1 to 4.18

◆ servo_sweep_from_t

Where the IOmcu's output was when it started a sweep.

Enumerator
SERVO_SWEEP_FROM_REST 

where it was held before the sweep

SERVO_SWEEP_FROM_HERE 

carrying on: a changed curve

SERVO_SWEEP_FROM_FROZEN 

where it froze when the sweep went unrepeated, frozen_ago_ms ago

SERVO_SWEEP_RESUMED 

where it was held: the paused sweep carried on from its phase; age_ms is the age of the curve's phase 0, moved on by the hold (servo_phase_resumed())

Function Documentation

◆ servo_cmd_pause_root()

uint16_t servo_cmd_pause_root ( const servo_cmd_t * c)

The pause a HOLD c ends when the panel lets it go: the pause its chain rests on (from_pause) when it was posted before an earlier pause's resume was acknowledged, and otherwise its own.

What the panel records for servo_cmd_stale() and hands to servo_screen_released().

Parameters
cThe command to test. NULL is refused.
Returns
The pause sequence number the command rests on, from_pause when it is set and pause_seq otherwise. 0 for NULL.

◆ servo_cmd_stale()

bool servo_cmd_stale ( servo_pause_end_t * e,
const servo_cmd_t * c )

Whether the drive command c (a position, a centre, a sweep or a hold) was asked during the pause e records as let go of, so is stale and is not to be sent: the screen has ended that pause, and the command would hold or move the servo somewhere it no longer shows.

The screen asks nothing more of a pause it has left, and commands keep their order, so the first drive command from after the pause retires e; a pause number reused after 65535 more is then not mistaken for it.

Parameters
eThe pause record. Cleared (on = false) when c is a drive command that is not stale. Not changed when c is stale or is not a drive command.
cThe command to test.
Returns
true when c is stale and must not be sent, false otherwise, including when e or c is NULL or e is off.

◆ servo_cmd_survives_link_loss()

bool servo_cmd_survives_link_loss ( const servo_cmd_t * c)

Whether a command kept to be said again may still be said after the link has gone and come back.

A sweep or a hold may not: both end with the link, on the screen and at the far end, and said again they would start motion nobody asked for. A position is what the screen still shows.

Parameters
cThe command to test. NULL is refused.
Returns
true for any kind other than a sweep or a hold, including NONE; false for a sweep, a hold and NULL.

◆ servo_rate_in_force()

servo_rate_state_t servo_rate_in_force ( uint16_t minor)

The state an acknowledged rate is shown in, by the IOmcu's protocol minor minor: SERVO_RATE_IN_FORCE from LINK_MINOR_SERVO_TARGET_RATE (4.19), where the rate reaches the PWM TARGET alone, and SERVO_RATE_IN_FORCE_SURFACES below it.

Parameters
minorIOmcu protocol minor version, as acknowledged.
Returns
SERVO_RATE_IN_FORCE for minor at 4.19 or above, SERVO_RATE_IN_FORCE_SURFACES below it. No other state is returned.