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

Commit fd728d0

Browse files
committed
Add a way to send responses to individual commands
This will allow commands to send one-off replies without neeing to pollute the global board 'status' with command-specific response information.
1 parent b591612 commit fd728d0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

robotd/master.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ def _send_board_status(self, connection):
115115
print('Sending board status:', board_status)
116116
connection.send(board_status)
117117

118+
def _send_command_response(self, connection, response):
119+
message = {'response': response}
120+
print('Sending command response:', message)
121+
connection.send(message)
122+
118123
def run(self):
119124
"""
120125
Control this board.
@@ -169,7 +174,9 @@ def run(self):
169174
continue
170175

171176
if command != {}:
172-
self.board.command(command)
177+
response = self.board.command(command)
178+
if response is not None:
179+
self._send_command_response(connection, response)
173180

174181
self._send_board_status(connection)
175182

0 commit comments

Comments
 (0)