Skip to content

Workflow added for a test compliation on CI, incl. updates and bugfixes. #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/testCompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Compile Script

# Controls when the action will run.
on:
push:
branches: [ '**' ]
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The introduction just shows some useful informations.
intro:
# The type of runner that the job will run on.
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job.
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "The name of the branch is ${{ github.ref }} and the repository is ${{ github.repository }}."

- name: Checkout repository
uses: actions/checkout@v4

- name: Checkout repository as custom library
uses: actions/checkout@v4
with:
path: CustomLibrary # must contain string "Custom"
# No need to put "Custom" library in the required-libraries list

- name: Checkout autowp-mcp2515 as custom library
uses: actions/checkout@v4
with:
repository: autowp/arduino-mcp2515
ref: master
path: CustomLibrary_autowp-mcp2515 # must contain string "Custom"
# No need to put "Custom" library in the required-libraries list

- name: Compile all examples
uses: ArminJo/arduino-test-compile@v3
with:
sketch-names: "*.ino"
sketch-names-find-start: examples/
required-libraries: mcp_can@1.5.1
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.0.4

- Fixed problem with backslashes in include paths.
- Fixed problem with wrong include path in vscp_evt_information.c module. Thanks to michpro!
- Examples updated to be working with latest CAN libraries.

## 2.0.3

