EVAL Command - Expression Evaluator
Mathematical, logical, and system state expression evaluation engine.
V, AIN, IN, GPS, ECU...
→Arithmetic, logical, bitwise
→printf style: %d, %f, %X
→Practical use cases
→📋 Syntax
EVAL expression[:format[:error_value]]| Parameter | Description | Default |
|---|---|---|
expression | Operation or query to evaluate | (required) |
format | Output format printf style | %.2f |
error_value | Value if evaluation fails | ERR |
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
| Variable | Description | Unit | Link |
|---|---|---|---|
V | Main voltage | dV (28.0V = 280) | |
VBU | Backup battery voltage | dV | |
OT | Total odometer | meters | |
OP | Partial odometer | meters | |
CREG | Network registration status | - | |
CSQ | Cellular signal quality | 0-31 | |
HO | Hour meter | seconds | |
VEL | Filtered GPS speed | km/h | |
HDG | GPS heading (v1.9.18+) | 0-360° | |
AGE | GPS data age | seconds | |
LAT | Latitude | degrees×10⁵ | |
LON | Longitude | degrees×10⁵ | |
IGN | Ignition status | 0/1 | |
CEL | Cellular connection | 0/1 | |
GPS | GPS active | 0/1 | |
PWR | Power supply | 0/1 | |
JMD | Jamming detected | 0/1 | |
PK | Parking | 0/1 | |
AC | Accelerometer | 0/1 | |
WIF | WiFi | 0/1 | |
CAN | CAN bus | 0/1 |
With One Parameter
| Variable | Description | Range | Link |
|---|---|---|---|
AIN(n) | Analog input | 0-3 | |
IN(n) | Digital input | 0-3 | |
XP(n) | Digital output | 0-n | |
UV(n) | User variable | 0-n | |
U(n) | Auxiliary variable | 0-n | |
MXB(n) | XB buffer | 0-n | |
DC(n) | Angle (ANG) | 0-n | |
DV(n) | Frequency (FRE) | 0-n | |
OW(n) | 1-Wire sensor | 0-n |
With Two Parameters
| Variable | Description | Param 1 | Param 2 |
|---|---|---|---|
ECU(i;t) | ECU data | Index | 0=value, 2=age |
MBS(i;t) | BLE sensors | Index | 0=temp, 1=humidity |
MTD(i;t) | TD timers | Index | 0=status, 1=timer, 2=dist, 3=timeout |
MTR(i;t) | Trips | Index | 0=trigger, 1=enabled, 2=time |
MNT(i;t) | Counters | Index | 0=current, 1=maximum |
MDL(i;t) | LOG data | Index | 0=quantity, 1=pending |
MPC(i;t) | Pulse counter | Index | 0=value, 1=factor K |
MFC(i;t) | Frequency meter | Index | 0=freq, 1=factor Q |
🧮 Operators
Arithmetic
| Operator | Description | Example | Result |
|---|---|---|---|
+ | Addition | EVAL 10 + 5 | 15.00 |
- | Subtraction | EVAL 20 - 8 | 12.00 |
* | Multiplication | EVAL 3 * 4 | 12.00 |
/ | Division | EVAL 10 / 2 | 5.00 |
Comparators
| Operator | Description | Example | Result |
|---|---|---|---|
gt | Greater than | EVAL 5 gt 3 | 1.00 |
lt | Less than | EVAL 5 lt 7 | 1.00 |
ge | Greater or equal | EVAL 5 ge 5 | 1.00 |
le | Less or equal | EVAL 4 le 5 | 1.00 |
eq | Equal | EVAL 5 eq 5 | 1.00 |
ne | Not equal | EVAL 5 ne 6 | 1.00 |
Logical
| Operator | Description | Example | Result |
|---|---|---|---|
&& | Logical AND | EVAL (5 gt 3) && (2 lt 4) | 1.00 |
|| | Logical OR | EVAL (5 gt 6) || (2 lt 4) | 1.00 |
Bitwise
| Operator | Description | Example | Result |
|---|---|---|---|
& | Bitwise AND | EVAL 5 & 3 | 1.00 |
| | Bitwise OR | EVAL 5 | 2 | 7.00 |
sl | Shift left | EVAL 2 sl 1 | 4.00 |
sr | Shift right | EVAL 4 sr 1 | 2.00 |
📝 Output Format
Customize result presentation using C printf syntax:
| Format | Description | Example | Result |
|---|---|---|---|
%.2f | Float 2 decimals | EVAL 3.14159:%.2f | 3.14 |
%.3f | Float 3 decimals | EVAL 3.14159:%.3f | 3.142 |
%d | Integer | EVAL 5.7:%d | 5 |
%x | Lowercase hexadecimal | EVAL 15:%x | f |
%X | Uppercase hexadecimal | EVAL 15:%X | F |
%b | Binary | EVAL 5:%b | 101 |
%05.2f | Left zero padding | EVAL 3.14:%05.2f | 03.14 |
%08.2f | More left zero padding | EVAL 3.14:%08.2f | 00003.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
| Error | Cause | Solution |
|---|---|---|
ERR | Undefined variable or incorrect syntax | Check spelling, use error_value |
Inf | Division by zero | Validate divisor or use error_value |
| Syntax | Unbalanced parentheses | Review expression structure |
| Index | Out of range (e.g., AIN(9)) | Check valid ranges for model |
Compatibility
See also
- Trigger List - Available signals
- Event Engine - Usage in rules
- User Reports Ux - Integration with EVAL