Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: sending data over CAN from teensy

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    15

    sending data over CAN from teensy

    I am using the improved flex can library and I have it reading Messages fine using

    Code:
       FRWJCAN =msg.buf[2]*256 +msg.buf[3];
          if (FRWJCAN> 32768)
            {
             FRP = (FRWJCAN- 65536)*1.00;
            }
          else
            {
             FRP = FRWJCAN*1.00;
            }
    to read a specific can message and wrapping it if it goes negative.

    What i want to do is send internal temp ( of the teensy3.6 on any CAN id)

    any ideas of how i can do that? I am using SN65HVD230D transceivers.

    Thank you!

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,134
    You mean like the sending struct?

    Code:
    CAN_message_t msg;
    msg.id = 0x123;
    msg.flags.extended = 0;
    msg.len = 8;
    msg.buf[0] = myTemperature;
    Can0.write(msg);
    As for keeping a value positive, you can use abs()

    Code:
    abs(-10.6);
    abs(18);
    Output:
    Code:
    10.6
    18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •