Rammbock
Rammbock copied to clipboard
new_protocol has no way to set endianess
In the function new_protocol
def new_protocol(self, protocol_name):
"""Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template.
"""
if self._protocol_in_progress:
raise Exception('Can not start a new protocol definition in middle of old.')
if protocol_name in self._protocols:
raise Exception('Protocol %s already defined' % protocol_name)
self._init_new_message_stack(Protocol(protocol_name, library=self))
self._protocol_in_progress = True
The line self._init_new_message_stack(Protocol(protocol_name, library=self))
gives no option to set the Protocol constructor option for little_endian
. Neither does the new_protocol
method.
So, there does not seem to be a way to use the robot api, and have this little_endian feature. It would be very useful if the endian setting could be set from the robot api.
At least, that's how it looks to me atm.
Thanks for reviewing this issue.
Cheers, Matt
So, I tried my fix and change the method to the following:
def new_protocol(self, protocol_name, little_endian=False):
"""Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template.
"""
if self._protocol_in_progress:
raise Exception('Can not start a new protocol definition in middle of old.')
if protocol_name in self._protocols:
raise Exception('Protocol %s already defined' % protocol_name)
self._init_new_message_stack(Protocol(protocol_name, little_endian, library=self))
self._protocol_in_progress = True
This maintains backward compatibility and appears to fix the issue I was having. My server now appears to be getting bytes in the correct order. (pending further testing)
I can now write this:
New protocol myProtocol True
which will turn on the little_endian feature.
Would be awesome if you could apply this to your great library.
Thanks, Matt
Yeah, the endiannes thing was usable only by extending the base library. (It has been used like that)
Thanks for the pull request, I will try to review it soon. I havent had time to look at this library for a long time... :(