mirror of
https://github.com/nasa/fpp.git
synced 2025-12-10 15:36:19 -06:00
Add compilation check for commands topology
This commit is contained in:
parent
6629dccd23
commit
6da17243e0
@ -0,0 +1,34 @@
|
||||
#ifndef M_C_HPP
|
||||
#define M_C_HPP
|
||||
|
||||
#include "CComponentAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
class C :
|
||||
public CComponentBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
C(const char* name) {
|
||||
|
||||
}
|
||||
|
||||
void init(U32 instanceId) {
|
||||
|
||||
}
|
||||
|
||||
void regCommandsSpecial() {
|
||||
|
||||
}
|
||||
|
||||
void C_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,5 @@
|
||||
namespace M {
|
||||
|
||||
typedef int TopologyState;
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
module Fw {
|
||||
|
||||
type CmdArgBuffer
|
||||
|
||||
@ Command registration port
|
||||
port CmdReg(
|
||||
opCode: FwOpcodeType @< Command Op Code
|
||||
)
|
||||
|
||||
@ Port for sending commands
|
||||
port Cmd(
|
||||
opCode: FwOpcodeType @< Command Op Code
|
||||
cmdSeq: U32 @< Command Sequence
|
||||
ref args: CmdArgBuffer @< Buffer containing arguments
|
||||
)
|
||||
|
||||
@ Enum representing a command response
|
||||
enum CmdResponse {
|
||||
OK = 0 @< Command successfully executed
|
||||
INVALID_OPCODE = 1 @< Invalid opcode dispatched
|
||||
VALIDATION_ERROR = 2 @< Command failed validation
|
||||
FORMAT_ERROR = 3 @< Command failed to deserialize
|
||||
EXECUTION_ERROR = 4 @< Command had execution error
|
||||
BUSY = 5 @< Component busy
|
||||
}
|
||||
|
||||
@ Port for sending command responses
|
||||
port CmdResponse(
|
||||
opCode: FwOpcodeType @< Command Op Code
|
||||
cmdSeq: U32 @< Command Sequence
|
||||
response: CmdResponse @< The command response argument
|
||||
)
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Created on: March 1, 2014
|
||||
* Author: T. Canham
|
||||
*/
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* This object contains the CmdARgBuffer type, used for holding the serialized arguments of commands
|
||||
*/
|
||||
#ifndef FW_CMD_ARG_BUFFER_HPP
|
||||
#define FW_CMD_ARG_BUFFER_HPP
|
||||
|
||||
#include <Fw/Types/BasicTypes.hpp>
|
||||
#include <Fw/Types/Serializable.hpp>
|
||||
#include <FpConfig.hpp>
|
||||
#include <Fw/Cfg/SerIds.hpp>
|
||||
|
||||
namespace Fw {
|
||||
|
||||
class CmdArgBuffer : public SerializeBufferBase {
|
||||
public:
|
||||
|
||||
enum {
|
||||
SERIALIZED_TYPE_ID = FW_TYPEID_CMD_BUFF, //!< type id for CmdArgBuffer
|
||||
SERIALIZED_SIZE = FW_CMD_ARG_BUFFER_MAX_SIZE + sizeof(I32) //!< size when serialized. Buffer + size of buffer
|
||||
};
|
||||
|
||||
CmdArgBuffer(const U8 *args, NATIVE_UINT_TYPE size); //!< buffer source constructor
|
||||
CmdArgBuffer(); //!< default constructor
|
||||
CmdArgBuffer(const CmdArgBuffer& other); //!< other arg buffer constructor
|
||||
virtual ~CmdArgBuffer(); //!< destructor
|
||||
const CmdArgBuffer& operator=(const CmdArgBuffer& other); //!< Equal operator
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity(void) const; //!< return capacity of buffer (how much it can hold)
|
||||
U8* getBuffAddr(void); //!< return address of buffer (non const version)
|
||||
const U8* getBuffAddr(void) const; //!< return address of buffer (const version)
|
||||
|
||||
private:
|
||||
U8 m_data[FW_CMD_ARG_BUFFER_MAX_SIZE]; //!< command argument buffer
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* CmdPacket.hpp
|
||||
*
|
||||
* Created on: May 24, 2014
|
||||
* Author: Timothy Canham
|
||||
*/
|
||||
|
||||
#ifndef CMDPACKET_HPP_
|
||||
#define CMDPACKET_HPP_
|
||||
|
||||
#include <Fw/Com/ComPacket.hpp>
|
||||
#include <Fw/Cmd/CmdArgBuffer.hpp>
|
||||
|
||||
namespace Fw {
|
||||
|
||||
class CmdPacket : public ComPacket {
|
||||
public:
|
||||
|
||||
CmdPacket();
|
||||
virtual ~CmdPacket();
|
||||
|
||||
SerializeStatus serialize(SerializeBufferBase& buffer) const; //!< serialize contents
|
||||
SerializeStatus deserialize(SerializeBufferBase& buffer);
|
||||
FwOpcodeType getOpCode(void) const;
|
||||
CmdArgBuffer& getArgBuffer(void);
|
||||
|
||||
protected:
|
||||
FwOpcodeType m_opcode;
|
||||
CmdArgBuffer m_argBuffer;
|
||||
};
|
||||
|
||||
} /* namespace Fw */
|
||||
|
||||
#endif /* CMDPACKET_HPP_ */
|
||||
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- =====================================================================
|
||||
CmdPortAi.xml
|
||||
Generated by fpp-to-xml
|
||||
====================================================================== -->
|
||||
<interface namespace="Fw" name="Cmd">
|
||||
<comment>
|
||||
Port for sending commands
|
||||
</comment>
|
||||
<include_header>Fw/Cmd/CmdArgBuffer.hpp</include_header>
|
||||
<args>
|
||||
<arg name="opCode" type="FwOpcodeType">
|
||||
<comment>
|
||||
Command Op Code
|
||||
</comment>
|
||||
</arg>
|
||||
<arg name="cmdSeq" type="U32">
|
||||
<comment>
|
||||
Command Sequence
|
||||
</comment>
|
||||
</arg>
|
||||
<arg name="args" type="Fw::CmdArgBuffer" pass_by="reference">
|
||||
<comment>
|
||||
Buffer containing arguments
|
||||
</comment>
|
||||
</arg>
|
||||
</args>
|
||||
</interface>
|
||||
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- =====================================================================
|
||||
CmdRegPortAi.xml
|
||||
Generated by fpp-to-xml
|
||||
====================================================================== -->
|
||||
<interface namespace="Fw" name="CmdReg">
|
||||
<comment>
|
||||
Command registration port
|
||||
</comment>
|
||||
<args>
|
||||
<arg name="opCode" type="FwOpcodeType">
|
||||
<comment>
|
||||
Command Op Code
|
||||
</comment>
|
||||
</arg>
|
||||
</args>
|
||||
</interface>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- =====================================================================
|
||||
CmdResponseEnumAi.xml
|
||||
Generated by fpp-to-xml
|
||||
====================================================================== -->
|
||||
<enum namespace="Fw" name="CmdResponse">
|
||||
<comment>
|
||||
Enum representing a command response
|
||||
</comment>
|
||||
<item name="OK" value="0" comment="Command successfully executed"/>
|
||||
<item name="INVALID_OPCODE" value="1" comment="Invalid opcode dispatched"/>
|
||||
<item name="VALIDATION_ERROR" value="2" comment="Command failed validation"/>
|
||||
<item name="FORMAT_ERROR" value="3" comment="Command failed to deserialize"/>
|
||||
<item name="EXECUTION_ERROR" value="4" comment="Command had execution error"/>
|
||||
<item name="BUSY" value="5" comment="Component busy"/>
|
||||
</enum>
|
||||
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- =====================================================================
|
||||
CmdResponsePortAi.xml
|
||||
Generated by fpp-to-xml
|
||||
====================================================================== -->
|
||||
<interface namespace="Fw" name="CmdResponse">
|
||||
<comment>
|
||||
Port for sending command responses
|
||||
</comment>
|
||||
<import_enum_type>Fw/Cmd/CmdResponseEnumAi.xml</import_enum_type>
|
||||
<args>
|
||||
<arg name="opCode" type="FwOpcodeType">
|
||||
<comment>
|
||||
Command Op Code
|
||||
</comment>
|
||||
</arg>
|
||||
<arg name="cmdSeq" type="U32">
|
||||
<comment>
|
||||
Command Sequence
|
||||
</comment>
|
||||
</arg>
|
||||
<arg name="response" type="Fw::CmdResponse">
|
||||
<comment>
|
||||
The command response argument
|
||||
</comment>
|
||||
</arg>
|
||||
</args>
|
||||
</interface>
|
||||
@ -0,0 +1,41 @@
|
||||
#ifndef FW_CMD_STRING_TYPE_HPP
|
||||
#define FW_CMD_STRING_TYPE_HPP
|
||||
|
||||
#include <Fw/Types/BasicTypes.hpp>
|
||||
#include <Fw/Types/StringType.hpp>
|
||||
#include <FpConfig.hpp>
|
||||
#include <Fw/Cfg/SerIds.hpp>
|
||||
|
||||
namespace Fw {
|
||||
|
||||
class CmdStringArg : public Fw::StringBase {
|
||||
public:
|
||||
|
||||
enum {
|
||||
SERIALIZED_TYPE_ID = FW_TYPEID_CMD_STR,
|
||||
SERIALIZED_SIZE = FW_CMD_STRING_MAX_SIZE + sizeof(FwBuffSizeType)
|
||||
};
|
||||
|
||||
CmdStringArg(const char* src);
|
||||
CmdStringArg(const StringBase& src);
|
||||
CmdStringArg(const CmdStringArg& src);
|
||||
CmdStringArg(void);
|
||||
~CmdStringArg(void);
|
||||
const char* toChar(void) const;
|
||||
NATIVE_UINT_TYPE length(void) const;
|
||||
|
||||
const CmdStringArg& operator=(const CmdStringArg& other); //!< equal operator for other strings
|
||||
|
||||
SerializeStatus serialize(SerializeBufferBase& buffer) const;
|
||||
SerializeStatus deserialize(SerializeBufferBase& buffer);
|
||||
|
||||
private:
|
||||
NATIVE_UINT_TYPE getCapacity(void) const ; //!< return buffer size
|
||||
void terminate(NATIVE_UINT_TYPE size); //!< terminate the string
|
||||
|
||||
char m_buf[FW_CMD_STRING_MAX_SIZE];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
23
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/Commands/check
Executable file
23
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/Commands/check
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
echo ' removing old files'
|
||||
./clean
|
||||
|
||||
dir=`cd ../..; echo $PWD`
|
||||
|
||||
echo ' generating XML'
|
||||
fpp-to-xml -p $dir -i ../../builtin.fpp ../../commands.fpp
|
||||
cp Fw/Cmd/*Ai.xml .
|
||||
|
||||
echo ' generating C++'
|
||||
for file in CComponent CmdPort CmdRegPort CmdResponsePort
|
||||
do
|
||||
fprime-codegen $file'Ai.xml' > /dev/null
|
||||
done
|
||||
for suffix in hpp cpp
|
||||
do
|
||||
cp ../../CommandsTopologyAc.ref.$suffix CommandsTopologyAc.$suffix
|
||||
done
|
||||
|
||||
echo ' compiling C++'
|
||||
fprime-gcc -I . -c CommandsTopologyAc.cpp
|
||||
6
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/Commands/clean
Executable file
6
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/Commands/clean
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
for file in `find . -maxdepth 1 -name '*~' -or -name '*Ac.*' -or -name '*Ai.xml' -or -name '*.o'`
|
||||
do
|
||||
rm $file
|
||||
done
|
||||
@ -1 +1,3 @@
|
||||
Basic
|
||||
Commands
|
||||
Health
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user