Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jimy-byerley opened this issue Mar 1, 2023 · 5 comments
Open

Comments

@jimy-byerley
Copy link

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

  • omron 1S, ESI file
  • tinsmith erob, ESI file

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) ?

@jimy-byerley jimy-byerley changed the title Unexpected character \u{feff} unable to load ESI files from regular constructors like Omron Mar 1, 2023
@birkenfeld
Copy link
Member

#2 fixes everything except handling of the duplicate Names.

@birkenfeld
Copy link
Member

Multiple Names are now also handled.

@v-morlock
Copy link

v-morlock commented Oct 27, 2023

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
Copy link
Contributor

flosse commented Oct 27, 2023

@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
Copy link
Contributor

flosse commented Oct 27, 2023

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 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants