mbuesch / pyprofibus

PROFIBUS-DP stack

Home Page:https://bues.ch/a/profibus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Siemens DP/AS-i LINK 20 support

arabel1a opened this issue · comments

Hello!
I'm trying to connect to siemens DP/AS link, but recieve
DPM1: RX error: PHY-serial: Failed to get received telegram size: Invalid telegram format.
GSD parser comes with a lot of warning about unknown lines Value(1) and BitArea(X-Y), and the separate warning Warning in GSD 'DP-ASi-LINK_20/SIEM804F.gsd': DPv1 User_Prm_Data override ignored.
As far as i understood, the problem is caused by User_Prm_Data attribute, it is specefied twice: in SIEM804F.GSD and in example_dummy.py in slaveDesc.setUserPrmData line. How should i add a slave with UserPrmData, exported from GSD file ? Where can i look at the real received telegram size?

Hi!

Thanks for your questions.

An Invalid telegram format error basically means that the PHY layer is not able to determine the telegram size from the FDL telegram headers.
That might be due to one of several reasons. For one, the other device might send incorrectly formatted frames to the PB line. Or the frames might be corrupted during transmission. Or it transmits in a format, that Pyprofibus doesn't understand.

I'd suggest to enable PHY + FDL layer debugging, which would dump all received data to the terminal log.
Set debug=2 in your .conf file.

The warnings in the GSD originate from missing features in the GSD parser of Pyprofibus.
Pyprofibus doesn't implement all features of a GSD file, yet. Usually these features are not needed, though. So most of the time these warnings can be ignored.

The warning about User_Prm_Data is kind of interesting, though.
Can you please send me the GSD file (in private) so that I could check what's going on?

Thanks.

Thank you very much for answering so fast and detailed. I'm new to github, and i didn't found a private chat, so i'll send that file via email.

I've already set debug = 2, but the message remains; the output looks like four lines TX 10 03 02 ..., then one DPM1: RX error: PHY-serial: Failed to get received telegram size: Invalid telegram format. Is there a possibility to look at serial buffer?

In my case there is only one device on the bus with terminal resistors on Siemens cable, terminal resistor on the usb-rs485 is switched off.

Can you please advice me a simple way to sniff serial dialog in linux?

Can this error be caused by using ttyUSB0 and correlating USB-RS485 adapter without +5V (pin 6 on DB9) connected. Is it necesыary? I thought, it is used for power supply for hubs or something like that.

The second warning disappeared as soon as i commented
slaveDesc.setUserPrmData(slaveConf.gsd.getUserPrmData(dp1PrmMask=dp1PrmMask,dp1PrmSet=dp1PrmSet))
string in example_dummy.py

You could go into phy_serial.py and then search for Invalid telegram format.
Above that line there is a line rxBuf = bytearray(), which clears the receive buffer.
You may put something like print("Fragment:", bytesToHex(rxBuf)) before that line.
That will then print the received telegram fragment to console to see if the received data makes any sense.

I'll see if I can add that to pyprofibus in a form that can be released. It probably makes sense for debugging.

Such behaviour can be caused by incorrect wiring.
If your RS485 transceiver has a pin for 5V power, then it probably needs that. But these boards are usually powered from the TTL side. On the PB DB9 side it's enough to connect the two data lines only.

The latest pyprofibus release 1.11 contains some improvements that might help debugging low level problems like this.
It also contains some bug fixes.

I'm closing this old issue now. If you still need help, please feel free to re-open it.