RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/jazzy/Concepts/Basic/About-Client-Libraries.html#community-maintained
Apache License 2.0
335 stars 72 forks source link

Append '\0' when pusblishing a raw string by Buffer #771

Closed minggangw closed 3 years ago

minggangw commented 3 years ago

Recently, the test-raw-pub-sub.js began to fain consistently.

https://github.com/RobotWebTools/rclnodejs/blob/31efa7c28e8d20bcd6fe1311fb10e9afa7bd63a7/test/test-raw-pub-sub.js#L42-L51

  1) rclnodejs publisher test suite
       Publish serialized messages:

      Uncaught AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: 1 !== 0

      + expected - actual

      -1
      +0

The root cause is that the received string is terminated by a null character \0, so we should add the \0 when sending the raw topic accordingly.