KITmedical / kacanopen

Easy-to-use CanOpen stack and CanOpen-to-ROS bridge.
Other
94 stars 57 forks source link

Byte vector passed to PDO::send has wrong size #4

Closed tobijk closed 6 years ago

tobijk commented 6 years ago

Transmit PDO mappings for uint64_t fail because in TransmitPDOMapping::send the data vector is resized to one byte too many. Meaning that data.resize(max_byte+1) will be 9 for a int64, which will trigger the assertion at the top of PDO::send.

diff --ignore-space-change -urN a/master/src/transmit_pdo_mapping.cpp b/master/src/transmit_pdo_mapping.cpp
--- a/master/src/transmit_pdo_mapping.cpp       2018-01-08 11:04:18.000000000 +0100
+++ b/master/src/transmit_pdo_mapping.cpp       2018-02-02 17:04:54.653689010 +0100
@@ -88,9 +88,8 @@

        }

-       data.resize(max_byte+1);
+       data.resize(max_byte);
        m_core.pdo.send(cob_id, data);
-
 }

 void TransmitPDOMapping::check_correctness() const {
thk1 commented 6 years ago

Fixed. Thank you.