Hi Sebastian, thanks - that is the right question to ask, and it is the one
I
was most careful about.

On protocol compatibility: so far everything I have seen says the wire
protocol is the same. The model generated from ads.mspec parses the symbol
table, the data type table and the upload-info of a TwinCAT 2.11 controller
without a single change to the spec. What differs is not the format but the
content and the conventions around it:

- the device names primitive types the way TcAdsDef.h does (INT16, UINT32)
  rather than the IEC names TwinCAT 3 reports (INT, UDINT)
- it stores symbol and member names upper case, while the program declares
  them in mixed case, so a lookup that is exact fails
- it answers the online-version read with an error result code and an empty
  payload instead of a version, and the driver parses the payload without
  looking at the result code, which is the EOF that ends the connection
  before anything else is tried

So nothing below the driver changes: no .mspec change, no regenerated code,
nothing outside plc4go/internal/ads. That also answers your second point -
plc4j, plc4c, plc4py and plc4net are not touched by any of this, and cannot
be, since the spec they are generated from is untouched.

On not breaking TwinCAT 3, the honest answer first: I do not have a TwinCAT
3
device, so I cannot test that myself. What I can say is how each change is
shaped so TwinCAT 3 keeps its current path:

- name lookup tries the exact name first and only falls back to a
  case-insensitive match when that fails, so a TwinCAT 3 device, whose names
  already match exactly, never reaches the fallback
- a primitive type is synthesised only when the name is absent from the
  uploaded data type table; TwinCAT 3 uploads those entries, so the table
  wins and the synthesis is dead code there
- the online-version handling only changes what happens when the device
  answers with an error result, which today is not checked at all

That is reasoning, not a measurement, and I would rather have the
measurement. If someone on the list has a TwinCAT 3 device and can run the
third PR against it, I would be glad of it - and I am happy to prepare
whatever makes that easy to do.

The first PR is up: https://github.com/apache/plc4x/pull/2889 - a browse
query without a dot panics the driver. One condition, with a test. Nothing
in
it distinguishes TwinCAT versions; the query never reaches the device.

Thanks,
Levent

Sebastian Rühl via dev <[email protected]>, 24 Kas 2026 Sal, 10:49
tarihinde şunu yazdı:

> Hi Levent,
>
> welcome to the list.
>
> One thing that jumps to my mind: We should carefully check if TwinCat 2
> and TwinCat 3 are protocol compatible.
> So as long as your changes don't break TwinCat3 is should be fine but we
> should check that.
> Luckly the spec is open and there should be Documentation by Beckhoff
> which could help us judge such things.
> Also keep in mind: the X stands for any language so that means a change
> must not break any of the languages.
>
> Sebastian
>
> On 2026-11-23 23:10 UTC Levent Sağıroğlu wrote:
> > Hi everyone, I'm Levent (LeventSA on GitHub) from NetYazilim in Turkey.
> I've
> > been writing software for over thirty years, and the part I enjoy most
> has
> > always been getting a computer to talk to a piece of hardware and making
> > something useful out of it. I'm building a data collection system for a
> > factory, reading its Beckhoff controllers with plc4go.
> >
> > What drew me to PLC4X is how much it covers from one design: more than a
> > dozen protocols behind a single API, five language bindings, one .mspec
> per
> > protocol to generate them from. We read Siemens and Modbus in the same
> > plant,
> > so that one API is why I chose plc4go - and the model generated from
> > ads.mspec parsed the TwinCAT 2 tables unchanged, so nothing below touches
> > the
> > spec.
> >
> > The ADS driver assumes TwinCAT 3 and cannot connect to a TwinCAT 2
> device at
> > all. That is #1424, open since February 2024, and the three symptoms
> > reported
> > there are all accounted for in what I have: INT16 where the driver
> expects
> > INT, symbol names that only match in upper case, and a nil pointer
> panic. I
> > have it working against three TwinCAT 2.11 controllers, from a CX9020
> with
> > 38
> > symbols to a plant PC with over 170,000 readable tags, and would like to
> > contribute that back. Introducing it here first, as the contributing
> guide
> > asks.
> >
> > It is not one change but three, so I would send three small PRs against
> > develop, smallest first, each with its own measurements:
> >
> > - a browse query with no dot in it panics the driver (a one character
> fix)
> > - a reply larger than the peek buffer is classified as a fatal transport
> >   error, which kills the connection on any device with a large symbol
> table
> > - TwinCAT 2 support itself, in plc4go/internal/ads only, with no .mspec
> >   change and no regenerated code
> >
> > There is a fourth change behind the tag count above: a browse of "*"
> lists
> > the symbols a device reports and "**" expands them into readable tags.
> That
> > one is a feature rather than a fix, so I'd rather offer it separately
> once
> > the three above are settled.
> >
> > Unless someone objects, I'll open the first one later this week and let
> it
> > be
> > reviewed before sending the next.
> >
> > I can follow these through, and the controllers are in a running plant I
> > have
> > access to. #1424 says TwinCAT 2 has gone uncovered mostly for lack of
> such a
> > device, so if anything else in the ADS driver needs checking against real
> > TwinCAT 2 hardware, I'm happy to run it.
> >
> > One note on process, as the contributing guide requires. English is not
> my
> > first language and I learned it mostly from reading technical
> documentation,
> > so I used Claude as an assistant here, for the language and for parts of
> the
> > work, as I will also disclose in each PR. The design decisions, the
> > measurements on real hardware and the validation against a reference tool
> > are
> > mine, and I have reviewed every line I am proposing. Plain, direct review
> > comments are welcome. Indirect phrasing is harder for me to read
> correctly,
> > so please just say what needs to change.
> >
> > Thanks,
> > Levent
> >
>

Reply via email to