• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

traintastic / traintastic / 23671871465

27 Mar 2026 11:30PM UTC coverage: 26.15% (-0.05%) from 26.198%
23671871465

push

github

reinder
[cbus] added SocketCAN io handler

0 of 47 new or added lines in 2 files covered. (0.0%)

16 existing lines in 2 files now uncovered.

8256 of 31572 relevant lines covered (26.15%)

182.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/server/src/hardware/protocol/marklincan/iohandler/socketcaniohandler.cpp
1
/**
2
 * This file is part of Traintastic,
3
 * see <https://github.com/traintastic/traintastic>.
4
 *
5
 * Copyright (C) 2023-2026 Reinder Feenstra
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 */
21

22
#include "socketcaniohandler.hpp"
23
#include "../kernel.hpp"
24
#include "../messages.hpp"
25

26
namespace MarklinCAN {
27

UNCOV
28
SocketCANIOHandler::SocketCANIOHandler(Kernel& kernel, const std::string& interface)
×
29
  : IOHandler(kernel)
UNCOV
30
  , m_socketCAN{kernel.ioContext(), interface, m_kernel.logId,
×
UNCOV
31
      [this](const CAN::SocketCANIOHandler::Frame& frame)
×
32
      {
UNCOV
33
        Message message;
×
UNCOV
34
        message.id = frame.can_id & CAN_EFF_MASK;
×
UNCOV
35
        message.dlc = frame.can_dlc;
×
UNCOV
36
        std::memcpy(message.data, frame.data, message.dlc);
×
UNCOV
37
        m_kernel.receive(message);
×
38
      },
×
UNCOV
39
      std::bind(&Kernel::error, &m_kernel)}
×
40
{
UNCOV
41
}
×
42

43
void SocketCANIOHandler::start()
×
44
{
UNCOV
45
  m_socketCAN.start();
×
UNCOV
46
  m_kernel.started();
×
47
}
×
48

49
void SocketCANIOHandler::stop()
×
50
{
51
  m_socketCAN.stop();
×
52
}
×
53

UNCOV
54
bool SocketCANIOHandler::send(const Message& message)
×
55
{
56
  CAN::SocketCANIOHandler::Frame frame;
57
  frame.can_id = CAN_EFF_FLAG | (message.id & CAN_EFF_MASK);
×
58
  frame.can_dlc = message.dlc;
×
UNCOV
59
  std::memcpy(frame.data, message.data, message.dlc);
×
60
  return m_socketCAN.send(frame);
×
61
}
62

63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc