Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

P0009

Code

P0009

Message

TwinCAT XML file has invalid structure

This error occurs when a TwinCAT XML file (.TcPOU, .TcGVL, or .TcDUT) does not have the expected structure. TwinCAT files must have a TcPlcObject root element containing a POU, GVL, or DUT child element with a Declaration section.

Example

The following XML is missing the required Declaration element:

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
  <POU Name="MAIN" Id="{00000000-0000-0000-0000-000000000000}">
    <Implementation>
      <ST><![CDATA[
myVar := myVar + 1;
      ]]></ST>
    </Implementation>
  </POU>
</TcPlcObject>

To fix this error, add a Declaration element containing the variable declarations:

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
  <POU Name="MAIN" Id="{00000000-0000-0000-0000-000000000000}">
    <Declaration><![CDATA[
PROGRAM MAIN
VAR
    myVar : INT;
END_VAR
    ]]></Declaration>
    <Implementation>
      <ST><![CDATA[
myVar := myVar + 1;
      ]]></ST>
    </Implementation>
  </POU>
</TcPlcObject>