McNeight / CAN_Library

Multiplatform Arduino library for supporting the native CAN controller on Due (SAM3X) and Teensy 3.1 (K2X) as well as MCP2515 through SPI
Other
95 stars 43 forks source link

How to instantiate lib for using two MCP2515 controllers? #6

Open igittigitt opened 7 years ago

igittigitt commented 7 years ago

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?

McNeight commented 6 years ago

The MCP2515 code wasn’t originally designed to utilize more than one controller. I don’t currently have an example, and I don’t think I have hardware to support that for testing.

I’ll take a look at the code to see if there is an easy modification I can make, but at the moment the support is for only a single MCP2515.

eudoxos commented 6 years ago

FWIW the MCP_CAN_lib does support two MCP's, see the example https://github.com/coryjfowler/MCP_CAN_lib/blob/master/examples/Dual_CAN/Dual_CAN.ino . Not sure how much of their code you used, though.