Python API - CharSeq

2 posts / 0 new
Last post
Offline
Last seen: 1 year 2 months ago
Joined: 01/13/2023
Posts: 1
Python API - CharSeq

Hi all,

I'm new to Python and DDS and I'm trying to deserialize a byte object using the DynamicData.TopicTypeSupport.from_cdr_buffer API, however it's throwing a TypeError when used as such:

import rti.connextdds as dds
from rti.connextdds import DynamicData
from rti.connextdds import CharSeq
 
QOS_URL = "file://CloudVehicleGeneric_GenericMessages.xml"
KVP_TYPE_NAME = "CloudVehicleGeneric::GenericMessage"
 
def test_cdr(kvp_type, buffer):
    destinationSample = dds.DynamicData(kvp_type)
 
    DynamicData.TopicTypeSupport.from_cdr_buffer(destinationSample, buffer)
 

    print(destinationSample) 

 
if __name__ == "__main__":
    qos_provider = dds.QosProvider(QOS_URL)
 
    my_type = qos_provider.type(qos_provider.type_libraries[0], KVP_TYPE_NAME)
 
    with open("./input/1655228721228.dat", 'rb') as file:
        test_cdr(my_type, file.read())
 
 
The TypeError is saying that the buffer needs to be of type CharSeq. Is there a conversion that needs to occur in order to use from_cdr_buffer correctly or is my approach incorrect altogether? 
Offline
Last seen: 2 months 2 weeks ago
Joined: 04/02/2013
Posts: 194

Try this:

destinationSample = dds.DynamicData(kvp_type)
destinationSample.from_cdr_buffer(buffer)
print(destinationSample)