Cannot set up CAN Channel in separate object in particle work bench

What do i need to import to fix this issue?

Can you fix the digitalWrite on line 21?

digitalWrite only works with HIGH or LOW.

I mean i can but that doesn’t cause an issue because it still meets the requirements given by the signature of the method. HIGH and LOW as I’m sure you know are just integer constants. The issue is with that i cant access the HAL_CAN_CHANNEL enum to get the CAN_D1_D2 reference to pass into the CANChannel constructor. Thank you for your input nonetheless!

Try a more recent device OS version.
0.6.4 is rather dated by now.

Also seeing the error message that actually describes the problem would be more helpful. And when you post your code clear text (instead as an image) you’d make it a lot easier for others to test and replicate your issue.

Also, could you embed your images directly and not just via an external link to some image hoster? (I have transferred your image from there to this thread directly - that way it should live here as long this thread lives)

Not quite. Anything but 0 would be taken as HIGH (similar to booloeans).


Although I don’t understand the reason for the original error I found a workaround that helps getting rid of the is not a type message by doing this instead

// inside a class definition 
// CANChannel can(CAN_D1_D2);           // for some obscure reason this doesn't compile
CANChannel can = CANChannel(CAN_D1_D2); // while this does

// however, as a global you can write it both ways

@rickkas7, have you got a clue why this is?

This is a (more flexible) alternative

class someClass
  CANChannel can;
  someClass(HAL_CAN_Channel channel = CAN_D1_D2) : can(channel) { }