Skip to content

Commit

Permalink
Merge branch 'master' into bracz-railcom-halfzero
Browse files Browse the repository at this point in the history
* master: (88 commits)
  Adds a method to send out a global alias mapping enquiry to the bus. (#479)
  Fixes todo in the bulk alias allocator that makes it actually operable. (#471)
  CC32xx set mac feature (#478)
  ESP32: Prep for Arduino-esp32 v1.0.5 (#473)
  Adjust DeviceBuffer to use OPENMRN_FEATURE_DEVTAB instead of ARDUINO define. (#474)
  Supports nullptr as argument to the node init flow. (#472)
  Fix compile errors.
  Add support for C++11 compilation of std::make_unique() (#470)
  Stores reserved aliases in the local alias cache (#467)
  Adds more test helpers to run code on the main executor. (#468)
  Fix console session close bug (#466)
  update to C++14 for cov and Linux.x86 targets. (#465)
  Protect unimplemented POSIX calls in BroadcastTime::clear_timezone() to allow OpenMRNLite to compile on Arduino flavored platforms. (#464)
  Fix OpenMRNLite problem with DEFAULT symbol (#462)
  fixes comments.
  Fixes comments.
  Fix comments.
  fix whitespace
  Adds support for conflict handling in the bulk alias allocator.
  adds time expectation
  ...
  • Loading branch information
balazsracz committed Nov 28, 2020
2 parents f7036f9 + d70607e commit 3fa2148
Show file tree
Hide file tree
Showing 148 changed files with 6,501 additions and 844 deletions.
1 change: 0 additions & 1 deletion applications/async_blink/targets/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
SUBDIRS = linux.x86 \
linux.armv7a \
linux.llvm \
mach.x86 \
mach.x86_64 \
freertos.armv7m.ek-lm4f120xl \
freertos.armv7m.ek-tm4c123gxl \
Expand Down
2 changes: 0 additions & 2 deletions applications/async_blink/targets/mach.x86/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions applications/async_blink/targets/mach.x86/NodeId.cxx

This file was deleted.

1 change: 1 addition & 0 deletions applications/async_blink/targets/mach.x86_64/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-include ../../config.mk
include $(OPENMRNPATH)/etc/prog.mk
10 changes: 5 additions & 5 deletions applications/clinic_app/targets/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
SUBDIRS = \
freertos.armv7m.ek-tm4c123gxl \
freertos.armv7m.ek-tm4c1294xl \
freertos.armv6m.st-stm32f072b-discovery \
freertos.armv7m.st-stm32f303-discovery \
freertos.armv7m.ek-tm4c123gxl \
freertos.armv7m.ek-tm4c1294xl \
freertos.armv6m.st-stm32f072b-discovery \
freertos.armv7m.st-stm32f303-discovery \
linux.armv7a \
linux.x86 \
mach.x86
mach.x86_64


# freertos.armv7m.lpc1768-mbed \
Expand Down
64 changes: 49 additions & 15 deletions applications/hub/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@

#include <memory>

#include "os/os.h"
#include "utils/constants.hxx"
#include "utils/Hub.hxx"
#include "utils/GcTcpHub.hxx"
#include "utils/ClientConnection.hxx"
#include "executor/Executor.hxx"
#include "executor/Service.hxx"
#include "os/os.h"
#include "utils/ClientConnection.hxx"
#include "utils/GcTcpHub.hxx"
#include "utils/Hub.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);
Expand All @@ -58,6 +60,7 @@ OVERRIDE_CONST(gridconnect_buffer_delay_usec, 2000);

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;
Expand All @@ -67,18 +70,28 @@ 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] [-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,
"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");
Expand All @@ -100,7 +113,7 @@ void usage(const char *e)
void parse_args(int argc, char *argv[])
{
int opt;
while ((opt = getopt(argc, argv, "hp:d:u:q:tlmn:")) >= 0)
while ((opt = getopt(argc, argv, "hp:d:s:u:q:tlmn:")) >= 0)
{
switch (opt)
{
Expand All @@ -110,6 +123,11 @@ void parse_args(int argc, char *argv[])
case 'd':
device_path = optarg;
break;
#if defined(__linux__)
case 's':
socket_can_path = optarg;
break;
#endif
case 'p':
port = atoi(optarg);
break;
Expand Down Expand Up @@ -160,12 +178,28 @@ int appl_main(int argc, char *argv[])
void mdns_client_start();
void mdns_publish(const char *name, uint16_t port);

if (export_mdns) {
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)
{
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(
Expand Down
2 changes: 1 addition & 1 deletion applications/hub/targets/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SUBDIRS = linux.x86 \
linux.armv7a \
mach.x86
mach.x86_64

include $(OPENMRNPATH)/etc/recurse.mk
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
-include ../../config.mk
include $(OPENMRNPATH)/etc/prog.mk

1 change: 1 addition & 0 deletions applications/hub/targets/linux.rpi1/AvaHiMDNS.cxx
36 changes: 36 additions & 0 deletions applications/hub/targets/linux.rpi1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Adding SocketCAN support on the Raspberry Pi 4

These are my notes from adding SocketCAN support and building the **hub** application in a Raspberry Pi.

- Start with the pre-built JMRI - RPI disk image from: [M Steve Todd's - JMRI RaspberryPi as Access Point](https://mstevetodd.com/rpi)

- Install the MCP2517 CAN interface hardware from: [2-Channel CAN-BUS(FD) Shield for Raspberry Pi](https://www.seeedstudio.com/2-Channel-CAN-BUS-FD-Shield-for-Raspberry-Pi-p-4072.html) and followed their instructions for building the MCP2517 kernel device driver on their [Support Wiki](http://wiki.seeedstudio.com/2-Channel-CAN-BUS-FD-Shield-for-Raspberry-Pi/#software) page.

- Install some needed packages on the RPi:

`sudo apt install git doxygen libavahi-client-dev`

- Download the OpenMRN source code to the RPi:

`cd ~`

`git clone https://github.com/bakerstu/openmrn.git`

- Build the **hub** application:

`cd openmrn/applications/hub/targets/linux.rpi1/`

`make`

- Configure the **can0** interface for 125,000 bps and run the **hub** application at system at start-up by creating the file: `/etc/network/interfaces.d/can0` with the following lines:
```
allow-hotplug can0
iface can0 can static
bitrate 125000
up /home/pi/openmrn/applications/hub/targets/linux.rpi1/hub -s $IFACE &
```

- Configure the LCC Layout Connection in JMRI to use
- System Connection: `CAN via GridConnect Network Interface`
- IP Address/Host Name: `localhost`
- TCP/UDP Port: `12021`
1 change: 0 additions & 1 deletion applications/hub/targets/mach.x86/lib/Makefile

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion applications/simple_client/targets/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SUBDIRS = linux.x86 mach.x86
SUBDIRS = linux.x86 mach.x86_64
-include config.mk
include $(OPENMRNPATH)/etc/recurse.mk
1 change: 1 addition & 0 deletions applications/simple_client/targets/mach.x86_64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simple_client
31 changes: 21 additions & 10 deletions bin/revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
outputcxx += ' "' + gcc + '",\n'
outputhxx += '"' + gcc + '\\n"\n'

main_git_hash = None

for x in inputs :
print x
# go into the root of the repo
Expand Down Expand Up @@ -121,17 +123,19 @@
outputcxx += ':' + os.path.split(os.path.abspath(x))[1]
outputhxx += '"' + git_hash + ':' + os.path.split(os.path.abspath(x))[1]

hashopts = ""

if dirty or untracked :
outputcxx += ':'
outputhxx += ':'
hashopts += ':'
if dirty :
outputcxx += '-d'
outputhxx += '-d'
hashopts += '-d'
if untracked :
outputcxx += '-u'
outputhxx += '-u'
outputcxx += '",\n'
outputhxx += '\\n"\n'
hashopts += '-u'
outputcxx += hashopts + '",\n'
outputhxx += hashopts + '\\n"\n'

if main_git_hash is None:
main_git_hash = git_hash + hashopts

outputcxx += ' nullptr\n'
outputcxx += '};\n'
Expand All @@ -142,6 +146,9 @@
outputhxx += '));\n'
outputhxx += 'CDI_GROUP_END();\n'

if main_git_hash is not None:
outputhxx += '\n#define REVISION_GIT_HASH "' + main_git_hash + '"\n'

os.chdir(orig_dir)

# generate the *.cxxout style content
Expand All @@ -165,14 +172,18 @@
"-I", """Thu, """, "-I", """Fri, """,
"-I", """Sat, """,
options.output + 'Try.hxxout',
options.output + '.hxxout'], stdout=f_null)
options.output + '.hxxout'],
stdout=f_null, stderr=f_null)
diffcxx = subprocess.call(['diff',
"-I", """Sun, """, "-I", """Mon, """,
"-I", """Tue, """, "-I", """Wed, """,
"-I", """Thu, """, "-I", """Fri, """,
"-I", """Sat, """,
options.output + 'Try.cxxout',
options.output + '.cxxout'], stdout=f_null)
options.output + '.cxxout'],
stdout=f_null, stderr=f_null)
# disable this because we are not actually writing a cxx file above.
diffcxx = 0

if diffhxx != 0 :
os.system('rm -f ' + options.output + '.hxxout')
Expand Down
1 change: 1 addition & 0 deletions boards/armv7m/default_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ __attribute__((__naked__)) static void hard_fault_handler(void)
" mrsne r0, psp\n"
" mov sp, r0 \n"
" bkpt #1 \n"
" bx lr \n"
);
#endif
#if 0
Expand Down
4 changes: 2 additions & 2 deletions boards/bracz-railcom/HwInit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ static TivaCan can0("/dev/can0", CAN0_BASE, INT_RESOLVE(INT_CAN0_, 0));

const unsigned TivaEEPROMEmulation::FAMILY = TM4C123;
const size_t EEPROMEmulation::SECTOR_SIZE = 4 * 1024;
static TivaEEPROMEmulation eeprom("/dev/eeprom", 1024);
static TivaEEPROMEmulation eeprom("/dev/eeprom", 1524);

const uint32_t RailcomDefs::UART_BASE[] = RAILCOM_BASE;
const uint32_t RailcomDefs::UART_PERIPH[] = RAILCOM_PERIPH;

TivaDAC<DACDefs> dac;
TivaGNDControl gnd_control;
TivaBypassControl bypass_control;

unsigned DCCDecode::sampleCount_ = 0;
uint8_t RailcomDefs::feedbackChannel_ = 0xff;
uint8_t dac_next_packet_mode = 0;

Expand Down
10 changes: 8 additions & 2 deletions boards/bracz-railcom/hardware.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "BlinkerGPIO.hxx"
#include "utils/Debouncer.hxx"

#define HARDWARE_REVA

GPIO_PIN(SW1, GpioInputPU, F, 4);
GPIO_PIN(SW2, GpioInputPU, F, 0);
Expand Down Expand Up @@ -128,6 +129,8 @@ struct Debug
typedef DummyPin DccDecodeInterrupts;
//typedef LED_GREEN_Pin DccDecodeInterrupts;

typedef DummyPin DccPacketFinishedHook;

// Flips every timer capture interrupt from the dcc deocder flow.
// typedef DBG_SIGNAL_Pin RailcomE0;
//typedef LED_GREEN_Pin RailcomE0;
Expand Down Expand Up @@ -176,6 +179,7 @@ struct RailcomDefs
static bool need_ch1_cutout() {
return true;
}
static void middle_cutout_hook() {}

static void enable_measurement(bool);
static void disable_measurement();
Expand Down Expand Up @@ -444,8 +448,6 @@ struct DCCDecode
HWREG(TIMER_BASE + TIMER_O_TAMR) |= (TIMER_TAMR_TAMIE);
}

static void cap_event_hook() {}

static const auto RCOM_TIMER = TIMER_A;
static const auto SAMPLE_PERIOD_CLOCKS = 60000;
//static const auto SAMPLE_TIMER_TIMEOUT = TIMER_TIMA_TIMEOUT;
Expand All @@ -466,6 +468,10 @@ struct DCCDecode
static inline void dcc_before_cutout_hook();
static inline void dcc_packet_finished_hook();
static inline void after_feedback_hook();

/// counts how many edges / transitions we had on the DCC signal.
static unsigned sampleCount_;
static inline void cap_event_hook() { ++sampleCount_; }
};

#endif // ! pindefs_only
Expand Down
3 changes: 2 additions & 1 deletion boards/ti-bracz-acc3/hardware.v3.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ struct RailcomHw

static bool need_ch1_cutout() { return true; }
static uint8_t get_feedback_channel() { return 0xff; }

static void middle_cutout_hook() {}

/// @returns a bitmask telling which pins are active. Bit 0 will be set if
/// channel 0 is active (drawing current).
static uint8_t sample() {
Expand Down
1 change: 1 addition & 0 deletions boards/ti-ek-tm4c123gxl-launchpad/HwInit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ struct RailcomDefs
static void disable_measurement() {}
static bool need_ch1_cutout() { return true; }
static uint8_t get_feedback_channel() { return 0xff; }
static void middle_cutout_hook() {}

/** @returns a bitmask telling which pins are active. Bit 0 will be set if
* channel 0 is active (drawing current).*/
Expand Down
Loading

0 comments on commit 3fa2148

Please sign in to comment.