ethercat-rs / ethercat-esi

EtherCAT Slave Information (ESI)
Apache License 2.0
12 stars 4 forks source link

unable to load ESI files from regular constructors like Omron #1

Open jimy-byerley opened 1 year ago

jimy-byerley commented 1 year ago

Hello dear maintainers

I'm trying to learn to use crate ethercat, but having an issue with the ESI XML files I'm trying to run ethercat/examples/cyclic-data.rs but the XML parsing fails with my ESI files I tried the following files: xml.zip

both work well on the sysmac-studio software, so I doubt there is something wrong about the files themselves. They both give the same parser errors when loaded by ethercat-esi

$ target/debug/examples/cyclic-data ~/omron-1s.xml
Error: Custom { kind: Other, error: "Syntax: 1:1 Unexpected characters outside the root element: \u{feff}" }
$ target/debug/examples/cyclic-data ~/tinsmith-erob.xml
Error: Custom { kind: Other, error: "Syntax: 1:1 Unexpected characters outside the root element: \u{feff}" }

\u{feff} is a character that marks the file as utf-8, so it should be considered as whitespace. I added it to is_whitespace_char() in xml-rs

Then I fall into a new error

$ target/debug/examples/cyclic-data ~/omron-1s.xml
Error: Custom { kind: Other, error: "custom: duplicate field `Name`" }

It seems that ethercat-esi doesn't handle locale variants in xml files, so I removed the duplicates and run again to get the following error

$ target/debug/examples/cyclic-data ~/omron-1s.xml
Error: Custom { kind: Other, error: "custom: missing field `Vendor`" }
$ target/debug/examples/cyclic-data ~/tinsmith-erob.xml
Error: Custom { kind: Other, error: "custom: missing field `Sm`" }

The fields mentionned are not missing in the xml files, so I don't know what is wrong. I tried to fix ethercat-esi by switching it from serde-xml-rs to quick-xml, but it gave me the same kind of error as the latest ones, as we can see on this issue

Is there a way to fix all these issues from ethercat-esi (especially the missing fields) ?

birkenfeld commented 10 months ago

2 fixes everything except handling of the duplicate Names.

birkenfeld commented 10 months ago

Multiple Names are now also handled.

v-morlock commented 10 months ago

Hey, unfortunately i'm still unable to load esi-files from Nanotec, i get errors like those:

called Result::unwrap() on an Err value: Custom { kind: Other, error: "custom: unknown variant Su, expected one of Type, Name, RxPdo, TxPdo, Sm, Info, HideType, GroupType, URL, Profile, Eeprom, Fmmu, Image16x14, ImageFile16x14, ImageData16x14, Mailbox, Dc, Slots" }

If i remove the "Su" entries, i'm getting this errors:

called Result::unwrap() on an Err value: Custom { kind: Other, error: "custom: missing field Sm" }

Edit: the files can be found in this package: https://de.nanotec.com/produkte/2533-plug-drive-studio-2 Take e.g. the C5-E-2-21.xml

flosse commented 10 months ago

@v-morlock I can confirm the file can't be read. Here is the corresponding test but I haven't fixed it yet: #3

flosse commented 10 months ago

The xml parser is also a bit out of date. Using the new one causes some other tests to fail. So here is an other PR that needs to be fixed: #4

I have no idea if i will get around to it soon, so if you feel like it, feel free to work on it already :wink: