Skip to content

Composite type parsing fails to process BitOffs and SINT signed values in ESI file #992

Description

@CeeVeeX

Prerequisites

  • Using NodeJS 20+
  • Using Npm 10+

Expected Behavior

  1. When parsing composite custom data types defined in ESI XML, extract each field according to its configured BitOffs and BitSize instead of reading the entire buffer as a single integer value.
  2. Apply two's complement sign conversion for fields marked as SINT (8-bit signed integer). For byte 0xFD, the parsed value should be -3.
  3. Ignore unused padding bits inside composite structures.

Current Behavior

Image
  1. The parser does not respect BitOffs field offsets for composite structures. It parses the whole 32-bit hex buffer into one unsigned integer directly, unable to split discrete fields at non-contiguous bit positions.
  2. SINT signed 8-bit variables are parsed as unsigned bytes without sign compensation, producing incorrect large positive values.
  3. This parsing error breaks any CANopen object that uses this irregular composite structure definition.

Steps to Reproduce

  1. Import ESI file KS100E_Ecat_V2.1.xml which contains composite DataType with scattered BitOffs.
  2. Read the hex default value FFFFFFFD of the composite-type object.
  3. Check the resolved value of the SINT subfield located at BitOffs=24.

Key ESI DataType definition

<DataType>
	<Name>DT60C2</Name>
	<BitSize>32</BitSize>
	<SubItem>
		<SubIdx>0</SubIdx>
		<Name>largest sub-index supported</Name>
		<Type>USINT</Type>
		<BitSize>8</BitSize>
		<BitOffs>0</BitOffs>
	</SubItem>
	<SubItem>
		<SubIdx>1</SubIdx>
		<Name>Interpolation time period value</Name>
		<Type>USINT</Type>
		<BitSize>8</BitSize>
		<BitOffs>16</BitOffs>
	</SubItem>
	<SubItem>
		<SubIdx>2</SubIdx>
		<Name>Interpolation time index</Name>
		<Type>SINT</Type>
		<BitSize>8</BitSize>
		<BitOffs>24</BitOffs>
	</SubItem>
</DataType>

DefaultData

<Object>
	<Index>#x60c2</Index>
	<Name>Interpolation time period</Name>
	<Type>DT60C2</Type>
	<BitSize>32</BitSize>
	<Info>
		<SubItem>
			<Name>largest sub-index supported</Name>
			<Info>
				<DefaultData>02</DefaultData>
			</Info>
		</SubItem>
		<SubItem>
			<Name>Interpolation time period value</Name>
			<Info>
				<DefaultData>01000000</DefaultData>
			</Info>
		</SubItem>
		<SubItem>
			<Name>Interpolation time index</Name>
			<Info>
				<DefaultData>FFFFFFFD</DefaultData>
			</Info>
		</SubItem>
	</Info>
	<Flags>
		<Access>rw</Access>
		<Category>o</Category>
	</Flags>
</Object>

Possible Solution

  1. Rewrite composite type parsing logic to slice binary data per BitOffs + BitSize for each sub-item.
  2. Add signed value conversion logic for the SINT data type.
  3. Skip unused padding bits between structure members.

Context

The lack of proper BitOffs parsing compatibility limits support for vendor-specific CANopen ESI object definitions with non-contiguous structure layout, leading to wrong parameter readings for servo drive configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions