Skip to content

Commit

Permalink
Merge pull request #168 from PolySync/maint/reorganize-software-stack
Browse files Browse the repository at this point in the history
Reorganize software stack
  • Loading branch information
nathanaschbacher authored Jul 28, 2017
2 parents 13b1af5 + 8c993d7 commit 1171726
Show file tree
Hide file tree
Showing 360 changed files with 6,756 additions and 10,869 deletions.
10 changes: 3 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ node('arduino') {
}
stage('Build') {
parallel 'kia soul firmware': {
sh 'cd platforms && mkdir build && cd build && cmake .. -DBUILD_KIA_SOUL=ON -DCMAKE_BUILD_TYPE=Release && make'
}, 'joystick commander': {
sh 'cd utils/joystick_commander && mkdir build && cd build && cmake .. && make'
}, 'diagnostics tool': {
sh 'cd utils/diagnostics_tool && mkdir build && cd build && cmake .. && make'
sh 'cd firmware && mkdir build && cd build && cmake .. -DKIA_SOUL=ON -DCMAKE_BUILD_TYPE=Release && make'
}
echo 'Build Complete!'
}
stage('Test') {
parallel 'unit tests': {
sh 'cd platforms && mkdir build_unit_tests && cd build_unit_tests && cmake .. -DTESTS=ON -DCMAKE_BUILD_TYPE=Release && make run-unit-tests'
sh 'cd firmware && mkdir build_unit_tests && cd build_unit_tests && cmake .. -DKIA_SOUL=ON -DTESTS=ON -DCMAKE_BUILD_TYPE=Release && make run-unit-tests'
echo 'Unit Tests Complete!'
}, 'property-based tests': {
sh 'cd platforms && mkdir build_property_tests && cd build_property_tests && cmake .. -DTESTS=ON -DCMAKE_BUILD_TYPE=Release && make run-property-tests'
sh 'cd firmware && mkdir build_property_tests && cd build_property_tests && cmake .. -DKIA_SOUL=ON -DTESTS=ON -DCMAKE_BUILD_TYPE=Release && make run-property-tests'
echo 'Property-Based Tests Complete!'
}, 'acceptance tests': {
echo 'Acceptance Tests Complete!'
Expand Down
252 changes: 116 additions & 136 deletions README.md

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions api/include/can_protocols/brake_can_protocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* @file brake_can_protocol.h
* @brief Brake CAN Protocol.
*
*/


#ifndef _OSCC_BRAKE_CAN_PROTOCOL_H_
#define _OSCC_BRAKE_CAN_PROTOCOL_H_


#include <stdint.h>
#include "magic.h"


/*
* @brief Brake command message (CAN frame) ID.
*
*/
#define OSCC_BRAKE_COMMAND_CAN_ID (0x60)

/*
* @brief Brake report message (CAN frame) ID.
*
*/
#define OSCC_BRAKE_REPORT_CAN_ID (0x61)

/*
* @brief Brake report message (CAN frame) length.
*
*/
#define OSCC_BRAKE_REPORT_CAN_DLC (8)

/*
* @brief Brake report message publishing frequency. [Hz]
*
*/
#define OSCC_BRAKE_REPORT_PUBLISH_FREQ_IN_HZ (50)

/*
* @brief Brake DTC bitfield position indicating an invalid sensor value.
*
*/
#define OSCC_BRAKE_DTC_INVALID_SENSOR_VAL (0x0)


#pragma pack(push)
#pragma pack(1)

/**
* @brief Brake command message data.
*
* CAN frame ID: \ref OSCC_BRAKE_COMMAND_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC.
Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */

uint16_t pedal_command; /*!< Pedal command. [65535 == 100%] */

uint8_t enable; /*!< Command to enable or disable steering control.
* Zero value means disable.
* Non-zero value means enable. */

uint8_t reserved[3]; /*!< Reserved. */
} oscc_brake_command_s;


/**
* @brief Brake report message data.
*
* CAN frame ID: \ref OSCC_BRAKE_REPORT_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC.
Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */

uint8_t enabled; /*!< Braking controls enabled state.
* Zero value means disabled (commands are ignored).
* Non-zero value means enabled (no timeouts or overrides have occured). */

uint8_t operator_override; /*!< Driver override state.
* Zero value means there has been no operator override.
* Non-zero value means an operator has physically overridden
* the system. */

uint8_t dtcs; /* Bitfield of DTCs present in the module. */

uint8_t reserved[3]; /*!< Reserved. */
} oscc_brake_report_s;

#pragma pack(pop)

