From ede534b644a0d09fd436ccc0a0f37b77822cd8a8 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 7 Dec 2022 10:42:59 +0000 Subject: [PATCH] Fixed write bug --- include/can_wrap.h | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/include/can_wrap.h b/include/can_wrap.h index 2d8c480..a7d7eb8 100644 --- a/include/can_wrap.h +++ b/include/can_wrap.h @@ -67,8 +67,9 @@ bool can_close( const int socket ) * @brief Passes call to can::_read() to read standard CAN frame. * * @pre must call connect() successfully first. - * @param socket Socket identifer as returned from can::connect(). - * @return const can_frame + * @param socket Socket identifer as returned from can_connect(). + * @param frame CAN frame variable to place read data. + * @return Success. */ bool can_read( const int socket, struct can_frame* frame ) { @@ -79,8 +80,9 @@ bool can_read( const int socket, struct can_frame* frame ) * @brief Passes call to can::_read() to read CANFD frame. * * @pre must call connectfd() successfully first. - * @param socket Socket identifer as returned from can::connect(). - * @return const canfd_frame + * @param socket Socket identifer as returned from can_connect(). + * @param frame CAN frame variable to place read data. + * @return Success. */ bool can_readfd( const int socket, struct canfd_frame* frame ) { @@ -90,12 +92,13 @@ bool can_readfd( const int socket, struct canfd_frame* frame ) /** * @brief Passes call to can::_write() to write standard CAN frame. * - * @param socket Socket identifer as returned from can::connect(). + * @param socket Socket identifer as returned from can_connect(). * @param frame CAN frame to be sent. + * @return Success. */ bool can_write( const int socket, struct can_frame* frame ) { - return write( socket, &frame, sizeof(struct can_frame) ) == sizeof(struct can_frame); + return write( socket, frame, sizeof(struct can_frame) ) == sizeof(struct can_frame); } /** @@ -103,34 +106,11 @@ bool can_write( const int socket, struct can_frame* frame ) * * @param socket Socket identifer as returned from can::connect(). * @param frame CANFD frame to be sent. + * @return Success. */ bool can_writefd( const int socket, struct canfd_frame* frame ) { - return write( socket, &frame, sizeof(struct canfd_frame) ) == sizeof(struct canfd_frame); -} - -/* -std::ostream& operator<<( std::ostream &os, const can_frame& frame ) -{ - os << "0x" << std::setw(3) << std::hex << frame.can_id << - " [" << static_cast(frame.can_dlc) << ']'; - for( int i=0; i(frame.data[i]); - - return os; + return write( socket, frame, sizeof(struct canfd_frame) ) == sizeof(struct canfd_frame); } -std::ostream& operator<<( std::ostream &os, const canfd_frame& frame ) -{ - os << "0x" << std::setw(3) << std::hex << frame.can_id << - " [" << static_cast(frame.len) << ']'; - os << std::uppercase << std::setfill('0') << std::setw(2); - for( int i=0; i(frame.data[i]); - - return os; -}*/ - #endif