Adds sitara_depot/free_rtos Original one is on server_gorbunov/SmartForce4.0/sitara_depot
63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
/*
|
|
* eth_udp_client.hpp
|
|
*
|
|
* Created on: 15 ìàð. 2023 ã.
|
|
* Author: sychev
|
|
*/
|
|
|
|
#ifndef FREE_RTOS_ETHERNET_IP_ETH_UDP_CLIENT_HPP_
|
|
#define FREE_RTOS_ETHERNET_IP_ETH_UDP_CLIENT_HPP_
|
|
|
|
#include "semaphore/semaphore.hpp"
|
|
#include "mutex/mutex.hpp"
|
|
#include "ethernet/eth_frame.h"
|
|
#include "ethernet_ip/eth_ip_iface.hpp"
|
|
#include "ethernet/eth_types.h"
|
|
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
namespace free_rtos {
|
|
|
|
class EthUpdClient {
|
|
friend class EthUdpServer;
|
|
|
|
public:
|
|
EthUpdClient(EthIpIface& ip_iface, TEthMacPorts port_id,
|
|
uint16_t port_dst_be, uint16_t port_src_be,
|
|
bool use_chksum);
|
|
|
|
int32_t read(uint8_t * p_data, uint32_t len);
|
|
|
|
int32_t write(uint32_t ip_dst_be, uint8_t * p_data, uint32_t len);
|
|
|
|
void clear(); ///î÷èñòêà ïðèåìíîãî áóôåðà
|
|
|
|
private:
|
|
void put_data(uint32_t src_ip, uint8_t * p_data, uint32_t len);
|
|
|
|
private:
|
|
const uint32_t max_buf_size = 0x100000; // 1Mb
|
|
|
|
Semaphore rx_sem_;
|
|
Mutex rx_mut_;
|
|
|
|
const uint16_t port_dst_be_; /// big endian
|
|
const uint16_t port_src_be_; /// big endian
|
|
const bool use_checksum_;
|
|
|
|
std::vector<uint8_t> buff_;
|
|
|
|
TEthPkt eth_pkt_;
|
|
|
|
EthIpIface& ip_iface_;
|
|
|
|
const TEthMacPorts port_id_;
|
|
|
|
uint32_t src_ip_; /// Ip Àäðåñ èñòî÷íèêà ïàêåòà UDP
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* FREE_RTOS_ETHERNET_IP_ETH_UDP_CLIENT_HPP_ */
|