mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
C2: Add EthernetStatusMessage
This commit is contained in:
committed by
Kyle Schwarz
parent
d86e3164af
commit
9d91524dc0
@@ -4,37 +4,41 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include "icsneo/icsneoc2types.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class EthernetStatusMessage : public Message {
|
||||
class EthernetStatusMessage : public RawMessage {
|
||||
public:
|
||||
enum class LinkSpeed {
|
||||
LinkSpeedAuto,
|
||||
LinkSpeed10,
|
||||
LinkSpeed100,
|
||||
LinkSpeed1000,
|
||||
LinkSpeed2500,
|
||||
LinkSpeed5000,
|
||||
LinkSpeed10000,
|
||||
enum class LinkSpeed: icsneoc2_link_speed_t {
|
||||
LinkSpeedAuto = icsneoc2_link_speed_auto,
|
||||
LinkSpeed10 = icsneoc2_link_speed_10mbps,
|
||||
LinkSpeed100 = icsneoc2_link_speed_100mbps,
|
||||
LinkSpeed1000 = icsneoc2_link_speed_1000mbps,
|
||||
LinkSpeed2500 = icsneoc2_link_speed_2500mbps,
|
||||
LinkSpeed5000 = icsneoc2_link_speed_5000mbps,
|
||||
LinkSpeed10000 = icsneoc2_link_speed_10000mbps,
|
||||
};
|
||||
enum class LinkMode {
|
||||
LinkModeAuto,
|
||||
LinkModeMaster,
|
||||
LinkModeSlave,
|
||||
LinkModeInvalid,
|
||||
LinkModeNone,
|
||||
enum class LinkMode: icsneoc2_link_mode_t {
|
||||
LinkModeAuto = icsneoc2_link_mode_auto,
|
||||
LinkModeMaster = icsneoc2_link_mode_master,
|
||||
LinkModeSlave = icsneoc2_link_mode_slave,
|
||||
LinkModeInvalid = icsneoc2_link_mode_invalid,
|
||||
LinkModeNone = icsneoc2_link_mode_none,
|
||||
};
|
||||
EthernetStatusMessage(Network net, bool state, LinkSpeed speed, bool duplex, LinkMode mode) : Message(Type::EthernetStatus),
|
||||
network(net), state(state), speed(speed), duplex(duplex), mode(mode) {}
|
||||
Network network;
|
||||
|
||||
EthernetStatusMessage(Network net, bool state, LinkSpeed speed, bool duplex, LinkMode mode) : RawMessage(Type::EthernetStatus, net),
|
||||
state(state), speed(speed), duplex(duplex), mode(mode) {}
|
||||
// Link State: False = Link Down, True = Link Up
|
||||
bool state;
|
||||
LinkSpeed speed;
|
||||
// Duplex: False = Half, True = Full
|
||||
bool duplex;
|
||||
LinkMode mode;
|
||||
static std::shared_ptr<Message> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
|
||||
static std::shared_ptr<RawMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
};
|
||||
|
||||
}; // namespace icsneo
|
||||
|
||||
@@ -298,10 +298,32 @@ icsneoc2_error_t icsneoc2_message_eth_t1s_props_get(icsneoc2_message_t* message,
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_message_is_ethernet(icsneoc2_message_t* message, bool* is_ethernet);
|
||||
|
||||
/**
|
||||
* Check if a message is an Ethernet status message
|
||||
*
|
||||
* @param[in] message The message to check.
|
||||
* @param[out] is_ethernet_status Pointer to a bool to copy the Ethernet status of the message into.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_message_is_ethernet_status(icsneoc2_message_t* message, bool* is_ethernet_status);
|
||||
|
||||
/**
|
||||
* Get the Ethernet status properties from an Ethernet status message
|
||||
*
|
||||
* @param[in] message The message to check.
|
||||
* @param[out] link_state Pointer to a bool to copy the link state into. True if the link is up, false if it's down. If NULL, it's ignored.
|
||||
* @param[out] duplex Pointer to a bool to copy the duplex state into. True if the link is full duplex, false if it's half duplex. If NULL, it's ignored.
|
||||
* @param[out] link_speed Pointer to a icsneoc2_link_speed_t to copy the link speed into. If NULL, it's ignored.
|
||||
* @param[out] link_mode Pointer to a icsneoc2_link_mode_t to copy the link mode into. If NULL, it's ignored.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters, icsneoc2_error_invalid_type otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_message_eth_status_props_get(icsneoc2_message_t* message, bool* link_state, bool* duplex, icsneoc2_link_speed_t* link_speed, icsneoc2_link_mode_t* link_mode);
|
||||
|
||||
/**
|
||||
* Check if a message is valid
|
||||
*
|
||||
* @param[in] device The device to check against.
|
||||
* @param[in] message The message to check.
|
||||
* @param[out] is_valid Pointer to a bool to copy the validity of the message into.
|
||||
*
|
||||
@@ -312,7 +334,6 @@ icsneoc2_error_t icsneoc2_message_is_valid(icsneoc2_message_t* message, bool* is
|
||||
/**
|
||||
* Check if a message is a raw message (message with data)
|
||||
*
|
||||
* @param[in] device The device to check against.
|
||||
* @param[in] message The message to check.
|
||||
* @param[out] is_raw Pointer to a bool to copy the raw status of the message into.
|
||||
*
|
||||
@@ -323,7 +344,6 @@ icsneoc2_error_t icsneoc2_message_is_raw(icsneoc2_message_t* message, bool* is_r
|
||||
/**
|
||||
* Check if a message is a frame message (message with data)
|
||||
*
|
||||
* @param[in] device The device to check against.
|
||||
* @param[in] message The message to check.
|
||||
* @param[out] is_frame Pointer to a bool to copy the frame status of the message into.
|
||||
*
|
||||
@@ -333,8 +353,7 @@ icsneoc2_error_t icsneoc2_message_is_frame(icsneoc2_message_t* message, bool* is
|
||||
|
||||
/**
|
||||
* Check if a message is a CAN message
|
||||
*
|
||||
* @param[in] device The device to check against.
|
||||
*
|
||||
* @param[in] message The message to check.
|
||||
* @param[out] is_can Pointer to a bool to copy the CAN status of the message into.
|
||||
*
|
||||
|
||||
@@ -683,6 +683,34 @@ typedef enum _icsneoc2_chip_id_t {
|
||||
|
||||
typedef uint8_t icsneoc2_chip_id_t;
|
||||
|
||||
typedef enum _icsneoc2_link_speed_t {
|
||||
icsneoc2_link_speed_auto = 0,
|
||||
icsneoc2_link_speed_10mbps,
|
||||
icsneoc2_link_speed_100mbps,
|
||||
icsneoc2_link_speed_1000mbps,
|
||||
icsneoc2_link_speed_2500mbps,
|
||||
icsneoc2_link_speed_5000mbps,
|
||||
icsneoc2_link_speed_10000mbps,
|
||||
|
||||
// Must be last entry.
|
||||
icsneoc2_link_speed_maxsize
|
||||
} _icsneoc2_link_speed_t;
|
||||
|
||||
typedef uint8_t icsneoc2_link_speed_t;
|
||||
|
||||
typedef enum _icsneoc2_link_mode_t {
|
||||
icsneoc2_link_mode_auto = 0,
|
||||
icsneoc2_link_mode_master,
|
||||
icsneoc2_link_mode_slave,
|
||||
icsneoc2_link_mode_invalid,
|
||||
icsneoc2_link_mode_none,
|
||||
|
||||
// Must be last entry.
|
||||
icsneoc2_link_mode_maxsize
|
||||
} _icsneoc2_link_mode_t;
|
||||
|
||||
typedef uint8_t icsneoc2_link_mode_t;
|
||||
|
||||
typedef struct icsneoc2_mac_addr_entry_t icsneoc2_mac_addr_entry_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user