changeset 125:ddbad6e9b017 main

Remove the code to reverse the SID,EID components. The MCP2515 code now writes the identifier consistently with how socketcan does.
author Bob Cook <bob@bobcookdev.com>
date Thu, 15 Dec 2011 06:54:21 -0800
parents 9b41739be9c2
children b2a2c22951fb
files main/packages/linux/can/CANSocket.cpp
diffstat 1 files changed, 5 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/main/packages/linux/can/CANSocket.cpp	Thu Dec 15 06:42:45 2011 -0800
+++ b/main/packages/linux/can/CANSocket.cpp	Thu Dec 15 06:54:21 2011 -0800
@@ -109,30 +109,16 @@
 CANMessage* CANSocket::read()
 {
     struct can_frame recvFrame;
-    size_t recvBytes = impl()->receiveBytes(&recvFrame, sizeof(recvFrame));
+    size_t recvBytes = impl()->receiveBytes( &recvFrame, sizeof( recvFrame ) );
 
     if ( recvBytes < sizeof( recvFrame ) )
     {
         throw Poco::Exception( "incomplete CAN frame received" );
     }
 
-    // our mcp2515 code reverses the bit order of sid+eid so reverse it again here
-    // (hopefully that will be fixed at some point)
-
-    uint32_t translatedId;
-
-    if ( recvFrame.can_id & CAN_EFF_FLAG )
-    {
-        recvFrame.can_id &= CAN_EFF_MASK;
-        translatedId  = recvFrame.can_id >> 18;
-        translatedId |= recvFrame.can_id << 11;
-    }
-    else
-    {
-        translatedId = recvFrame.can_id & CAN_SFF_MASK;
-    }
-
-    return new CANMessage( translatedId, recvFrame.data, recvFrame.can_dlc );
+    return new CANMessage( recvFrame.can_id & CAN_EFF_MASK,
+                           recvFrame.data, 
+                           recvFrame.can_dlc );
 }
 
 // ----------------------------------------------------------------------------------------
@@ -140,16 +126,9 @@
 void CANSocket::write( const CANMessage& msg )
 {
     struct can_frame sendFrame;
+    sendFrame.can_id  = msg.msgIdentifier() | CAN_EFF_FLAG;
     sendFrame.can_dlc = msg.msgData( sendFrame.data, sizeof( sendFrame.data ) );
 
-    // reverse sid+eid because that is what our mcp2515 code expects
-    // (hopefully that will be fixed at some point)
-
-    uint32_t translatedId = msg.msgIdentifier() >> 11;
-    translatedId |= ( msg.msgIdentifier() & 0x7ff ) << 18;
-
-    sendFrame.can_id = translatedId | CAN_EFF_FLAG;
-
     size_t sentBytes = impl()->sendBytes( &sendFrame, sizeof( sendFrame ) );
 
     if (sentBytes < sizeof( sendFrame ) )