summaryrefslogtreecommitdiff
path: root/maximus/sci/src
diff options
context:
space:
mode:
authorburet2007-07-18 09:46:16 +0000
committerburet2007-07-18 09:46:16 +0000
commitff0091cef88cd388d1ea5af85588e2205e6ee549 (patch)
tree640d675e4b7380c2abee887d3baf3c035c2419d0 /maximus/sci/src
parent9b5f168c7dd1278f0d9bf0370de14d29498388c6 (diff)
Maximus phy sci msg:
- check msg header - receive/send msg - create unitary test files + old corrections git-svn-id: svn+ssh://pessac/svn/cesar/trunk@495 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus/sci/src')
-rw-r--r--maximus/sci/src/SciServer.cpp52
-rw-r--r--maximus/sci/src/SciServerTest.cpp39
2 files changed, 80 insertions, 11 deletions
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 1c55190085..c6b17d382b 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -287,6 +287,58 @@ bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
}
+bool SciServer::sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const
+{
+ clog << "<--- SciServer::sendSciMsgToAllActiveStations" << endl;
+ bool bSend = false;
+
+ // Skim through stations list
+ //
+ if ( (NULL != mpListOfStations) && (!mpListOfStations->empty()) )
+ {
+ int length;
+ int totalLength;
+
+ for (StationsList::const_iterator it = mpListOfStations->begin(); it != mpListOfStations->end(); ++it)
+ {
+ if (NULL != *it)
+ {
+ // Before sending a SCI msg, check that station status is not 'DEACTIVATED'
+ // Then, station status is set to 'BUSY'
+ // Station status will stay 'BUSY' until a system 'IDLE' msg will be received
+ //
+ if (MAXIMUS_STATION_STATUS_DEACTIVATED != (*it)->getStationStatus())
+ {
+ (*it)->setStationStatus(MAXIMUS_STATION_STATUS_BUSY);
+
+ // Write data into output pipe
+ //
+ length = 0;
+ totalLength = 0;
+ while(totalLength < (int)sci_msg_to_send.getSciMsgDataLength())
+ {
+ length = write((*it)->getOutputFileDescriptor(), sci_msg_to_send.getSciMsgData() + totalLength, sci_msg_to_send.getSciMsgDataLength());
+ if(length < 0)
+ {
+ throw Error("SciServer::sendSciMsgToAllActiveStations", "Write data failed");
+ }
+ totalLength += length;
+ }
+ clog << "\tSCI msg data have been written on pipe" << endl;
+ bSend = true;
+ }
+ }
+ else
+ {
+ throw Error("SciServer::sendSciMsgToAllActiveStations", "A station pointer is NULL");
+ }
+ }
+ }
+
+ return bSend;
+}
+
+
bool SciServer::registerSpecializedSciMsg ( const Sci_Msg_Type sci_msg_type, SciMsg * sci_msg )
{
clog << "SciServer::registerSpecializedSciMsg" << endl;
diff --git a/maximus/sci/src/SciServerTest.cpp b/maximus/sci/src/SciServerTest.cpp
index e6d6601ea6..f69a7c8fc7 100644
--- a/maximus/sci/src/SciServerTest.cpp
+++ b/maximus/sci/src/SciServerTest.cpp
@@ -147,6 +147,9 @@ void SciServerTest::receiveMsgTest (void)
0xFFFF, //uint16_t flags
0xFFFF }; // uint16_t reserved
+ clog << "\tSciServerTest -> SystemManager::updateStationStatus" << endl;
+ mpSystemManager->updateStationStatus ( stationId, MAXIMUS_STATION_STATUS_IDLE );
+
try
{
receiveClockSciMsgTest (msgHeader);
@@ -333,23 +336,37 @@ void SciServerTest::receivePhySciMsgTest ( Sci_Msg_Header & msg_header )
//
msg_header.type = SCI_MSG_TYPE_PHY; // uint8_t type = 0x03
- Phy_Header phyHeader = { PHY_VERSION, // uint8_t version = 0x01
- PHY_TYPE_AV_DATA, // uint8_t type = 0x01
- 0x0000, // uint16_t nek
- MAXIMUS_PHY_MPDU_FORMAT_NONE, // uint8_t mpdu_format = 0x00
- MAXIMUS_PHY_DATA_TYPE_NONE, // uint8_t data_type = 0x00
- 0x0000, // uint16_t nb_of_pbs
- MAXIMUS_PHY_PB_SIZE_NONE, // uint8_t pb_size = 0x00
- 0xFFFF, // uint16_t reserved
- 0xFFFF }; // uint16_t flags
-
- unsigned long dataLength = sizeof(struct Phy_Header);
+ uint32_t nek[4];
+ memset(nek, 'a', 4*sizeof(uint32_t));
+ uint32_t pbMeasurement [PHY_PB_MAX_NB];
+ memset(pbMeasurement, 'b', PHY_PB_MAX_NB*sizeof(uint32_t));
+ uint32_t pbHeader [PHY_PB_MAX_NB];
+ memset(pbHeader, 'c', PHY_PB_MAX_NB*sizeof(uint32_t));
+
+ Phy_Header phyHeader;
+ phyHeader.version = PHY_VERSION;
+ phyHeader.type = PHY_TYPE_MPDU_PAYLOAD;
+ phyHeader.mpdu_format = PHY_MPDU_FORMAT_BEACON;
+ phyHeader.pb_nb = 1;
+ phyHeader.tonemap_index = 2;
+ phyHeader.flags = PHY_FLAG_CRC_OK;
+ phyHeader.reserved = 0xFFFF;
+ memcpy(phyHeader.nek, nek, 4*sizeof(uint32_t));
+ memcpy(phyHeader.pb_measurement, pbMeasurement, PHY_PB_MAX_NB*sizeof(uint32_t));
+ memcpy(phyHeader.pb_header, pbHeader, PHY_PB_MAX_NB*sizeof(uint32_t));
+
+ unsigned long pbDataLength = 128;
+ unsigned char pbData [pbDataLength];
+ memset (pbData, '9', pbDataLength);
+
+ unsigned long dataLength = sizeof(struct Phy_Header)+pbDataLength;
msg_header.length = (uint16_t)dataLength;
unsigned char * pData = new unsigned char [dataLength];
if (NULL != pData)
{
memcpy(pData, (unsigned char *)&phyHeader, sizeof(struct Phy_Header));
+ memcpy(pData+sizeof(struct Phy_Header), pbData, pbDataLength);
}
//Test the receiveMsg method