-
Notifications
You must be signed in to change notification settings - Fork 32
Issue #368: Bad packet size handling in built-in server handlers #456
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
180aa55
cedc7cb
ec2ebab
921b1ad
4e12180
e58e893
613da40
4aca498
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,27 +19,30 @@ def __init__(self, input_type=None, output_type=None, **kwargs): | |
| If packet is specified but not present in default tlm dict. | ||
| """ | ||
| super(PacketHandler, self).__init__(input_type, output_type) | ||
| self.packet = kwargs.get("packet", None) | ||
| self.packet_name = kwargs.get("packet", None) | ||
| self.tlm_dict = tlm.getDefaultDict() | ||
|
|
||
| if not self.packet: | ||
| msg = 'PacketHandler: No packet name provided in handler config as key "packet"' | ||
| if not self.packet_name: | ||
| msg = f'PacketHandler: No packet type provided in handler config as key "packet"' | ||
| raise ValueError(msg) | ||
|
|
||
| tlm_dict = tlm.getDefaultDict() | ||
| if self.packet not in tlm_dict: | ||
| msg = "PacketHandler: Packet name {} not present in telemetry dictionary".format( | ||
| self.packet | ||
| ) | ||
| msg += " Available packet types are {}".format(tlm_dict.keys()) | ||
| if self.packet_name not in self.tlm_dict: | ||
| msg = f"PacketHandler: Packet name '{self.packet_name}' not present in telemetry dictionary." | ||
| msg += f" Available packet types are {self.tlm_dict.keys()}" | ||
| raise ValueError(msg) | ||
|
|
||
| self._pkt_defn = tlm_dict[self.packet] | ||
| self._pkt_defn = self.tlm_dict[self.packet_name] | ||
|
|
||
| def handle(self, input_data): | ||
| def handle(self, packet): | ||
| """ | ||
| Params: | ||
| input_data: message received by stream | ||
| packet: message received by stream (packet) | ||
| Returns: | ||
| tuple of packet UID and message received by stream | ||
| """ | ||
| return pickle.dumps((self._pkt_defn.uid, input_data), 2) | ||
|
|
||
| if self._pkt_defn.nbytes != packet.nbytes: | ||
| msg = f"PacketHandler: Packet data length does not match packet definition." | ||
| raise ValueError(msg) | ||
|
||
|
|
||
| return pickle.dumps((self._pkt_defn.uid, packet), 2) | ||
Uh oh!
There was an error while loading. Please reload this page.