From f2f8d9b14593253ce2014f8af9bcc74b21483406 Mon Sep 17 00:00:00 2001 From: Grigor Kolev Date: Mon, 4 Mar 2024 14:51:47 +0200 Subject: [PATCH 1/2] Update sas.py Returns event only once or 'No Activity'. Not tested in a real casino. FIX: flush becomes flush_hard. Using flush is recommended because not all hardware supports flush_hard --- sas.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sas.py b/sas.py index eb39b0a..ac1bec1 100644 --- a/sas.py +++ b/sas.py @@ -55,6 +55,7 @@ def __init__( # Init the Logging system self.log = log_to_stderr() self.log.setLevel(logging.getLevelName(debug_level)) + self.last_gpoll_event = None # Open the serial connection while 1: @@ -80,8 +81,16 @@ def __init__( def is_open(self): return self.connection.is_open - + def flush(self): + try: + if self.is_open() == False: + self.open() + self.connection.flush() + except Exception as e: + self.log.error(e, exc_info=True) + + def flush_hard(self): """Flush the serial buffer in input and output""" try: if not self.is_open(): @@ -241,6 +250,10 @@ def events_poll(self): raise EMGGpollBadResponse except Exception as e: raise e + if self.last_gpoll_event != event: + self.last_gpoll_event = event + else: + event = 'No activity' return event def shutdown(self): From b88cfdafc0a8a82fb5b8cc1ae69a8dd3298b3825 Mon Sep 17 00:00:00 2001 From: Grigor Kolev Date: Mon, 4 Mar 2024 14:57:15 +0200 Subject: [PATCH 2/2] Update sas.py Remove self.close() from flush_hard() --- sas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sas.py b/sas.py index ac1bec1..dac2fd7 100644 --- a/sas.py +++ b/sas.py @@ -100,7 +100,7 @@ def flush_hard(self): except Exception as e: self.log.error(e, exc_info=True) - self.close() + #self.close() def start(self): """Warm Up the connection to the VLT"""