Converting a program from Arduino to Flowcode help.
-
- 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.
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
-
- Posts: 35
- Joined: Wed Dec 02, 2020 11:41 am
- Been thanked: 2 times
Re: Converting a program from Arduino to Flowcode help.
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'"
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'"
-
- 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.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 35
- Joined: Wed Dec 02, 2020 11:41 am
- Been thanked: 2 times
Re: Converting a program from Arduino to Flowcode help.
Thanks Ben. it would have been a nice function to have. In the meantime, I'll do as you suggestBenR wrote: ↑Fri Sep 16, 2022 11:26 amHello,
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.
-
- Posts: 35
- Joined: Wed Dec 02, 2020 11:41 am
- Been thanked: 2 times
Re: Converting a program from Arduino to Flowcode help.
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;
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;
-
- 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.
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)
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)
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 35
- Joined: Wed Dec 02, 2020 11:41 am
- Been thanked: 2 times
Re: Converting a program from Arduino to Flowcode help.
Thanks Ben, I have added the TypeConversion component but get this error message in the Calculation
- Attachments
-
- TypeConversion.jpg (91.96 KiB) Viewed 1343 times
-
- Posts: 35
- Joined: Wed Dec 02, 2020 11:41 am
- Been thanked: 2 times
Re: Converting a program from Arduino to Flowcode help.
I figured it out Ben. I was just missing an s at the end of in TypeConversion's name