× Welcome to the Kunena forum!

Tell us and our members who you are, what you like and why you became a member of this site.
We welcome all new members and hope to see you around a lot!

Greetings from Down Under

  • Compsys
  • Compsys's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 3 weeks ago #282 by Compsys
Greetings from Down Under was created by Compsys
I found this site and SavvyCAN from github. I've been working up a prototype for a CAN gateway that modifies certain bytes and forwards them on. It also reads some packets and activates extra lockouts for the AWD system..

It mostly works very well with a DUE board and a proto shield I built using MCP2562 (with the VIO pin for 3.3v operation). Currently passing 116 frames at anywhere from 200hz to once every 3 seconds.

The only problem I've got is when I try to modify the speed bytes. They are four seperatee bytees located in one id. I can modify them but then I get the corresponding bytes in all the other ID's skewed by the same factor.

This is the offending bit of code. I've also tried resetting them to the same as what comes in as part of the else statement. With the code this way it doesn't modify the speed channel at all.
void loop() {
  CAN_FRAME incoming;
  CAN_FRAME gearpos;
  CAN_FRAME speedzero;
  CAN_FRAME carspeed;
  
  if (Can0.available() > 0) {
    Can0.read(incoming);
    if (incoming.id == 0x0AA) {
    incoming.data.bytes[1] *= 1.1;
    incoming.data.bytes[3] *= 1.1;
    incoming.data.bytes[5] *= 1.1;
    incoming.data.bytes[7] *= 1.1;
    Can1.sendFrame(incoming);
    }
    else {
//      incoming.data.bytes[1] = incoming.data.bytes[1];
//      incoming.data.bytes[3] = incoming.data.bytes[3];
//      incoming.data.bytes[5] = incoming.data.bytes[5];
//      incoming.data.bytes[7] = incoming.data.bytes[7];
    Can1.sendFrame(incoming);
    }
  }

If I use the method in the CAN TrafficModifier example I get the same byte in every id modified.

Any help would be appreciated.

Please Log in or Create an account to join the conversation.

Time to create page: 0.049 seconds
Powered by Kunena Forum