-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Issue Title
[dcf/lint.py] False positive "LowLimit overflow" when parsing hex negative values (0x80000000) for INT32
Description
I am encountering a UserWarning: LowLimit overflow when using ros2_canopen with an EDS file that defines LowLimit using hexadecimal notation for Integer32 (0x0004) objects.
The specific case is the standard CiA402 object 0x607C (Home Offset), where the lower limit is set to 0x80000000 (representing -2147483648 in 32-bit two's complement). The parser seems to interpret 0x80000000 as a large positive unsigned integer (
Environment
- OS: Linux (Ubuntu 24.04)
- ROS Distro: ROS 2 Jazzy
- Package:
ros2_canopen - Python: 3.12
Steps to Reproduce
- Create or use an EDS file containing an entry for
[607C](or any INT32 object) withLowLimitset to0x80000000.
Snippet from EDS:
[607C]
ParameterName=Home offset
ObjectType=0x7
DataType=0x0004
AccessType=rww
DefaultValue=0
PDOMapping=1
LowLimit=0x80000000
HighLimit=0x7FFFFFFF
ObjFlags=0x0- Launch the canopen node or run the dcf lint tool.
Current Behavior (Logs)
The system outputs the following warning:
/opt/ros/jazzy/lib/python3.12/site-packages/dcf/lint.py:93: UserWarning: LowLimit overflow in [607C]
if not __parse_object(cfg, section, index):
Expected Behavior
The parser should recognize that DataType=0x0004 indicates a signed 32-bit integer. Consequently, 0x80000000 should be interpreted as -2147483648 (min value for INT32) rather than +2147483648, and no warning should be issued.
Possible Cause / Analysis
It appears the parser uses standard Python hex conversion (e.g., int('0x80000000', 16)), which results in a positive value. When validating against DataType=0x0004 (INT32), the parser likely checks:
value > MAX_INT32 (2147483647) -> True, causing the overflow warning.
The logic needs to handle two's complement for hex values when the DataType is signed.