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

Timing #29

Open
AliMoal opened this issue Jun 10, 2023 · 6 comments
Open

Timing #29

AliMoal opened this issue Jun 10, 2023 · 6 comments

Comments

@AliMoal
Copy link
Contributor

AliMoal commented Jun 10, 2023

how this library handles 1.5 or 3.5 character times according to Modbus over Serial Line document?

@debevv
Copy link
Owner

debevv commented Jun 13, 2023

Hi, basically it doesn't. It behaves similarly to libmodbus (stephane/libmodbus@a11805c and stephane/libmodbus#18). We addressed this some time ago with another user in this issue.
I thought about implementing it at the time, but it would make the library more complex both internally and for the user. Also in my experience I never found a device honoring those timings, so having the library not rely on them makes it definitely more robust.
Would you mind explaining me your use case?

@AliMoal
Copy link
Contributor Author

AliMoal commented Jun 14, 2023

Actually, I want to use this library to communicate with PLC devices, I don't have any idea this lack of timing may cause problem or not.

@AliMoal
Copy link
Contributor Author

AliMoal commented Jun 14, 2023

As I see in here, libmodbus library handles those timings.

@debevv
Copy link
Owner

debevv commented Jun 16, 2023

Sorry, can you point me to the exact line? Because I can't find it in the linked file.
By the way, if those PLC devices do follow the spec about the timings, there are two cases:

  • when you receive data from them, there shouldn't be any problems because nanomodbus ignores the the intervals between characters and frames
  • when you send data, I think you can get away with waiting before making a request (if you are a client), waiting before responding in a request handler (if you are a server) and spacing the characters in your write() platform function

@AliMoal
Copy link
Contributor Author

AliMoal commented Jun 17, 2023

I guess line 1277.
Could you show me how to implement Write() function? I'll use this library and see there is any problem or not.

@debevv
Copy link
Owner

debevv commented Jun 21, 2023

Yeah after reading my previous message again I realized that the t1,5 in the spec is not mandatory inter-character spacing but instead a timeout, so you really don't need any particular handling in your write() function.
The only things you should implement are the waits before requests and responses, to simulate inter-frame spacing

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

2 participants