#!/usr/bin/python

import sys, os
#import serial
    
import mod_globals

os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))

import mod_elm


############## change me ################

ecu_functional_address  = "26" # UCH
mod_globals.opt_port    = 'bt'
#mod_globals.opt_port    = '192.168.0.10:35000'

#mod_globals.opt_demo    = True
mod_globals.opt_speed   = 38400
mod_globals.opt_log     = 'Alarm_lt.txt'

#########################################


print 'Opening ELM'
elm = mod_elm.ELM( mod_globals.opt_port, mod_globals.opt_speed, True ) # open ELM with global vars

print 'Init    ELM'
elm.init_can()

TXa = mod_elm.dnat[ecu_functional_address]
RXa = mod_elm.snat[ecu_functional_address]

print elm.cmd("at sh "+TXa)
print elm.cmd("at cra "+RXa)
print elm.cmd("at fc sh "+TXa)
print elm.cmd("at fc sd 30 00 00") 	# status BS STmin
print elm.cmd("at fc sm 1")
print elm.cmd("at sp 6")
print elm.cmd("10C0")				# Open diag session


# Perimetric Alarm Configuration
# PERIMETRIC_ALARM_CF (Enable alarm on perimeter)
print elm.cmd("3B4600") 				# PERIMETRIC_ALARM_CF WITHOUT
#print elm.cmd("3B4680") 				# PERIMETRIC_ALARM_CF WITH

#  Door lock Configuration
# AUTO_RELOCK_TIMEOUT_CF (Time in minutes to lock again doors when it was not opened)
#print elm.cmd("3B1500") 				# AUTO_RELOCK_TIMEOUT_CF DISABLE
#print elm.cmd("3B1505") 				# AUTO_RELOCK_TIMEOUT_CF 5 minutes
#print elm.cmd("3B150A") 				# AUTO_RELOCK_TIMEOUT_CF 10 minutes

