Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Add support for generic arduino commands #55

Merged
merged 7 commits into from
Feb 1, 2018

Conversation

PeterJCLaw
Copy link
Contributor

This adds a new direct_command method which takes in a command as a list of JSON-encodable entities and passes that to robotd. It expects to immediately get back a response message (as well as the usual status blob) which contains either valid data from the arduino or a description of the failure.

This includes a novel testing approach which:

  • creates a valid robotd Board instance
  • mocks the underlying serial connection
  • creates a robot-api Board instance
  • mocks the socket connecting the robot-api Board such that it
    connects to the robotd Board instance

This avoids real sockets and multiprocessing, both of which incur substantial overhead during tests along with the introduction of timeouts (which is just nasty).

This relies on sourcebots/robotd#35.

We take in a command as a list of JSON-encodable entities and
pass that to robotd. We expect to immediately get back a response
message (as well as the usual status blob) which contains either
valid data from the arduino or a description of the failure.

This includes a novel testing approach which:
- creates a valid robotd Board instance
- mocks the underlying serial connection
- creates a robot-api Board instance
- mocks the socket connecting the robot-api Board such that it
  connects to the robotd Board instance

This avoids real sockets and multiprocessing, both of which incur
substantial overhead during tests along with the introduction of
timeouts (which is just nasty).
@PeterJCLaw
Copy link
Contributor Author

The test failure on the CI is due to sourcebots/robotd#35 not being available in that test environment.

@RealOrangeOne
Copy link
Member

I'm liking this use of fake sockets, hopefully these changes can be backported into the remainder of the tests (separate PR) to reduce the oddness they bring

@PeterJCLaw
Copy link
Contributor Author

@RealOrangeOne indeed, I've some thoughts -> #57

for cls in (CommandError, InvalidResponse):
if cls.__name__ == response['type']:
raise cls(response['description'])

Copy link
Member

Choose a reason for hiding this comment

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

What happens if we receive a response with an invalid type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point; I'll make that error harder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kierdavis
Copy link
Member

After testing on a kit last night I'm confident this works as intended. I would be grateful if the conflicts could be resolved before I approve.

@PeterJCLaw
Copy link
Contributor Author

@kierdavis conflicts resolved; please could you take another look?

@kierdavis kierdavis merged commit d7f7ebe into sourcebots:master Feb 1, 2018
@PeterJCLaw PeterJCLaw deleted the generic-arduino-commands branch February 2, 2018 01:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants