Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions sas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#ser = serial.Serial('/dev/ttyS3','19200', timeout=1) # open first serial port
data_to_sent=[0x01, 0x21, 0x00, 0x00]
#adress=1
#print "OK"
#print "OK
PARYTY_CHANGE = True
meters = dict.fromkeys(('total_cancelled_credits_meter',
'total_in_meter',
'total_out_meter',
Expand Down Expand Up @@ -267,7 +268,19 @@ def start(self):


return True

def __events_port_conf(self):
self.connection.close()
self.connection.parity = serial.PARITY_NONE
self.connection.stopbits = serial.STOPBITS_TWO
self.connection.open()

def __port_conf(self):
self.connection.close()
self.connection.parity = serial.PARITY_SPACE
self.connection.stopbits = serial.STOPBITS_ONE
self.connection.open()

def __send_command( self, command, no_response=False, timeout=3, crc_need=True):
busy = True
response=b''
Expand Down Expand Up @@ -358,6 +371,8 @@ def checkResponse(self, rsp):
## return

def events_poll(self, timeout=1):
if PARYTY_CHANGE == True:
self.__events_port_conf()
event=''
cmd=[0x80+self.adress]
try:
Expand All @@ -372,7 +387,9 @@ def events_poll(self, timeout=1):

except Exception as e:
print e
return None
event = None
if PARYTY_CHANGE == True:
self.__port_conf()
return event


Expand Down