summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--maximus/common/types/functioncall_types.h7
-rw-r--r--maximus/common/types/phy_types.h32
-rw-r--r--maximus/common/types/system_types.h4
-rw-r--r--maximus/functioncall/inc/FunctionSciMsg.h14
-rw-r--r--maximus/functioncall/src/FunctionCallManager.cpp2
-rw-r--r--maximus/functioncall/src/FunctionSciMsg.cpp58
-rw-r--r--maximus/networkclock/inc/ClockSciMsg.h26
-rw-r--r--maximus/networkclock/src/ClockSciMsg.cpp61
-rw-r--r--maximus/sci/inc/SciMsg.h7
-rw-r--r--maximus/sci/src/SciMsg.cpp90
-rw-r--r--maximus/sci/src/SciServer.cpp25
-rw-r--r--maximus/sci/src/SciServerTest.cpp135
-rw-r--r--maximus/system/src/SystemSciMsg.cpp17
13 files changed, 308 insertions, 170 deletions
diff --git a/maximus/common/types/functioncall_types.h b/maximus/common/types/functioncall_types.h
index 7bf36e8d1f..e8cd91de39 100644
--- a/maximus/common/types/functioncall_types.h
+++ b/maximus/common/types/functioncall_types.h
@@ -19,12 +19,13 @@ struct Function_Call_Parameter
enum Function_Call_Type
{
- FUNCTION_CALL_TYPE_NONE = 0,
- FUNCTION_CALL_TYPE_REQ,
- FUNCTION_CALL_TYPE_RSP,
+ FUNCTION_CALL_TYPE_NONE = 0x00,
+ FUNCTION_CALL_TYPE_REQ = 0x01,
+ FUNCTION_CALL_TYPE_RSP = 0x02,
FUNCTION_CALL_TYPE_NB
};
+typedef uint8_t Function_Call_Parameters_Number;
struct Function_Call_Header
{
diff --git a/maximus/common/types/phy_types.h b/maximus/common/types/phy_types.h
index e955b34014..ecf7b01c42 100644
--- a/maximus/common/types/phy_types.h
+++ b/maximus/common/types/phy_types.h
@@ -16,37 +16,37 @@ enum Phy_Link_Quality
enum Phy_Sci_Msg_Mpdu_Format
{
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NONE = 0,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_AV_ONLY_LONG,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_HYBRID_LONG,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_AV_ONLY_SHORT,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_HYBRID_SHORT,
+ MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NONE = 0x00,
+ MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_AV_ONLY_LONG = 0x01,
+ MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_HYBRID_LONG = 0x02,
+ MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_AV_ONLY_SHORT = 0x03,
+ MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_HYBRID_SHORT = 0x04,
MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NB
};
enum Phy_Sci_Msg_Data_Type
{
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NONE = 0,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_HP10_FC,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_AV_FC,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_PB,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_TONE_MAP,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_CHANDATA,
+ MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NONE = 0x00,
+ MAXIMUS_PHY_SCI_MSG_DATA_TYPE_HP10_FC = 0x01,
+ MAXIMUS_PHY_SCI_MSG_DATA_TYPE_AV_FC = 0x02,
+ MAXIMUS_PHY_SCI_MSG_DATA_TYPE_PB = 0x03,
+ MAXIMUS_PHY_SCI_MSG_DATA_TYPE_TONE_MAP = 0x04,
+ MAXIMUS_PHY_SCI_MSG_DATA_TYPE_CHANDATA = 0x05,
MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NB
};
enum Phy_Sci_Msg_Pb_Size
{
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_NONE = 0,
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_520_OCTETS,
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_136_OCTETS,
+ MAXIMUS_PHY_SCI_MSG_PB_SIZE_NONE = 0x00,
+ MAXIMUS_PHY_SCI_MSG_PB_SIZE_520_OCTETS = 0x01,
+ MAXIMUS_PHY_SCI_MSG_PB_SIZE_136_OCTETS = 0x02,
MAXIMUS_PHY_SCI_MSG_PB_SIZE_NB
};
enum Phy_Type
{
- PHY_TYPE_NONE = 0,
- PHY_TYPE_AV_DATA,
+ PHY_TYPE_NONE = 0x00,
+ PHY_TYPE_AV_DATA = 0x01,
PHY_TYPE_NB
};
diff --git a/maximus/common/types/system_types.h b/maximus/common/types/system_types.h
index 001739dc21..9a5b09cd87 100644
--- a/maximus/common/types/system_types.h
+++ b/maximus/common/types/system_types.h
@@ -41,8 +41,8 @@ typedef int Error_Id;
enum System_Type
{
- SYSTEM_TYPE_NONE = 0,
- SYSTEM_TYPE_IDLE,
+ SYSTEM_TYPE_NONE = 0x00,
+ SYSTEM_TYPE_IDLE = 0x01,
SYSTEM_TYPE_NB
};
diff --git a/maximus/functioncall/inc/FunctionSciMsg.h b/maximus/functioncall/inc/FunctionSciMsg.h
index cb990bb978..8493371932 100644
--- a/maximus/functioncall/inc/FunctionSciMsg.h
+++ b/maximus/functioncall/inc/FunctionSciMsg.h
@@ -58,8 +58,10 @@ private:
// private attributes
//
+
Sci_Station_Id mStationId;
Function_Call_Type mSpecializedSciMsgType;
+ Function_Call_Parameters_Number mSpecializedSciMsgParametersNumber;
char * mpFunctionName; // unique string identifier for function call
FunctionCallManager * mpFunctionCallManager;
ParametersList * mpListOfParameters;
@@ -223,17 +225,17 @@ public:
Function_Call_Type getSpecializedSciMsgType ( ) const;
/**
- * Set the value of mpSpecializedSciMsgHeader->param_nb
+ * Set the value of mSpecializedSciMsgParametersNumber
* @return bool
- * @param number the new value of mpSpecializedSciMsgHeader->param_nb
+ * @param number_of_parameters the new value of mSpecializedSciMsgParametersNumber
*/
- bool setNumberOfParameters ( const unsigned int number_of_parameters );
+ bool setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters );
/**
- * Get the value of mpSpecializedSciMsgHeader->param_nb
- * @return the value of mpSpecializedSciMsgHeader->param_nb
+ * Get the value of mSpecializedSciMsgParametersNumber
+ * @return the value of mSpecializedSciMsgParametersNumber
*/
- unsigned int getNumberOfParameters ( ) const;
+ Function_Call_Parameters_Number getSpecializedSciMsgParametersNumber ( ) const;
// protected attribute accessor methods
//
diff --git a/maximus/functioncall/src/FunctionCallManager.cpp b/maximus/functioncall/src/FunctionCallManager.cpp
index a4d5bbf192..2355f3aa1f 100644
--- a/maximus/functioncall/src/FunctionCallManager.cpp
+++ b/maximus/functioncall/src/FunctionCallManager.cpp
@@ -172,7 +172,7 @@ bool FunctionCallManager::sendMsg ( FunctionSciMsg * function_sci_msg_to_send )
struct Function_Call_Header functionSciMsgHeader = { FUNCTION_CALL_VERSION,
FUNCTION_CALL_TYPE_REQ,
- function_sci_msg_to_send->getNumberOfParameters(),
+ function_sci_msg_to_send->getSpecializedSciMsgParametersNumber(),
0 }; // flags
bSend &= function_sci_msg_to_send->setSpecializedSciMsgHeader(&functionSciMsgHeader);
diff --git a/maximus/functioncall/src/FunctionSciMsg.cpp b/maximus/functioncall/src/FunctionSciMsg.cpp
index 6f23343abd..56d37a3c58 100644
--- a/maximus/functioncall/src/FunctionSciMsg.cpp
+++ b/maximus/functioncall/src/FunctionSciMsg.cpp
@@ -48,6 +48,7 @@ using namespace std;
FunctionSciMsg::FunctionSciMsg ( ):
mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
+mSpecializedSciMsgParametersNumber(0),
mpFunctionName(NULL),
mpFunctionCallManager(NULL),
mpListOfParameters(NULL),
@@ -61,6 +62,7 @@ mpSpecializedSciMsgHeader(NULL)
FunctionSciMsg::FunctionSciMsg ( FunctionCallManager * p_function_call_manager ):
mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
+mSpecializedSciMsgParametersNumber(0),
mpFunctionName(NULL),
mpFunctionCallManager(NULL),
mpListOfParameters(NULL),
@@ -252,8 +254,15 @@ bool FunctionSciMsg::identifySpecializedSciMsgHeader ( const unsigned long data_
if (NULL != mpSpecializedSciMsgHeader)
{
*mpSpecializedSciMsgHeader = *((Function_Call_Header*)p_data);
- setSpecializedSciMsgType ((Function_Call_Type)mpSpecializedSciMsgHeader->type);
- displaySpecializedSciMsgHeader();
+
+ mSpecializedSciMsgType = static_cast<Function_Call_Type>(mpSpecializedSciMsgHeader->type);
+
+ mSpecializedSciMsgParametersNumber = static_cast<Function_Call_Parameters_Number>(mpSpecializedSciMsgHeader->param_nb);
+
+ //displaySpecializedSciMsgHeader();
+ clog << dec << "\ttype = " << getSpecializedSciMsgType() << endl;
+ clog << dec << "\tnumber of parameters = " << getSpecializedSciMsgParametersNumber() << endl;
+
bIdentifyHeader = true;
}
}
@@ -334,9 +343,9 @@ bool FunctionSciMsg::identifyCallbackParameters ( )
clog << "FunctionSciMsg::identifyCallbackParameters" << endl;
bool bIdentifyParameters = true;
- if ( (0 != getNumberOfParameters()) && (NULL != getSpecializedSciMsgData()) )
+ if ( (0 != getSpecializedSciMsgParametersNumber()) && (NULL != getSpecializedSciMsgData()) )
{
- for (unsigned int n=0; n<getNumberOfParameters(); n++)
+ for (unsigned int n=0; n<getSpecializedSciMsgParametersNumber(); n++)
{
// Find parameter name length
//
@@ -357,32 +366,32 @@ bool FunctionSciMsg::identifyCallbackParameters ( )
clog << "\tparameter " << n+1 << " name = ";
for (unsigned int i=0; i<parameterNameLength+1; i++)
{
- *(parameterToFill.p_name+i) = *(getSpecializedSciMsgData()+i);
+ *(parameterToFill.p_name+i) = static_cast<char>(*(getSpecializedSciMsgData()+i));
clog << *(parameterToFill.p_name+i);
}
clog << endl;
unsigned long tempDataLength = getSpecializedSciMsgDataLength();
unsigned char * pTempData = getSpecializedSciMsgData();
- SciMsg::removeData (parameterNameLength+2, tempDataLength, &pTempData);
+ SciMsg::removeData (parameterNameLength+1, tempDataLength, &pTempData);
bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
- bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
+ bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
+ pTempData = NULL;
// Find parameter length
// Length of parameter value is coded on 2 bytes
//
- stringstream ioss;
- ioss << *(getSpecializedSciMsgData()) << *(getSpecializedSciMsgData()+1);
- ioss >> parameterToFill.length;
- clog << dec << "\tlength of parameter " << n+1 << " value = " << parameterToFill.length << endl;
-
+ uint16_t tempLength = (static_cast<uint8_t>(*(getSpecializedSciMsgData()))<<8) + static_cast<uint8_t>(*(getSpecializedSciMsgData()+1));
+ parameterToFill.length = (unsigned long)tempLength;
+ clog << dec << "\tlength of parameter " << n+1 << " value = " << parameterToFill.length << endl;
+
// Find parameter value
//
parameterToFill.p_value = new unsigned char [parameterToFill.length];
if (NULL != parameterToFill.p_value)
{
clog << "\tparameter " << n+1 << " value = ";
- for (unsigned int i=0; i<parameterToFill.length; i++)
+ for (unsigned int i=0; i<(unsigned int)parameterToFill.length; i++)
{
*(parameterToFill.p_value+i) = *(getSpecializedSciMsgData()+2+i); // +2 because Length of parameter value is coded on 2 bytes
clog << *(parameterToFill.p_value+i);
@@ -391,7 +400,9 @@ bool FunctionSciMsg::identifyCallbackParameters ( )
tempDataLength = getSpecializedSciMsgDataLength();
pTempData = getSpecializedSciMsgData();
+ SciMsg::displaySpecializedSciMsgData();
SciMsg::removeData (2+parameterToFill.length, tempDataLength, &pTempData); // 2 because Length of parameter value is coded on 2 bytes
+ SciMsg::displaySpecializedSciMsgData();
bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
}
@@ -584,7 +595,7 @@ bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
//
if (NULL != pData)
{
- bFill = setNumberOfParameters(numberOfParameters); // set number of parameters
+ bFill = setSpecializedSciMsgParametersNumber (numberOfParameters); // set number of parameters
bFill &= setSpecializedSciMsgDataLength(dataLength); // set data length
bFill &= setSpecializedSciMsgData(pData); // set data
@@ -750,27 +761,20 @@ bool FunctionSciMsg::setFunctionCallManager ( FunctionCallManager * p_function_c
}
-bool FunctionSciMsg::setNumberOfParameters ( const unsigned int number_of_parameters )
+bool FunctionSciMsg::setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters )
{
- clog << "FunctionSciMsg::setNumberOfParameters" << endl;
+ clog << "FunctionSciMsg::setSpecializedSciMsgParametersNumber" << endl;
- mpSpecializedSciMsgHeader->param_nb = (uint8_t)number_of_parameters;
- clog << "\tnumber of parameters = " << dec << mpSpecializedSciMsgHeader->param_nb << endl;
+ mSpecializedSciMsgParametersNumber = number_of_parameters;
+ clog << "\tnumber of parameters = " << dec << mSpecializedSciMsgParametersNumber << endl;
return true;
}
-unsigned int FunctionSciMsg::getNumberOfParameters ( ) const
+Function_Call_Parameters_Number FunctionSciMsg::getSpecializedSciMsgParametersNumber ( ) const
{
- unsigned int numberOfParameters = 0;
-
- // Convert uint8_t to unsigned integer
- stringstream ioss;
- ioss << getSpecializedSciMsgHeader()->param_nb;
- ioss >> numberOfParameters;
-
- return numberOfParameters;
+ return mSpecializedSciMsgParametersNumber;
}
diff --git a/maximus/networkclock/inc/ClockSciMsg.h b/maximus/networkclock/inc/ClockSciMsg.h
index c20653a1b4..ce683cdeeb 100644
--- a/maximus/networkclock/inc/ClockSciMsg.h
+++ b/maximus/networkclock/inc/ClockSciMsg.h
@@ -54,7 +54,9 @@ private:
// private attributes
//
+ Network_Clock_Id mSpecializedSciMsgId;
Network_Clock_Type mSpecializedSciMsgType;
+ Network_Clock_Tick mSpecializedSciMsgTick;
Network_Clock_Header * mpSpecializedSciMsgHeader;
NetworkClockProcessor * mpNetworkClockProcessor;
@@ -130,6 +132,28 @@ public:
* @param type
*/
bool setSpecializedSciMsgType ( const Network_Clock_Type type );
+
+ /**
+ * @return Network_Clock_Tick
+ */
+ Network_Clock_Tick getSpecializedSciMsgTick ( ) const;
+
+ /**
+ * @return bool
+ * @param tick
+ */
+ bool setSpecializedSciMsgTick ( const Network_Clock_Tick tick );
+
+ /**
+ * @return Network_Clock_Id
+ */
+ Network_Clock_Id getSpecializedSciMsgId ( ) const;
+
+ /**
+ * @return bool
+ * @param id
+ */
+ bool setSpecializedSciMsgId ( const Network_Clock_Id id );
// protected attribute accessor methods
//
@@ -142,7 +166,7 @@ private:
void initAttributes ( ) ;
void displaySpecializedSciMsgHeader ( ) const;
-
+
protected:
// protected methods
diff --git a/maximus/networkclock/src/ClockSciMsg.cpp b/maximus/networkclock/src/ClockSciMsg.cpp
index 4023c16241..9413fffafe 100644
--- a/maximus/networkclock/src/ClockSciMsg.cpp
+++ b/maximus/networkclock/src/ClockSciMsg.cpp
@@ -32,8 +32,10 @@ The original location of this file is /home/buret/eclipse/maximus/networkclock/s
#include "NetworkClockProcessor.h"
#include "Error.h"
+//#include <cstring>
#include <iomanip> // for 'std::setfill' and 'std::setw'
#include <iostream> // for 'cout', 'clog' and 'cerr'
+#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
using namespace std;
@@ -42,7 +44,9 @@ using namespace std;
ClockSciMsg::ClockSciMsg ( ):
+mSpecializedSciMsgId(0),
mSpecializedSciMsgType(NETWORK_CLOCK_TYPE_NONE),
+mSpecializedSciMsgTick(0),
mpSpecializedSciMsgHeader(NULL),
mpNetworkClockProcessor(NULL)
{
@@ -53,7 +57,9 @@ mpNetworkClockProcessor(NULL)
ClockSciMsg::ClockSciMsg ( NetworkClockProcessor * p_network_clock_processor ):
+mSpecializedSciMsgId(0),
mSpecializedSciMsgType(NETWORK_CLOCK_TYPE_NONE),
+mSpecializedSciMsgTick(0),
mpSpecializedSciMsgHeader(NULL),
mpNetworkClockProcessor(NULL)
{
@@ -78,7 +84,7 @@ void ClockSciMsg::initAttributes ( )
mpSpecializedSciMsgHeader = new Network_Clock_Header;
if (NULL != mpSpecializedSciMsgHeader)
{
- mpSpecializedSciMsgHeader->version = NETWORK_CLOCK_VERSION;
+ mpSpecializedSciMsgHeader->version = 0;
mpSpecializedSciMsgHeader->type = 0;
mpSpecializedSciMsgHeader->id = 0;
mpSpecializedSciMsgHeader->flags = 0;
@@ -139,28 +145,21 @@ bool ClockSciMsg::dispatchMsg ( )
{
if ( (NULL != SciMsg::getSciMsgHeader()) && (NULL != getSpecializedSciMsgHeader()) )
{
- // Recompose tick value at which event has to be inserted or removed
- //
- uint64_t tempTickValue = (((uint64_t)getSpecializedSciMsgHeader()->tick_high) << 32)+(uint64_t)getSpecializedSciMsgHeader()->tick_low;
- clog << "\ttemp tick value = 0x" << hex << setfill('0') << setw(16) << uppercase << tempTickValue << endl;
- Network_Clock_Tick tickValue = Network_Clock_Tick(tempTickValue);
- clog << "\ttick value = " << dec << tickValue << endl;
-
// Create event to insert or remove
//
NetworkClockEvt evtToDispatch ( SciMsg::getSciMsgHeader()->station_id,
- getSpecializedSciMsgHeader()->id,
+ getSpecializedSciMsgId(),
getSpecializedSciMsgType() );
// According to the clock SCI msg type, dispatch clock SCI msg
//
if ( NETWORK_CLOCK_TYPE_REMOVE == getSpecializedSciMsgType() )
{
- bDispatch = mpNetworkClockProcessor->removeEvt (tickValue, evtToDispatch);
+ bDispatch = mpNetworkClockProcessor->removeEvt (getSpecializedSciMsgTick(), evtToDispatch);
}
else
{
- bDispatch = mpNetworkClockProcessor->insertEvt (tickValue, evtToDispatch);
+ bDispatch = mpNetworkClockProcessor->insertEvt (getSpecializedSciMsgTick(), evtToDispatch);
}
}
else
@@ -195,7 +194,24 @@ bool ClockSciMsg::identifySpecializedSciMsgHeader ( const unsigned long data_len
{
if (NULL != mpSpecializedSciMsgHeader)
{
+ clog << "\tdata = " << p_data << endl;
+
*mpSpecializedSciMsgHeader = *((Network_Clock_Header*)p_data);
+
+ mpSpecializedSciMsgHeader->id = ntohs(mpSpecializedSciMsgHeader->id);
+ mSpecializedSciMsgId = static_cast<Network_Clock_Id>(mpSpecializedSciMsgHeader->id);
+
+ mSpecializedSciMsgType = static_cast<Network_Clock_Type>(mpSpecializedSciMsgHeader->type);
+
+ // Recompose tick value
+ //
+ mpSpecializedSciMsgHeader->tick_high = ntohl(mpSpecializedSciMsgHeader->tick_high);
+ mpSpecializedSciMsgHeader->tick_low = ntohl(mpSpecializedSciMsgHeader->tick_low);
+ uint64_t tempTickValue = (static_cast<uint64_t>(mpSpecializedSciMsgHeader->tick_high)<<32) + static_cast<uint64_t>(mpSpecializedSciMsgHeader->tick_low);
+ clog << "\ttemp tick value = 0x" << hex << setfill('0') << setw(16) << uppercase << tempTickValue << endl;
+ mSpecializedSciMsgTick = static_cast<Network_Clock_Tick>(tempTickValue);
+ clog << "\ttick value = " << dec << mSpecializedSciMsgTick << endl;
+
displaySpecializedSciMsgHeader();
bIdentifyHeader = true;
}
@@ -227,14 +243,9 @@ void ClockSciMsg::displaySpecializedSciMsgHeader( ) const
clog << "ClockSciMsg::displaySciMsgHeader" << endl;
clog << "\tclock SCI msg header = " << endl;
- clog << "\t\tversion = 0x" << hex << setfill('0') << setw(2) << uppercase << getSpecializedSciMsgHeader()->version << endl;
- clog << "\t\ttype = " << dec << getSpecializedSciMsgHeader()->type << endl;
- clog << "\t\tid = 0x" << hex << setfill('0') << setw(4) << uppercase << getSpecializedSciMsgHeader()->id << endl;
- clog << "\t\tflags = 0x" << setfill('0') << setw(4) << uppercase << getSpecializedSciMsgHeader()->flags << endl;
- clog << "\t\treserved = 0x" << setfill('0') << setw(4) << uppercase << getSpecializedSciMsgHeader()->reserved << endl;
- clog << "\t\ttick_high = 0x" << setfill('0') << setw(8) << uppercase << getSpecializedSciMsgHeader()->tick_high << endl;
- clog << "\t\ttick_low = 0x" << setfill('0') << setw(8) << uppercase << getSpecializedSciMsgHeader()->tick_low << endl;
- clog << dec;
+ clog << "\t\ttype = 0x" << hex << setfill('0') << setw(2) << uppercase << getSpecializedSciMsgType() << endl;
+ clog << "\t\tid = 0x" << hex << setfill('0') << setw(4) << uppercase << getSpecializedSciMsgId() << endl;
+ clog << "\t\ttick = 0x" << hex << setfill('0') << setw(8) << uppercase << getSpecializedSciMsgTick() << endl;
}
@@ -300,6 +311,18 @@ bool ClockSciMsg::setSpecializedSciMsgType ( const Network_Clock_Type type )
}
+Network_Clock_Tick ClockSciMsg::getSpecializedSciMsgTick ( ) const
+{
+ return mSpecializedSciMsgTick;
+}
+
+
+Network_Clock_Id ClockSciMsg::getSpecializedSciMsgId ( ) const
+{
+ return mSpecializedSciMsgId;
+}
+
+
// protected attribute accessor methods
//
diff --git a/maximus/sci/inc/SciMsg.h b/maximus/sci/inc/SciMsg.h
index b184414004..e23c7dce03 100644
--- a/maximus/sci/inc/SciMsg.h
+++ b/maximus/sci/inc/SciMsg.h
@@ -248,8 +248,6 @@ private:
void displaySciMsgData ( ) const;
- void displaySpecializedSciMsgData ( ) const;
-
protected:
// protected methods
@@ -261,8 +259,9 @@ protected:
* @param data_length
* @param data
*/
- bool removeData ( const unsigned long data_length_to_remove, unsigned long & data_length, unsigned char ** pp_data );
-
+ bool removeData ( const unsigned long data_length_to_remove, unsigned long & data_length, unsigned char ** pp_data );
+
+ void displaySpecializedSciMsgData ( ) const;
};
diff --git a/maximus/sci/src/SciMsg.cpp b/maximus/sci/src/SciMsg.cpp
index 06f894b01a..711c89e15a 100644
--- a/maximus/sci/src/SciMsg.cpp
+++ b/maximus/sci/src/SciMsg.cpp
@@ -32,6 +32,7 @@ The original location of this file is /home/buret/eclipse/maximus/sci/src/SciMsg
#include "Station.h"
#include "Error.h"
+#include <sstream> // for 'stringstream'
#include <iomanip> // for 'std::setfill' and 'std::setw'
#include <iostream> // for 'cout', 'cerr' and 'clog'
using namespace std;
@@ -221,16 +222,15 @@ void SciMsg::displaySciMsgHeader ( ) const
clog << "\tSCI msg header = " << endl;
clog << "\t\tmagic_id = 0x" << hex << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->magic_id << endl;
+ clog << "\t\tversion = 0x" << hex << setfill('0') << setw(2) << uppercase << getSciMsgHeader()->version << endl;
+ clog << "\t\ttype = 0x" << hex << setfill('0') << setw(2) << uppercase << getSciMsgHeader()->type << endl;
clog << "\t\tlength = " << dec << getSciMsgHeader()->length << endl;
- clog << "\t\ttype = " << getSciMsgHeader()->type << endl;
- clog << "\t\tversion = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->version << endl;
- clog << "\t\tmsg_id = 0x" << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->msg_id << endl;
- clog << "\t\tstation_id = 0x" << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->station_id << endl;
- clog << "\t\tnetclock_high = 0x" << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->netclock_high << endl;
- clog << "\t\tnetclock_low = 0x" << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->netclock_low << endl;
- clog << "\t\treserved = 0x" << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->reserved << endl;
- clog << "\t\tflags = 0x" << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->flags << endl;
- clog << dec;
+ clog << "\t\tstation_id = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->station_id << endl;
+ clog << "\t\tmsg_id = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->msg_id << endl;
+ clog << "\t\tnetclock_high = 0x" << hex << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->netclock_high << endl;
+ clog << "\t\tnetclock_low = 0x" << hex << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->netclock_low << endl;
+ clog << "\t\tflags = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->flags << endl;
+ clog << "\t\treserved = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->reserved << endl;
}
@@ -254,26 +254,6 @@ void SciMsg::displaySciMsgData ( ) const
}
-void SciMsg::displaySpecializedSciMsgData ( ) const
-{
- clog << "SciMsg::displaySpecializedSciMsgData" << endl;
-
- clog << "\tspecialized SCI msg data = ";
- if (NULL != getSpecializedSciMsgData())
- {
- for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
- {
- clog << *(getSpecializedSciMsgData()+i);
- }
- }
- else
- {
- clog << "NULL";
- }
- clog << endl;
-}
-
-
// protected methods
//
@@ -299,6 +279,10 @@ bool SciMsg::removeData ( const unsigned long data_length_to_remove, unsigned lo
}
data_length -= data_length_to_remove; // update data length
+ if (0 == data_length)
+ {
+ *pp_data = NULL;
+ }
delete [] remainingData;
remainingData = NULL;
@@ -309,6 +293,26 @@ bool SciMsg::removeData ( const unsigned long data_length_to_remove, unsigned lo
}
+void SciMsg::displaySpecializedSciMsgData ( ) const
+{
+ clog << "SciMsg::displaySpecializedSciMsgData" << endl;
+
+ clog << "\tspecialized SCI msg data = ";
+ if (NULL != getSpecializedSciMsgData())
+ {
+ for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
+ {
+ clog << *(getSpecializedSciMsgData()+i);
+ }
+ }
+ else
+ {
+ clog << "NULL";
+ }
+ clog << endl;
+}
+
+
// Accessor methods
//
@@ -433,7 +437,7 @@ bool SciMsg::setSciMsgDataLength ( const unsigned long data_length )
clog << "SciMsg::setSciMsgDataLength" << endl;
mSciMsgDataLength = data_length;
- clog << "\tSCI msg data length = " << mSciMsgDataLength << endl;
+ clog << "\tSCI msg data length = " << dec << mSciMsgDataLength << endl;
return true;
}
@@ -487,20 +491,28 @@ bool SciMsg::setSpecializedSciMsgData ( const unsigned char * p_data )
{
clog << "SciMsg::setSpecializedSciMsgData" << endl;
bool bSetData = false;
-
- mpSpecializedSciMsgData = new unsigned char [getSpecializedSciMsgDataLength()];
- if (NULL != mpSpecializedSciMsgData)
- {
- for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
+
+ if (NULL != p_data)
+ {
+ mpSpecializedSciMsgData = new unsigned char [getSpecializedSciMsgDataLength()];
+ if (NULL != mpSpecializedSciMsgData)
+ {
+ for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
+ {
+ *(mpSpecializedSciMsgData+i) = *(p_data+i);
+ }
+ displaySpecializedSciMsgData ();
+ bSetData = true;
+ }
+ else
{
- *(mpSpecializedSciMsgData+i) = *(p_data+i);
+ throw Error("SciMsg::setSciMsgData", "Initialized data pointer is NULL");
}
- displaySpecializedSciMsgData ();
- bSetData = true;
}
else
{
- throw Error("SciMsg::setSciMsgData", "Received data pointer is NULL");
+ mpSpecializedSciMsgData = NULL;
+ bSetData = true;
}
return bSetData;
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 9279646bf4..4919ced251 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -242,8 +242,6 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
//
if (NULL != header)
{
- displayMsgHeader(header);
-
// Create a specialized SCI message according to the message header type
//
SciMsg * sciMsg = NULL;
@@ -420,18 +418,17 @@ void SciServer::displayMsgHeader ( const Sci_Msg_Header * msg_header ) const
if (NULL != msg_header)
{
- clog << hex;
- clog << "\tmagic_id = 0x" << setfill('0') << setw(8) << uppercase << msg_header->magic_id << endl;
- clog << "\tversion = 0x" << setfill('0') << setw(2) << uppercase << msg_header->version << endl;
- clog << "\ttype = 0x" << setfill('0') << setw(2) << uppercase << msg_header->type << endl;
- clog << "\tlength = 0x" << setfill('0') << setw(4) << uppercase << msg_header->length << endl;
- clog << "\tstation_id = 0x" << setfill('0') << setw(4) << uppercase << msg_header->station_id << endl;
- clog << "\tmsg_id = 0x" << setfill('0') << setw(4) << uppercase << msg_header->msg_id << endl;
- clog << "\tnetclock_high = 0x" << setfill('0') << setw(8) << uppercase << msg_header->netclock_high << endl;
- clog << "\tnetclock_low = 0x" << setfill('0') << setw(8) << uppercase << msg_header->netclock_low << endl;
- clog << "\tflags = 0x" << setfill('0') << setw(4) << uppercase << msg_header->flags << endl;
- clog << "\treserved = 0x" << setfill('0') << setw(4) << uppercase << msg_header->reserved << endl;
- clog << dec;
+ clog << "\tmsg header = " << endl;
+ clog << "\t\tmagic_id = 0x" << hex << setfill('0') << setw(8) << uppercase << msg_header->magic_id << endl;
+ clog << "\t\tversion = 0x" << hex << setfill('0') << setw(2) << uppercase << msg_header->version << endl;
+ clog << "\t\ttype = 0x" << hex << setfill('0') << setw(2) << uppercase << msg_header->type << endl;
+ clog << "\t\tlength = " << dec << msg_header->length << endl;
+ clog << "\t\tstation_id = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->station_id << endl;
+ clog << "\t\tmsg_id = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->msg_id << endl;
+ clog << "\t\tnetclock_high = 0x" << hex << setfill('0') << setw(8) << uppercase << msg_header->netclock_high << endl;
+ clog << "\t\tnetclock_low = 0x" << hex << setfill('0') << setw(8) << uppercase << msg_header->netclock_low << endl;
+ clog << "\t\tflags = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->flags << endl;
+ clog << "\t\treserved = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->reserved << endl;
}
else
{
diff --git a/maximus/sci/src/SciServerTest.cpp b/maximus/sci/src/SciServerTest.cpp
index d95d590e53..bdc3353bff 100644
--- a/maximus/sci/src/SciServerTest.cpp
+++ b/maximus/sci/src/SciServerTest.cpp
@@ -10,8 +10,6 @@
#include <string>
#include <iostream>
#include <iomanip>
-#include <stdio.h>
-#include <stdlib.h>
using namespace std;
CPPUNIT_TEST_SUITE_REGISTRATION (SciServerTest);
@@ -238,26 +236,44 @@ void SciServerTest::receiveClockSciMsgTest ( Sci_Msg_Header & msg_header )
// Message header type and length have to be set to the corresponding specialized SCI message
//
- msg_header.type = 0x01;//SCI_MSG_TYPE_NETWORK_CLOCK; // uint8_t type = 0x01
- msg_header.length = (uint16_t)(sizeof(struct Network_Clock_Header)); // uint16_t length = 0x0010
-
- unsigned long dataLength = 28;//(unsigned long)msg_header.length; // 16
-
+ msg_header.type = SCI_MSG_TYPE_NETWORK_CLOCK; // uint8_t type = 0x01
+
+ /*
stringstream ioss;
ioss << hex << setfill('0') << setw(2) << uppercase << NETWORK_CLOCK_VERSION; // uint8_t version = 0x01
ioss << hex << setfill('0') << setw(2) << uppercase << NETWORK_CLOCK_TYPE_STATION; // uint8_t type = 0x02
- ioss << hex << setfill('0') << setw(4) << uppercase << 0x0000; // uint16_t id
- ioss << hex << setfill('0') << setw(4) << uppercase << 0xFFFF; // uint16_t flags
- ioss << hex << setfill('0') << setw(4) << uppercase << 0xFFFF; // uint16_t reserved
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0x0123; // uint16_t id
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0x4567; // uint16_t flags
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0x8912; // uint16_t reserved
ioss << hex << setfill('0') << setw(8) << uppercase << 0x01234567; // uint32_t tick_high
ioss << hex << setfill('0') << setw(8) << uppercase << 0x89101113; // uint32_t tick_low
- unsigned char * pData = new unsigned char [ioss.str().length()];
+ */
+
+ unsigned long dataLength = (unsigned long)sizeof(Network_Clock_Header);
+ clog << "\tdata length = " << dec << dataLength << endl;
+ msg_header.length = (uint16_t)dataLength;
+
+ unsigned char * pData = new unsigned char [dataLength];
if (NULL != pData)
{
- ioss >> (unsigned char *)pData;
- clog << "\tdata = 0x" << hex << pData << endl;
+ *pData = static_cast<unsigned char>(NETWORK_CLOCK_VERSION);
+ *(pData+1) = static_cast<unsigned char>(NETWORK_CLOCK_TYPE_STATION);
+ *(pData+2) = static_cast<unsigned char>(0x01);
+ *(pData+3) = static_cast<unsigned char>(0x23);
+ *(pData+4) = static_cast<unsigned char>(0x45);
+ *(pData+5) = static_cast<unsigned char>(0x67);
+ *(pData+6) = static_cast<unsigned char>(0x89);
+ *(pData+7) = static_cast<unsigned char>(0x12);
+ *(pData+8) = static_cast<unsigned char>(0x01);
+ *(pData+9) = static_cast<unsigned char>(0x23);
+ *(pData+10) = static_cast<unsigned char>(0x45);
+ *(pData+11) = static_cast<unsigned char>(0x67);
+ *(pData+12) = static_cast<unsigned char>(0x89);
+ *(pData+13) = static_cast<unsigned char>(0x10);
+ *(pData+14) = static_cast<unsigned char>(0x11);
+ *(pData+15) = static_cast<unsigned char>(0x13);
}
-
+
// Test the receiveMsg method
//
clog << "\tSciServerTest -> SciServer::receiveMsg" << endl;
@@ -280,11 +296,28 @@ void SciServerTest::receiveSystemSciMsgTest ( Sci_Msg_Header & msg_header )
// Message header type and length have to be set to the corresponding specialized SCI message
//
- msg_header.type = SCI_MSG_TYPE_SYSTEM;
- msg_header.length = (uint16_t)sizeof(struct System_Header);
+ msg_header.type = SCI_MSG_TYPE_SYSTEM; // uint8_t type = 0x04
- unsigned long dataLength = (unsigned long)msg_header.length;
- unsigned char * pData = new unsigned char [dataLength]; // TO FILL
+ /*
+ stringstream ioss;
+ ioss << hex << setfill('0') << setw(2) << uppercase << SYSTEM_VERSION; // uint8_t version = 0x01
+ ioss << hex << setfill('0') << setw(2) << uppercase << SYSTEM_TYPE_IDLE; // uint8_t type = 0x01
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0xFFFF; // uint16_t flags
+ */
+
+ unsigned long dataLength = sizeof(struct System_Header);
+ clog << "\tdata length = " << dec << dataLength << endl;
+ msg_header.length = (uint16_t)dataLength;
+
+ unsigned char * pData = new unsigned char [dataLength];
+ if (NULL != pData)
+ {
+ *pData = static_cast<unsigned char>(SYSTEM_VERSION);
+ *(pData+1) = static_cast<unsigned char>(SYSTEM_TYPE_IDLE);
+ *(pData+2) = static_cast<unsigned char>(0xFF);
+ *(pData+3) = static_cast<unsigned char>(0xFF);
+ clog << "\tdata = " << pData << endl;
+ }
// Test the receiveMsg method
//
@@ -308,11 +341,31 @@ void SciServerTest::receivePhySciMsgTest ( Sci_Msg_Header & msg_header )
// Message header type and length have to be set to the corresponding specialized SCI message
//
- msg_header.type = SCI_MSG_TYPE_PHY;
- msg_header.length = (uint16_t)sizeof(struct Phy_Header);
-
- unsigned long dataLength = (unsigned long)msg_header.length;
- unsigned char * pData = new unsigned char [dataLength]; // TO FILL
+ msg_header.type = SCI_MSG_TYPE_PHY; // uint8_t type = 0x03
+
+ /*
+ stringstream ioss;
+ ioss << hex << setfill('0') << setw(2) << uppercase << PHY_VERSION; // uint8_t version = 0x01
+ ioss << hex << setfill('0') << setw(2) << uppercase << PHY_TYPE_AV_DATA; // uint8_t type = 0x01
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0x0000; // uint16_t nek
+ ioss << hex << setfill('0') << setw(2) << uppercase << MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NONE; // uint8_t mpdu_format = 0x00
+ ioss << hex << setfill('0') << setw(2) << uppercase << MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NONE; // uint8_t data_type = 0x00
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0x0000; // uint16_t nb_of_pbs
+ ioss << hex << setfill('0') << setw(2) << uppercase << MAXIMUS_PHY_SCI_MSG_PB_SIZE_NONE; // uint8_t pb_size = 0x00
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0xFFFF; // uint16_t reserved
+ ioss << hex << setfill('0') << setw(4) << uppercase << 0xFFFF; // uint16_t flags
+ */
+
+ unsigned long dataLength = sizeof(struct Phy_Header);
+ clog << "\tdata length = " << dec << dataLength << endl;
+ msg_header.length = (uint16_t)dataLength;
+
+ unsigned char * pData = new unsigned char [dataLength];
+ if (NULL != pData)
+ {
+ // ...
+ clog << "\tdata = " << pData << endl;
+ }
//Test the receiveMsg method
//
@@ -337,11 +390,37 @@ void SciServerTest::receiveFunctionSciMsgTest ( Sci_Msg_Header & msg_header )
// Message header type and length have to be set to the corresponding specialized SCI message
//
msg_header.type = SCI_MSG_TYPE_FUNCTION_CALL;
- msg_header.length = 60;
- unsigned long dataLength = (unsigned long)msg_header.length;
- unsigned char * pData = new unsigned char [dataLength]; // TO FILL
- //"0020functionSciMsgCallback\0parameter1\0 012parameter2\0 03123\0"
+ stringstream ioss;
+ ioss << static_cast<unsigned char>(FUNCTION_CALL_VERSION); // uint8_t version = 0x01
+ ioss << static_cast<unsigned char>(FUNCTION_CALL_TYPE_REQ); // uint8_t type = 0x01
+ ioss << static_cast<unsigned char>(0x02); // uint8_t param_nb
+ ioss << static_cast<unsigned char>(0xFF); // uint8_t flags
+ ioss << "functionSciMsgCallback"; // function call id: null terminated string; id of the called function
+ ioss << '\0';
+ // parameter list: for each parameter inside the function call message
+ ioss << "parameter1"; // parameter id: null terminated string; id of the parameter
+ ioss << '\0';
+ ioss << static_cast<unsigned char>(0x00); // parameter length: 2 bytes; length of parameter data
+ ioss << static_cast<unsigned char>(0x01);
+ ioss << static_cast<unsigned char>(0x02); // parameter data: binary content of parameter data
+ ioss << "parameter2"; // parameter id: null terminated string; id of the parameter
+ ioss << '\0';
+ ioss << static_cast<unsigned char>(0x00); // parameter length: 2 bytes; length of parameter data
+ ioss << static_cast<unsigned char>(0x02);
+ ioss << static_cast<unsigned char>(0x01); // parameter data: binary content of parameter data
+ ioss << static_cast<unsigned char>(0x23);
+
+ unsigned long dataLength = ioss.str().length();
+ clog << "\tdata length = " << dec << dataLength << endl;
+ msg_header.length = (uint16_t)dataLength;
+
+ unsigned char * pData = new unsigned char [dataLength+1];
+ if (NULL != pData)
+ {
+ ioss >> pData;
+ clog << "\tdata = " << pData << endl;
+ }
// Register callback
//
@@ -360,7 +439,7 @@ void SciServerTest::receiveFunctionSciMsgTest ( Sci_Msg_Header & msg_header )
//
clog << "\tSciServerTest -> SciServer::receiveMsg" << endl;
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("receiveMsg FunctionSciMsg failed"),
- !mpSciServer->receiveMsg (&msg_header, dataLength, pData) );
+ mpSciServer->receiveMsg (&msg_header, dataLength, pData) );
// Free allocated memory
//
diff --git a/maximus/system/src/SystemSciMsg.cpp b/maximus/system/src/SystemSciMsg.cpp
index c6f8e38897..8c0f58dedc 100644
--- a/maximus/system/src/SystemSciMsg.cpp
+++ b/maximus/system/src/SystemSciMsg.cpp
@@ -164,15 +164,12 @@ bool SystemSciMsg::identifySpecializedSciMsgHeader ( const unsigned long data_le
if (NULL != mpSpecializedSciMsgHeader)
{
*mpSpecializedSciMsgHeader = *((System_Header*)p_data);
- if ( '1' == getSpecializedSciMsgHeader()->type )
- {
- setSpecializedSciMsgType(SYSTEM_TYPE_IDLE);
- }
- else
- {
- setSpecializedSciMsgType(SYSTEM_TYPE_NONE);
- }
- displaySpecializedSciMsgHeader();
+
+ mSpecializedSciMsgType = static_cast<System_Type>(mpSpecializedSciMsgHeader->type);
+
+ displaySpecializedSciMsgHeader();
+
+
bIdentifyHeader = true;
}
else
@@ -206,7 +203,7 @@ void SystemSciMsg::displaySpecializedSciMsgHeader ( ) const
clog << "\tsystem SCI msg header = " << endl;
clog << "\t\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << getSpecializedSciMsgHeader()->version << endl;
- clog << "\t\ttype = " << dec << getSpecializedSciMsgHeader()->type << endl;
+ clog << "\t\ttype = " << dec << getSpecializedSciMsgType() << endl;
clog << "\t\tflags = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->flags << endl;
clog << dec;
}