Converting a program from Arduino to Flowcode help.

For general Flowcode discussion that does not belong in the other sections.
kennethnilsen69
Posts: 35
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

sorry DLC 4 is just a typo. I use 8 :-) But I found out that I had to use FCV_ in front of the variable (FCV_ID155_INIT[1]) so now it works as it should :-)

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

A new question.
If, for example, I want to send out the entire id155_INIT[8], I can do it like this:
FC_CAN_SetTxIdent_1(0, 0x155);FC_CAN_SetTxData_1(0, 8, FCV_id155_INIT[0], FCV_id155_INIT[1], FCV_id155_INIT[2], FCV_id155_INIT[3], FCV_id155_INIT[4], FCV_id155_INIT[5], FCV_id155_INIT[6], FCV_id155_INIT[7]);FC_CAN_SendBuffer_1(0);

but as long as I send out the entire variable unchanged, there will be a lot of writing and I wonder if there is an easier way to do this.

I try:
FC_CAN_SetTxIdent_1(0, 0x155);FC_CAN_SetTxData_1(0, 8, FCV_id155[8]);FC_CAN_SendBuffer_1(0);
But it does not want to accept this. FC then says "error: too few arguments to function 'FC_CAN_SetTxData_1'"

BenR
Matrix Staff
Posts: 1747
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 444 times
Been thanked: 604 times

Re: Converting a program from Arduino to Flowcode help.

Post by BenR »

Hello,

Sorry the long hand method is currently the only way. If you put the code inside a macro then you would just have to call the macro whenever you want to send the data.

We could add a function to allow the data to be loaded from and to an array so I'll get this on the list.

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

BenR wrote:
Fri Sep 16, 2022 11:26 am
Hello,

Sorry the long hand method is currently the only way. If you put the code inside a macro then you would just have to call the macro whenever you want to send the data.

We could add a function to allow the data to be loaded from and to an array so I'll get this on the list.
Thanks Ben. it would have been a nice function to have. In the meantime, I'll do as you suggest :-)

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

Does anyone have a suggestion for how I write this calculation in a FC calculation box

unsigned long odo = ((unsigned long)id599[0] << 24)
| ((unsigned long)id599[1] << 16)
| ((unsigned long)id599[2] << 8)
| (id599[3]);
odo /= 10;
id55E[6] = odo >> 8;
id55E[7] = odo & 0x00ff;

BenR
Matrix Staff
Posts: 1747
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 444 times
Been thanked: 604 times

Re: Converting a program from Arduino to Flowcode help.

Post by BenR »

Hello,

I would recommend using the type conversion component to do this. Should be way more efficient than doing 32-bit typecast bit shifts.

TypeConversion::SetByte(0, id599[3])
TypeConversion::SetByte(1, id599[2])
TypeConversion::SetByte(2, id599[1])
TypeConversion::SetByte(3, id599[0])
odo = TypeConversion::GetLong()

odo = odo / 10

TypeConversion::SetLong(odo)
id599[6] = TypeConversion::GetByte(1)
id599[7] = TypeConversion::GetByte(0)

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

Thanks Ben, I have added the TypeConversion component but get this error message in the Calculation
Attachments
TypeConversion.jpg
TypeConversion.jpg (91.96 KiB) Viewed 1343 times

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

I figured it out Ben. I was just missing an s at the end of in TypeConversion's name

Post Reply