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 Python3-XPC sendDREFs issue #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DisgracedPilot
Copy link

@DisgracedPilot DisgracedPilot commented Nov 11, 2020

Resolves #198, where the Python3 version fails when using sendDREF / sendDREFs for a dataref that requires multiple values. Issue is that the array of dataref values is passed directly into the pack function instead of passing each array element as a separate argument. Solution due to @jamesdunham in the issue comments.

Addresses Issue nasa#198, where the Python3 version fails when using sendDREF / sendDREFs for a dataref that contains multiple values. Solution by jamesdunham.
@DisgracedPilot DisgracedPilot marked this pull request as ready for review November 11, 2020 10:46
@DisgracedPilot DisgracedPilot changed the title Fix Issue #198 Fix Python3-XPC sendDREFs issue Nov 11, 2020
@bgeiger99
Copy link

I came across this issue recently and implemented the same fix with one difference. The second change (Line 316) should be reverted to the original code - in that case, value would not be a list and struct.pack will error trying to unpack a non-iterable.

buffer += struct.pack(fmt.encode(), len(dref), dref.encode(), 1, value) # reverted from *value

@jason-watkins
Copy link
Contributor

Sorry for the long delay. I don't get much time to work on this project anymore. Could either of you explain exactly what this change does? My Python is a little rusty and I'm having trouble evaluating who is correct here.

@bgeiger99
Copy link

bgeiger99 commented Jun 29, 2021

Sure - Line 309 is checking to see if value is a list of values (i.e. [1,2,3..]) or a single number (i.e. 7).

If it is a list of values, Line 313 is executed. The change on Line 313 is correct because *value is the correct way to unpack a list of values into the call to struct.

If value is a single number, Line 315 is executed. Line 315 is not correct because this part of the code expects a single value (just a number, not a list). Therefore, the call to struct should use value instead of *value (because value is just a number and not a list that needs unpacking). Additionally, the argument before value is 1, signifying only a single number is expected.

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.

SendDREF fails in Python when sending a list
3 participants