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

traintastic / traintastic / 23670474187

27 Mar 2026 10:38PM UTC coverage: 27.99% (-0.02%) from 28.009%
23670474187

push

github

reinder
[marklincan] extracted generic SocketCAN logic from MarklinCAN::SocketCANIOHandler

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

8182 of 29232 relevant lines covered (27.99%)

194.62 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

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

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

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

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;
×
59
  std::memcpy(frame.data, message.data, message.dlc);
×
NEW
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