Implemented debugging commands
This commit is contained in:
parent
3b60d7511e
commit
1fc554ae25
2 changed files with 19 additions and 11 deletions
|
@ -1,2 +1,9 @@
|
||||||
# pizzabox-mc
|
# pizzabox-mc
|
||||||
Python software for controlling a mobile interactive artwork for "Invisible Cities"
|
Python software for controlling a mobile interactive artwork for "Invisible Cities"
|
||||||
|
|
||||||
|
# Deployment (Testing)
|
||||||
|
|
||||||
|
Terminal command
|
||||||
|
|
||||||
|
[…]pizzabox-main$ scp pizzactrl/*.py pi@10.10.0.23:/home/pi/pizzabox-main/pizzactrl/
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,9 @@ class SerialCommands(Enum):
|
||||||
RECORD = b'C'
|
RECORD = b'C'
|
||||||
REWIND = b'R'
|
REWIND = b'R'
|
||||||
|
|
||||||
|
DEBUG_SCROLL = b'S'
|
||||||
|
DEBUG_SENSORS = b'Z'
|
||||||
|
|
||||||
EOT = b'\n'
|
EOT = b'\n'
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,24 +89,22 @@ class PizzaHAL:
|
||||||
resp = self.serialcon.read_until()
|
resp = self.serialcon.read_until()
|
||||||
if resp == (SerialCommands.HELLO.value + SerialCommands.EOT.value):
|
if resp == (SerialCommands.HELLO.value + SerialCommands.EOT.value):
|
||||||
self.serialcon.write(SerialCommands.ALREADY_CONNECTED.value + SerialCommands.EOT.value)
|
self.serialcon.write(SerialCommands.ALREADY_CONNECTED.value + SerialCommands.EOT.value)
|
||||||
elif resp == (SerialCommands.ALREADY_CONNECTED.value + SerialCommands.EOT.value):
|
|
||||||
logger.warn('Serial Connection received ALREADY CONNECTED as response to HELLO. Assuming connection ok.')
|
|
||||||
self.connected = True
|
|
||||||
return
|
|
||||||
elif resp == b'':
|
|
||||||
raise SerialCommunicationError('Timeout on initializing connection.')
|
|
||||||
else:
|
|
||||||
raise SerialCommunicationError(f'Serial Connection received invalid response to HELLO: {resp}')
|
|
||||||
resp = self.serialcon.read_until()
|
resp = self.serialcon.read_until()
|
||||||
if resp == (SerialCommands.ALREADY_CONNECTED.value + SerialCommands.EOT.value):
|
if resp == (SerialCommands.ALREADY_CONNECTED.value + SerialCommands.EOT.value):
|
||||||
self.connected == True
|
|
||||||
logger.info('Serial Connection established')
|
logger.info('Serial Connection established')
|
||||||
elif resp == b'':
|
elif resp == b'':
|
||||||
raise SerialCommunicationError('Timeout on initializing connection.')
|
raise SerialCommunicationError('Timeout on initializing connection.')
|
||||||
else:
|
else:
|
||||||
raise SerialCommunicationError(f'Serial Connection received invalid response to ALREADY CONNECTED: {resp}')
|
raise SerialCommunicationError(f'Serial Connection received invalid response to ALREADY CONNECTED: {resp}')
|
||||||
|
elif resp == (SerialCommands.ALREADY_CONNECTED.value + SerialCommands.EOT.value):
|
||||||
|
logger.warn('Serial Connection received ALREADY CONNECTED as response to HELLO. Assuming connection ok.')
|
||||||
|
elif resp == b'':
|
||||||
|
raise SerialCommunicationError('Timeout on initializing connection.')
|
||||||
|
else:
|
||||||
|
raise SerialCommunicationError(f'Serial Connection received invalid response to HELLO: {resp}')
|
||||||
|
self.connected = True
|
||||||
|
|
||||||
def send_cmd(self, command: SerialCommands, *options: bytes):
|
def send_cmd(self, command: SerialCommands, *options):
|
||||||
"""
|
"""
|
||||||
Send a command and optional options. Options need to be encoded as bytes before passing.
|
Send a command and optional options. Options need to be encoded as bytes before passing.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue