Skip to content

Commit

Permalink
Merge pull request #378 from openxc/next
Browse files Browse the repository at this point in the history
Prep for next release
  • Loading branch information
emarsman committed Dec 12, 2016
2 parents 45eeb2a + a349b79 commit 25b93b0
Show file tree
Hide file tree
Showing 33 changed files with 286 additions and 64 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.mkd
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# OpenXC Vehicle Interface Firmware Changelog

## v7.2.1-dev

* BREAKING: Removed fine_odometer_since_restart from emulator.
* Feature: Added sending evented messages from emulator.
Evented messages will come at a slower rate then other messages to simulate real world frequency
* Fix: When building emualtor, obd2, or translated_obd2 firmware, those designations will now be
indicated in the version number instead of the type number in signals.cpp.
* Feature: Add support for multi-frame diagnostic responses (currently just for
receiving, not sending)
* Feature: VIs running emulator firmware will now respond to basic diagnostic requests from enabler
and the command line. The response will mimic the request's bus, message ID, mode, and PID (if sent).
The response will also include a randomly generated value between 0 and 100.
Recurring diagnostic messages when running emulator firmware are currently not supported.

## v7.2.0

* BREAKING: This version requires updates to bootstrap. 'vagrant up --provision' must be run after 'git pull'.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OpenXC Vehicle Interface Firmware

.. image:: /docs/_static/logo.png

:Version: 7.2.0
:Version: 7.2.1-dev
:Web: http://openxcplatform.com
:Documentation: http://vi-firmware.openxcplatform.com
:Source: http://github.com/openxc/vi-firmware
Expand Down
Binary file modified docs/_static/OpenXC-CrossChasm-Flash.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
# built documents.
#
# The short X.Y version.
version = '7.2.0'
version = '7.2.1-dev'
# The full version, including alpha/beta/rc tags.
release = '7.2.0'
release = '7.2.1-dev'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OpenXC Vehicle Interface Firmware

.. image:: /_static/logo.png

:Version: 7.2.0
:Version: 7.2.1-dev
:Web: http://openxcplatform.com
:Documentation: http://vi-firmware.openxcplatform.com
:Source: http://github.com/openxc/vi-firmware
Expand Down
4 changes: 4 additions & 0 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def build_options():
DEFAULT_COMPILER_OPTIONS = {
'DEBUG': env.debug,
'MSD_ENABLE' : env.msd_enable,
'ENVIRONMENT_MODE' : 'default_mode',
'DEFAULT_FILE_GENERATE_SECS' : env.default_file_generate_secs,
'BOOTLOADER': env.bootloader,
'TEST_MODE_ONLY': env.test_mode_only,
Expand All @@ -151,11 +152,14 @@ def build_options():
if env.mode == 'emulator':
options['DEFAULT_EMULATED_DATA_STATUS'] = True
options['DEFAULT_POWER_MANAGEMENT'] = "ALWAYS_ON"
options['ENVIRONMENT_MODE'] = env.mode
elif env.mode == 'translated_obd2':
options['DEFAULT_POWER_MANAGEMENT'] = "OBD2_IGNITION_CHECK"
options['DEFAULT_RECURRING_OBD2_REQUESTS_STATUS'] = True
options['ENVIRONMENT_MODE'] = env.mode
elif env.mode == 'obd2':
options['DEFAULT_POWER_MANAGEMENT'] = "OBD2_IGNITION_CHECK"
options['ENVIRONMENT_MODE'] = env.mode
return " ".join((build_option(key, value)
for key, value in options.iteritems()))

Expand Down
7 changes: 7 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ OBJDIR = $(OBJDIR_ROOT)
# 0 or 1
BOOTLOADER ?= 1

PLATFORM ?= "NONE"
SYMBOLS += PLATFORM="\"$(PLATFORM)\""

DEFAULT_ALLOW_RAW_WRITE_USB ?= 1
SYMBOLS += DEFAULT_ALLOW_RAW_WRITE_USB=$(DEFAULT_ALLOW_RAW_WRITE_USB)

Expand Down Expand Up @@ -72,6 +75,9 @@ SYMBOLS += DEFAULT_USB_PRODUCT_ID=$(DEFAULT_USB_PRODUCT_ID)
DEFAULT_CAN_ACK_STATUS ?= 0
SYMBOLS += DEFAULT_CAN_ACK_STATUS=$(DEFAULT_CAN_ACK_STATUS)

ENVIRONMENT_MODE ?= "default_mode"
SYMBOLS += ENVIRONMENT_MODE="\"$(ENVIRONMENT_MODE)\""

# TODO see https://github.com/openxc/vi-firmware/issues/189
# ifeq ($(NETWORK), 1)
# SYMBOLS += __USE_NETWORK__
Expand Down Expand Up @@ -213,6 +219,7 @@ endif
define show_options
$(call show_vi_config_variable,PLATFORM)
$(call show_vi_config_variable,BOOTLOADER)
$(call show_vi_config_variable,ENVIRONMENT_MODE)
$(call show_vi_config_variable,TEST_MODE_ONLY)
$(call show_vi_config_variable,DEBUG)
$(call show_vi_config_variable,MSD_ENABLE)
Expand Down
14 changes: 14 additions & 0 deletions src/can/canread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ void openxc::can::read::publishStringMessage(const char* name,
publishVehicleMessage(name, &decodedValue, pipeline);
}

void openxc::can::read::publishStringEventedMessage(const char* name,
const char* value, const char* event, openxc::pipeline::Pipeline* pipeline) {
openxc_DynamicField decodedValue = payload::wrapString(value);
openxc_DynamicField decodedEvent = payload::wrapString(event);
publishVehicleMessage(name, &decodedValue, &decodedEvent, pipeline);
}

void openxc::can::read::publishStringEventedBooleanMessage(const char* name,
const char* value, bool event, openxc::pipeline::Pipeline* pipeline) {
openxc_DynamicField decodedValue = payload::wrapString(value);
openxc_DynamicField decodedEvent = payload::wrapBoolean(event);
publishVehicleMessage(name, &decodedValue, &decodedEvent, pipeline);
}

void openxc::can::read::publishBooleanMessage(const char* name, bool value,
openxc::pipeline::Pipeline* pipeline) {
openxc_DynamicField decodedValue = payload::wrapBoolean(value);
Expand Down
4 changes: 4 additions & 0 deletions src/can/canread.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ void publishNumericalMessage(const char* name, float value,
openxc::pipeline::Pipeline* pipeline);
void publishStringMessage(const char* name, const char* value,
openxc::pipeline::Pipeline* pipeline);
void publishStringEventedMessage(const char* name, const char* value, const char* event,
openxc::pipeline::Pipeline* pipeline);
void publishStringEventedBooleanMessage(const char* name, const char* value, bool event,
openxc::pipeline::Pipeline* pipeline);
void publishBooleanMessage(const char* name, bool value,
openxc::pipeline::Pipeline* pipeline);

Expand Down
5 changes: 5 additions & 0 deletions src/commands/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "commands/diagnostic_request_command.h"
#include "commands/version_command.h"
#include "commands/device_id_command.h"
#include "commands/device_platform_command.h"
#include "commands/can_message_write_command.h"
#include "commands/simple_write_command.h"
#include "commands/af_bypass_command.h"
Expand Down Expand Up @@ -39,6 +40,9 @@ static bool handleComplexCommand(openxc_VehicleMessage* message) {
case openxc_ControlCommand_Type_DEVICE_ID:
status = openxc::commands::handleDeviceIdCommmand();
break;
case openxc_ControlCommand_Type_PLATFORM:
status = openxc::commands::handleDevicePlatformCommmand();
break;
case openxc_ControlCommand_Type_PASSTHROUGH:
status = openxc::commands::handlePassthroughModeCommand(command);
break;
Expand Down Expand Up @@ -138,6 +142,7 @@ static bool validateControlCommand(openxc_VehicleMessage* message) {
break;
case openxc_ControlCommand_Type_VERSION:
case openxc_ControlCommand_Type_DEVICE_ID:
case openxc_ControlCommand_Type_PLATFORM:
case openxc_ControlCommand_Type_SD_MOUNT_STATUS:
valid = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/device_id_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ bool openxc::commands::handleDeviceIdCommmand() {
ble::BleDevice* ble = getConfiguration()->ble;

sprintf(ids,"%02X:%02X:%02X:%02X:%02X:%02X",
ble->blesettings.bdaddr[0],ble->blesettings.bdaddr[1],ble->blesettings.bdaddr[2],
ble->blesettings.bdaddr[3],ble->blesettings.bdaddr[4],ble->blesettings.bdaddr[5]
ble->blesettings.bdaddr[5],ble->blesettings.bdaddr[4],ble->blesettings.bdaddr[3],
ble->blesettings.bdaddr[2],ble->blesettings.bdaddr[1],ble->blesettings.bdaddr[0]
);
sendCommandResponse(openxc_ControlCommand_Type_DEVICE_ID, true,
(char *)ids, strlen(ids));
Expand Down
40 changes: 40 additions & 0 deletions src/commands/device_platform_command.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "device_platform_command.h"
#include "config.h"
#include "diagnostics.h"
#include "interface/usb.h"
#include "util/log.h"
#include "config.h"
#include "pb_decode.h"
#include <payload/payload.h>
#include "signals.h"
#include <can/canutil.h>
#include <bitfield/bitfield.h>
#include <limits.h>

using openxc::util::log::debug;
using openxc::config::getConfiguration;
using openxc::payload::PayloadFormat;
using openxc::signals::getCanBuses;
using openxc::signals::getCanBusCount;
using openxc::signals::getSignals;
using openxc::signals::getSignalCount;
using openxc::signals::getCommands;
using openxc::signals::getCommandCount;
using openxc::can::lookupBus;
using openxc::can::lookupSignal;

namespace can = openxc::can;
namespace payload = openxc::payload;
namespace config = openxc::config;
namespace diagnostics = openxc::diagnostics;
namespace usb = openxc::interface::usb;
namespace uart = openxc::interface::uart;
namespace pipeline = openxc::pipeline;

bool openxc::commands::handleDevicePlatformCommmand() {
char* platform_name;
platform_name = strdup(config::getConfiguration()->platform);
sendCommandResponse(openxc_ControlCommand_Type_PLATFORM, true,
platform_name, strlen(platform_name));
return true;
}
12 changes: 12 additions & 0 deletions src/commands/device_platform_command.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef __DEVICE_PLATFORM_COMMAND_H__
#define __DEVICE_PLATFORM_COMMAND_H__

namespace openxc {
namespace commands {

bool handleDevicePlatformCommmand();

} // namespace commands
} // namespace openxc

#endif // __DEVICE_PLATFORM_COMMAND_H__
15 changes: 12 additions & 3 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ble::BleDevice bleDevice = {
allowRawWrites: DEFAULT_ALLOW_RAW_WRITE_BLE
},
blesettings: {
"OpenXC_C5_BTLE",
"OPENXC-VI-XXXX",
adv_min_ms: 100,
adv_max_ms: 100,
slave_min_ms : 8, //range 0x0006 to 0x0C80
Expand Down Expand Up @@ -118,7 +118,9 @@ openxc::telitHE910::TelitDevice telitDevice = {
openxc::config::Configuration* openxc::config::getConfiguration() {
static openxc::config::Configuration CONFIG = {
messageSetIndex: 0,
version: "7.2.0",
version: "7.2.1-dev",
platform: PLATFORM,
environmentMode: ENVIRONMENT_MODE,
payloadFormat: PayloadFormat::DEFAULT_OUTPUT_FORMAT,
recurringObd2Requests: DEFAULT_RECURRING_OBD2_REQUESTS_STATUS,
obd2BusAddress: DEFAULT_OBD2_BUS,
Expand Down Expand Up @@ -184,9 +186,16 @@ openxc::config::Configuration* openxc::config::getConfiguration() {
}

void openxc::config::getFirmwareDescriptor(char* buffer, size_t length) {
snprintf(buffer, length, "%s (%s)", getConfiguration()->version,
const char* envMode = getConfiguration()->environmentMode;
if(strcmp(envMode, "default_mode") != 0)
{
snprintf(buffer, length, "%s (%s)", getConfiguration()->version, getConfiguration()->environmentMode);
}
else {
snprintf(buffer, length, "%s (%s)", getConfiguration()->version,
signals::getActiveMessageSet() != NULL ?
signals::getActiveMessageSet()->name : "default");
}
}

#ifdef TELIT_HE910_SUPPORT
Expand Down
5 changes: 5 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ typedef enum {
* messageSetIndex - The index of the currently active message set from the
* signals module.
* version - A string describing the firmware version.
* environmentMode - A string describing the what type of firmware it is.
* Modes: default_mode, emulator, obd2, translated_obd2
* "default_mode" is when there is no modifier present (ie: emulator, obd2, etc)
* payloadFormat - The currently active payload format, from the payload module.
* This is used for both input and output.
* recurringObd2Requests - True if the VI should automatically query for
Expand Down Expand Up @@ -107,6 +110,8 @@ typedef enum {
typedef struct {
int messageSetIndex;
const char* version;
const char* platform;
const char* environmentMode;
openxc::payload::PayloadFormat payloadFormat;
bool recurringObd2Requests;
uint8_t obd2BusAddress;
Expand Down
48 changes: 38 additions & 10 deletions src/data_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
#include <stdlib.h>

#define MAX_EMULATED_MESSAGES 1000
#define NUMERICAL_SIGNAL_COUNT 11
#define NUMERICAL_SIGNAL_COUNT 10
#define BOOLEAN_SIGNAL_COUNT 5
#define STATE_SIGNAL_COUNT 2
#define EVENT_SIGNAL_COUNT 1
#define EVENT_SIGNAL_COUNT 2
#define EMULATOR_SEND_FREQUENCY 500

using openxc::can::read::publishNumericalMessage;
using openxc::can::read::publishBooleanMessage;
using openxc::can::read::publishStringMessage;
using openxc::can::read::publishStringEventedMessage;
using openxc::can::read::publishStringEventedBooleanMessage;
using openxc::pipeline::Pipeline;

static const char* NUMERICAL_SIGNALS[NUMERICAL_SIGNAL_COUNT] = {
Expand All @@ -24,7 +26,6 @@ static const char* NUMERICAL_SIGNALS[NUMERICAL_SIGNAL_COUNT] = {
"vehicle_speed",
"accelerator_pedal_position",
"odometer",
"fine_odometer_since_restart",
"latitude",
"longitude",
"fuel_level",
Expand All @@ -49,6 +50,21 @@ static const char* EMULATED_SIGNAL_STATES[STATE_SIGNAL_COUNT][3] = {
{ "off", "run", "accessory" },
};

static const char* EVENT_SIGNALS[EVENT_SIGNAL_COUNT] = {
"door_status",
"button_event",
};

static const char* EVENT_SIGNAL_STATES[EVENT_SIGNAL_COUNT][4] = {
{ "driver", "passenger", "rear_left", "rear_right" },
{ "up", "left", "down", "right" },
};

static const char* EVENT_SIGNAL_EVENT[EVENT_SIGNAL_COUNT][2] = {
{ "true", "false"},
{ "pressed", "released"},
};

static int messageCount = 0;
static bool unlimitedEmulatedMessages = true;

Expand All @@ -62,17 +78,29 @@ void openxc::emulator::generateFakeMeasurements(Pipeline* pipeline) {
++emulatorRateLimiter;
++messageCount;
if(emulatorRateLimiter == EMULATOR_SEND_FREQUENCY / 2) {
publishNumericalMessage(
NUMERICAL_SIGNALS[rand() % NUMERICAL_SIGNAL_COUNT],
rand() % 50 + rand() % 100 * .1, pipeline);
publishNumericalMessage(NUMERICAL_SIGNALS[rand() % NUMERICAL_SIGNAL_COUNT],
rand() % 50 + rand() % 100 * .1, pipeline);
publishBooleanMessage(BOOLEAN_SIGNALS[rand() % BOOLEAN_SIGNAL_COUNT],
rand() % 2 == 1 ? true : false, pipeline);
rand() % 2 == 1 ? true : false, pipeline);
} else if(emulatorRateLimiter == EMULATOR_SEND_FREQUENCY) {
emulatorRateLimiter = 0;

int stateSignalIndex = rand() % STATE_SIGNAL_COUNT;
publishStringMessage(STATE_SIGNALS[stateSignalIndex],
EMULATED_SIGNAL_STATES[stateSignalIndex][rand() % 3], pipeline);
publishStringMessage(STATE_SIGNALS[stateSignalIndex],
EMULATED_SIGNAL_STATES[stateSignalIndex][rand() % 3], pipeline);
//These signals are not reoccurring, so they are published at a
//slower rate then all of the other signals. The % 50 allows them to
//publish at a much more realistic rate
if(rand() % 50 == 0){
//door_status - cant just do a random call of the string like
//button event b/c emulator needs a boolean
publishStringEventedBooleanMessage(EVENT_SIGNALS[0],
EVENT_SIGNAL_STATES[0][rand() % 4], rand() % 2 == 1 ? true : false, pipeline);
}
else if(rand() % 50 == 1){
//button_event
publishStringEventedMessage(EVENT_SIGNALS[1],
EVENT_SIGNAL_STATES[1][rand() % 4], EVENT_SIGNAL_EVENT[1][rand() % 2], pipeline);
}
}
}
}
Loading

0 comments on commit 25b93b0

Please sign in to comment.