Skip to content

Commit 4911c70

Browse files
authored
Merge branch 'main' into adrian/vt-server-better-connectionless-responses
2 parents f823660 + d3fd6df commit 4911c70

38 files changed

+301
-22
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// "forwardPorts": [],
3030

3131
// Use 'postCreateCommand' to run commands after the container is created.
32-
"postCreateCommand": "gcc -v"
32+
"postCreateCommand": "bash -lc 'set -e; gcc -v; if ! command -v pip3 >/dev/null 2>&1; then apt-get update && apt-get install -y python3-pip; fi; pip3 install --upgrade pip; if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi'"
3333

3434
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
3535
// "remoteUser": "root"

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ if(BUILD_EXAMPLES)
6969
add_subdirectory("examples/virtual_terminal/version3_object_pool")
7070
add_subdirectory("examples/virtual_terminal/aux_functions")
7171
add_subdirectory("examples/virtual_terminal/aux_inputs")
72+
add_subdirectory("examples/virtual_terminal/iop_parser_tester")
7273
add_subdirectory("examples/task_controller_client")
7374
add_subdirectory("examples/task_controller_server")
7475
add_subdirectory("examples/guidance")

examples/virtual_terminal/version3_object_pool/console_logger.cpp renamed to examples/virtual_terminal/common/console_logger.cpp

File renamed without changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(iop_parser)
3+
4+
if(NOT BUILD_EXAMPLES)
5+
find_package(isobus REQUIRED)
6+
endif()
7+
find_package(Threads REQUIRED)
8+
9+
add_executable(iop_parser main.cpp ../common/console_logger.cpp)
10+
11+
target_compile_features(iop_parser PUBLIC cxx_std_11)
12+
set_target_properties(iop_parser PROPERTIES CXX_EXTENSIONS OFF)
13+
14+
target_link_libraries(
15+
iop_parser PRIVATE isobus::Isobus Threads::Threads
16+
isobus::HardwareIntegration isobus::Utility)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
2+
3+
#include <cstdint>
4+
#include <fstream>
5+
#include <iostream>
6+
#include <vector>
7+
8+
#include "../common/console_logger.cpp"
9+
10+
int main(int argc, char *argv[])
11+
{
12+
if (argc != 2)
13+
{
14+
std::cerr << "Usage: " << argv[0] << " <iop file path>\n";
15+
return 1;
16+
}
17+
18+
const char *filename = argv[1];
19+
std::ifstream file(filename, std::ios::binary);
20+
if (!file)
21+
{
22+
std::cerr << "Unable to open: " << filename << "\n";
23+
return 1;
24+
}
25+
26+
std::vector<std::uint8_t> buffer((std::istreambuf_iterator<char>(file)),
27+
std::istreambuf_iterator<char>());
28+
29+
if (buffer.empty())
30+
{
31+
std::cerr << "File is empty or not readable.\n";
32+
return 1;
33+
}
34+
35+
isobus::CANStackLogger::set_can_stack_logger_sink(&logger);
36+
37+
isobus::VirtualTerminalServerManagedWorkingSet vt;
38+
bool result = vt.parse_iop_into_objects(buffer.data(),
39+
static_cast<std::uint32_t>(buffer.size()));
40+
41+
std::cout << "IOP parse result: " << std::boolalpha << result << "\n";
42+
return 0;
43+
}

examples/virtual_terminal/version3_object_pool/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ if(NOT BUILD_EXAMPLES)
66
endif()
77
find_package(Threads REQUIRED)
88

9-
add_executable(VT3ExampleTarget main.cpp console_logger.cpp objectPoolObjects.h)
9+
add_executable(VT3ExampleTarget main.cpp ../common/console_logger.cpp
10+
objectPoolObjects.h)
1011

1112
target_compile_features(VT3ExampleTarget PUBLIC cxx_std_11)
1213
set_target_properties(VT3ExampleTarget PROPERTIES CXX_EXTENSIONS OFF)

examples/virtual_terminal/version3_object_pool/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "isobus/isobus/isobus_virtual_terminal_client_update_helper.hpp"
88
#include "isobus/utility/iop_file_interface.hpp"
99

10-
#include "console_logger.cpp"
10+
#include "../common/console_logger.cpp"
1111
#include "objectPoolObjects.h"
1212

1313
#include <atomic>
@@ -102,7 +102,7 @@ int main()
102102
// Automatically load the desired CAN driver based on the available drivers
103103
std::shared_ptr<isobus::CANHardwarePlugin> canDriver = nullptr;
104104
#if defined(ISOBUS_SOCKETCAN_AVAILABLE)
105-
canDriver = std::make_shared<isobus::SocketCANInterface>("can0");
105+
canDriver = std::make_shared<isobus::SocketCANInterface>("vcan0");
106106
#elif defined(ISOBUS_WINDOWSPCANBASIC_AVAILABLE)
107107
canDriver = std::make_shared<isobus::PCANBasicWindowsPlugin>(PCAN_USBBUS1);
108108
#elif defined(ISOBUS_WINDOWSINNOMAKERUSB2CAN_AVAILABLE)

hardware_integration/include/isobus/hardware_integration/can_hardware_plugin.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef CAN_HARDEWARE_PLUGIN_HPP
1010
#define CAN_HARDEWARE_PLUGIN_HPP
1111

12+
#include <string>
1213
#include "isobus/isobus/can_message_frame.hpp"
1314

1415
namespace isobus
@@ -23,6 +24,11 @@ namespace isobus
2324
public:
2425
virtual ~CANHardwarePlugin() = default;
2526

27+
/// @brief Returns with the name of the plugin in a format which is suitable to be displayed
28+
/// to the user for e.g. on a ComboBox
29+
/// @returns the name of the plugin
30+
virtual std::string get_name() const = 0;
31+
2632
/// @brief Returns if the driver is ready and in a good state
2733
/// @details This should return `false` until `open` is called, and after `close` is called, or
2834
/// if anything happens that causes the driver to be invalid, like the hardware is disconnected.

hardware_integration/include/isobus/hardware_integration/flex_can_t4_plugin.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ namespace isobus
2727
/// @brief The destructor for FlexCANT4Plugin
2828
virtual ~FlexCANT4Plugin() = default;
2929

30+
/// @brief Returns the displayable name of the plugin
31+
/// @returns FlexCANT4
32+
std::string get_name() const override;
33+
3034
/// @brief Returns if the connection with the hardware is valid
3135
/// @returns `true` if connected, `false` if not connected
3236
bool get_is_valid() const override;

hardware_integration/include/isobus/hardware_integration/innomaker_usb2can_windows_plugin.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ namespace isobus
5959
/// @brief The destructor for InnoMakerUSB2CANWindowsPlugin
6060
virtual ~InnoMakerUSB2CANWindowsPlugin();
6161

62+
/// @brief Returns the displayable name of the plugin
63+
/// @returns INNO-Maker USB2CAN
64+
std::string get_name() const override;
65+
6266
/// @brief Returns if the connection with the hardware is valid
6367
/// @returns `true` if connected, `false` if not connected
6468
bool get_is_valid() const override;

0 commit comments

Comments
 (0)