16 #include <sys/types.h> 30 const char *
const compName
31 ) : UdpSenderComponentBase(compName),
43 if (this->m_fd != -1) {
56 this->m_fd = socket(AF_INET, SOCK_DGRAM, 0);
57 if (-1 == this->m_fd) {
59 this->log_WARNING_HI_US_SocketError(arg);
64 memset(&m_servAddr, 0,
sizeof(m_servAddr));
65 m_servAddr.sin_family = AF_INET;
66 m_servAddr.sin_port = htons(atoi(port));
67 inet_aton(addr , &m_servAddr.sin_addr);
70 this->log_ACTIVITY_HI_US_PortOpened(arg,atoi(port));
80 void UdpSenderComponentImpl ::
86 this->tlmWrite_US_BytesSent(this->m_bytesSent);
87 this->tlmWrite_US_PacketsSent(this->m_packetsSent);
94 void UdpSenderComponentImpl ::
101 if (-1 == this->m_fd) {
106 m_sendBuff.resetSer();
109 stat = m_sendBuff.serialize(this->m_seq++);
112 stat = m_sendBuff.serialize(static_cast<U8>(portNum));
115 stat = m_sendBuff.serialize(Buffer);
118 ssize_t sendStat = sendto(this->m_fd,
119 m_sendBuff.getBuffAddr(),
120 m_sendBuff.getBuffLength(),
122 reinterpret_cast<struct sockaddr *
>(&m_servAddr),
124 if (-1 == sendStat) {
126 this->log_WARNING_HI_US_SendError(arg);
128 FW_ASSERT((
int)m_sendBuff.getBuffLength() == sendStat,(int)m_sendBuff.getBuffLength(),sendStat,portNum);
129 this->m_packetsSent++;
130 this->m_bytesSent += sendStat;
135 UdpSerialBuffer& UdpSenderComponentImpl::UdpSerialBuffer::operator=(
const Svc::UdpSenderComponentImpl::UdpSerialBuffer& other) {
137 this->serialize(other.getBuffAddr(),other.getBuffLength(),
true);
141 UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer(
148 UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer(
149 const UdpSenderComponentImpl::UdpSerialBuffer& other) :
Fw::SerializeBufferBase() {
150 FW_ASSERT(
sizeof(this->m_buff)>= other.getBuffLength(),
sizeof(this->m_buff),other.getBuffLength());
151 memcpy(this->m_buff,other.m_buff,other.getBuffLength());
152 this->setBuffLen(other.getBuffLength());
155 UdpSenderComponentImpl::UdpSerialBuffer::UdpSerialBuffer():
Fw::SerializeBufferBase() {
Serialization/Deserialization operation was successful.
UdpSenderComponentImpl(const char *const compName)
PlatformIndexType FwIndexType
SerializeStatus
forward declaration for string
~UdpSenderComponentImpl()
Serializable::SizeType getBuffLength() const
returns current buffer size
void open(const char *addr, const char *port)
C++-compatible configuration header for fprime configuration.
virtual U8 * getBuffAddr()=0
gets buffer address for data filling