[openrtm-commit:03195] r947 - trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO

openrtm @ openrtm.org openrtm @ openrtm.org
2018年 2月 27日 (火) 17:14:47 JST


Author: miyamoto
Date: 2018-02-27 17:14:47 +0900 (Tue, 27 Feb 2018)
New Revision: 947

Modified:
   trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqIn.py
   trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqOut.py
Log:
[bugfix, ->trunk] bug fixed. refs #4466

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqIn.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqIn.py	2018-02-27 07:20:18 UTC (rev 946)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqIn.py	2018-02-27 08:14:47 UTC (rev 947)
@@ -34,7 +34,11 @@
     self._long      = RTC.TimedLong(RTC.Time(0,0),0)
     self._float     = RTC.TimedFloat(RTC.Time(0,0),0)
     self._double    = RTC.TimedDouble(RTC.Time(0,0),0)
-    self._octetSeq  = RTC.TimedOctetSeq(RTC.Time(0,0),[])
+    
+    self._octetSeq  = RTC.TimedOctetSeq(RTC.Time(0,0),"")
+    if sys.version_info[0] == 3:
+      self._octetSeq.data = self._octetSeq.data.encode("utf-8")
+    
     self._shortSeq  = RTC.TimedShortSeq(RTC.Time(0,0),[])
     self._longSeq   = RTC.TimedLongSeq(RTC.Time(0,0),[])
     self._floatSeq  = RTC.TimedFloatSeq(RTC.Time(0,0),[])
@@ -80,7 +84,13 @@
     floatSeq_  = self._floatSeqIn.read()
     doubleSeq_ = self._doubleSeqIn.read()
 
-    octetSize_  = len(octetSeq_.data)
+
+    if sys.version_info[0] == 2:
+      octet_data = octetSeq_.data
+    else:
+      octet_data = octetSeq_.data.decode("utf-8")
+
+    octetSize_  = len(octet_data)
     shortSize_  = len(shortSeq_.data)
     longSize_   = len(longSeq_.data)
     floatSize_  = len(floatSeq_.data)
@@ -88,7 +98,7 @@
 
     octetSeqDisp_ = []
     for i in range(octetSize_):
-      octetSeqDisp_.append(ord(octetSeq_.data[i]))
+      octetSeqDisp_.append(ord(octet_data[i]))
 
     maxsize = max(octetSize_, shortSize_, longSize_, floatSize_, doubleSize_)
     octetSeqDisp_   = octetSeqDisp_   + ['-'] * (maxsize - octetSize_)

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqOut.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqOut.py	2018-02-27 07:20:18 UTC (rev 946)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/examples/SeqIO/SeqOut.py	2018-02-27 08:14:47 UTC (rev 947)
@@ -101,7 +101,11 @@
     # Moving cursor (^[[nA : n lines upward)
     print("\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r")
         
-    self._octetSeq.data = octetSeq
+    
+    if sys.version_info[0] == 2:
+      self._octetSeq.data = octetSeq
+    else:
+      self._octetSeq.data = octetSeq.encode("utf-8")
     self._shortSeq.data = shortSeq
     self._longSeq.data = longSeq
     self._floatSeq.data = floatSeq



More information about the openrtm-commit mailing list