Hello!
I need help on passing an array as a parameter. It seems real simple, but I can't figure it out on flowcode at the moment. The array is set as a global byte msg[255].
I have one call needing to go as "crc_out(msg[], timeout, true)" but I cant get the array(msg[]) to pass.
Then the next should go as "crc = CalcCRC(msg_len + 2, &msg[1])" but the "&msg[1]" wont go through. Neither would "msg[1]" if I tried.
And finally, the CalcCRC macro should read in those parameters as "crc = CalcCRC(LEN, *u8Buf)".
How can I make flowcode macros understand passing arrays or address/pointer of arrays through?? Please help and thank you in advance.
How to pass array as parameter to macro
Moderator: Benj
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
How to pass array as parameter to macro
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: How to pass array as parameter to macro
Hello,
Here's an example. If you're still having trouble then please post what you have so far then we might be able to help directly with your project file.
Here's an example. If you're still having trouble then please post what you have so far then we might be able to help directly with your project file.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: How to pass array as parameter to macro
Thank you! That does help, but not quite. I'll send the project over in a private message.
Thanks again Benj!
-Steven
Thanks again Benj!
-Steven
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: How to pass array as parameter to macro
I think I see what you need you're trying to pass a sub part of an array.
Flowcode won't currently let you do this so you might have to do it like this.
CalcCRC(MsgLength, DataArray, ArrayOffset)
The ArrayOffset basically tells you to start from location 1 of the data array.
Arduino uses arrays all over the place to work with their C++ philosophy and avoid variable naming clashes when using multiple instances of a library.
With Flowcode you can simply have a global array and access this globally, this will significantly cut down on all the overhead of passing arrays around as parameters. Flowcode components allow the variable to get intelligently renamed so there won't be a clash. Therefore Arduino hacks are not required in Flowcode. Whenever I'm porting an Arduino library to a Flowcode component I get rid of any arrays as parameters and simply have a global array. This also gets away from the user having to create the unique array to drive the component, the variables required by the component are supplied by the component.
Flowcode won't currently let you do this so you might have to do it like this.
CalcCRC(MsgLength, DataArray, ArrayOffset)
The ArrayOffset basically tells you to start from location 1 of the data array.
Arduino uses arrays all over the place to work with their C++ philosophy and avoid variable naming clashes when using multiple instances of a library.
With Flowcode you can simply have a global array and access this globally, this will significantly cut down on all the overhead of passing arrays around as parameters. Flowcode components allow the variable to get intelligently renamed so there won't be a clash. Therefore Arduino hacks are not required in Flowcode. Whenever I'm porting an Arduino library to a Flowcode component I get rid of any arrays as parameters and simply have a global array. This also gets away from the user having to create the unique array to drive the component, the variables required by the component are supplied by the component.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: How to pass array as parameter to macro
I definitely understand that Benj! We just figured that out as well. So that gets rid of the first issue. Thank you on that. I believe the 2 & 3 go together with address/pointer.
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven