-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bjb-stm32g0b1
* master: (76 commits) Fixes some compile errors in nucleo and bracz.acc. ESP-IDF CMakeLists (#800) BLE Basic Infrastructure (#788) Handles unhandled-addressed-messages by generating an OIR reply. (#798) Adds factory reset handler to linux:io_board. (#797) Fixes a standards compliance issue with the alias conflict handler. (#793) Bug fixes in DataBuffer (#791) Fixes race conditions in HubDeviceSelect. (#795) Fixes missing translation of enums when reading the security mode from a simplelink profile. (#796) Fixes flaky IfCanStress.test. (#794) Pin esp32 platform to 2.0.x (#792) Fixes detecting EOF in the memory config protocol handler. (#789) Adds a new hub application using DirectHub (#761) High-performance hub component for dealing with many sockets and high throughput (#760) Fix build of esp8266 train implementation. Removes unnecessary includes that might not exist on an embedded compiler. Fix compilation of TempFile under esp8266. Add libatomic to esp8266 nonos target. Fix compile errors in time_client app. Fixes in file memory space: (#786) ...
- Loading branch information
Showing
267 changed files
with
15,464 additions
and
1,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ jobs: | |
sketch-names: ESP32CanLoadTest.ino,ESP32IOBoard.ino,ESP32SerialBridge.ino,ESP32WifiCanBridge.ino | ||
debug-compile: true | ||
required-libraries: OpenMRNLite | ||
arduino-platform: esp32:[email protected] | ||
if: ${{ matrix.target == 'esp32' }} | ||
|
||
- name: Compile ESP32-C3 examples | ||
|
@@ -74,6 +75,7 @@ jobs: | |
sketch-names: ESP32C3CanLoadTest.ino,ESP32C3IOBoard.ino | ||
debug-compile: true | ||
required-libraries: OpenMRNLite | ||
arduino-platform: esp32:[email protected] | ||
if: ${{ matrix.target == 'esp32c3' }} | ||
|
||
- name: Compile ESP32-S2 examples | ||
|
@@ -84,4 +86,5 @@ jobs: | |
sketch-names: ESP32S2CanLoadTest.ino,ESP32S2IOBoard.ino | ||
debug-compile: true | ||
required-libraries: OpenMRNLite | ||
arduino-platform: esp32:[email protected] | ||
if: ${{ matrix.target == 'esp32s2' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SUBDIRS = targets | ||
-include config.mk | ||
include $(OPENMRNPATH)/etc/recurse.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../default_config.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
/** \copyright | ||
* Copyright (c) 2013, Balazs Racz | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* \file main.cxx | ||
* | ||
* An application which acts as an openlcb hub with the GC protocol, using the | ||
* DirectHub infrastructure. | ||
* | ||
* @author Balazs Racz | ||
* @date 31 Dec 2023 | ||
*/ | ||
|
||
#include <fcntl.h> | ||
#include <getopt.h> | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
|
||
#include <memory> | ||
|
||
#include "executor/Executor.hxx" | ||
#include "executor/Service.hxx" | ||
#include "os/os.h" | ||
#include "utils/ClientConnection.hxx" | ||
#include "utils/DirectHub.hxx" | ||
#include "utils/HubDeviceSelect.hxx" | ||
#include "utils/SocketCan.hxx" | ||
#include "utils/constants.hxx" | ||
|
||
Executor<1> g_executor("g_executor", 0, 1024); | ||
Service g_service(&g_executor); | ||
|
||
std::unique_ptr<ByteDirectHubInterface> g_direct_hub {create_hub(&g_executor)}; | ||
|
||
CanHubFlow can_hub0(&g_service); | ||
|
||
OVERRIDE_CONST(gc_generate_newlines, 1); | ||
OVERRIDE_CONST(gridconnect_tcp_snd_buffer_size, 8192); | ||
OVERRIDE_CONST(gridconnect_tcp_rcv_buffer_size, 8192); | ||
OVERRIDE_CONST(gridconnect_tcp_notsent_lowat_buffer_size, 1024); | ||
|
||
int port = 12021; | ||
const char *device_path = nullptr; | ||
const char *socket_can_path = nullptr; | ||
int upstream_port = 12021; | ||
const char *upstream_host = nullptr; | ||
bool timestamped = false; | ||
bool export_mdns = false; | ||
const char *mdns_name = "openmrn_hub"; | ||
bool printpackets = false; | ||
|
||
void usage(const char *e) | ||
{ | ||
fprintf(stderr, | ||
"Usage: %s [-p port] [-d device_path] [-u upstream_host] " | ||
"[-q upstream_port] [-m] [-n mdns_name] " | ||
#if defined(__linux__) | ||
"[-s socketcan_interface] " | ||
#endif | ||
"[-t] [-l]\n\n", | ||
e); | ||
fprintf(stderr, | ||
"GridConnect CAN HUB.\nListens to a specific TCP port, " | ||
"reads CAN packets from the incoming connections using " | ||
"the GridConnect protocol, and forwards all incoming " | ||
"packets to all other participants.\n\nArguments:\n"); | ||
fprintf(stderr, | ||
"\t-p port specifies the port number to listen on, " | ||
"default is 12021.\n"); | ||
fprintf(stderr, | ||
"\t-d device is a path to a physical device doing " | ||
"serial-CAN or USB-CAN. If specified, opens device and " | ||
"adds it to the hub.\n"); | ||
#if defined(__linux__) | ||
fprintf(stderr, | ||
"\t-s socketcan_interface is a socketcan device (e.g. 'can0'). " | ||
"If specified, opens device and adds it to the hub.\n"); | ||
#endif | ||
fprintf(stderr, | ||
"\t-u upstream_host is the host name for an upstream " | ||
"hub. If specified, this hub will connect to an upstream " | ||
"hub.\n"); | ||
fprintf(stderr, | ||
"\t-q upstream_port is the port number for the upstream hub.\n"); | ||
fprintf(stderr, "\t-t prints timestamps for each packet.\n"); | ||
fprintf(stderr, "\t-l print all packets.\n"); | ||
#ifdef HAVE_AVAHI_CLIENT | ||
fprintf(stderr, "\t-m exports the current service on mDNS.\n"); | ||
fprintf( | ||
stderr, "\t-n mdns_name sets the exported mDNS name. Implies -m.\n"); | ||
#endif | ||
exit(1); | ||
} | ||
|
||
void parse_args(int argc, char *argv[]) | ||
{ | ||
int opt; | ||
while ((opt = getopt(argc, argv, "hp:d:s:u:q:tlmn:")) >= 0) | ||
{ | ||
switch (opt) | ||
{ | ||
case 'h': | ||
usage(argv[0]); | ||
break; | ||
case 'd': | ||
device_path = optarg; | ||
break; | ||
#if defined(__linux__) | ||
case 's': | ||
socket_can_path = optarg; | ||
break; | ||
#endif | ||
case 'p': | ||
port = atoi(optarg); | ||
break; | ||
case 'u': | ||
upstream_host = optarg; | ||
break; | ||
case 'q': | ||
upstream_port = atoi(optarg); | ||
break; | ||
case 't': | ||
timestamped = true; | ||
break; | ||
case 'm': | ||
export_mdns = true; | ||
break; | ||
case 'n': | ||
mdns_name = optarg; | ||
export_mdns = true; | ||
break; | ||
case 'l': | ||
printpackets = true; | ||
break; | ||
default: | ||
fprintf(stderr, "Unknown option %c\n", opt); | ||
usage(argv[0]); | ||
} | ||
} | ||
} | ||
|
||
void create_legacy_bridge() { | ||
static bool is_created = false; | ||
if (!is_created) { | ||
is_created = true; | ||
create_gc_to_legacy_can_bridge(g_direct_hub.get(), &can_hub0); | ||
} | ||
} | ||
|
||
/** Entry point to application. | ||
* @param argc number of command line arguments | ||
* @param argv array of command line arguments | ||
* @return 0, should never return | ||
*/ | ||
int appl_main(int argc, char *argv[]) | ||
{ | ||
parse_args(argc, argv); | ||
// GcPacketPrinter packet_printer(&can_hub0, timestamped); | ||
GcPacketPrinter *packet_printer = NULL; | ||
if (printpackets) | ||
{ | ||
create_legacy_bridge(); | ||
packet_printer = new GcPacketPrinter(&can_hub0, timestamped); | ||
} | ||
fprintf(stderr, "packet_printer points to %p\n", packet_printer); | ||
create_direct_gc_tcp_hub(g_direct_hub.get(), port); | ||
vector<std::unique_ptr<ConnectionClient>> connections; | ||
|
||
#ifdef HAVE_AVAHI_CLIENT | ||
void mdns_client_start(); | ||
void mdns_publish(const char *name, uint16_t port); | ||
|
||
if (export_mdns) | ||
{ | ||
mdns_client_start(); | ||
mdns_publish(mdns_name, port); | ||
} | ||
#endif | ||
|
||
#if defined(__linux__) | ||
if (socket_can_path) | ||
{ | ||
int s = socketcan_open(socket_can_path, 1); | ||
if (s >= 0) | ||
{ | ||
create_legacy_bridge(); | ||
new HubDeviceSelect<CanHubFlow>(&can_hub0, s); | ||
fprintf(stderr, "Opened SocketCan %s: fd %d\n", socket_can_path, s); | ||
} | ||
else | ||
{ | ||
fprintf(stderr, "Failed to open SocketCan %s.\n", socket_can_path); | ||
} | ||
} | ||
#endif | ||
|
||
if (upstream_host) | ||
{ | ||
connections.emplace_back(new UpstreamConnectionClient( | ||
"upstream", g_direct_hub.get(), upstream_host, upstream_port)); | ||
} | ||
|
||
if (device_path) | ||
{ | ||
connections.emplace_back(new DeviceConnectionClient( | ||
"device", g_direct_hub.get(), device_path)); | ||
} | ||
|
||
while (1) | ||
{ | ||
for (const auto &p : connections) | ||
{ | ||
p->ping(); | ||
} | ||
sleep(1); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SUBDIRS = \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SUBDIRS = linux.x86 \ | ||
|
||
include $(OPENMRNPATH)/etc/recurse.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
direct_hub | ||
*_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../hub/targets/linux.x86/AvaHiMDNS.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-include ../../config.mk | ||
include $(OPENMRNPATH)/etc/prog.mk | ||
|
||
SYSLIBRARIES += -lavahi-client -lavahi-common | ||
CXXFLAGS += -DHAVE_AVAHI_CLIENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(OPENMRNPATH)/etc/app_target_lib.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SUBDIRS = targets | ||
-include config.mk | ||
include $(OPENMRNPATH)/etc/recurse.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Hub throughput testing application {#hub_test_application} | ||
================================== | ||
|
||
[TOC] | ||
|
||
# Goal | ||
|
||
The purpose of Hub testing is to verify an OpenLCB link or bus for qualitative | ||
and quantitative performance characteristics. These are as follows. | ||
|
||
Qualitative: | ||
- The link has to be lossless. | ||
- There is only limited reordering allowed within the link. | ||
- There has to be proper throttling for ingress of packets to the link. | ||
|
||
Quantitative: | ||
- What is the maximum throughut of packets that can be accepted on the link. | ||
- What is the round-trip-time of the link. | ||
- What is the jitter on the timing of the packet round-trips. | ||
|
||
For hubs, a relevant question is also how do these metrics change as the number | ||
of clients on the hub are increased. | ||
|
||
## Testing methodology | ||
|
||
The application contains a load generator, and a receiver. For a given test, | ||
one generator and one or more receivers have to be attached to the same bus. | ||
|
||
The generator supplies a given load to the bus. This load may be a fixes | ||
traffic, or the maximum traffic that the bus is willing to accept. | ||
|
||
The receiver watches for the traffic coming from the generator, verifies the | ||
qualitative attributes, and measures the quantitative attributes. Statistics | ||
about this are printed to the screen. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../default_config.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SUBDIRS = \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SUBDIRS = \ | ||
linux.x86 \ | ||
|
||
include $(OPENMRNPATH)/etc/recurse.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hub_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-include ../../config.mk | ||
include $(OPENMRNPATH)/etc/prog.mk |
Oops, something went wrong.