Hi, I have a plugin that reads a hexadecimal string from a frame. This string is made up of 8 groups of 2 bytes each. My purpose is to join (or add) two groups to get a parameter. it's possible?
I have this code:

optional .can.data.frame.4 ==> %hex ==> bits:
48 ==> skip
8 ==> #bms4.cicloIADer2
optional .can.data.frame.4 ==> %hex ==> bits:
56 ==> skip
8 ==> #bms4.cicloIADer1

I want to get a
#bms4.total = #bms4.cicloIADer1 + #bms4.cicloAder2

thank you

  • kial replied to this.

    Hi DavidSoriano , can you please post here an example of your incoming message and a result value you expect from it?

      DavidSoriano If I understand you correctly, here is a solution for you:

      optional .can.data.frame.4 ==> %hex ==> bits:
      	48 ==> skip
      	8 ==> $value2 ==> #bms4.cicloIADer2
      	8 ==> $value1 ==> #bms4.cicloIADer1
      optional $value1 + optional $value2 ==> #bms4.cicloAder2

      This code will convert a message {"can.data.frame.4": "0A05000000000000"} to {"bms4.cicloAder2": 15, "bms4.cicloIADer1": 10, "bms4.cicloIADer2": 5, "can.data.frame.4": "0A05000000000000"}

      And the same result can be achieved with the following code:

      optional .can.data.frame.4 ==> %hexstr ==> input:
      	%uint8 ==> $value1 ==> #bms4.cicloIADer1
      	%uint8 ==> $value2 ==> #bms4.cicloIADer2
      	$value1 + $value2 ==> #bms4.cicloAder2

      But if you need a 2-byte result value in parameter "bms4.cicloAder2", there will be a solution:

      optional .can.data.frame.4 ==> %hexstr ==> input:
      	%uint16 ==> #bms4.cicloAder2

      For the same input {"can.data.frame.4": "0A05000000000000"} it will produce the value 1290 (0x050A), and if you need it in a BIG endian:

      optional .can.data.frame.4 ==> %hexstr ==> input:
      	%uint16[BIG] ==> #bms4.cicloAder2

      It will produce the value 2565 (0x0A05)

      Write a Reply...