summaryrefslogtreecommitdiff
path: root/maximus
diff options
context:
space:
mode:
authorburet2007-12-04 17:09:33 +0000
committerburet2007-12-04 17:09:33 +0000
commita10b4d7c1f46696b2b0b54c1d52b0a0e97bc9a2f (patch)
treed036df55f82a943403afb547a7884dcab0e7bc3d /maximus
parent0b263f2f76445fea160db64f772c81bbd91e7939 (diff)
Maximus V2: add a "get_date" function to get the Maximus current tick value.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1089 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus')
-rw-r--r--maximus/common/interfaces/Maximus.h5
-rw-r--r--maximus/coreengine/inc/MaximusTest.h2
-rw-r--r--maximus/coreengine/src/Maximus.cpp19
-rw-r--r--maximus/coreengine/src/MaximusTest.cpp20
-rw-r--r--maximus/python/maximus/simu/__init__.py2
-rw-r--r--maximus/python/maximus/simu/date.py7
-rw-r--r--maximus/python/src/interface_module.cpp3
-rw-r--r--maximus/python/test/test_interface.py12
-rw-r--r--maximus/python/test/test_macframe.py31
-rw-r--r--maximus/python/test/test_simu.py6
10 files changed, 71 insertions, 36 deletions
diff --git a/maximus/common/interfaces/Maximus.h b/maximus/common/interfaces/Maximus.h
index ee375b7f32..2d2f9bc84b 100644
--- a/maximus/common/interfaces/Maximus.h
+++ b/maximus/common/interfaces/Maximus.h
@@ -159,6 +159,11 @@ public:
*/
void disturb_channel ( const bool enable = true );
+ /**
+ * Get the Network Clock current tick.
+ */
+ const tick_t get_date ( );
+
private:
// private attributes
diff --git a/maximus/coreengine/inc/MaximusTest.h b/maximus/coreengine/inc/MaximusTest.h
index db1fcfeca3..bb5140ad16 100644
--- a/maximus/coreengine/inc/MaximusTest.h
+++ b/maximus/coreengine/inc/MaximusTest.h
@@ -20,6 +20,7 @@ class MaximusTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST (send_mpdu_test);
CPPUNIT_TEST (wait_test);
CPPUNIT_TEST (disturb_channel_test);
+ CPPUNIT_TEST (get_date_test);
CPPUNIT_TEST_SUITE_END ();
public:
@@ -37,6 +38,7 @@ protected:
void send_mpdu_test (void);
void wait_test (void);
void disturb_channel_test (void);
+ void get_date_test (void);
private:
diff --git a/maximus/coreengine/src/Maximus.cpp b/maximus/coreengine/src/Maximus.cpp
index ebfbefa807..08331daba8 100644
--- a/maximus/coreengine/src/Maximus.cpp
+++ b/maximus/coreengine/src/Maximus.cpp
@@ -520,6 +520,25 @@ void Maximus::disturb_channel ( const bool enable )
}
+const tick_t Maximus::get_date ( )
+{
+ logFunction();
+ tick_t date = 0;
+
+ try
+ {
+ date = getNetworkClockProcessor()->getCurrentTickValue();
+ }
+ catch ( Error &e )
+ {
+ e.display();
+ stop();
+ }
+
+ return date;
+}
+
+
// private methods
//
diff --git a/maximus/coreengine/src/MaximusTest.cpp b/maximus/coreengine/src/MaximusTest.cpp
index 6247616d23..7be3497c2c 100644
--- a/maximus/coreengine/src/MaximusTest.cpp
+++ b/maximus/coreengine/src/MaximusTest.cpp
@@ -195,7 +195,6 @@ void MaximusTest::wait_test (void)
{
Sta sta = mpMaximus->create_sta();
mpMaximus->wait(10);
- mpMaximus->process();
mpMaximus->wait();
}
else
@@ -220,3 +219,22 @@ void MaximusTest::disturb_channel_test (void)
}
}
+
+void MaximusTest::get_date_test (void)
+{
+ logTest();
+
+ if (NULL != mpMaximus)
+ {
+ tick_t date = mpMaximus->get_date();
+ tick_t offset = 100;
+ Sta sta = mpMaximus->create_sta();
+ mpMaximus->wait(offset);
+ CPPUNIT_ASSERT_MESSAGE ( "get_date failed", date + offset == mpMaximus->get_date() );
+ }
+ else
+ {
+ CPPUNIT_FAIL ("Maximus pointer is NULL");
+ }
+}
+
diff --git a/maximus/python/maximus/simu/__init__.py b/maximus/python/maximus/simu/__init__.py
index bc30c2eb04..52df4e4ef8 100644
--- a/maximus/python/maximus/simu/__init__.py
+++ b/maximus/python/maximus/simu/__init__.py
@@ -2,5 +2,5 @@
print __name__
-__all__ = ["date", "filter", "receive", "send"]
+__all__ = ["filter", "receive", "send"]
diff --git a/maximus/python/maximus/simu/date.py b/maximus/python/maximus/simu/date.py
deleted file mode 100644
index 48193e8870..0000000000
--- a/maximus/python/maximus/simu/date.py
+++ /dev/null
@@ -1,7 +0,0 @@
-#! usr/bin/env python
-
-print __name__
-
-def get_date():
- print get_date.func_name
-
diff --git a/maximus/python/src/interface_module.cpp b/maximus/python/src/interface_module.cpp
index b682ee7ec8..61d8185998 100644
--- a/maximus/python/src/interface_module.cpp
+++ b/maximus/python/src/interface_module.cpp
@@ -424,8 +424,6 @@ BOOST_PYTHON_MODULE(interface)
class_<Maximus, boost::noncopyable>("Maximus")
.def("init", init_wrap)
- .def("init_phy", &Maximus::init_phy)
- //.def("init_ether", &Maximus::init_ether)
.def("process", &Maximus::process)
.def("create_sta", create_sta_wrap)
.def("create_fcall", create_fcall_wrap)
@@ -437,6 +435,7 @@ BOOST_PYTHON_MODULE(interface)
.def("wait", waitx1)
.def("wait", waitx2)
.def("disturb_channel", &Maximus::disturb_channel, disturb_channel_overloads())
+ .def("get_date", &Maximus::get_date)
;
/* class Sta */
diff --git a/maximus/python/test/test_interface.py b/maximus/python/test/test_interface.py
index 22c0d407b4..427a2371f0 100644
--- a/maximus/python/test/test_interface.py
+++ b/maximus/python/test/test_interface.py
@@ -133,11 +133,17 @@ class TestInterfaceFunctions(unittest.TestCase):
def test_wait(self):
self.m.wait()
self.m.wait(500000)
-
- def test_enable_channel(self):
+
+ def test_disturb_channel(self):
self.m.disturb_channel()
self.m.disturb_channel(False)
-
+
+ def test_get_date(self):
+ date = self.m.get_date()
+ offset = 10000
+ self.m.wait(offset)
+ self.assertEqual(date+offset, self.m.get_date(), "get_date failed")
+
def test_remove(self):
# Remove station
diff --git a/maximus/python/test/test_macframe.py b/maximus/python/test/test_macframe.py
index b27f2a85e1..be3897ea46 100644
--- a/maximus/python/test/test_macframe.py
+++ b/maximus/python/test/test_macframe.py
@@ -19,6 +19,9 @@ m = Maximus()
argv = ['test_macframe.py', '-e', '/home/buret/workspace/maximus/maximus/stationtest/obj/stationtest.elf', '-l', '0']
m.init(argv)
+def prepare_rx(s):
+ m.create_fcall('prepare_rx').send(s)
+
# Create a MAC Frame
macFrame1 = macframe.MACFrame(FC_10 = fc_10.FC_10(), FC_AV = fc_av.FC_AV())
@@ -45,18 +48,13 @@ station = m.create_sta()
fcall1 = m.create_fcall('set_tonemask')
fcall1.send(station)
-# Send the MAC Frame synchronously
-fcall2 = m.create_fcall('prepare_rx')
-fcall2.send(station)
-rsp = macFrame4.sendnrecv(m)
-
# Send the MAC Frame asynchronously
-fcall2.send(station)
+prepare_rx(station)
macFrame4.send(m)
# Create a MAC Frame containing an MME
macFrame5 = macframe.MACFrame(msdu=mme.MME())
-fcall2.send(station)
+prepare_rx(station)
macFrame5.send(m)
station.remove()
@@ -319,21 +317,20 @@ class TestMACFrameFunctions(unittest.TestCase):
def test_set_macframe_attr(self):
fc10 = 10
fcav = (0, 1, 2, 3)
- payload = 'ABCDEFGHIJKL'
+ msdu = 'ABCDEFGHIJKL'
+ header = macframe.MACFrameHeader(MFL=len(msdu)-1)
+ icv = '1234'
+ payload = header.get() + msdu + icv
self.macframe.set_macframe_attr(fc10, fcav, payload)
self.assertEqual(self.macframe.get_fc_10(), fc10)
self.assertEqual(self.macframe.get_fc_av(), fcav)
- self.assertEqual(self.macframe.get_macframeheader(), 'AB')
- self.assertEqual(self.macframe.get_msdu(), 'CDEFGH')
- self.assertEqual(self.macframe.get_icv(), 'IJKL')
+ self.assertEqual(self.macframe.get_macframeheader(), header.get())
+ self.assertEqual(self.macframe.get_msdu(), msdu)
+ self.assertEqual(self.macframe.get_icv(), icv)
def test_sendnrecv(self):
- rx1 = self.m.create_fcall('prepare_rx')
- rx1.send(self.sta)
- self.macframe.set_fc_10(123)
- self.macframe.set_fc_av(pack('IIII', 123, 456, 789, 10))
- self.macframe.set_msdu('This is the MPDU payload')
- self.macframe.sendnrecv(self.m)
+ # Tested in 'py/test_tx_rx.py' because another station is needed for this test
+ pass
def test_send(self):
rx2 = self.m.create_fcall('prepare_rx')
diff --git a/maximus/python/test/test_simu.py b/maximus/python/test/test_simu.py
index f17a0d42c4..50cfe3551a 100644
--- a/maximus/python/test/test_simu.py
+++ b/maximus/python/test/test_simu.py
@@ -28,17 +28,14 @@ def my_filter(rx_macframe):
# Reception
rsp = receive.recv(maximus=m, timeout=10000, filter=my_filter, count=0)
-#rsp1 = rsp[1]
-#rsp2 = rsp[2]
# Get the current date
-t = date.get_date()
+t = m.get_date()
# DOC TEST
import doctest
-doctest.testmod(date)
doctest.testmod(filter)
doctest.testmod(receive)
doctest.testmod(send)
@@ -118,7 +115,6 @@ class TestRxFunctions(unittest.TestCase):
suite = unittest.TestLoader().loadTestsFromTestCase(TestRxFunctions)
try:
- suite.addTest(doctest.DocTestSuite(date))
suite.addTest(doctest.DocTestSuite(filter))
suite.addTest(doctest.DocTestSuite(receive))
suite.addTest(doctest.DocTestSuite(send))