Skip to content

Commit

Permalink
fix: flush becomes flush_hard
Browse files Browse the repository at this point in the history
- Remove self.close() from flush_hard()
- Returns event only once or 'No Activity'.
- Not tested in a real casino.
- flush becomes flush_hard.
- using flush is recommended because not all hardware supports flush_hard
  • Loading branch information
well-it-wasnt-me authored Mar 4, 2024
2 parents 4e213e6 + b88cfda commit 7dcd0bb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sas.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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:
Expand All @@ -82,8 +83,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():
Expand All @@ -93,7 +102,7 @@ def flush(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"""
Expand Down Expand Up @@ -242,6 +251,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):
Expand Down

0 comments on commit 7dcd0bb

Please sign in to comment.