Serialize and deserialize arrays#45
Conversation
| printf("vector overcomes the maximum length\n"); | ||
| throw std::runtime_error("vector overcomes the maximum length"); | ||
| } | ||
| ser << (int32_t)data.size; |
There was a problem hiding this comment.
Instead of replicating the wire format here this should use the API of Cdr to perform the serialization. I guess in this case it should call serializeSequence instead of serializing the size and calling serializeArray.
|
|
||
| auto & string_array_field = *reinterpret_cast<rosidl_generator_c__String__Array *>(field); | ||
| if(!rosidl_generator_c__String__Array__init(&string_array_field, cpp_string_vector.size())) { | ||
| printf("unable to initialize rosidl_generator_c__String array\n"); |
There was a problem hiding this comment.
All error messages should go to stderr. But since the exception is thrown anyway I would say the error message is redundant and can be removed.
|
Thanks for the patch @esteve! I agree that the With that comment addressed the changes lgtm. I'll just start some CI (assuming that removing the |
| deser.deserializeArray((T*)field, member->array_size_); | ||
| } else { | ||
| auto & data = *reinterpret_cast<typename GenericCArray<T>::type *>(field); | ||
| int32_t dsize; |
There was a problem hiding this comment.
Looks like cppcheck is concerned about this not be initialized:
http://ci.ros2.org/job/ci_linux/1606/testReport/(root)/projectroot/cppcheck/
You could either give it a default value or use the no lint comment to squelch cppcheck.
|
@wjwwood the so I'm going to leave the |
|
@richiprosima I've rebased this and removed the |
|
Can you please trigger the CI builds for these changes. |
|
I tested this PR with my .Net wrapper and it seems to work fine, apart from passing c-typesupport messages to cpp. What works:
What doesn't work:
|
|
@firesurfer thanks for testing this PR. That's weird, once the messages go through the wire, the typesupport should matter. Do you have a concrete example which I can test? I recall I tested this between rclpy (c-typesupport) and rclpp (c++-typesupport), and it seemed to work, but I'll check again. |
|
@esteve I tested it only with my C# wrapper so far. In my testing workspace ( https://github.com/firesurfer/rclcs_testing_ws ) I got one program that uses in C# - test_cs.exe (c-typesupport) and one program that uses c++ - test_cpp (c++-typesupport). Sending a message from the C# program to another program that uses the C# wrapper works. But sending a message from the C# wrapper to the C++ program doesn't work. On the other side a program that uses the C# wrapper receives the message published from a C++ program. I haven't had the time yet to investigate this issue further but I think I can find some time to have a deeper look at it tomorrow. |
|
@firesurfer do you have the message definition you used? I can test it out and see if I can find the problem. |
|
@esteve this is my dummy message: https://github.com/firesurfer/rclcs_testing_ws/blob/master/src/test_msgs/msg/Dummy.msg |
|
@firesurfer thanks! |
|
TD;DR this PR does fix the serialisation/deserialisation of dynamic primitive array messages ( @esteve do you prefer:
Here is the results of my investigation for the remaining test failures:
|
|
Thank you so much for looking into this @mikaelarguedas! I think it'd be fine to just merge this PR and continue any remaining bits On Sep 16, 2016 03:47, "Mikael Arguedas" notifications@github.com wrote:
|
|
After talking to @mikaelarguedas we will merge this as-is and go from there. Thanks. |
|
@esteve @firesurfer #58 may solve some of the issues you encountered. The tests are passing in both rclcpp -> rclpy and rclpy -> rclcpp for all message types |
This PR serializes and deserializes unbounded arrays. Tested locally with two Python scripts (listener and talker), using different permutations of OpenSplice and FastRTPS.