Need help with custom.xml and digital bits

I’m reading all my digital inputs and sending them over similar to the arduion example:
DigitalPins (a 16 bit int with 13 bits set (1) or unset (0) as a bit mask

  SendCANFrameToSerial(3203, buf);

  // build 4th CAN frame, cruise
  memcpy(buf, &cruiseActive, 2);
  memcpy(buf + 2, &cruiseSetValue, 2);
  memcpy(buf + 4, &digitalPins, 2);
  memcpy(buf + 6, &zeros, 2);

  // write 4th CAN frame to serial
  SendCANFrameToSerial(3204, buf);
}

My custom XML:

    <frame id="3204">
      <!-- cruise active, decel, accel, speedactive, setvalue -->
      <value targetId="169" offset="0" length="2"></value>
      <value targetId="171" offset="2" length="2"></value>
      <!-- overdrive, TCC, left, right, parking, head_low, head_high, running. water_fuel, low_washer -->
      <value targetId="147" units="bit" startbit="4" bitcount="1"></value>
      <value targetId="143" units="bit" startbit="5" bitcount="1"></value>
      <value targetId="160" units="bit" startbit="6" bitcount="1"></value>
      <value targetId="161" units="bit" startbit="7" bitcount="1"></value>
      <value targetId="164" units="bit" startbit="8" bitcount="1"></value>
      <value targetId="156" units="bit" startbit="9" bitcount="1"></value>
      <value targetId="157" units="bit" startbit="10" bitcount="1"></value>
      <value targetId="155" units="bit" startbit="11" bitcount="1"></value>
      <value targetId="Water In Fuel" units="bit" startbit="12" bitcount="1"></value>
      <value targetId="176" units="bit" startbit="13" bitcount="1"></value>      
    </frame>

I can use the can monitor and see packet 3204 and see the values change as I toggle the different inputs.

The behavior I want is when the High Beam bit gets set to 1, I want the high beam indicator/gauge to turn on. I put a text gauge in to print out the HighBeam setting and it just stays at 0.0. Even when I see the bit toggle in the CAN monitor.

High Beam is 157, so that should be bit 10 of the 3204 packet. I can toggle every input and high beam never changes from a 0.0.

I’m sure I could sent an int for everyone, but that is a ton of data. I’d like to be able to use the bitmask instead.

I’m missing something fundamental. Hoping someone can help.

thanks
david

Seems like the first four bytes (bit 1 - 32) are being used for your two analogue readings, which means your startbit for targetId157 should be 42 and not 10, same for the other digital values in bytes 4 and 5

1 Like

Yep that was it! Thank you! I knew I had to be counting wrong, just confused bits and bytes.

thanks again

1 Like