-
-
Save ta0kira/5a675eaa86312fc89b3c to your computer and use it in GitHub Desktop.
A patch to fix issue #4 with pyxid (https://github.com/cedrus-opensource/pyxid/issues/4).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- pyxid/pyxid/internal.py.orig 2013-04-10 11:17:28.540172465 -0400 | |
+++ pyxid/pyxid/internal.py 2013-06-06 11:18:56.113084268 -0400 | |
@@ -126,7 +126,7 @@ | |
def check_for_keypress(self): | |
- response = self.read(6) | |
+ response = self.read(self.__bytes_in_buffer % 6 if (self.__bytes_in_buffer % 6) else 6) | |
response_found = NO_KEY_DETECTED | |
if len(response) > 0: | |
@@ -138,9 +138,10 @@ | |
def xid_input_found(self): | |
input_found = NO_KEY_DETECTED | |
+ input_error = False | |
if self.__bytes_in_buffer >= 6: | |
- last_byte_index = self.__bytes_in_buffer - self.__xid_packet_size | |
+ last_byte_index = (self.__bytes_in_buffer // 6) * 6 - self.__xid_packet_size | |
i = 0 | |
while i <= last_byte_index: | |
@@ -150,6 +151,7 @@ | |
last_byte_index: | |
last_byte_index+6]) | |
except Exception: | |
+ input_error = True | |
i += 1 | |
continue | |
@@ -178,6 +180,10 @@ | |
i += 1 | |
+ if input_error: | |
+ self.__response_buffer = '' | |
+ self.__bytes_in_buffer = 0 | |
+ | |
return input_found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment