JohnBrodie / pyjector

Library to help control your projector over a serial connection
MIT License
50 stars 19 forks source link

TypeError: must be str, not bytes #16

Open carstenschroeder opened 5 years ago

carstenschroeder commented 5 years ago

I get the following error:

carsten@ubuntu:~/$ python3 pyjector_test.py 
dict_keys(['computer', 'computer_22', 'component', 'dvi_a', 'dvi_d', 'hdmi', 'hdmi_2', 'composite', 's_video', 'network', 'usb_display', 'usb_reader', 'status'])
ERROR:root:unexpected response to handshake b'>'
Traceback (most recent call last):
  File "pyjector_test.py", line 24, in <module>
    pyjector.source('hdmi')
  File "/home/carsten/home-assistant/lib/python3.6/site-packages/pyjector/pyjector.py", line 298, in handler
    return self._command_handler(command, action)
  File "/home/carsten/home-assistant/lib/python3.6/site-packages/pyjector/pyjector.py", line 255, in _command_handler
    response = self.get_response()
  File "/home/carsten/home-assistant/lib/python3.6/site-packages/pyjector/pyjector.py", line 311, in get_response
    response += self._recv(1)
TypeError: must be str, not bytes

I use the following test script under python 3.6:

from pyjector.pyjector import Pyjector

# Look up what port your projector is connected to, using something
# like `dmesg` if you're on linux.
port = '/dev/ttyUSB0'

# The only valid device id at the moment is `benq`. This is used
# to figure out what commands are supported, and the format needed.
device_id = 'benq'

pyjector = Pyjector(port=port, device_id=device_id)

# Let's check what commands claim to be supported by our device.
#print(pyjector.command_list)

# Let's check the actions associated with each command
#print(pyjector.command_spec)

# Turn the projector on
#pyjector.power('on')
# We need to change the source, which are supported?
print(pyjector.get_actions_for_command('source'))
# Change the source to hdmi-2
pyjector.source('hdmi')