Giter VIP home page Giter VIP logo

can_library's Introduction

CAN_Library Build Status

This library supports the Controller Area Network (CAN bus or CAN) and allows you to communicate with multiple types of CAN controllers using a consistent API, making CAN communications across development platforms easier through Arduino.

The idea behind this CAN library is to use a similar approach to Adafruit's Unified Sensor library by standardizing CAN function calls, frame structure, filters, masks, buffers, etc to be used with a wide variety of CAN controllers. This library currently supports the following controllers:

Since I have taken features from so many libraries I can’t tell what came from where, so in order not to violate any GPL, LGPL or any other license out there I am trying to give credit where credit is due. I am only a contributor to this library and some of the work here might not be mine. I can take credit in putting it together and releasing back to the public to make any variation as needed.

To start using this library, simply add the following two lines to your sketch:

#include <CAN.h>
#include <SPI.h> // required to resolve #define conflicts

Acknowledgements:

can_library's People

Contributors

bondjames12 avatar jpiat avatar mcneight avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

can_library's Issues

Two issues Im seeing

Neil,

Im using the library with an Arduino Uno and a SparkFun CanBus shield. Im seeing two different things and I wonder if you would have some feedback:

1.) CAN.available() always returns 0 for me. Immediately after setup, and anytime afterwards. Is this expected?

2.) When I run my very basic test project to send data to the can bus, see in the logs "write2" after my calls to CAN.write() only 3 times and then it stops, no matter how many more calls I make to CAN.write(). I checked the source and it looks like I've filled the write buffers, but I had assumed that the buffers would clear themselves without a secondary "reader" device on the line to clear them. Is that a correct assumption?

Many thanks,
Mat

Not compile for AT90CAN

Hello.
I tried to compile the "Recieve CAN Messages" example for AT90CAN board and got errors

C:\Users\VADIM\AppData\Local\Temp\arduino_build_445438\sketch\ReceiveCANMessages.ino.cpp.o: In function `CAN_AT90CAN::begin(unsigned long)':
C:\Users\VADIM\Documents\Arduino\libraries\CAN_Library-master/CAN_AT90CAN.h:180: undefined reference to `CAN_AT90CAN::begin(unsigned long, unsigned char)'
C:\Users\VADIM\AppData\Local\Temp\arduino_build_445438\sketch\ReceiveCANMessages.ino.cpp.o: In function `readMessage()':
C:\Users\VADIM\AppData\Local\Temp\arduino_modified_sketch_693090/ReceiveCANMessages.ino:50: undefined reference to `CAN_AT90CAN::available()'
C:\Users\VADIM\AppData\Local\Temp\arduino_modified_sketch_693090/ReceiveCANMessages.ino:52: undefined reference to `CAN_AT90CAN::read()'
C:\Users\VADIM\AppData\Local\Temp\arduino_build_445438\libraries\CAN_Library-master\CAN_AT90CAN.cpp.o: In function `CAN_AT90CAN::CAN_AT90CAN()':
C:\Users\VADIM\Documents\Arduino\libraries\CAN_Library-master/CAN_AT90CAN.cpp:73: undefined reference to `vtable for CAN_AT90CAN'
C:\Users\VADIM\Documents\Arduino\libraries\CAN_Library-master/CAN_AT90CAN.cpp:73: undefined reference to `vtable for CAN_AT90CAN'
collect2.exe: error: ld returned 1 exit status

What I can do for fix it?

16 Mhz

MCP2515 runs @8MHz with Arduino Uno with no problem using another CAN lib.
With Arduino Due, @16 Mhz default in your program, I couldn't receive any CAN Data from Vehicle OBDII.
How can I change 16 Mhz to 8 Mhz.

Thank you

Ozer

can SAM3X8E losing a frame

Hi, I have a problem with losing 1 frame, on SAM3X8E
I get packets of 256 frames.
problem is the loss of 1 frame (eventually).

receive file
ex:
read(256)...ok
read(256)...ok
read(255)...bad <---cause the processing to stop
read(256)...ok

tried with con0.init() library
I tried direct mode can_init(CAN0, 84000000, bd).
send receiver ok, but sometimes miss 1 frame,
I use fifio buffer, I tried 2 types (fifo or Queue ).

I thought it might be CAN_BR =00142211, 500k /12xtal

if anyone has any new ideas.

thanks.

How to instantiate lib for using two MCP2515 controllers?

I'd like use two MCP2515 controllers for filtering/gateway a midspeed CAN-Bus (125kbs). All your examples, and even the documentation did not mention this setup. All the examples did not explicit instantiate from a class, they just simple use "CAN.".

So i tried to do: CAN TOBUS(9); but this gave me an error while compiling.
Also CANClass TOBUS(9); did not work.
Even CAN_MCP2515 TOBUS(9); failed.

What do i do wrong? Could you please provide an example for it?

CAN Filters with MCP2515 - define doublet

In CAN_MCP2515.h the label MCP2515_RXM0 is defined twice. Once at line 158 and again at line 281. Nasty.

CAN Filters will not work in the prepared manor if setMask, setFilter and all the other helpers are defined private. MemFuncs writeAddress, setMode, readRXStatus, setMask, setFilter and readAddress at least should be public.

Now filters for std messages work - extened messages still don't get filtered/accepted.

MCP215 and teensy

Hi.
I'm just trying to use the library to create a canbus beetwen teensy boards and arduinos.

I can, with the example, send and receive message from a teensy board to another teensy board with the example.

But i can't send or receive message from an arduino to another with the sample example !!
I have an MCP 2515 connect to him. all connection are good+ 16mhz oscillator.

Do you have some example for each module. one for mcp25-15 (send and receive) and one for teensy.

i want to create a canbus beetween an arduino and a teensy board.

(I either tried other library with mcp25-15, it's work beetween arduino's but the teensy can't receive any message).

can you help me i'm lost.

Can't compile sample for Due

I have installed the library and am trying to compile the SendCANMessages example.

I'm getting the following errors:

Arduino: 1.8.5 (Windows 10), TD: 1.41, Board: "Arduino Due (Native USB Port)"

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x20): undefined reference to `CANClass::setMask(unsigned char, CAN_Filter)'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x24): undefined reference to `CANClass::setMask(CAN_Filter)'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x28): undefined reference to `CANClass::clearMask(unsigned char)'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x2c): undefined reference to `CANClass::setFilter(unsigned char, CAN_Filter)'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x30): undefined reference to `CANClass::setFilter(CAN_Filter)'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x34): undefined reference to `CANClass::clearFilter(unsigned char)'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x38): undefined reference to `CANClass::enableRXInterrupt()'

libraries\CAN_Library\CAN_SAM3X.cpp.o:(.rodata._ZTV9CAN_SAM3X+0x3c): undefined reference to `CANClass::disableRXInterrupt()'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Due (Native USB Port).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.