MAC address of BT in launcher
This commit is contained in:
parent
93982447eb
commit
6238916b25
48
main.py
48
main.py
@ -6,7 +6,7 @@
|
|||||||
##################################
|
##################################
|
||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
# Version: 3.0 (1-Aug-2022) #
|
# Version: 3.1 (2-Jan-2023) #
|
||||||
# Author: Shr-Lnm #
|
# Author: Shr-Lnm #
|
||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
@ -16,7 +16,7 @@ __author__ = "Shr-Lnm"
|
|||||||
__copyright__ = "Copyright 2018-2022"
|
__copyright__ = "Copyright 2018-2022"
|
||||||
__credits__ = []
|
__credits__ = []
|
||||||
# __license__ = "GNU" # Unknown licence!
|
# __license__ = "GNU" # Unknown licence!
|
||||||
__version__ = "3.0.0" # python3 maybe ?
|
__version__ = "3.1.0" # python3 maybe ?
|
||||||
__maintainer__ = "Shr-Lnm"
|
__maintainer__ = "Shr-Lnm"
|
||||||
__email__ = "mshkn@inbox.ru"
|
__email__ = "mshkn@inbox.ru"
|
||||||
__status__ = "Beta"
|
__status__ = "Beta"
|
||||||
@ -26,6 +26,7 @@ import shutil
|
|||||||
from os import listdir
|
from os import listdir
|
||||||
from os.path import isdir
|
from os.path import isdir
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -244,9 +245,17 @@ def run(s, cmd):
|
|||||||
cmdr = __import__('mod_ddt')
|
cmdr = __import__('mod_ddt')
|
||||||
elif cmd == 'term':
|
elif cmd == 'term':
|
||||||
cmdr = __import__('mod_term')
|
cmdr = __import__('mod_term')
|
||||||
|
elif cmd == 'pids':
|
||||||
|
cmdr = __import__('mod_ecu')
|
||||||
|
|
||||||
|
if s.port.upper() == 'BT' or s.port == '':
|
||||||
|
s.port = 'bt'
|
||||||
|
|
||||||
|
if s.port.upper().endswith(';BT'):
|
||||||
|
s.port = s.port.split(';')[0]
|
||||||
|
|
||||||
if s.port.lower() == 'bt' or s.port == '': s.port = 'bt'
|
|
||||||
sys.argv.append('-p' + s.port)
|
sys.argv.append('-p' + s.port)
|
||||||
|
|
||||||
if cmd == 'demo':
|
if cmd == 'demo':
|
||||||
sys.argv.append('--demo')
|
sys.argv.append('--demo')
|
||||||
if cmd == 'scan' and cmd != 'term':
|
if cmd == 'scan' and cmd != 'term':
|
||||||
@ -276,6 +285,8 @@ def run(s, cmd):
|
|||||||
# sys.argv.append('--demo')
|
# sys.argv.append('--demo')
|
||||||
if cmd == 'ddt':
|
if cmd == 'ddt':
|
||||||
sys.argv.append('--demo')
|
sys.argv.append('--demo')
|
||||||
|
# if cmd == 'pids':
|
||||||
|
# sys.argv = [ 'mod_ecu.py', 'ask', s.lang, 'torq']
|
||||||
os.chdir(s.path)
|
os.chdir(s.path)
|
||||||
cmdr.main()
|
cmdr.main()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
@ -903,6 +914,11 @@ else:
|
|||||||
self.droid.fullDismiss()
|
self.droid.fullDismiss()
|
||||||
run(self.save, 'term')
|
run(self.save, 'term')
|
||||||
|
|
||||||
|
def cmd_PIDs(self):
|
||||||
|
self.saveSettings()
|
||||||
|
self.droid.fullDismiss()
|
||||||
|
run(self.save, 'pids')
|
||||||
|
|
||||||
def cmd_Update(self):
|
def cmd_Update(self):
|
||||||
res = update_from_gitlab()
|
res = update_from_gitlab()
|
||||||
if res == 0:
|
if res == 0:
|
||||||
@ -920,7 +936,15 @@ else:
|
|||||||
if self.droid.fullQueryDetail("rb_bt").result['checked'] == 'false':
|
if self.droid.fullQueryDetail("rb_bt").result['checked'] == 'false':
|
||||||
self.save.port = self.droid.fullQueryDetail("in_wifi").result['text']
|
self.save.port = self.droid.fullQueryDetail("in_wifi").result['text']
|
||||||
else:
|
else:
|
||||||
self.save.port = 'BT'
|
portName = self.droid.fullQueryDetail("in_wifi").result['text']
|
||||||
|
upPortName = portName.upper()
|
||||||
|
MAC = ''
|
||||||
|
if re.match (r"^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$", upPortName) or \
|
||||||
|
re.match (r"^[0-9A-F]{4}.[0-9A-F]{4}.[0-9A-F]{4}$", upPortName) or \
|
||||||
|
re.match (r"^[0-9A-F]{12}$", upPortName):
|
||||||
|
upPortName = upPortName.replace(':','').replace('.','')
|
||||||
|
MAC = ':'.join (a + b for a, b in zip (upPortName[::2], upPortName[1::2]))
|
||||||
|
self.save.port = MAC + ';' + 'BT'
|
||||||
|
|
||||||
self.save.speed = '38400'
|
self.save.speed = '38400'
|
||||||
|
|
||||||
@ -984,10 +1008,13 @@ else:
|
|||||||
|
|
||||||
if self.save.port == '':
|
if self.save.port == '':
|
||||||
self.save.port = "192.168.0.10:35000"
|
self.save.port = "192.168.0.10:35000"
|
||||||
if self.save.port.lower() == 'bt':
|
if self.save.port.upper().endswith('BT'):
|
||||||
|
MAC = ""
|
||||||
|
if ';' in self.save.port:
|
||||||
|
MAC = self.save.port.split(';')[0]
|
||||||
self.droid.fullSetProperty("rb_bt", "checked", "true")
|
self.droid.fullSetProperty("rb_bt", "checked", "true")
|
||||||
self.droid.fullSetProperty("rb_wifi", "checked", "false")
|
self.droid.fullSetProperty("rb_wifi", "checked", "false")
|
||||||
self.droid.fullSetProperty("in_wifi", "text", "192.168.0.10:35000")
|
self.droid.fullSetProperty("in_wifi", "text", MAC)
|
||||||
else:
|
else:
|
||||||
self.droid.fullSetProperty("rb_bt", "checked", "false")
|
self.droid.fullSetProperty("rb_bt", "checked", "false")
|
||||||
self.droid.fullSetProperty("rb_wifi", "checked", "true")
|
self.droid.fullSetProperty("rb_wifi", "checked", "true")
|
||||||
@ -1256,6 +1283,13 @@ else:
|
|||||||
android:layout_below="@id/bt_start"
|
android:layout_below="@id/bt_start"
|
||||||
android:layout_toLeftOf="@+id/bt_mon"
|
android:layout_toLeftOf="@+id/bt_mon"
|
||||||
android:text="Macro" />
|
android:text="Macro" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_pids"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/bt_start"
|
||||||
|
android:layout_toLeftOf="@+id/bt_term"
|
||||||
|
android:text="PIDs" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bt_update"
|
android:id="@+id/bt_update"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -1287,6 +1321,8 @@ else:
|
|||||||
self.cmd_Mon()
|
self.cmd_Mon()
|
||||||
elif id == "bt_term":
|
elif id == "bt_term":
|
||||||
self.cmd_Term()
|
self.cmd_Term()
|
||||||
|
elif id == "bt_pids":
|
||||||
|
self.cmd_PIDs()
|
||||||
elif id == "bt_update":
|
elif id == "bt_update":
|
||||||
self.cmd_Update()
|
self.cmd_Update()
|
||||||
|
|
||||||
|
@ -1275,6 +1275,7 @@ def main():
|
|||||||
ecuid = input('Enetr ECU ID:')
|
ecuid = input('Enetr ECU ID:')
|
||||||
lanid = input('Language [RU]:')
|
lanid = input('Language [RU]:')
|
||||||
if len(lanid)<2: lanid = 'RU'
|
if len(lanid)<2: lanid = 'RU'
|
||||||
|
sys.argv = sys.argv[:1]
|
||||||
sys.argv.append(ecuid)
|
sys.argv.append(ecuid)
|
||||||
sys.argv.append(lanid)
|
sys.argv.append(lanid)
|
||||||
sys.argv.append('TORQ')
|
sys.argv.append('TORQ')
|
||||||
@ -1386,8 +1387,11 @@ def main():
|
|||||||
ddd = '82'+F2A[family]+'F1'
|
ddd = '82'+F2A[family]+'F1'
|
||||||
filename = "PR_"+F2A[family]+"_"+eindex+"_"+sys.argv[2]+".csv"
|
filename = "PR_"+F2A[family]+"_"+eindex+"_"+sys.argv[2]+".csv"
|
||||||
|
|
||||||
if mod_globals.os=='android' and os.path.exists('/sdcard/.torque/extendedpids'):
|
ext_path = '/storage/emulated/0/.torque/extendedpids/'
|
||||||
filename = '/sdcard/.torque/extendedpids/'+filename
|
if mod_globals.os=='android':
|
||||||
|
if not os.path.exists(ext_path):
|
||||||
|
os.makedirs( ext_path, exist_ok=True )
|
||||||
|
filename = ext_path+filename
|
||||||
|
|
||||||
cf = open( filename, "w")
|
cf = open( filename, "w")
|
||||||
|
|
||||||
@ -1496,8 +1500,11 @@ def main():
|
|||||||
|
|
||||||
# make profile for torque
|
# make profile for torque
|
||||||
profilename = str(int(time.time()))+'.tdv'
|
profilename = str(int(time.time()))+'.tdv'
|
||||||
if mod_globals.os=='android' and os.path.exists('/sdcard/.torque/vehicles'):
|
veh_path = '/storage/emulated/0/.torque/vehicles/'
|
||||||
profilename = '/sdcard/.torque/vehicles/'+str(int(time.time()))+'.tdv'
|
if mod_globals.os=='android':
|
||||||
|
if not os.path.exists(veh_path):
|
||||||
|
os.makedirs( veh_path, exist_ok=True )
|
||||||
|
profilename = veh_path+str(int(time.time()))+'.tdv'
|
||||||
|
|
||||||
prn = open( profilename, "w")
|
prn = open( profilename, "w")
|
||||||
prn.write( '#This is an ECU profile generated by pyren\n' )
|
prn.write( '#This is an ECU profile generated by pyren\n' )
|
||||||
|
@ -165,9 +165,10 @@ class Port:
|
|||||||
if re.match (r"^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$", upPortName) or \
|
if re.match (r"^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$", upPortName) or \
|
||||||
re.match (r"^[0-9A-F]{4}.[0-9A-F]{4}.[0-9A-F]{4}$", upPortName) or \
|
re.match (r"^[0-9A-F]{4}.[0-9A-F]{4}.[0-9A-F]{4}$", upPortName) or \
|
||||||
re.match (r"^[0-9A-F]{12}$", upPortName):
|
re.match (r"^[0-9A-F]{12}$", upPortName):
|
||||||
MAC = upPortName
|
upPortName = upPortName.replace(':','').replace('.','')
|
||||||
|
MAC = ':'.join (a + b for a, b in zip (upPortName[::2], upPortName[1::2]))
|
||||||
|
|
||||||
if MAC:
|
if mod_globals.os != 'android' and MAC:
|
||||||
try:
|
try:
|
||||||
self.macaddr = portName
|
self.macaddr = portName
|
||||||
self.channel = 1
|
self.channel = 1
|
||||||
@ -1552,11 +1553,13 @@ class ELM:
|
|||||||
|
|
||||||
if responses[0][:1] == '0': # single frame (sf)
|
if responses[0][:1] == '0': # single frame (sf)
|
||||||
nBytes = int(responses[0][1:2], 16)
|
nBytes = int(responses[0][1:2], 16)
|
||||||
|
rspLen = nBytes
|
||||||
nFrames = 1
|
nFrames = 1
|
||||||
result = responses[0][2:2 + nBytes * 2]
|
result = responses[0][2:2 + nBytes * 2]
|
||||||
|
|
||||||
elif responses[0][:1] == '1': # first frame (ff)
|
elif responses[0][:1] == '1': # first frame (ff)
|
||||||
nBytes = int(responses[0][1:4], 16)
|
nBytes = int(responses[0][1:4], 16)
|
||||||
|
rspLen = nBytes
|
||||||
nBytes = nBytes - 6 # we assume that it should be more then 7
|
nBytes = nBytes - 6 # we assume that it should be more then 7
|
||||||
nFrames = 1 + nBytes // 7 + bool(nBytes % 7)
|
nFrames = 1 + nBytes // 7 + bool(nBytes % 7)
|
||||||
cFrame = 1
|
cFrame = 1
|
||||||
@ -1605,7 +1608,7 @@ class ELM:
|
|||||||
|
|
||||||
if noerrors and len(result) // 2 >= nBytes:
|
if noerrors and len(result) // 2 >= nBytes:
|
||||||
# trim padding
|
# trim padding
|
||||||
result = result[:nBytes*2]
|
result = result[:rspLen*2]
|
||||||
# split by bytes and return
|
# split by bytes and return
|
||||||
result = ' '.join(a + b for a, b in zip(result[::2], result[1::2]))
|
result = ' '.join(a + b for a, b in zip(result[::2], result[1::2]))
|
||||||
return result
|
return result
|
||||||
@ -1772,11 +1775,13 @@ class ELM:
|
|||||||
|
|
||||||
if responses[0][:1] == '0': # single frame (sf)
|
if responses[0][:1] == '0': # single frame (sf)
|
||||||
nBytes = int (responses[0][1:2], 16)
|
nBytes = int (responses[0][1:2], 16)
|
||||||
|
rspLen = nBytes
|
||||||
nFrames = 1
|
nFrames = 1
|
||||||
result = responses[0][2:2 + nBytes * 2]
|
result = responses[0][2:2 + nBytes * 2]
|
||||||
|
|
||||||
elif responses[0][:1] == '1': # first frame (ff)
|
elif responses[0][:1] == '1': # first frame (ff)
|
||||||
nBytes = int (responses[0][1:4], 16)
|
nBytes = int (responses[0][1:4], 16)
|
||||||
|
rspLen = nBytes
|
||||||
nBytes = nBytes - 6 # we assume that it should be more then 7
|
nBytes = nBytes - 6 # we assume that it should be more then 7
|
||||||
nFrames = 1 + nBytes//7 + bool(nBytes%7)
|
nFrames = 1 + nBytes//7 + bool(nBytes%7)
|
||||||
cFrame = 1
|
cFrame = 1
|
||||||
@ -1826,7 +1831,7 @@ class ELM:
|
|||||||
|
|
||||||
if len (result) // 2 >= nBytes and noErrors and result[:2] != '7F':
|
if len (result) // 2 >= nBytes and noErrors and result[:2] != '7F':
|
||||||
# trim padding
|
# trim padding
|
||||||
result = result[:nBytes*2]
|
result = result[:rspLen*2]
|
||||||
# split by bytes and return
|
# split by bytes and return
|
||||||
result = ' '.join (a + b for a, b in zip (result[::2], result[1::2]))
|
result = ' '.join (a + b for a, b in zip (result[::2], result[1::2]))
|
||||||
return result
|
return result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user