Data payload of the frame for ArCANFrameType

I have a question regarding ArCAN FramType
B&R Online Help

I need to send lets say " 40 18 10 00 00 00 00 00". For that i program it like

ArCanSender.ArCanSend_0.Frame.Data[0] := 16#40;
ArCanSender.ArCanSend_0.Frame.Data[1] := 16#18;
ArCanSender.ArCanSend_0.Frame.Data[2] := 16#10;
ArCanSender.ArCanSend_0.Frame.Data[3] := 16#00;
ArCanSender.ArCanSend_0.Frame.Data[4] := 16#00;
ArCanSender.ArCanSend_0.Frame.Data[5] := 16#00;
ArCanSender.ArCanSend_0.Frame.Data[6] := 16#00;
ArCanSender.ArCanSend_0.Frame.Data[7] := 16#00;

My question is : Is itpossible to send the whole data in a single line of code like

ArCanSender.ArCanSend_0.Frame.Data := BYTE [ 40 18 10 00 00 00 00 00];

If i try this i get “Expression missing” error.

I have almost 10 to 15 data like this which i need to send to a CAN device and sending it as a single payload would make my life easier.

Do anyone have any ideas`? Or in simpler words: If i want to send a set of commands via SDO 60?h like 40 18 10 00 00 00 00 00, then 40 18 10 01 00 00 00 00, 40 18 10 00 00 00 00 00 then 23 01 10 00 00 00 00 00 one after the other , how can i implement it?

THanks

Matt

There is not an option to input the values like you specified in single lines of code.

However You could create premade variables with our predefined messages with the ArCanFrame datatype and then just change the whole frame.

ResetDeviceCommandFrame.Data[0] := 16#18;
ResetDeviceCommandFrame.Data[1] := 16#15;
...

And then use it

ArCanSender.ArCanSend_0.Frame := ResetDeviceCommandFrame;
2 Likes

Are these hardcoded frames, or do you expect the data to change?

If it’s hardcoded, then Tommi’s suggestion is a good one. You could also initialize the frame data in the variable declaration if want to clean up your main program file.

The way I’ve packed ArCan frames in the past is by creating custom functions. For example, I’ll have a function called CreateXyzFrame() with the inputs being the data that’s included in that frame. Then the function can organize/modify/pack the frame, with the output being an ArCanFrameType.

Thanks Tommi for the tip. Yes Marcus these are hardcoded frames and i have like 50 frames to be send one after the other to initialize a device.

This frame looks like a CanOpen SDO command with Index and Subindex.