-
Notifications
You must be signed in to change notification settings - Fork 46
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
UDP Support V0.1 #16
Merged
Merged
UDP Support V0.1 #16
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly I'd like to appreciate the work done by @sstevan and @tp0x45 on this awesome project. And Specially thank @sstevan for the support on doing this PR.
A lot of commit and tests for UDP Support, so a short description of what's happening.
I've added the method getReceivedData and the keyword argument receivedData1 on CommonFrame because it's useful for my application and as it is a keyword argument(kwarg)it shouldn't affect backwards compatibility. On the Topic of kwargs I've added the kwargs config2 on PDC init because my PMU won't answer the cfg2 on UDP so I've capture the CFG2 in TCP mode and the use it on UDP ergo the need for a kwarg with the insertion of the cfg2 frame to the PDC class. Also shouldn't change the backward compatibility and doesn't affect TCP connection, in the tests I've made.
On the pmu.py file there are the biggest changes due to UDP. To be noticed that due to issues with daemonic threads and processes I've named them to make them easier to be found. Also I've passed the logger through to the pdc_handler method though the creation of the Process(this removes the need for the logger to be recreated). Also in the pdc_handler method should be seen that there is a 60 second send, on UDP, of the CFG2 frame to the recipient that's due to the OpenPDC for some reason not "being green" without this send each 60 seconds (can provide images if necessary). Also on this file I've added "from traceback import print_exception" that's because of debugging purposes that without was really hard to catch the unhanded exceptions. Probably should be removed. But helps to find error so I left it there to your discretion.
As well on this file I've added a list that writes down where to send when start command is received and deletes when stop command is received. So that the module is capable of sending to more than one recipient. Again useful for my application. Also I commented out the sleep on the last lines because I found the need to command the sleep time not using only delay but as shown in tinyRandomPMU(only python 3.8 compatible),the program takes in account the time the program takes to execute.(I removed this file because I couldn't find the source of this algorithm I referenced, in the future can come back as an example)
There's also an interesting thing on UDP (acknowledge I didn't test this on Windows, only on Linux) but for some reason if you read the UDP socket only the 4 first bytes to get the size of the packet, it drops the rest that's the reason the packet read is of the entire packet and not by parts as it is in TCP.
There's also the change I've commented in issue #10 of the value change on line 401 of frame.py get_fracsec method.
I've started on Multicast as well, because the Python syntax isn't much different than UDP, but is still not fully functional. At least I had problems with making it work.
I've added also a acknowledgement to the project that is funding my research. Can (and probably should) be discussed the placement.