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

Feature/G9_Driver #16

Draft
wants to merge 122 commits into
base: develop
Choose a base branch
from
Draft

Feature/G9_Driver #16

wants to merge 122 commits into from

Conversation

mslaffin
Copy link
Collaborator

Opening this for discussion of initial work on G9 driver code.

@mslaffin
Copy link
Collaborator Author

Looks like calculate_checksum included an extra end byte that may have caused an off-by-one problem. I had all tests passing after stripping off the old invalid checksums from the saved msg data and re-adding it using the fixed method.

(venv) PS C:\Users\Admin\EBEAM_dashboard> python -m unittest .\instrumentctl\errorTests.py -v
test_checksum_validation (instrumentctl.errorTests.TestG9Driver.test_checksum_validation) ... ok
test_input_error (instrumentctl.errorTests.TestG9Driver.test_input_error) ... ok
test_invalid_length (instrumentctl.errorTests.TestG9Driver.test_invalid_length) ... ok
test_invalid_start_byte (instrumentctl.errorTests.TestG9Driver.test_invalid_start_byte) ... ok
test_no_error (instrumentctl.errorTests.TestG9Driver.test_no_error) ... ok
test_output_error (instrumentctl.errorTests.TestG9Driver.test_output_error) ... ok
test_unit_state_error (instrumentctl.errorTests.TestG9Driver.test_unit_state_error) ... ok

----------------------------------------------------------------------
Ran 7 tests in 0.010s

OK

Comment on lines +25 to +31
def handle_errors(self, data):
try:
response = g9_driv.read_response()
return {"status":"passes", "message":"No errors thrown at this time."}

except ValueError as e:
return {"status":"error", "message":str(e)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is being defined outside the class (self makes no sense as a param) and not used. I think this should be deleted and implement error handling directly in update_data

def update_interlock(self, name, safety, data):
# means good
if safety & data == 1:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think there's an issue with this logic here. The == operator has higher precedence than & so this is evaluated as safety & (data == 1) not (safety & data) == 1 (which is how I think it should be)

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.

5 participants