- Update to VSCP framework v2.0.3, please see the ![changelog](https://github.com/BlueAndi/vscp-framework/releases/tag/v2.0.3) there.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/Generic/Generic.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* The MIT License (MIT)
*
* Copyright (c) 2014 - 2020, Andreas Merkle
* Copyright (c) 2014 - 2024, Andreas Merkle
* http://www.blue-andi.de
* vscp@blue-andi.de
*
Expand Down
4 changes: 2 additions & 2 deletions examples/LampAndButtonTest/LampAndButtonTest.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* The MIT License (MIT)
*
* Copyright (c) 2014 - 2020, Andreas Merkle
* Copyright (c) 2014 - 2024, Andreas Merkle
* http://www.blue-andi.de
* vscp@blue-andi.de
*
Expand Down Expand Up @@ -84,4 +84,4 @@ void loop() {
gInitButtonState = HIGH;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* The MIT License (MIT)
*
* Copyright (c) 2014 - 2020, Andreas Merkle
* Copyright (c) 2014 - 2024, Andreas Merkle
* http://www.blue-andi.de
* vscp@blue-andi.de
*
Expand Down Expand Up @@ -44,13 +44,13 @@ static bool isActive = false;
// If no message is received return false, otherwise true.
bool transportRead(vscp_RxMessage * const rxMsg) {

bool status = false;
bool status = false;

if (CAN_MSGAVAIL == canCom.checkReceive())
{
unsigned long canMsgId = 0;
unsigned long canMsgId = 0;

if (CAN_OK == canCom.readMsgBufID(&canMsgId, &rxMsg->dataSize, rxMsg->data)) {
if (CAN_OK == canCom.readMsgBuf(&canMsgId, &rxMsg->dataSize, rxMsg->data)) {

rxMsg->vscpClass = (uint16_t)((canMsgId >> 16) & 0x01ff);
rxMsg->vscpType = (uint8_t)((canMsgId >> 8) & 0x00ff);
Expand Down Expand Up @@ -88,7 +88,7 @@ bool transportWrite(vscp_TxMessage const * const txMsg) {
}

// Send CAN message
if (CAN_OK != canCom.sendMsgBuf(canMsgId, 1, 0, txMsg->dataSize, (unsigned char*)txMsg->data)) {
if (CAN_OK != canCom.sendMsgBuf(canMsgId, 1, txMsg->dataSize, (unsigned char*)txMsg->data)) {

// CAN message couldn't be sent, try again.
++retryCnt;
Expand Down Expand Up @@ -133,7 +133,7 @@ void setup() {
do {

// Initialize CAN controller with 125 kbit/s (VSCP default bitrate)
if (CAN_OK != canCom.begin(CAN_125KBPS)) {
if (CAN_OK != canCom.begin(MCP_STDEXT, CAN_125KBPS, MCP_16MHZ)) {

// Try again
delay(100);
Expand All @@ -158,6 +158,9 @@ void setup() {
} else {

Serial.println("CAN controller initialized successful.");

// Change to normal mode to allow messages to be transmitted
canCom.setMode(MCP_NORMAL);

// Only CAN frames with 29-bit identifier shall be received
canCom.init_Mask(0, 1, 0x1fffffff);
Expand Down
105 changes: 44 additions & 61 deletions examples/Sparkfun_CAN-BUS_Shield/Sparkfun_CAN-BUS_Shield.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* The MIT License (MIT)
*
* Copyright (c) 2014 - 2020, Andreas Merkle
* Copyright (c) 2014 - 2024, Andreas Merkle
* http://www.blue-andi.de
* vscp@blue-andi.de
*
Expand All @@ -26,35 +26,40 @@

#include <VSCP.h> // VSCP framework
#include <SPI.h> // SPI used for CAN controller communication
#include <MCP2515.h> // CAN controller driver
#include <mcp2515.h> // CAN controller driver

// Create an instance of the VSCP framework
VSCP vscp;

// Create an instance of the CAN controller driver
MCP2515 mcp2515(
9 // Set CS (chip select) pin, note if you use a CAN BUS shield prior to V1.1 use pin 10!
);

// Node is in active state or not
static bool isActive = false;

// Read a message from the transport layer, e.g. the CAN bus
// If no message is received return false, otherwise true.
bool transportRead(vscp_RxMessage * const rxMsg) {

bool status = false;
CANMSG canMsg;
bool status = false;
struct can_frame canMsg;

// Any CAN frame received?
if (true == MCP2515::receiveCANMessage(&canMsg, 10)) {
if (MCP2515::ERROR_OK == mcp2515.readMessage(&canMsg)) {

// Is it a extended CAN frame?
if (true == canMsg.isExtendedAdrs) {
if (0 != ((canMsg.can_id >> 31) & 0x01)) {

unsigned char index = 0;

rxMsg->vscpClass = (uint16_t)((canMsg.adrsValue >> 16) & 0x01ff);
rxMsg->vscpType = (uint8_t)((canMsg.adrsValue >> 8) & 0x00ff);
rxMsg->oAddr = (uint8_t)((canMsg.adrsValue >> 0) & 0x00ff);
rxMsg->hardCoded = (uint8_t)((canMsg.adrsValue >> 25) & 0x0001);
rxMsg->priority = (VSCP_PRIORITY)((canMsg.adrsValue >> 26) & 0x0007);
rxMsg->dataSize = canMsg.dataLength;
rxMsg->vscpClass = (uint16_t)((canMsg.can_id >> 16) & 0x01ff);
rxMsg->vscpType = (uint8_t)((canMsg.can_id >> 8) & 0x00ff);
rxMsg->oAddr = (uint8_t)((canMsg.can_id >> 0) & 0x00ff);
rxMsg->hardCoded = (uint8_t)((canMsg.can_id >> 25) & 0x0001);
rxMsg->priority = (VSCP_PRIORITY)((canMsg.can_id >> 26) & 0x0007);
rxMsg->dataSize = canMsg.can_dlc;

// Protect against a buffer out of bounce access
if (VSCP_L1_DATA_SIZE < rxMsg->dataSize) {
Expand All @@ -79,24 +84,23 @@ bool transportRead(vscp_RxMessage * const rxMsg) {
// If it fails to send the message return false, otherwise true.
bool transportWrite(vscp_TxMessage const * const txMsg) {

bool status = false;
CANMSG canMsg;
unsigned char index = 0;
unsigned char retryCnt = 0;

canMsg.isExtendedAdrs = true;

canMsg.adrsValue = (((uint32_t)txMsg->priority) << 26) |
(((uint32_t)txMsg->hardCoded) << 25) |
(((uint32_t)txMsg->vscpClass) << 16) |
(((uint32_t)txMsg->vscpType) << 8) |
txMsg->oAddr;

canMsg.rtr = 0;

canMsg.dataLength = txMsg->dataSize;
bool status = false;
struct can_frame canMsg;
unsigned char index = 0;
unsigned char retryCnt = 0;

canMsg.can_id = (1 << 31) | // Extended 29 bit
(0 << 30) | // No RTR
(0 << 29) | // No error message frame
(((uint32_t)txMsg->priority) << 26) |
(((uint32_t)txMsg->hardCoded) << 25) |
(((uint32_t)txMsg->vscpClass) << 16) |
(((uint32_t)txMsg->vscpType) << 8) |
txMsg->oAddr;

canMsg.can_dlc = txMsg->dataSize;

for(index = 0; index < canMsg.dataLength; ++index) {
for(index = 0; index < canMsg.can_dlc; ++index) {

canMsg.data[index] = txMsg->data[index];
}
Expand All @@ -110,7 +114,7 @@ bool transportWrite(vscp_TxMessage const * const txMsg) {
}

// Send CAN message
if (false == MCP2515::transmitCANMessage(canMsg, 10)) {
if (MCP2515::ERROR_OK == mcp2515.sendMessage(&canMsg)) {

// CAN message couldn't be sent, try again.
++retryCnt;
Expand All @@ -121,7 +125,7 @@ bool transportWrite(vscp_TxMessage const * const txMsg) {
}

} while((false == status) && (0 < retryCnt));

return status;
}

Expand Down Expand Up @@ -152,37 +156,16 @@ void setup() {
Serial.begin(115200);
Serial.println("VSCP node starts up ...");

do {
// Initialize CAN controller with 125 kbit/s (VSCP default bitrate)
if (false == MCP2515::initCAN(CAN_BAUD_125K)) {

// Try again
delay(100);
--retry;

if (0 == retry) {
isError = true;
}

} else {

// Successful initialized
retry = 0;
}

} while(0 < retry);

if (true == isError) {

Serial.println("Failed to initialize CAN controller!");

if (MCP2515::ERROR_OK != mcp2515.reset()) {
isError = true;
}
// Set to normal mode non single shot
else if (false == MCP2515::setCANNormalMode(LOW)) {

Serial.println("Failed to set CAN controller to normal mode!");

} else {
else if (MCP2515::ERROR_OK != mcp2515.setBitrate(CAN_125KBPS)) {
isError = true;
}
else if (MCP2515::ERROR_OK != mcp2515.setNormalMode()) {
isError = true;
}
else {

Serial.println("CAN controller initialized successful.");

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscp-arduino",
"version": "2.0.3",
"version": "2.0.4",
"keywords": "vscp, arduino-library, vscp-arduino, automation, home automation",
"description": "Very Simple Control Procotol (VSCP) Level 1 Library for the arduino IDE.",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=VSCP
version=2.0.3
version=2.0.4
author=Andreas Merkle
maintainer=Andreas Merkle <vscp@blue-andi.de>
sentence=Very Simple Control Protocol L1 framework for all Arduino boards.
paragraph=
category=Communication
url=http://github.com/BlueAndi/vscp-arduino
architectures=avr
architectures=*
2 changes: 1 addition & 1 deletion src/VSCP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* The MIT License (MIT)
*
* Copyright (c) 2014 - 2020, Andreas Merkle
* Copyright (c) 2014 - 2024, Andreas Merkle
* http://www.blue-andi.de
* vscp@blue-andi.de
*
Expand Down
6 changes: 3 additions & 3 deletions src/framework/events/vscp_evt_alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ This file is automatically generated. Don't change it manually.
INCLUDES
*******************************************************************************/
#include "vscp_evt_alarm.h"
#include "..\core\vscp_core.h"
#include "..\core\vscp_class_l1.h"
#include "..\core\vscp_type_alarm.h"
#include "../core/vscp_core.h"
#include "../core/vscp_class_l1.h"
#include "../core/vscp_type_alarm.h"

/*******************************************************************************
COMPILER SWITCHES
Expand Down
2 changes: 1 addition & 1 deletion src/framework/events/vscp_evt_alarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This file is automatically generated. Don't change it manually.
INCLUDES
*******************************************************************************/
#include <stdint.h>
#include "..\user\vscp_platform.h"
#include "../user/vscp_platform.h"

#ifdef __cplusplus
extern "C"
Expand Down
6 changes: 3 additions & 3 deletions src/framework/events/vscp_evt_aol.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ This file is automatically generated. Don't change it manually.
INCLUDES
*******************************************************************************/
#include "vscp_evt_aol.h"
#include "..\core\vscp_core.h"
#include "..\core\vscp_class_l1.h"
#include "..\core\vscp_type_aol.h"
#include "../core/vscp_core.h"
#include "../core/vscp_class_l1.h"
#include "../core/vscp_type_aol.h"

/*******************************************************************************
COMPILER SWITCHES
Expand Down
2 changes: 1 addition & 1 deletion src/framework/events/vscp_evt_aol.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This file is automatically generated. Don't change it manually.
INCLUDES
*******************************************************************************/
#include <stdint.h>
#include "..\user\vscp_platform.h"
#include "../user/vscp_platform.h"

#ifdef __cplusplus
extern "C"
Expand Down
6 changes: 3 additions & 3 deletions src/framework/events/vscp_evt_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ This file is automatically generated. Don't change it manually.
INCLUDES
*******************************************************************************/
#include "vscp_evt_configuration.h"
#include "..\core\vscp_core.h"
#include "..\core\vscp_class_l1.h"
#include "..\core\vscp_type_configuration.h"
#include "../core/vscp_core.h"
#include "../core/vscp_class_l1.h"
#include "../core/vscp_type_configuration.h"

/*******************************************************************************
COMPILER SWITCHES
Expand Down
2 changes: 1 addition & 1 deletion src/framework/events/vscp_evt_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This file is automatically generated. Don't change it manually.
INCLUDES
*******************************************************************************/
#include <stdint.h>
#include "..\user\vscp_platform.h"
#include "../user/vscp_platform.h"

#ifdef __cplusplus
extern "C"
Expand Down
Loading