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

Bug fix in the GetSZL function #143

Merged
merged 3 commits into from
Dec 6, 2019
Merged

Bug fix in the GetSZL function #143

merged 3 commits into from
Dec 6, 2019

Conversation

StefanHasensperling
Copy link
Contributor

This is a Bug fix in the GetSZL function. The INDEX data-type is really an Uint16 and not an Int16.
The int16 definition lead to the following problem:

Some SZL's have their most significant bit set to TRUE. this happens in particular for SZL 0x0D91 (Uploading Module Information of an Profinet/DP device), when the station is on an Profinet System. In that case the INDEX parameter is something like "0x8006" or similar. The important thing is that the bit 15 is true (it indicates that we area dealing with an Profinet and not Profibus).
However the "readSZL" in the IDaveConnection interface defines an integer (32/64 bits). Unfortunately when you call into IDaveConnection.ReadSZL, the INDEX gets sign-expanded from an int16 to an int32/int64. But that is not correct. The Index parameter must not be expanded.

In the end this results that LibNoDave sends Index 0x8106 instead 0x8006 on the wire. I confirmed this with Wireshark, and the change from int16 to Uint16 fixes this issue.

This was tested on an VIPA 017 SLIO CPU (basically it is an S7-317 PN/DP in a smaller form factor), with an real Profinet Configuration.

Stefan Hasensperling added 2 commits December 5, 2019 13:23
…ly an Uint16 and not an Int16.

The int16 definition lead to the following problem:

Some SZL's have their most significant bit set to TRUE. this happens in particular for SZL 0x0D91 (Uploading Module Information of an Profinet/DP device), when the station is on an Profinet System. In that case the INDEX parameter is something like "0x8006" or similar. The important thing is that the bit 15 is true (it indicates that we area dealing with an Profinet and not Profibus).
However the "readSZL" in the IDaveConnection interface defines an integer (32/64 bits). Unfortunately when you call into IDaveConnection.ReadSZL, the INDEX gets sign-expanded from an int16 to an int32/int64. But that is not correct. The Index parameter must not be expanded.

In the end this results that LibNoDave sends Index 0x8106 instead 0x8006 on the wire. How exactly this transformation happens, i also don't know exactly, I think it is an artifact of some ByteSwappint. I confirmed this with Wireshark, and the change from int16 to Uint16 fixes this issue.

This was tested on an VIPA 017 SLIO CPU (basically it is an S7-317 PN/DP in a smaller form factor), with an real Profinet Configuration.
@StefanHasensperling
Copy link
Contributor Author

I just realized, the change i made fixes the bug, but it might break existing code..

@jogibear9988
Copy link
Member

maybe create a overload?

@StefanHasensperling
Copy link
Contributor Author

true, did not think about that. But anyway we should remove the int16 eventually. for now i will make an overload

@StefanHasensperling
Copy link
Contributor Author

OK. made an overload for compatibility.

@jogibear9988 jogibear9988 merged commit 4c599a5 into dotnetprojects:master Dec 6, 2019
@jogibear9988
Copy link
Member

thanks again.

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

Successfully merging this pull request may close these issues.

2 participants