-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from BlueAndi/release/2.0.x
Prepare v2.0.4
- Loading branch information
Showing
58 changed files
with
208 additions
and
173 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 |
---|---|---|
@@ -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: [email protected] |
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
File renamed without changes.
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 |
---|---|---|
@@ -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 | ||
* [email protected] | ||
* | ||
|
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 |
---|---|---|
@@ -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 | ||
* [email protected] | ||
* | ||
|
@@ -84,4 +84,4 @@ void loop() { | |
gInitButtonState = HIGH; | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
@@ -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 | ||
* [email protected] | ||
* | ||
|
@@ -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); | ||
|
@@ -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; | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
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 |
---|---|---|
@@ -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 | ||
* [email protected] | ||
* | ||
|
@@ -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) { | ||
|
@@ -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]; | ||
} | ||
|
@@ -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; | ||
|
@@ -121,7 +125,7 @@ bool transportWrite(vscp_TxMessage const * const txMsg) { | |
} | ||
|
||
} while((false == status) && (0 < retryCnt)); | ||
|
||
return status; | ||
} | ||
|
||
|
@@ -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."); | ||
|
||
|
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=VSCP | ||
version=2.0.3 | ||
version=2.0.4 | ||
author=Andreas Merkle | ||
maintainer=Andreas Merkle <[email protected]> | ||
sentence=Very Simple Control Protocol L1 framework for all Arduino boards. | ||
paragraph= | ||
category=Communication | ||
url=http://github.com/BlueAndi/vscp-arduino | ||
architectures=avr | ||
architectures=* |
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 |
---|---|---|
@@ -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 | ||
* [email protected] | ||
* | ||
|
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
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
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
Oops, something went wrong.