Protective Stop
Loading...
Searching...
No Matches
pstop_application.h
1// SPDX-FileCopyrightText: 2026 Polymath Robotics, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef PSTOP_PSTOP_APPLICATION_H
5#define PSTOP_PSTOP_APPLICATION_H
6
7#include <stdint.h>
8#include <stdbool.h>
9
10#include "pstop/error.h"
11#include "pstop/device_id.h"
12#include "pstop/os.h"
13
15typedef enum {
16 PSTOP_STATUS_OK = 0,
17 PSTOP_STATUS_STOP = 1
18} pstop_status_message_t;
19
21typedef struct {
22
26 bool allowed;
27
31 uint64_t heartbeat_ms;
32
37
39
40void remote_detail_set(remote_details_t *oper, bool is_allowed, uint64_t heartbeat_ms, bool is_stop_only);
41
45void remote_detail_init(remote_details_t *oper);
46
57typedef remote_details_t (* get_remote_details_t)(const device_id_t *device_id);
58
64typedef void (* pstop_status_t)(pstop_status_message_t status);
65
74typedef void (* log_message_t)(uint64_t timestamp, const device_id_t *client, uint8_t message, pstop_error_t error);
75
79typedef struct {
80
86
92
98
100
136
137void pstop_application_init(pstop_application_t *app);
138
139void pstop_application_set_time_cb(pstop_application_t *app, get_current_time_t time_cb);
140
141void pstop_application_set_machine_id(pstop_application_t *app, const device_id_t *machine_id);
142
143void pstop_application_set_remote_cb(pstop_application_t *app, get_remote_details_t remote_cb);
144
145void pstop_application_set_hardware_status_cb(pstop_application_t *app, pstop_status_t status_cb);
146
147void pstop_application_set_log_cb(pstop_application_t *app, log_message_t log_cb);
148
149void pstop_application_set_protocol_limits(pstop_application_t *app,
150 uint16_t max_lost_messages, uint16_t max_missed_heartbeats, uint32_t stop_ok_delay_ms);
151
152#endif /* PSTOP_PSTOP_APPLICATION_H */
Identifier of a pstop device.
Definition device_id.h:12
Some configuration details.
Definition pstop_application.h:79
uint32_t delay_between_stop_ms
The minimum time (in milliseconds) between the stop and OK messages used for transitioning to OK afte...
Definition pstop_application.h:97
uint16_t max_lost_messages
The maximum number of messages that can be lost before the pstop library reports a client as lost and...
Definition pstop_application.h:85
uint16_t max_missed_heartbeats
The maximum number of heartbeat messages that can be lost before the library reports a client as lost...
Definition pstop_application.h:91
Callbacks and configuration supplied by the application.
Definition pstop_application.h:102
get_remote_details_t remote_details_cb
Callback to return details for a specified remote.
Definition pstop_application.h:120
pstop_application_config_t app_config
Limits for lost messages and heartbeats.
Definition pstop_application.h:133
device_id_t machine_device_id
The device ID for this machine.
Definition pstop_application.h:113
pstop_os_env_t env
An OS environment struct that contains a callback for getting the current time.
Definition pstop_application.h:108
pstop_status_t status_cb
Notifies the underlying hardware about the status of this PSTOP.
Definition pstop_application.h:125
log_message_t log_message_cb
Callback to log any errors in the system.
Definition pstop_application.h:130
This struct contains a callback function to return the current time in milliseconds.
Definition os.h:21
Per-remote settings returned by get_remote_details_t.
Definition pstop_application.h:21
bool allowed
Is this device_id allowed?
Definition pstop_application.h:26
uint64_t heartbeat_ms
The heartbeat time for this device_id in milliseconds.
Definition pstop_application.h:31
bool stop_only
Is this device_id a stop-only (can't transition to OK) operator?
Definition pstop_application.h:36