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

traintastic / traintastic / 24288605255

11 Apr 2026 06:17PM UTC coverage: 25.599% (-2.4%) from 27.99%
24288605255

push

github

web-flow
Merge pull request #222 from traintastic/cbus

Added CBUS/VLCB hardware support

169 of 3369 new or added lines in 99 files covered. (5.02%)

5 existing lines in 4 files now uncovered.

8300 of 32423 relevant lines covered (25.6%)

178.31 hits per line

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

20.69
/server/src/lua/object/cbusinterface.cpp
1
/**
2
 * This file is part of Traintastic,
3
 * see <https://github.com/traintastic/traintastic>.
4
 *
5
 * Copyright (C) 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 "cbusinterface.hpp"
23
#include "interface.hpp"
24
#include "object.hpp"
25
#include "../check.hpp"
26
#include "../checkarguments.hpp"
27
#include "../checkvector.hpp"
28
#include "../push.hpp"
29
#include "../to.hpp"
30
#include "../metatable.hpp"
31

32
namespace Lua::Object {
33

34
void CBUSInterface::registerType(lua_State* L)
99✔
35
{
36
  MetaTable::clone(L, Interface::metaTableName, metaTableName);
99✔
37
  lua_pushcfunction(L, __index);
99✔
38
  lua_setfield(L, -2, "__index");
99✔
39
  lua_pop(L, 1);
99✔
40
}
99✔
41

NEW
42
int CBUSInterface::index(lua_State* L, ::CBUSInterface& object)
×
43
{
NEW
44
  const auto key = to<std::string_view>(L, 2);
×
NEW
45
  LUA_OBJECT_METHOD(send)
×
NEW
46
  LUA_OBJECT_METHOD(send_dcc)
×
NEW
47
  return Interface::index(L, object);
×
48
}
49

NEW
50
int CBUSInterface::__index(lua_State* L)
×
51
{
NEW
52
  return index(L, *check<::CBUSInterface>(L, 1));
×
53
}
54

NEW
55
int CBUSInterface::send(lua_State* L)
×
56
{
NEW
57
  checkArguments(L, 1);
×
NEW
58
  auto interface = check<::CBUSInterface>(L, lua_upvalueindex(1));
×
NEW
59
  auto message = checkVector<uint8_t>(L, 1);
×
NEW
60
  Lua::push(L, interface->send(std::move(message)));
×
NEW
61
  return 1;
×
NEW
62
}
×
63

NEW
64
int CBUSInterface::send_dcc(lua_State* L)
×
65
{
NEW
66
  const uint8_t defaultRepeat = 2;
×
NEW
67
  const int argc = checkArguments(L, 1, 2);
×
NEW
68
  auto interface = check<::CBUSInterface>(L, lua_upvalueindex(1));
×
NEW
69
  auto dccPacket = checkVector<uint8_t>(L, 1);
×
NEW
70
  auto repeat = (argc >= 2) ? check<uint8_t>(L, 2) : defaultRepeat;
×
NEW
71
  Lua::push(L, interface->sendDCC(std::move(dccPacket), repeat));
×
NEW
72
  return 1;
×
NEW
73
}
×
74

75
}
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