Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VxWorks/C++ fixes #797

Merged
merged 17 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern id="ASYNC_PORT">
<rule context="component">
<assert test="(//component/@kind = 'active' and (count(//component/ports/port/@kind[. = 'async_input']) + count(//component/internal_interfaces/internal_interface) ) >= 1) or not (//component/@kind = 'active')">
<assert test="(//component/@kind = 'active' and (count(//component/ports/port/@kind[. = 'async_input']) + count(//component/commands/command/@kind[. = 'async']) + count(//component/internal_interfaces/internal_interface) ) >= 1) or not (//component/@kind = 'active')">
Active components should have at least 1 port of kind async_input or internal_interface.
</assert>
</rule>
Expand Down
8 changes: 5 additions & 3 deletions Drv/Ip/IpSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,22 @@ SocketIpStatus IpSocket::setupTimeouts(NATIVE_INT_TYPE socketFd) {
if (setsockopt(socketFd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout)) < 0) {
return SOCK_FAILED_TO_SET_SOCKET_OPTIONS;
}
return SOCK_SUCCESS;
#endif
return SOCK_SUCCESS;
}

SocketIpStatus IpSocket::addressToIp4(const char* address, void* ip4) {
FW_ASSERT(address != NULL);
FW_ASSERT(ip4 != NULL);
// Get the IP address from host
#ifdef TGT_OS_TYPE_VXWORKS
U32 ip = inet_addr(address);
NATIVE_INT_TYPE ip = inet_addr(address);
if (ip == ERROR) {
return SOCK_INVALID_IP_ADDRESS;
}
*ip4 = ip;
// from sin_addr, which has one struct
// member s_addr, which is unsigned int
*reinterpret_cast<unsigned long*>(ip4) = ip;
#else
// First IP address to socket sin_addr
if (not ::inet_pton(AF_INET, address, ip4)) {
Expand Down
1 change: 1 addition & 0 deletions Drv/Ip/IpSocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum SocketIpStatus {
class IpSocket {
public:
IpSocket();
virtual ~IpSocket(){};
/**
* \brief configure the ip socket with host and transmission timeouts
*
Expand Down
36 changes: 18 additions & 18 deletions Fw/Buffer/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,39 @@ namespace Fw {

Buffer::Buffer(): Serializable(),
m_serialize_repr(),
m_data(NULL),
m_bufferData(NULL),
m_size(0),
m_context(0xFFFFFFFF)
{}

Buffer::Buffer(const Buffer& src) : Serializable(),
m_serialize_repr(src.m_data, src.m_size),
m_data(src.m_data),
m_serialize_repr(src.m_bufferData, src.m_size),
m_bufferData(src.m_bufferData),
m_size(src.m_size),
m_context(src.m_context)
{}

Buffer::Buffer(U8* data, U32 size, U32 context) : Serializable(),
m_serialize_repr(data, size),
m_data(data),
m_bufferData(data),
m_size(size),
m_context(context)
{}

Buffer& Buffer::operator=(const Buffer& src) {
// Ward against self-assignment
if (this != &src) {
this->set(src.m_data, src.m_size, src.m_context);
this->set(src.m_bufferData, src.m_size, src.m_context);
}
return *this;
}

bool Buffer::operator==(const Buffer& src) const {
return (this->m_data == src.m_data) && (this->m_size == src.m_size) && (this->m_context == src.m_context);
return (this->m_bufferData == src.m_bufferData) && (this->m_size == src.m_size) && (this->m_context == src.m_context);
}

U8* Buffer::getData() const {
return this->m_data;
return this->m_bufferData;
}

U32 Buffer::getSize() const {
Expand All @@ -66,16 +66,16 @@ U32 Buffer::getContext() const {
}

void Buffer::setData(U8* const data) {
this->m_data = data;
if (m_data != NULL) {
this->m_serialize_repr.setExtBuffer(m_data, m_size);
this->m_bufferData = data;
if (m_bufferData != NULL) {
this->m_serialize_repr.setExtBuffer(m_bufferData, m_size);
}
}

void Buffer::setSize(const U32 size) {
this->m_size = size;
if (m_data != NULL) {
this->m_serialize_repr.setExtBuffer(m_data, m_size);
if (m_bufferData != NULL) {
this->m_serialize_repr.setExtBuffer(m_bufferData, m_size);
}
}

Expand All @@ -84,10 +84,10 @@ void Buffer::setContext(const U32 context) {
}

void Buffer::set(U8* const data, const U32 size, const U32 context) {
this->m_data = data;
this->m_bufferData = data;
this->m_size = size;
if (m_data != NULL) {
this->m_serialize_repr.setExtBuffer(m_data, m_size);
if (m_bufferData != NULL) {
this->m_serialize_repr.setExtBuffer(m_bufferData, m_size);
}
this->m_context = context;
}
Expand All @@ -104,7 +104,7 @@ Fw::SerializeStatus Buffer::serialize(Fw::SerializeBufferBase& buffer) const {
return stat;
}
#endif
stat = buffer.serialize(reinterpret_cast<POINTER_CAST>(this->m_data));
stat = buffer.serialize(reinterpret_cast<POINTER_CAST>(this->m_bufferData));
if (stat != Fw::FW_SERIALIZE_OK) {
return stat;
}
Expand Down Expand Up @@ -139,7 +139,7 @@ Fw::SerializeStatus Buffer::deserialize(Fw::SerializeBufferBase& buffer) {
if (stat != Fw::FW_SERIALIZE_OK) {
return stat;
}
this->m_data = reinterpret_cast<U8*>(pointer);
this->m_bufferData = reinterpret_cast<U8*>(pointer);

stat = buffer.deserialize(this->m_size);
if (stat != Fw::FW_SERIALIZE_OK) {
Expand All @@ -157,7 +157,7 @@ void Buffer::toString(Fw::StringBase& text) const {
static const char * formatString = "(data = %p, size = %u,context = %u)";
char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE];

(void)snprintf(outputString, FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE, formatString, this->m_data, this->m_size,
(void)snprintf(outputString, FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE, formatString, this->m_bufferData, this->m_size,
this->m_context);
// Force NULL termination
outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0;
Expand Down
2 changes: 1 addition & 1 deletion Fw/Buffer/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Buffer : public Fw::Serializable {

PRIVATE:
Fw::ExternalSerializeBuffer m_serialize_repr; //<! Representation for serialization and deserialization functions
U8* m_data; //<! data - A pointer to the data
U8* m_bufferData; //<! data - A pointer to the data
U32 m_size; //<! size - The data size in bytes
U32 m_context; //!< Creation context for disposal

Expand Down
10 changes: 5 additions & 5 deletions Fw/Cmd/CmdArgBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ namespace Fw {
}

CmdArgBuffer::CmdArgBuffer(const CmdArgBuffer& other) : Fw::SerializeBufferBase() {
SerializeStatus stat = this->setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = this->setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

const CmdArgBuffer& CmdArgBuffer::operator=(const CmdArgBuffer& other) {
SerializeStatus stat = this->setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = this->setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
return *this;
}

NATIVE_UINT_TYPE CmdArgBuffer::getBuffCapacity(void) const {
return sizeof(this->m_data);
return sizeof(this->m_bufferData);
}

const U8* CmdArgBuffer::getBuffAddr(void) const {
return this->m_data;
return this->m_bufferData;
}

U8* CmdArgBuffer::getBuffAddr(void) {
return this->m_data;
return this->m_bufferData;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Cmd/CmdArgBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Fw {
const U8* getBuffAddr(void) const; //!< return address of buffer (const version)

private:
U8 m_data[FW_CMD_ARG_BUFFER_MAX_SIZE]; //!< command argument buffer
U8 m_bufferData[FW_CMD_ARG_BUFFER_MAX_SIZE]; //!< command argument buffer
};

}
Expand Down
10 changes: 5 additions & 5 deletions Fw/Com/ComBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ namespace Fw {
}

ComBuffer::ComBuffer(const ComBuffer& other) : Fw::SerializeBufferBase() {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

const ComBuffer& ComBuffer::operator=(const ComBuffer& other) {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
return *this;
}

NATIVE_UINT_TYPE ComBuffer::getBuffCapacity(void) const {
return sizeof(this->m_data);
return sizeof(this->m_bufferData);
}

const U8* ComBuffer::getBuffAddr(void) const {
return this->m_data;
return this->m_bufferData;
}

U8* ComBuffer::getBuffAddr(void) {
return this->m_data;
return this->m_bufferData;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Com/ComBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Fw {
const U8* getBuffAddr(void) const;

private:
U8 m_data[FW_COM_BUFFER_MAX_SIZE]; // packet data buffer
U8 m_bufferData[FW_COM_BUFFER_MAX_SIZE]; // packet data buffer
};

}
Expand Down
10 changes: 5 additions & 5 deletions Fw/Log/LogBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ namespace Fw {
}

LogBuffer::LogBuffer(const LogBuffer& other) : Fw::SerializeBufferBase() {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

const LogBuffer& LogBuffer::operator=(const LogBuffer& other) {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
return *this;
}

NATIVE_UINT_TYPE LogBuffer::getBuffCapacity(void) const {
return sizeof(this->m_data);
return sizeof(this->m_bufferData);
}

const U8* LogBuffer::getBuffAddr(void) const {
return this->m_data;
return this->m_bufferData;
}

U8* LogBuffer::getBuffAddr(void) {
return this->m_data;
return this->m_bufferData;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Log/LogBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Fw {
const U8* getBuffAddr(void) const;

private:
U8 m_data[FW_LOG_BUFFER_MAX_SIZE]; // command argument buffer
U8 m_bufferData[FW_LOG_BUFFER_MAX_SIZE]; // command argument buffer
};

}
Expand Down
10 changes: 5 additions & 5 deletions Fw/Prm/PrmBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ namespace Fw {
}

ParamBuffer::ParamBuffer(const ParamBuffer& other) : Fw::SerializeBufferBase() {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

const ParamBuffer& ParamBuffer::operator=(const ParamBuffer& other) {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
return *this;
}

NATIVE_UINT_TYPE ParamBuffer::getBuffCapacity(void) const {
return sizeof(this->m_data);
return sizeof(this->m_bufferData);
}

const U8* ParamBuffer::getBuffAddr(void) const {
return this->m_data;
return this->m_bufferData;
}

U8* ParamBuffer::getBuffAddr(void) {
return this->m_data;
return this->m_bufferData;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Prm/PrmBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Fw {
const U8* getBuffAddr(void) const;

private:
U8 m_data[FW_PARAM_BUFFER_MAX_SIZE]; // command argument buffer
U8 m_bufferData[FW_PARAM_BUFFER_MAX_SIZE]; // command argument buffer
};

}
Expand Down
10 changes: 5 additions & 5 deletions Fw/Tlm/TlmBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ namespace Fw {
}

TlmBuffer::TlmBuffer(const TlmBuffer& other) : Fw::SerializeBufferBase() {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

const TlmBuffer& TlmBuffer::operator=(const TlmBuffer& other) {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_data,other.getBuffLength());
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
return *this;
}

NATIVE_UINT_TYPE TlmBuffer::getBuffCapacity(void) const {
return sizeof(this->m_data);
return sizeof(this->m_bufferData);
}

const U8* TlmBuffer::getBuffAddr(void) const {
return this->m_data;
return this->m_bufferData;
}

U8* TlmBuffer::getBuffAddr(void) {
return this->m_data;
return this->m_bufferData;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Tlm/TlmBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Fw {
const U8* getBuffAddr(void) const;

PRIVATE:
U8 m_data[FW_TLM_BUFFER_MAX_SIZE]; // command argument buffer
U8 m_bufferData[FW_TLM_BUFFER_MAX_SIZE]; // command argument buffer
};

}
Expand Down
3 changes: 2 additions & 1 deletion Svc/ActiveTextLogger/ActiveTextLoggerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <Svc/ActiveTextLogger/ActiveTextLoggerImpl.hpp>
#include <Fw/Types/Assert.hpp>
#include <Fw/Logger/Logger.hpp>
#include <time.h>

namespace Svc {
Expand Down Expand Up @@ -130,7 +131,7 @@ namespace Svc {
{

// Print to console:
(void) printf("%s",text.toChar());
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
Fw::Logger::logMsg(text.toChar(),0,0,0,0,0,0,0,0,0);

// Print to file if there is one:
(void) this->m_log_file.write_to_log(text.toChar(), text.length()); // Ignoring return status
Expand Down
Loading