Error when compiling to target

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Billduck1302
Posts: 23
http://meble-kuchenne.info.pl
Joined: Fri Dec 06, 2024 4:41 pm
Has thanked: 1 time
Been thanked: 1 time

Error when compiling to target

Post by Billduck1302 »

This is the message. Is there a way to troubleshoot based on the last message "error code 0x1", or " invalid operands to binary | (have 'MX_FLOAT {aka volatile float}' and 'float')"? The correct programmer port is selected. Thanks in advance.

"C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell>"C:\Program Files (x86)\Flowcode\Common\Compilers\avrv5\bin\avr-gcc.exe" -mmcu=atmega328p -Os -ffunction-sections -fdata-sections -funsigned-char -o "C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.elf" "C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.c" -lm -Wl,-gc-sections
C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.c: In function 'main':
C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.c:3916:34: error: invalid operands to binary | (have 'MX_FLOAT {aka volatile float}' and 'float')
C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\AVR\batchfiles\avra.bat reported error code 0x1
"
Attachments
June19,25_LeafCell_V2.fcfx
(31.2 KiB) Downloaded 32 times

chipfryer27
Valued Contributor
Posts: 1745
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 386 times
Been thanked: 597 times

Re: Error when compiling to target

Post by chipfryer27 »

Hi

It doesn't seems to like your decision in Main

Cell_1_Voltage_Float OR Cell_2_Voltage_Float < 3.0

If you use a Logical OR (||) it compiles.

Cell_1_Voltage_Float || Cell_2_Voltage_Float < 3.0

Regards

LeighM
Valued Contributor
Posts: 502
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 87 times
Been thanked: 268 times

Re: Error when compiling to target

Post by LeighM »

Well spotted, also it will need to be more explicit..
(Cell_1_Voltage_Float < 3.0) || (Cell_2_Voltage_Float < 3.0)

Billduck1302
Posts: 23
Joined: Fri Dec 06, 2024 4:41 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Error when compiling to target

Post by Billduck1302 »

Thank you so much. I am just learning about Injectors, when using the F8 key.
Can it be done that, when prompted to read an analog input, that I could type in the bite when I have the command "Get Average Int".
By the way, this is a program to test the capacity of Nissan Leaf cells.(2S2P)
Leight, what do you mean y more explicit?

chipfryer27
Valued Contributor
Posts: 1745
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 386 times
Been thanked: 597 times

Re: Error when compiling to target

Post by chipfryer27 »

Hi

One of the great features of Flowcode is to "step through" your program.

This could be in simulation, where you have the option to view any variable you choose, or if using Ghost enabled hardware you can step through and view everything in real time. Highly recommended debug tool.

I think what Leigh was refering to, was that you need to break down your decision into two separate calculations, each in their own parentheses, to be "OR'd".

Hope this helps.

LeighM
Valued Contributor
Posts: 502
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 87 times
Been thanked: 268 times

Re: Error when compiling to target

Post by LeighM »

Yes, that's it.
You need to be aware of the syntax/format of IF expressions.
IF something, where something is true or false.
In C, false is 0 (zero) and true is non-zero.
So sometimes "IF variable" will be a valid statement, assuming variable is an int (not float).
And will treat the statement as true if the variable is not zero.
Your "IF this OR that < 3" would be true if "this" is non-zero OR "that" is less than 3.
So it's better to explicitly say "this <> 0" to avoid confusion.
Hope that helps.
(and that I've not mistyped on my phone :lol:
Ps. If you want to dig deeper, look up operator precedence

Steve-Matrix
Matrix Staff
Posts: 1595
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 222 times
Been thanked: 373 times

Re: Error when compiling to target

Post by Steve-Matrix »

There has always been a bit of confusion with the terms "AND", "OR" and "NOT" within Flowcode, because these refer to "bitwise" operators rather than "logical" operators. These were used in the very first version of Flowcode when the logical AND/OR/NOT were not supported (we introduced this in v3).

There is a post about this on our old forums:
https://www.flowcode.co.uk/mmforums/vie ... php?p=8157

In the new version of Flowcode, which should be released soon, the operators "AND", "OR" and "NOT" are still supported (as bitwise operators for backwards compatibility) but we now promote using the C-style syntax that explicitly refers to the bitwise or the logical operators (e.g. "&&" and "&").

Here's a screenshot of the new dropdown for mathematical functions, which groups together similar mathematical operators:
flowcode operators.png
flowcode operators.png (22.92 KiB) Viewed 1892 times

Note also there is a similar issue with "equals". In C code, the single "=" is used when assigning values to variables and the double equals "==" is a 'relational' operator that is used when comparing values (e.g. "is x equal to 5"). Flowcode has always allowed the single "=" to mean "is equal to" in a decision even though this is incorrect in most modern computer languages (we originally copied this dual use from BASIC). Recent versions of Flowcode have also allowed the double "==" when comparing values (as per C, JavaScript, etc).

We continue to allow this dual use for the single "=", but now the suggested relational operator when comparing values is "==" as this makes it easier for Flowcode users to understand and learn C code.

Post Reply