Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions hdmi_matrix_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def _generate_cmd(cmd_code, arg1=0, arg2=0):
data[2] = arg2
cmd = _CMD_HEADER + cmd_code + data
HdmiMatrixController._append_checksum(cmd)
return ''.join(chr(c) for c in cmd)
serial.iterbytes(cmd)
return cmd

@staticmethod
def _append_checksum(cmd):
Expand Down Expand Up @@ -336,13 +337,11 @@ def _send_cmd(self, cmd):
HdmiMatrixControllerException: Error writing to serial.
"""
try:
logging.debug('Sending cmd: %s.',
' '.join(c.encode('hex') for c in cmd))
logging.debug('Sending cmd: %s.',' '.join(hex(c) for c in cmd))
self._ser.write(cmd)
except (serial.SerialException, serial.SerialTimeoutException) as exception:
logging.error('Error writing to serial: %s', str(exception))
raise HdmiMatrixControllerException(exception, 'Error writing to serial.')

def _receive_response(self):
"""Reads and validates a response.

Expand Down
Binary file added hdmi_matrix_controller.pyc
Binary file not shown.
14 changes: 14 additions & 0 deletions setport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import serial
import sys

import hdmi_matrix_controller

BAUD_RATE = 19200
TIMEOUT = 10

serial_dev = serial.Serial('/dev/ttyUSB1', baudrate=BAUD_RATE, timeout=TIMEOUT)
controller = hdmi_matrix_controller.HdmiMatrixController(serial_dev)

#controller.set_beep(0)
controller.change_port(int(sys.argv[1:][0]), int(sys.argv[1:][1]))
print("Done")