summaryrefslogtreecommitdiffstats
path: root/src/can_reader.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-16 16:09:08 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-16 16:10:14 +0000
commitd6d322103eaf1d2d5a1a94a0720a01a692f6a134 (patch)
treed2086d32c7203db7ff9de9984b79f74b4bbb41c3 /src/can_reader.cpp
parent109ba77a295811c5037c2c4dfc618c3f7e047228 (diff)
Changing CanBus_c to can_bus_t class name
Change-Id: Ibf277e36187b78853718f76552ff730d0474a3e6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can_reader.cpp')
-rw-r--r--src/can_reader.cpp39
1 files changed, 4 insertions, 35 deletions
diff --git a/src/can_reader.cpp b/src/can_reader.cpp
index 6403cfa7..80889372 100644
--- a/src/can_reader.cpp
+++ b/src/can_reader.cpp
@@ -23,44 +23,13 @@
#include "can-utils.h"
-void can_reader(CanBus_c *can_bus))
+void can_reader(CanBus_t &can_bus)
{
- ssize_t nbytes;
- int maxdlen;
CanMessage_c can_message;
- canfd_frame canfd_frame;
- /* Test that socket is really opened */
- if ( can_bus->socket < 0)
+ while(can_bus.is_running())
{
- ERROR(interface, "read_can: Socket unavailable");
- return -1;
- }
-
- while(true)
- {
- nbytes = read(can_bus->socket, &canfd_frame, CANFD_MTU);
-
- switch(nbytes)
- {
- case CANFD_MTU:
- DEBUG(interface, "read_can: Got an CAN FD frame with length %d", canfd_frame.len);
- maxdlen = CANFD_MAX_DLEN;
- break;
- case CAN_MTU:
- DEBUG(interface, "read_can: Got a legacy CAN frame with length %d", canfd_frame.len);
- maxdlen = CAN_MAX_DLEN;
- break;
- default:
- if (errno == ENETDOWN)
- ERROR(interface, "read_can: %s interface down", device);
-
- ERROR(interface, "read_can: Error reading CAN bus");
- return -2;
- }
-
- can_message.convert_from_canfd_frame(canfd_frame);
-
- can_message_q.push(can_message);
+ can_message.convert_from_canfd_frame(canbus.read());
+ can_bus.insert_new_can_message(can_message);
}
} \ No newline at end of file