#!/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

#mod_globals.opt_demo    = True

ecu_functional_address  = "51"

mod_globals.opt_port    = 'bt'
#mod_globals.opt_port    = '192.168.0.10:35000'
mod_globals.opt_speed   = 38400
mod_globals.opt_log     = 'lang_tdb.txt'


print 'Opening ELM'
elm = mod_elm.ELM( 'bt', 38400, True )
#elm = mod_elm.ELM( '192.168.0.10:35000', 38400, True )

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")
#print elm.cmd("2E010170") # Turce
print elm.cmd("2E01019E") # Russian
#print elm.cmd("2E010110") # English
#print elm.cmd("2E010100") # Francias
print elm.cmd("1103") # reboot