23#define DEBUG_PRINT(x,...)
31 UdpSenderComponentImpl ::
32 UdpSenderComponentImpl(
33 const char *
const compName
34 ) : UdpSenderComponentBase(compName),
43 void UdpSenderComponentImpl ::
50 UdpSenderComponentBase::init(queueDepth, msgSize, instance);
53 UdpSenderComponentImpl ::
54 ~UdpSenderComponentImpl()
56 if (this->m_fd != -1) {
69 this->m_fd = socket(AF_INET, SOCK_DGRAM, 0);
70 if (-1 == this->m_fd) {
72 this->log_WARNING_HI_US_SocketError(arg);
77 memset(&m_servAddr, 0,
sizeof(m_servAddr));
78 m_servAddr.sin_family = AF_INET;
79 m_servAddr.sin_port = htons(atoi(port));
80 inet_aton(addr , &m_servAddr.sin_addr);
83 this->log_ACTIVITY_HI_US_PortOpened(arg,atoi(port));
93 void UdpSenderComponentImpl ::
99 this->tlmWrite_US_BytesSent(this->m_bytesSent);
100 this->tlmWrite_US_PacketsSent(this->m_packetsSent);
107 void UdpSenderComponentImpl ::
114 if (-1 == this->m_fd) {
120 m_sendBuff.resetSer();
123 stat = m_sendBuff.serialize(this->m_seq++);
126 stat = m_sendBuff.serialize(
static_cast<U8>(portNum));
129 stat = m_sendBuff.serialize(Buffer);
132 DEBUG_PRINT(
"Sending %d bytes\n",m_sendBuff.getBuffLength());
133 ssize_t sendStat = sendto(this->m_fd,
134 m_sendBuff.getBuffAddr(),
135 m_sendBuff.getBuffLength(),
137 reinterpret_cast<struct sockaddr *
>(&m_servAddr),
139 if (-1 == sendStat) {
141 this->log_WARNING_HI_US_SendError(arg);
143 FW_ASSERT((
int)m_sendBuff.getBuffLength() == sendStat,(
int)m_sendBuff.getBuffLength(),sendStat,portNum);
144 this->m_packetsSent++;
145 this->m_bytesSent += sendStat;
152 this->serialize(other.getBuffAddr(),other.getBuffLength(),
true);
156 UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer(
163 UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer(
164 const UdpSenderComponentImpl::UdpSerialBuffer& other) :
Fw::SerializeBufferBase() {
165 FW_ASSERT(
sizeof(this->m_buff)>= other.getBuffLength(),
sizeof(this->m_buff),other.getBuffLength());
166 memcpy(this->m_buff,other.m_buff,other.getBuffLength());
167 this->setBuffLen(other.getBuffLength());
170 UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer():
Fw::SerializeBufferBase() {
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
C++-compatible configuration header for fprime configuration.
#define DEBUG_PRINT(x,...)
SerializeBufferBase & operator=(const SerializeBufferBase &src)
equal operator
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
void open(const char *addr, const char *port)
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.