-
Notifications
You must be signed in to change notification settings - Fork 27
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
Issue #368: Bad packet size handling in built-in server handlers #456
base: master
Are you sure you want to change the base?
Conversation
raise ValueError(msg) | ||
|
||
self._pkt_defn = tlm_dict[self.packet] | ||
self._pkt_defn = self.tlm_dict[self.packet_type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JHofman728 Since you are already grabbing the packet definition here, there really should be no need for the new get_packet_lengths()
function below.
|
||
if not self.packet: | ||
msg = 'PacketHandler: No packet name provided in handler config as key "packet"' | ||
if not self.packet_type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please update this field to be packet_name
?
return pickle.dumps((self._pkt_defn.uid, input_data), 2) | ||
|
||
if self._pkt_defn.nbytes != packet.nbytes: | ||
msg = f"PacketHandler: Packet length of packet does not match packet definition." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please rephrase to: "PacketHandler: Packet data length does not match packet definition"
@JimHofman Were you able to successfully run pytest on this branch? |
|
||
if self._pkt_defn.nbytes != packet.nbytes: | ||
msg = f"PacketHandler: Packet data length does not match packet definition." | ||
raise ValueError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JimHofman Could this be an error log message instead of thrown error (same as CCSDS handler)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, will work on pickle error before pushing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the pickle error is coming from the unit tests that test bad packet length. It's is set up by passing a 1552 packet to an Ethernet handler, so it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check doesn't even look valid? You should be checking the length of the received input data not the number of bytes in a packet definition.
Add error handling for PacketHandler and CCSDSPacketHandler for check on the size relative to the configured packet definitions.
Fixes #368