2023-06-06 10:27:01 +03:00
|
|
|
/*
|
|
|
|
* eth_ecat_telegram.hpp
|
|
|
|
*
|
|
|
|
* Created on: Jun 5, 2023
|
|
|
|
* Author: algin
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_TELEGRAM_HPP_
|
|
|
|
#define FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_TELEGRAM_HPP_
|
|
|
|
|
|
|
|
#include "ethernet/eth.hpp"
|
|
|
|
|
|
|
|
#include "ethernet_industry/eth_ecat_datagram.hpp"
|
|
|
|
|
|
|
|
namespace free_rtos {
|
|
|
|
|
|
|
|
namespace telegram {
|
|
|
|
|
|
|
|
class EcatTelegram : public Handler {
|
|
|
|
public:
|
|
|
|
EcatTelegram(Eth& eth)
|
|
|
|
: eth_{eth}
|
2023-06-08 12:27:49 +03:00
|
|
|
, tx_flow_{*eth.getTxFlowPtr()}
|
|
|
|
, eth_stack_{*eth.getEthStackPtr()} { }
|
2023-06-06 10:27:01 +03:00
|
|
|
|
|
|
|
virtual int32_t Process(uint8_t *p_data, uint32_t len) override;
|
2023-06-08 12:27:49 +03:00
|
|
|
virtual uint32_t Sender(uint8_t *p_data, size_t scatter_segment) override;
|
2023-06-06 10:27:01 +03:00
|
|
|
|
|
|
|
void init(TEthMacPorts port_id) {
|
|
|
|
port_id_ = port_id;
|
2023-06-08 12:27:49 +03:00
|
|
|
eth_.getEthStackPtr()->Register(ETH_PROT_ECAT_LE, this);
|
2023-06-06 10:27:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void transfer(datagram::IEcatDatagram& first);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Eth& eth_;
|
|
|
|
EthTxFlowIface& tx_flow_;
|
2023-06-08 12:27:49 +03:00
|
|
|
EthStackIface& eth_stack_;
|
2023-06-06 10:27:01 +03:00
|
|
|
TEthMacPorts port_id_;
|
|
|
|
|
|
|
|
free_rtos::Semaphore rx_sem_;
|
|
|
|
|
2023-06-08 12:27:49 +03:00
|
|
|
datagram::IEcatDatagram *datagram_queue_{nullptr};
|
2023-06-06 10:27:01 +03:00
|
|
|
|
2023-06-08 12:27:49 +03:00
|
|
|
uint8_t* pack(uint8_t *raw);
|
|
|
|
uint8_t* unpack(uint8_t *raw);
|
2023-06-06 10:27:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_TELEGRAM_HPP_ */
|