You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
#include "slaveconfig.h"
|
|
#include <stdio.h>
|
|
|
|
|
|
/*!
|
|
* @brief Prints the state in which the Slave is and also give basic infomations about that state.
|
|
* @param uint16_t state is the state flag of the slave which will be masked to ist 8 LSB's
|
|
* @link https://infosys.beckhoff.com/english.php?content=../content/1033/ethercatsystem/1036980875.html&id=
|
|
* @return void
|
|
* */
|
|
void printState(uint16_t state)
|
|
{
|
|
uint8_t state_masked = state & 0x0F; // Mask first byte
|
|
|
|
switch (state_masked) {
|
|
case EC_STATE_INIT:
|
|
printf("State: INIT (0x%02X) - No communication yet.\n", state_masked);
|
|
break;
|
|
|
|
case EC_STATE_PRE_OP:
|
|
printf("State: PRE-OP (0x%02X) - Configuration possible.\n", state_masked);
|
|
break;
|
|
|
|
case EC_STATE_SAFE_OP:
|
|
printf("State: SAFE-OP (0x%02X) - Inputs work, outputs disabled.\n", state_masked);
|
|
break;
|
|
|
|
case EC_STATE_OPERATIONAL:
|
|
printf("State: OPERATIONAL (0x%02X) - Fully active.\n", state_masked);
|
|
break;
|
|
|
|
case EC_STATE_BOOT:
|
|
printf("State: BOOTSTRAP (0x%02X) - Firmware update mode.\n", state_masked);
|
|
break;
|
|
|
|
default:
|
|
printf("State: UNKNOWN STATE (0x%02X)\n", state_masked);
|
|
break;
|
|
}
|
|
}
|