How to combine 2 bits of hex can data then convert to decimal?

Working on a small can project.

I have a uno v 1.6.7 and a Seeedstudio Can-Bus-Shield v 1.2

The code I'm using is just the example included with the library.

I have a device that sends a 2 bit can message to this Arduino/Seeed setup.

For Example I send a message 01 C0 (Hex)

In order for me to use this data how I need, I need the decimal conversion of 01CO

So I need 448 from 01 C0

So I need to combine the 2 bits then convert from hex to dec.

The can message changes all the time so it needs to calculate this each time.

After that I need to do some math to that number to get what I need.

Any Help would be great! Thanks

// demo: CAN-BUS Shield, receive data
#include <mcp_can.h>
#include <SPI.h>

unsigned char Flag_Recv = 0;
unsigned char len = 0;
unsigned char buf[8];
char str[20];

void setup()
{
  CAN.begin(CAN_100KBPS);                       // init can bus : baudrate = 500k
  attachInterrupt(0, MCP2515_ISR, FALLING);     // start interrupt
  Serial.begin(115200);
}

void MCP2515_ISR()
{
    Flag_Recv = 1;
}

void loop()
{
    if(Flag_Recv)                           // check if get data
    {
      Flag_Recv = 0;                        // clear flag
      CAN.readMsgBuf(&len, buf);            // read data,  len: data length, buf: data buf
      Serial.println("CAN_BUS GET DATA!");
      Serial.print("data len = ");
      Serial.println(len);
      
      for(int i = 0; i<len; i++)            // print the data
      {
        Serial.print(buf[i]);Serial.print("\t");
      }
      Serial.println();
    }
}

/*********************************************************************************************************
  END FILE
*********************************************************************************************************/

It looks like you CAN bus message can be up to 8 characters in length.
01C0 is 4 bytes in length where a byte is 8 bits.
You need to search on converting hex string to integer.

Variables. like Flag_Recv, that are used in the interrupt handler and in other code must be volatile.

      CAN.readMsgBuf(&len, buf);            // read data,  len: data length, buf: data buf

Once you've read the data, NULL terminate the array (len tells you where) and then use strtoul() to convert to unsigned long. Even though your value is not a long, that is the only function that deals with HEX values. You can store the result in an int, and print it in decimal form.

Thank you for the replys. I will look into that.

I'm very new to programming. I've been learning fast but have a long way to go.

Thanks

I've been learning fast but have a long way to go.

Me, too. I've only been at it for 40 years, though. Give me time. And stop the world from making progress while I'm learning.