-
Notifications
You must be signed in to change notification settings - Fork 594
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
Set PLC-time through code #502
Comments
Yes. Are those captures from the Wireshark page about the S7 dissector? I think I might have seen them as well... I recently implemented PLC status reading, which uses the SZL subset of communication, I believe system time uses SZL commands as well. |
I have seen that you implemented that great feature. I am not sure that the set clock function is an SZL protocol function, by just browsing the wireshark capture, SZL seems to be related to diagnostic and status data FROM the PLC. Here is the link to the wireshark captures: https://wiki.wireshark.org/S7comm. |
Just started on this. Will start by implementing clock read, then I'll add clock write. I hope to have this finished within a few days. |
Perfect. I tried to create a set clock method. ``public static void WriteClockRequest(System.IO.MemoryStream stream, System.DateTime dateTime)
}`` |
Hi @SmackyPappelroy, I think what's wrong is your Anyway, in the meantime I added clock read in #507, you can take that for a spin and see if it works as expected. I'll be adding clock write soon. |
Hello @mycroes. I tried your code on a simulated S7300 and it worked as expected. System.Exception This exception was originally thrown at this call stack: I am not sure why this happens. If I can be of any assistance, let me know. I have access to real Siemens PLCs, so I can test changes. |
Could you provide the contents of |
pduErr = 33028 and message is: Byte50 |
I'm not sure if this maybe just doesn't work on S7 1500. I've been comparing my code to st-one-io/nodes7 and from what I see it's producing the same data. The message you received from the PLC seems to be a valid response message to the request (all of the data seems to indicate this is indeed a response to the get time request that was sent), it just doesn't have actual time data but the error fields are all set. The returned error code is actually defined in nodes7: "33028": "This service is not implemented on the module or a frame error was reported", That does seem to indicate it might just not be available on S7 1500. If you can get the time from TIA portal there's probably a different communication method to do that. I'll continue on adding this feature though, but I guess it might only work for 300/400 PLC's. |
I haven't been able to get it to work on an S7-1500. The S7COMM filter for WireShark is mainly for S7300/S7400 CPUs so I haven't been able to capture anything useful when I try to do a clock read in TIA Portal. Nevertheless it is a good feature to have even if we can't figure out how to do it for an S7-1500 CPU. |
Clock write support is there as well now. I guess it only works for S7 300 / S7 400, but if you could give that a spin that would be nice. I didn't expand the exception messages yet, I haven't decided on including that in the PR or as a separate PR. Looking forward to your response. |
I have tried both the sync and the async methods against an S7300 and it worked perfectly. I have also tried against both a real S71500 and a simulated. That did not work, I only get this exception: System.Exception This exception was originally thrown at this call stack: |
Thanks a lot for testing, I'll try to release this soon. |
Is it possible to implement a method to set the PLC-time? That would be a great feature to have in a logging application so the clocks are synchronized. I have seen Wireshark captures of how to set the clock. That might provide some guidance.
The text was updated successfully, but these errors were encountered: