Skip to content
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

fix fragment bug #316

Merged
merged 10 commits into from
Jan 15, 2018
Merged

fix fragment bug #316

merged 10 commits into from
Jan 15, 2018

Conversation

WH-0501
Copy link
Contributor

@WH-0501 WH-0501 commented Jan 11, 2018

This PR fix the 的fragment bug while using the rosbridge_library/test/experimental/fragmentation+srv+tcp test.

First, self.received_fragments[msg_id]["fragment_list"] in defragmentation.py has type dict, but dict doesn't support slice.

Second, response_object in test_non-ros_service_server_fragmented.py doesn't has 'service' field, and the ‘data’ field should be 'values'

"id": request_object["id"],
"data": service_response_data # put service response in "data"-field of response object (in this case it's twice "data", because response value is also named data (in srv-file)
"values": service_response_data # put service response in "data"-field of response object (in this case it's twice "data", because response value is also named data (in srv-file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this comment need to be updated to refer to the new field name "values"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modifed is to repair service_response message error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I resubmit it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WH-0501 You can just add the changes we've requested to the branch you created your Pull Request from, then push to it. The Pull Request will be updated automatically, no need to make a new one :)

@@ -169,7 +169,12 @@ def defragment(self, message):
self.protocol.log("debug", log_msg)

# Reconstruct the message
reconstructed_msg = ''.join(self.received_fragments[msg_id]["fragment_list"][0:message["total"]])
print(type(self.received_fragments[msg_id]["fragment_list"]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

@@ -169,7 +169,12 @@ def defragment(self, message):
self.protocol.log("debug", log_msg)

# Reconstruct the message
reconstructed_msg = ''.join(self.received_fragments[msg_id]["fragment_list"][0:message["total"]])
print(type(self.received_fragments[msg_id]["fragment_list"]))
#reconstructed_msg = ''.join(self.received_fragments[msg_id]["fragment_list"][0:message["total"]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented code

print(type(self.received_fragments[msg_id]["fragment_list"]))
#reconstructed_msg = ''.join(self.received_fragments[msg_id]["fragment_list"][0:message["total"]])
reconstructed_msg = ''
for key,value in self.received_fragments[msg_id]["fragment_list"].items():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You're not checking the size bound from the message (msg['total']) any more
  2. Please change your code back to use ''.join(), as it's significantly faster (see https://waymoot.org/home/python_string/ )

@WH-0501
Copy link
Contributor Author

WH-0501 commented Jan 15, 2018

@T045T, Thanks. How about this change?

Copy link
Contributor

@T045T T045T left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@@ -56,7 +56,8 @@ def calculate_service_response(request):

response_object = { "op": "service_response",
"id": request_object["id"],
"data": service_response_data # put service response in "data"-field of response object (in this case it's twice "data", because response value is also named data (in srv-file)
"service": service_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the indentation in the merge commit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants