Merge pull request #65 from ntb001/master

Allow for extended CAN IDs in the example programs
This commit is contained in:
Jack Shao
2018-06-19 17:32:47 +08:00
committed by GitHub
11 changed files with 188 additions and 58 deletions
+131
View File
@@ -0,0 +1,131 @@
## WINDOWS
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
## MAC OS
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
## DROPBOX
# Dropbox settings and caches
.dropbox
.dropbox.attr
.dropbox.cache
## VS CODE
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
## VIM
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
## EMACS
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
+1 -2
View File
@@ -145,7 +145,7 @@ When frame is received you may check whether it was remote request and whether i
<br>
For more information, please refer to [wiki page](http://www.seeedstudio.com/wiki/CAN-BUS_Shield).
For more information, please refer to [wiki page](http://wiki.seeedstudio.com/CAN-BUS_Shield_V2.0/).
----
@@ -165,4 +165,3 @@ global distributors and partners to push open hardware movement.<br>
[![Analytics](https://ga-beacon.appspot.com/UA-46589105-3/CAN_BUS_Shield)](https://github.com/igrigorik/ga-beacon)
+1 -1
View File
@@ -97,7 +97,7 @@ void taskCanRecv()
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
Serial.println("\r\n------------------------------------------------------------------");
Serial.print("Get Data From id: ");
Serial.print("Get Data From id: 0x");
Serial.println(CAN.getCanId(), HEX);
for(int i = 0; i<len; i++) // print the data
{
+3 -3
View File
@@ -37,11 +37,11 @@ void loop()
{
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
unsigned char canId = CAN.getCanId();
unsigned long canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.println("get data from ID: ");
Serial.println(canId);
Serial.println("get data from ID: 0x");
Serial.println(canId, HEX);
for(int i = 0; i<len; i++) // print the data
{
+2 -2
View File
@@ -36,10 +36,10 @@ void loop()
{
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
unsigned int canId = CAN.getCanId();
unsigned long canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.print("Get data from ID: ");
Serial.print("Get data from ID: 0x");
Serial.println(canId, HEX);
for(int i = 0; i<len; i++) // print the data
+1 -1
View File
@@ -27,7 +27,7 @@ unsigned char stmp[8] = {ledHIGH, 1, 2, 3, ledLOW, 5, 6, 7};
void loop()
{ Serial.println("In loop");
// send data: id = 0x00, standard frame, data len = 8, stmp: data buf
// send data: id = 0x70, standard frame, data len = 8, stmp: data buf
CAN.sendMsgBuf(0x70, 0, 8, stmp);
delay(1000); // send data once per second
}
+4 -4
View File
@@ -776,10 +776,8 @@ void MCP_CAN::mcp2515_read_canMsg( const byte buffer_load_addr, volatile unsigne
// mcp2515 has auto-increment of address-pointer
for (i = 0; i < 4; i++) tbufdata[i] = spi_read();
*rtrBit=(tbufdata[3]&0x08 ? 1 : 0 );
*id = (tbufdata[MCP_SIDH] << 3) + (tbufdata[MCP_SIDL] >> 5);
*ext = 0;
if ( (tbufdata[MCP_SIDL] & MCP_TXB_EXIDE_M) == MCP_TXB_EXIDE_M )
{
/* extended id */
@@ -789,7 +787,9 @@ void MCP_CAN::mcp2515_read_canMsg( const byte buffer_load_addr, volatile unsigne
*ext = 1;
}
*len=spi_read() & MCP_DLC_MASK;
byte pMsgSize = spi_read();
*len = pMsgSize & MCP_DLC_MASK;
*rtrBit = (pMsgSize & MCP_RTR_MASK) ? 1 : 0;
for (i = 0; i < *len && i<CAN_MAX_CHAR_IN_MESSAGE; i++) {
buf[i] = spi_read();
}