#endif /* _OSCC_BRAKE_CAN_PROTOCOL_H_ */
59 changes: 59 additions & 0 deletions api/include/can_protocols/fault_can_protocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @file fault_can_protocol.h
* @brief Fault CAN Protocol.
*
*/


#ifndef _OSCC_FAULT_CAN_PROTOCOL_H_
#define _OSCC_FAULT_CAN_PROTOCOL_H_


#include <stdint.h>
#include "magic.h"

/*
* @brief Fault report message (CAN frame) ID.
*
*/
#define OSCC_FAULT_REPORT_CAN_ID (0x99)

/*
* @brief Fault report message (CAN frame) length.
*
*/
#define OSCC_FAULT_REPORT_CAN_DLC (8)


typedef enum
{
FAULT_ORIGIN_BRAKE,
FAULT_ORIGIN_STEERING,
FAULT_ORIGIN_THROTTLE
} fault_origin_id_t;


#pragma pack(push)
#pragma pack(1)

/**
* @brief Fault report message data.
*
* Message size (CAN frame DLC): \ref OSCC_FAULT_REPORT_CAN_DLC
*
*/
typedef struct
{
uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC.
Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */

uint32_t fault_origin_id; /* ID of the module that is sending out the fault. */

uint8_t reserved[2]; /* Reserved */
} oscc_fault_report_s;

#pragma pack(pop)


#endif /* _OSCC_FAULT_CAN_PROTOCOL_H_ */
27 changes: 27 additions & 0 deletions api/include/can_protocols/magic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file magic.h
* @brief Definitions of the magic bytes identifying messages as from OSCC.
*
*/


#ifndef _OSCC_MAGIC_H_
#define _OSCC_MAGIC_H_


/*
* @brief First magic byte used in commands and reports to distinguish CAN
* frame as coming from OSCC (and not OBD).
*
*/
#define OSCC_MAGIC_BYTE_0 ( 0x05 )

/*
* @brief Second magic byte used in commands and reports to distinguish CAN
* frame as coming from OSCC (and not OBD).
*
*/
#define OSCC_MAGIC_BYTE_1 ( 0xCC )


#endif /* _OSCC_MAGIC_H_ */
103 changes: 103 additions & 0 deletions api/include/can_protocols/steering_can_protocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* @file steering_can_protocol.h
* @brief Steering CAN Protocol.
*
*/


#ifndef _OSCC_STEERING_CAN_PROTOCOL_H_
#define _OSCC_STEERING_CAN_PROTOCOL_H_


#include <stdint.h>
#include "magic.h"


/*
* @brief Steering command message (CAN frame) ID.
*
*/
#define OSCC_STEERING_COMMAND_CAN_ID (0x64)

/*
* @brief Steering report message (CAN frame) ID.
*
*/
#define OSCC_STEERING_REPORT_CAN_ID (0x65)

/*
* @brief Steering report message (CAN frame) length.
*
*/
#define OSCC_STEERING_REPORT_CAN_DLC (8)

/*
* @brief Steering report message publishing frequency. [Hz]
*
*/
#define OSCC_REPORT_STEERING_PUBLISH_FREQ_IN_HZ (50)

/*
* @brief Steering DTC bitfield position indicating an invalid sensor value.
*
*/
#define OSCC_STEERING_DTC_INVALID_SENSOR_VAL (0x0)


#pragma pack(push)
#pragma pack(1)

/**
* @brief Steering command message data.
*
* CAN frame ID: \ref OSCC_STEERING_COMMAND_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC.
Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */

uint16_t spoof_value_low; /*!< Value to be sent on the low spoof signal. */

uint16_t spoof_value_high; /*!< Value to be sent on the high spoof signal. */

uint8_t enable; /*!< Command to enable or disable steering control.
* Zero value means disable.
* Non-zero value means enable. */

uint8_t reserved; /*!< Reserved. */
} oscc_steering_command_s;


/**
* @brief Steering report message data.
*
* CAN frame ID: \ref OSCC_STEERING_REPORT_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC.
Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */

uint8_t enabled; /*!< Steering controls enabled state.
* Zero value means disabled (commands are ignored).
* Non-zero value means enabled (no timeouts or overrides have occured). */

uint8_t operator_override; /*!< Driver override state.
* Zero value means there has been no operator override.
* Non-zero value means an operator has physically overridden
* the system. */

uint8_t dtcs; /* Bitfield of DTCs present in the module. */

uint8_t reserved[3]; /*!< Reserved. */
} oscc_steering_report_s;

#pragma pack(pop)


#endif /* _OSCC_STEERING_CAN_PROTOCOL_H_ */
Loading

0 comments on commit 1171726

Please sign in to comment.