From 9774618d377f0f9af8bc94635c947672677b9a69 Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Sun, 28 Feb 2016 02:26:38 -0800 Subject: [PATCH 1/2] Bugfix 1550891 - non-standard class reply from projector --- openlp/core/lib/projector/pjlink1.py | 10 +++++++++- .../openlp_core_lib/test_projector_pjlink1.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index 5feda33f4..3a99dd7da 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -665,7 +665,15 @@ class PJLink1(QTcpSocket): :param data: Class that projector supports. """ - self.pjlink_class = data + # bug 1550891: Projector returns non-standard class response: + # : Expected: %1CLSS=1 + # : Received: %1CLSS=Class 1 + if len(data) > 1: + # Split non-standard information from response + clss = data.split()[-1] + else: + clss = data + self.pjlink_class = clss log.debug('(%s) Setting pjlink_class for this projector to "%s"' % (self.ip, self.pjlink_class)) return diff --git a/tests/functional/openlp_core_lib/test_projector_pjlink1.py b/tests/functional/openlp_core_lib/test_projector_pjlink1.py index 92ce02acd..067818957 100644 --- a/tests/functional/openlp_core_lib/test_projector_pjlink1.py +++ b/tests/functional/openlp_core_lib/test_projector_pjlink1.py @@ -60,3 +60,17 @@ class TestPJLink(TestCase): "Connection request should have been called with TEST_SALT")) self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN, "Connection request should have been called with TEST_PIN")) + + def non_standard_class_reply_test(self): + """ + bugfix 1550891 - CLSS request returns non-standard 'Class N' reply + """ + # GIVEN: Test object + pjlink = pjlink_test + + # WHEN: Process non-standard reply + pjlink.process_clss('Class 1') + + # THEN: Projector class should be set with proper value + self.assertEquals(pjlink.pjlink_class, '1', + 'Non-standard class reply should have set proper class') From 7c23941f359f1a6a6ca49019a639ddd54f8c0533 Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Sun, 28 Feb 2016 04:35:15 -0800 Subject: [PATCH 2/2] Fix sending unicode string when expecting ascii (binary) data --- openlp/core/lib/projector/pjlink1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index 3a99dd7da..c5c765d62 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -515,7 +515,7 @@ class PJLink1(QTcpSocket): self.socket_timer.start() try: self.projectorNetwork.emit(S_NETWORK_SENDING) - sent = self.write(out) + sent = self.write(out.encode('ascii')) self.waitForBytesWritten(2000) # 2 seconds should be enough if sent == -1: # Network error?