Skip to Content

EVAL Command - Expression Evaluator

Mathematical, logical, and system state expression evaluation engine.


📋 Syntax

EVAL expression[:format[:error_value]]
ParameterDescriptionDefault
expressionOperation or query to evaluate(required)
formatOutput format printf style%.2f
error_valueValue if evaluation failsERR

Parentheses after EVAL are optional. The expression ends with < or the first ; found.

Basic Examples

>EVAL 10 + 5<

Result: 15.00

>EVAL 10 + 5.5 * 2:%.1f:NA<

Result: 21.0 (if fails, returns NA)


📊 System Variables

Without Parameters

VariableDescriptionUnitLink
VMain voltagedV (28.0V = 280)
VBUBackup battery voltagedV
OTTotal odometermeters
OPPartial odometermeters
CREGNetwork registration status-
CSQCellular signal quality0-31
HOHour meterseconds
VELFiltered GPS speedkm/h
HDGGPS heading (v1.9.18+)0-360°
AGEGPS data ageseconds
LATLatitudedegrees×10⁵
LONLongitudedegrees×10⁵
IGNIgnition status0/1
CELCellular connection0/1
GPSGPS active0/1
PWRPower supply0/1
JMDJamming detected0/1
PKParking0/1
ACAccelerometer0/1
WIFWiFi0/1
CANCAN bus0/1

With One Parameter

VariableDescriptionRangeLink
AIN(n)Analog input0-3
IN(n)Digital input0-3
XP(n)Digital output0-n
UV(n)User variable0-n
U(n)Auxiliary variable0-n
MXB(n)XB buffer0-n
DC(n)Angle (ANG)0-n
DV(n)Frequency (FRE)0-n
OW(n)1-Wire sensor0-n

With Two Parameters

VariableDescriptionParam 1Param 2
ECU(i;t)ECU dataIndex0=value, 2=age
MBS(i;t)BLE sensorsIndex0=temp, 1=humidity
MTD(i;t)TD timersIndex0=status, 1=timer, 2=dist, 3=timeout
MTR(i;t)TripsIndex0=trigger, 1=enabled, 2=time
MNT(i;t)CountersIndex0=current, 1=maximum
MDL(i;t)LOG dataIndex0=quantity, 1=pending
MPC(i;t)Pulse counterIndex0=value, 1=factor K
MFC(i;t)Frequency meterIndex0=freq, 1=factor Q

🧮 Operators

Arithmetic

OperatorDescriptionExampleResult
+AdditionEVAL 10 + 515.00
-SubtractionEVAL 20 - 812.00
*MultiplicationEVAL 3 * 412.00
/DivisionEVAL 10 / 25.00

Comparators

OperatorDescriptionExampleResult
gtGreater thanEVAL 5 gt 31.00
ltLess thanEVAL 5 lt 71.00
geGreater or equalEVAL 5 ge 51.00
leLess or equalEVAL 4 le 51.00
eqEqualEVAL 5 eq 51.00
neNot equalEVAL 5 ne 61.00

Logical

OperatorDescriptionExampleResult
&&Logical ANDEVAL (5 gt 3) && (2 lt 4)1.00
||Logical OREVAL (5 gt 6) || (2 lt 4)1.00

Bitwise

OperatorDescriptionExampleResult
&Bitwise ANDEVAL 5 & 31.00
|Bitwise OREVAL 5 | 27.00
slShift leftEVAL 2 sl 14.00
srShift rightEVAL 4 sr 12.00

📝 Output Format

Customize result presentation using C printf syntax:

FormatDescriptionExampleResult
%.2fFloat 2 decimalsEVAL 3.14159:%.2f3.14
%.3fFloat 3 decimalsEVAL 3.14159:%.3f3.142
%dIntegerEVAL 5.7:%d5
%xLowercase hexadecimalEVAL 15:%xf
%XUppercase hexadecimalEVAL 15:%XF
%bBinaryEVAL 5:%b101
%05.2fLeft zero paddingEVAL 3.14:%05.2f03.14
%08.2fMore left zero paddingEVAL 3.14:%08.2f00003.14

⚠️ Error Handling

Custom error value

>EVAL toker + 5:%0.2f:NA<

Result: NA (undefined variable)

Default error

>EVAL toker + 5<

Result: ERR

Division by zero

>EVAL 10 / 0<

Result: Inf


💬 Practical Examples

GPS Heading (HDG)

>EVAL HDG<

Returns current heading in degrees (0-360°). Example: 185.00

>EVAL HDG ge 180<

Returns 1.00 if the vehicle points south-west-north (180°-360°).

>EVAL (HDG ge 0) && (HDG lt 90)<

Returns 1.00 if pointing north-east (0°-90°).

ECU parameter sum

>EVAL ECU(0;0) + ECU(1;0) + ECU(2;0):%0.2f<

Sums ECU values from indices 0, 1, and 2.

AIN comparison

>EVAL AIN(0) gt 500<

Returns 1.00 if AIN(0) > 500, otherwise 0.00.

Compound logic

>EVAL (V gt 150) && (AIN(0) lt 100)<

Verifies compound condition on voltage and analog input.

Calculation with format

>EVAL (10 * 5) + 3:%0.3f<

Result: 53.000

Complex expression

>EVAL ((AIN(0) * 10) + (AIN(1) * 5)) / 2:%0.2f:NA<

Calculates weighted average with custom format and NA error.

Bitwise mask

>EVAL IN(0) & 0x0F:%X<

Applies mask to digital input and displays in hexadecimal.

Bit shift

>EVAL 8 sr 2<

Result: 2.00 (8 >> 2)

Division with integer format

>EVAL 25 / 4:%d<

Result: 6 (integer division)

Temperature conversion

>EVAL (AIN(0) * 0.1) - 40:%0.1f:ERR<

Converts ADC reading to temperature with ERR error.


🔧 Error Troubleshooting

ErrorCauseSolution
ERRUndefined variable or incorrect syntaxCheck spelling, use error_value
InfDivision by zeroValidate divisor or use error_value
SyntaxUnbalanced parenthesesReview expression structure
IndexOut of range (e.g., AIN(9))Check valid ranges for model

Compatibility

ZE-IoT
SP-IoT
SM-IoT

See also

Last updated