Ste Cooper

Arduino project communicating with CAN

Recommended Posts

So ive begun a project to attempt to interact with the CAN system on my Focus.

The Repo is here: https://github.com/ste2425/ArduinoCanBUSWIP

In the root of that repo is a spreadsheet with the messages iv'e gathered so far and what i think at this early stage their meaning is.
 

The code is written in C++ and runs on an Arduino. Take the code with a pinch of salt, I'm a web developer and used to very abstracted languages such as C# and JavaScript so this is quite a new experience! I never knew i would miss dynamically allocated Array sizes for example!

Iv'e made quite a bit of progress to say this is my first Arduino project and i have very little experience with C++. I can read messages, filter them out and believe ive located messages relating to indicators, locking / unlocking, brake peddle, clutch peddle, main beam, dipped beam etc.

I've noticed that when the bus comes alive, turn radio on, lock car through key, turn ignition on, it sends messages all the time. Each message indicating a current status at that point.
So every time message id 210 is emitted the first message body block will always have a value of 32 if the doors are locked. Only changing to 64 if the doors open. However i only expected a message to be sent on the action of locking or unlocking so that was unexpected. Also different message ID's appear to emit at different frequencies.

This is all interacting with the MSCAN at this stage.

I do however have a couple of questions and will probably have more as this project continues so i will update this thread.

First question.

Are can messages a cause or affect? I mean does the message trigger the action, or is the existence of the message indicating the action happened?

For example I attempted to emit the message relating to doors being locked and expected my doors to lock. However they didn't. The bus came alive and messages started emitting, which makes me believe i correctly sent the message.

Also the message ID relating to locking doors, 210, emits with the new values i sent. From that i gathered that i did correctly send the message. However all the actions that should have happened of the back of that, foot-well lights go out, interior light go out etc didn't.

This and the fact messages are being emitted all the time makes me think their more of a read mode indicating the current status of that system, not directly instructing that system to change. Which leads me on the the next question.

Second question

Are the messages being emitted read-only, is there a special message i have to emit to indicate a status change / action? I need to read up on the CAN protocol and how you communicate with other systems on it. Do they literally just emit everything and other systems choose to react to it, or do you have to emit a special 'update' message to indicate intent?

So if anyone has any information that could help with this project i would be very grateful to hear it!

 

Ta
 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.