IgH EtherCAT Master  1.7.0
fsm_mbox.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * Copyright (C) 2026 Florian Pose, Ingenieurgemeinschaft IgH
4 *
5 * This file is part of the IgH EtherCAT Master.
6 *
7 * The IgH EtherCAT Master is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2, as
9 * published by the Free Software Foundation.
10 *
11 * The IgH EtherCAT Master is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with the IgH EtherCAT Master; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 ****************************************************************************/
21
25
26/****************************************************************************/
27
28#ifndef __EC_FSM_MBOX_H__
29#define __EC_FSM_MBOX_H__
30
31#include "globals.h"
32#include "datagram.h"
33#include "mailbox.h"
34
35/****************************************************************************/
36
44
45/****************************************************************************/
46
47typedef struct ec_fsm_mbox ec_fsm_mbox_t;
48
73
74/****************************************************************************/
75
78
80 unsigned long, unsigned long);
83 ec_mbox_data_t *, unsigned long, unsigned long);
84
89
90/****************************************************************************/
91
92#endif
EtherCAT datagram structure.
void ec_fsm_mbox_clear(ec_fsm_mbox_t *fsm)
Destructor.
Definition fsm_mbox.c:64
void ec_fsm_mbox_receive(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data, unsigned long jiffies_start, unsigned long timeout_ms)
Starts waiting for a mailbox response.
Definition fsm_mbox.c:102
void ec_fsm_mbox_fetch_nosync(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data, unsigned long jiffies_start, unsigned long timeout_ms)
Starts a single mailbox fetch without a preceding check.
Definition fsm_mbox.c:140
void ec_fsm_mbox_poll(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data)
Starts a single mailbox check without waiting.
Definition fsm_mbox.c:123
int ec_fsm_mbox_exec(ec_fsm_mbox_t *fsm, ec_datagram_t *datagram)
Executes the current state of the state machine.
Definition fsm_mbox.c:161
int ec_fsm_mbox_holds_lock(const ec_fsm_mbox_t *fsm)
Checks, if the state machine holds the slave's mailbox read lock.
Definition fsm_mbox.c:208
int ec_fsm_mbox_result(const ec_fsm_mbox_t *fsm)
Returns the result of the terminated state machine.
Definition fsm_mbox.c:195
void ec_fsm_mbox_abort(ec_fsm_mbox_t *fsm)
Aborts the state machine and releases the mailbox read lock, if held.
Definition fsm_mbox.c:220
void ec_fsm_mbox_init(ec_fsm_mbox_t *fsm)
Constructor.
Definition fsm_mbox.c:45
ec_fsm_mbox_mode_t
Mode of the mailbox receive state machine.
Definition fsm_mbox.h:39
@ EC_FSM_MBOX_NOSYNC
Fetch the mailbox once without checking it.
Definition fsm_mbox.h:42
@ EC_FSM_MBOX_WAIT
Wait for a response until the timeout elapsed.
Definition fsm_mbox.h:40
@ EC_FSM_MBOX_POLL
Check the mailbox once, do not wait.
Definition fsm_mbox.h:41
struct ec_fsm_mbox ec_fsm_mbox_t
Definition fsm_mbox.h:47
Global definitions and macros.
struct ec_slave ec_slave_t
Definition globals.h:315
Mailbox functionality.
EtherCAT datagram.
Definition datagram.h:81
EtherCAT mailbox receive state machine.
Definition fsm_mbox.h:62
ec_fsm_mbox_mode_t mode
Receive mode.
Definition fsm_mbox.h:65
void(*) state(ec_fsm_mbox_t *, ec_datagram_t *)
State function.
Definition fsm_mbox.h:68
unsigned int retries
Retries upon datagram timeout.
Definition fsm_mbox.h:70
ec_slave_t * slave
Slave the FSM runs on.
Definition fsm_mbox.h:63
ec_mbox_data_t * mbox_data
Response buffer of the protocol.
Definition fsm_mbox.h:64
int result
Zero on success, otherwise a negative error code.
Definition fsm_mbox.h:71
unsigned long jiffies_start
Reference time for the timeout.
Definition fsm_mbox.h:66
ec_datagram_t * datagram
Datagram used in the last step.
Definition fsm_mbox.h:69
unsigned long timeout_ms
Response timeout in [ms].
Definition fsm_mbox.h:67
EtherCAT mailbox response data.
Definition mailbox.h:58