[openrtm-commit:02073] r727 - in trunk/OpenRTM-aist-Python/OpenRTM_aist: . test
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 10月 20日 (木) 19:37:21 JST
Author: miyamoto
Date: 2016-10-20 19:37:21 +0900 (Thu, 20 Oct 2016)
New Revision: 727
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/InPortSHMConsumer.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortSHMProvider.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/test/test_SharedMemory.py
Log:
[compat,bugfix,->RELENG_1_2] fixed SharedMemory.py. refs #3410
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/InPortSHMConsumer.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/InPortSHMConsumer.py 2016-10-20 10:05:51 UTC (rev 726)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/InPortSHMConsumer.py 2016-10-20 10:37:21 UTC (rev 727)
@@ -99,6 +99,7 @@
oid = OpenRTM_aist.Manager.instance().getPOA().servant_to_id(self._shmem)
OpenRTM_aist.Manager.instance().getPOA().deactivate_object(oid)
+ self._endian = True
return
@@ -136,15 +137,14 @@
endian = prop.getProperty("serializer.cdr.endian")
if not endian:
self._rtcout.RTC_ERROR("init(): endian is not set.")
- self._endian = None
+
+
endian = OpenRTM_aist.split(endian, ",")
endian = OpenRTM_aist.normalize(endian)
if endian == "little":
self._endian = True
elif endian == "big":
self._endian = False
- else:
- self._endian = None
else:
self._endian = True
@@ -197,9 +197,7 @@
inportcdr = ref_._narrow(OpenRTM__POA.PortSharedMemory)
guard = OpenRTM_aist.ScopedLock(self._mutex)
- if not self._endian:
- self._rtcout.RTC_ERROR("put(): endian is not set.")
- return self.UNKNOWN_ERROR
+
self._shmem.setEndian(self._endian)
self._shmem.create_memory(self._memory_size, self._shm_address)
self._shmem.write(data)
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortSHMProvider.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortSHMProvider.py 2016-10-20 10:05:51 UTC (rev 726)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortSHMProvider.py 2016-10-20 10:37:21 UTC (rev 727)
@@ -69,7 +69,7 @@
self._shm_address = str(OpenRTM_aist.uuid1())
-
+ self._endian = True
@@ -113,15 +113,14 @@
endian = prop.getProperty("serializer.cdr.endian")
if not endian:
self._rtcout.RTC_ERROR("init(): endian is not set.")
- self._endian = None
+
endian = OpenRTM_aist.split(endian, ",")
endian = OpenRTM_aist.normalize(endian)
if endian == "little":
self._endian = True
elif endian == "big":
self._endian = False
- else:
- self._endian = None
+
else:
self._endian = True
@@ -182,9 +181,7 @@
self._rtcout.RTC_TRACE(OpenRTM_aist.Logger.print_exception())
return OpenRTM.UNKNOWN_ERROR
- if not self._endian:
- self._rtcout.RTC_ERROR("get(): endian is not set.")
- return self.UNKNOWN_ERROR
+
self.setEndian(self._endian)
self.create_memory(self._memory_size, self._shm_address)
self.write(cdr[0])
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/test/test_SharedMemory.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/test/test_SharedMemory.py 2016-10-20 10:05:51 UTC (rev 726)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/test/test_SharedMemory.py 2016-10-20 10:37:21 UTC (rev 727)
@@ -123,7 +123,34 @@
self.outport_obj.disconnect_all()
+ def test_Push_big_endian(self):
+
+ prop = OpenRTM_aist.Properties()
+ #prop.setProperty("dataport.shem_default_size","10k")
+ prop.setProperty("dataport.interface_type","shared_memory")
+ prop.setProperty("dataport.dataflow_type","push")
+ prop.setProperty("dataport.serializer.cdr.endian","big")
+ ret = OpenRTM_aist.connect("con1",prop,self.inport_obj,self.outport_obj)
+
+ self._d_out.data = "a"*100
+ self._outOut.write()
+ ret = self._inIn.isNew()
+ self.assertTrue(ret)
+
+ data = self._inIn.read()
+ self.assertEqual(data.data, self._d_out.data)
+
+
+ self._d_out.data = "a"*50000
+ self._outOut.write()
+
+ data = self._inIn.read()
+ self.assertEqual(data.data, self._d_out.data)
+
+
+ self.outport_obj.disconnect_all()
+
def test_Pull(self):
prop = OpenRTM_aist.Properties()
#prop.setProperty("dataport.shem_default_size","10k")
@@ -151,6 +178,35 @@
self.outport_obj.disconnect_all()
+
+ def test_Pull_big_endian(self):
+ prop = OpenRTM_aist.Properties()
+ #prop.setProperty("dataport.shem_default_size","10k")
+ prop.setProperty("dataport.interface_type","shared_memory")
+ prop.setProperty("dataport.dataflow_type","pull")
+ prop.setProperty("dataport.serializer.cdr.endian","big")
+ ret = OpenRTM_aist.connect("con1",prop,self.inport_obj,self.outport_obj)
+
+ self._d_out.data = "a"*100
+ self._outOut.write()
+
+ #ret = self._inIn.isNew()
+ #self.assertTrue(ret)
+
+ data = self._inIn.read()
+ self.assertEqual(data.data, self._d_out.data)
+
+
+ self._d_out.data = "a"*50000
+ self._outOut.write()
+
+
+ data = self._inIn.read()
+ self.assertEqual(data.data, self._d_out.data)
+
+
+ self.outport_obj.disconnect_all()
+
############### test #################
if __name__ == '__main__':
unittest.main()
More information about the openrtm-commit
mailing list