Skip to content

Commit 7dcd0bb

Browse files
fix: flush becomes flush_hard
- 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
2 parents 4e213e6 + b88cfda commit 7dcd0bb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sas.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
# Init the Logging system
5858
self.log = log_to_stderr()
5959
self.log.setLevel(logging.getLevelName(debug_level))
60+
self.last_gpoll_event = None
6061

6162
# Open the serial connection
6263
while 1:
@@ -82,8 +83,16 @@ def __init__(
8283

8384
def is_open(self):
8485
return self.connection.is_open
85-
86+
8687
def flush(self):
88+
try:
89+
if self.is_open() == False:
90+
self.open()
91+
self.connection.flush()
92+
except Exception as e:
93+
self.log.error(e, exc_info=True)
94+
95+
def flush_hard(self):
8796
"""Flush the serial buffer in input and output"""
8897
try:
8998
if not self.is_open():
@@ -93,7 +102,7 @@ def flush(self):
93102
except Exception as e:
94103
self.log.error(e, exc_info=True)
95104

96-
self.close()
105+
#self.close()
97106

98107
def start(self):
99108
"""Warm Up the connection to the VLT"""
@@ -242,6 +251,10 @@ def events_poll(self):
242251
raise EMGGpollBadResponse
243252
except Exception as e:
244253
raise e
254+
if self.last_gpoll_event != event:
255+
self.last_gpoll_event = event
256+
else:
257+
event = 'No activity'
245258
return event
246259

247260
def shutdown(self):

0 commit comments

Comments
 (0)