Using untyped read

6 posts / 0 new
Last post
Offline
Last seen: 6 years 9 months ago
Joined: 07/12/2012
Posts: 51
Using untyped read

The Java API documentation for read_untyped is:

void read_untyped (List received_data, SampleInfoSeq info_seq, int max_samples, int sample_states, int view_states, int instance_states)

What is the approprate type to  use for the received_data parameter ?

 List<T> dataSeq = new ArrayList<>(); does not work. It throws this exception. The list has an initial length of 0, but

so does any FooSeq.

Exception in thread "main" java.lang.IllegalStateException: expected sequence of length 1642; found 0
at com.rti.dds.subscription.DataReaderDelegateImpl.pull_data_sequence_from_native(Unknown Source)
at com.rti.dds.subscription.DataReaderImpl.read_or_take_untypedI(Unknown Source)
at com.rti.dds.subscription.DataReaderImpl.read_or_take_untypedI(Unknown Source)
at com.rti.dds.subscription.DataReaderImpl.read_untyped(Unknown Source)
at com.joy.fb20.da.ddsaccess.DaAIGeneric.read_io(DaAIGeneric.java:311)
at com.joy.fb20.da.main.DaTestClass.testSoFar3(DaTestClass.java:335)
at com.joy.fb20.da.main.DaTestClass.main(DaTestClass.java:66)

 

Thanks

Nico.

 

Organization:
Offline
Last seen: 3 years 2 months ago
Joined: 01/22/2021
Posts: 8

I know this is from 2014, but was there any resolution to this? I am having the same problem.

ken
ken's picture
Offline
Last seen: 2 months 1 week ago
Joined: 04/13/2011
Posts: 64

Hi gmaayan, Nico,

   It should be a list of the type associated to the DataReader (it's registered type to be specific).

Thanks,
Ken

Offline
Last seen: 3 years 2 months ago
Joined: 01/22/2021
Posts: 8

I'm still not exactly sure what's going wrong here, but what fixed it for me was using:

LoanableSequence _dataSeq = new LoanableSequence(Class.class);

for the received data instead of something like

List<MsgT> _dataSeq = new ArrayList<>();

Offline
Last seen: 3 years 2 months ago
Joined: 01/22/2021
Posts: 8

Hi Ken,

The problem here happens when you're trying to use generics. If you can just use "FooSeq" then you're golden.

ken
ken's picture
Offline
Last seen: 2 months 1 week ago
Joined: 04/13/2011
Posts: 64

Hi gmaayan,

   I did do a little experiment years ago related to this question (see attached). I'm not sure if it is helpful but it does attempt to support a somewhat generic data reader in Java.

Thanks,
Ken

File Attachments: