Compare commits
7 Commits
pyren3
...
cfc1_audio
Author | SHA1 | Date | |
---|---|---|---|
|
038ba98ddf | ||
|
e55bc086f8 | ||
|
63b378d483 | ||
|
35e0bf9045 | ||
|
ba6ad18559 | ||
|
c8a91e9236 | ||
|
f187661e1c |
@ -23,7 +23,7 @@ init_can {
|
||||
at l0
|
||||
at al
|
||||
at caf0
|
||||
at cfc0
|
||||
at cfc1
|
||||
at sh $txa
|
||||
at cra $rxa
|
||||
at fc sh $txa
|
||||
@ -47,7 +47,9 @@ can500 {
|
||||
init_can
|
||||
at st ff
|
||||
at at 0
|
||||
at sp 6
|
||||
STP 53
|
||||
STPBR 500000
|
||||
STI
|
||||
at at 1
|
||||
$prompt = CAN500
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ delay 2
|
||||
# open session
|
||||
10C0
|
||||
|
||||
#Radio reception
|
||||
2E2B2D00011E1422241A14280D0A081F0F020206020408300301010001001430121220121400800100640A050F011402080A043C0F0F140F321E3250050F0009120A8CE10A5A5A0384300101063C961401C80000050000000100000000
|
||||
|
||||
#Phone acoustic parameters
|
||||
2E2B250101705AC7400401701800029402950064E0A00073C0003333030B00005AA10000000810082E2D38DD6A86000000000FFF00310004B0239C31E6E0B775239C6798E6E039961F941E0E3D36B70CD6A096531E0E76B1FF80B76A37F6CA7D3EB7412E37F6403B070461FD7F40FFFF07043B0061FD900000000000000502950000747EC3402C00CCCC0003027F8DCEFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
@ -17,7 +20,17 @@ delay 2
|
||||
#Accoustic Whole car
|
||||
2E2B2C3E9B522F0001FFFAFDDA0164FE002C973E9B511E0001FFF4FDD302CCFC00164C00003E9B732D0001FFF4FE7803E0FE002C973E9B5B490001FFECFE1104FFFC00164C0000000040000001000000004000C0004000000040000001000000004000C0004000000040000001000000004000C0004000000040000001000000004000C00040000000400040000001000000004000C0004000400040000001000000004000C0004000400040000001000000004000C0004000400040000001000000004000C000400000002D43400000010000FFE9006FFF8021043FE8400000010000FFD200EFFF0014F63FDA40000001FFFFFFB5018EFE001C223FBE400000010044FF7D0044FF8041C23F0140000001FFE2FE1507A1F80024513DB440000001FF88FBBE0D0EF00024C900003D5B40000001FE33FB362B9EE000182B3DD740000001FEB6FC2E262BC0000EC836A140000001F0F8F1D166ABC0001F234F8C400000010BC6FC463076E000547B3FE440000001004BFFCB0122FF005FD73FE640000001FFFFFFCE03B8FE0017BE00002C4740000001000000004000C00040003FEC400000010000FFD90167FF00166C3FF5400000010000FFEC0052FF8017093DC940000001FF98FBD30BC3F0001CFF00003DB040000001FEE1FBA01F18F0001B043E1040000001FED3FC6B26CAE00013293FBE400000010044FF7D0044FF8041C23B1940000001F81BF7B36709B0000FB900000600060006000600200000000001000020000000000100002000000000010000200000000001000000000000003F00000000003F16A700000001000016A7000000010000
|
||||
|
||||
#Radio reception
|
||||
2E2B2D00011E1422241A14280D0A081F0F020206020408300301010001001430121220121400800100640A050F011402080A043C0F0F140F321E3250050F0009120A8CE10A5A5A0384300101063C961401C80000050000000100000000
|
||||
delay 8
|
||||
# open session
|
||||
10C0
|
||||
|
||||
delay 2
|
||||
# open session
|
||||
10C0
|
||||
|
||||
222B2D
|
||||
222B25
|
||||
222B2B
|
||||
222B2C
|
||||
|
||||
exit
|
||||
|
127
pyren/mod_elm.py
127
pyren/mod_elm.py
@ -1198,7 +1198,10 @@ class ELM:
|
||||
if self.ATCFC0:
|
||||
return self.send_can_cfc0 (command)
|
||||
else:
|
||||
rsp = self.send_can (command)
|
||||
if mod_globals.opt_obdlink:
|
||||
rsp = self.send_can_cfc(command)
|
||||
else:
|
||||
rsp = self.send_can (command)
|
||||
if self.error_frame > 0 or self.error_bufferfull > 0: # then fallback to cfc0
|
||||
self.ATCFC0 = True
|
||||
self.cmd ("at cfc0")
|
||||
@ -1343,6 +1346,7 @@ class ELM:
|
||||
def send_can_cfc(self, command):
|
||||
|
||||
command = command.strip().replace(' ', '').upper()
|
||||
uncutCommand = command
|
||||
|
||||
if len(command) == 0:
|
||||
return
|
||||
@ -1374,32 +1378,46 @@ class ELM:
|
||||
ST = 0 # Frame Interval
|
||||
Fc = 0 # Current frame
|
||||
Fn = len(raw_command) # Number of frames
|
||||
frsp = ''
|
||||
|
||||
if Fn > 1:
|
||||
self.send_raw('at cfc1')
|
||||
# if Fn > 1:
|
||||
# self.send_raw('at cfc1')
|
||||
# print 'cfc1', raw_command
|
||||
|
||||
while Fc < Fn:
|
||||
if raw_command[Fc].startswith('0'):
|
||||
if uncutCommand in self.l1_cache.keys():
|
||||
frsp = self.send_raw (raw_command[Fc] + self.l1_cache[uncutCommand]) # we'll get only 1 frame: fc, ff or sf
|
||||
else:
|
||||
frsp = self.send_raw (raw_command[Fc])
|
||||
|
||||
if Fn > 1 and (Fn - Fc) == 1:
|
||||
self.send_raw('at cfc0')
|
||||
# print 'cfc0:', Fn, Fc
|
||||
if raw_command[Fc].startswith('1'):
|
||||
frsp = self.send_raw (raw_command[Fc] + '1')
|
||||
|
||||
while Fc < Fn:
|
||||
# if Fn > 1 and (Fn - Fc) == 1:
|
||||
# self.send_raw('at cfc0')
|
||||
# # print 'cfc0:', Fn, Fc
|
||||
|
||||
# enable responses
|
||||
frsp = ''
|
||||
if not self.ATR1:
|
||||
frsp = self.send_raw('at r1')
|
||||
self.ATR1 = True
|
||||
|
||||
# if not self.ATR1:
|
||||
# frsp = self.send_raw('at r1')
|
||||
# self.ATR1 = True
|
||||
|
||||
tb = time.time() # time of sending (ff)
|
||||
|
||||
if len (raw_command[Fc]) == 16:
|
||||
frsp = self.send_raw (raw_command[Fc])
|
||||
else:
|
||||
frsp = self.send_raw (raw_command[Fc] + '1') # we'll get only 1 frame: fc, ff or sf
|
||||
# if len (raw_command[Fc]) == 16:
|
||||
# frsp = self.send_raw (raw_command[Fc])
|
||||
# else:
|
||||
# frsp = self.send_raw (raw_command[Fc] + '1') # we'll get only 1 frame: fc, ff or sf
|
||||
|
||||
frsp = self.send_raw(raw_command[Fc])
|
||||
Fc = Fc + 1
|
||||
# if raw_command[Fc].startswith('0'):
|
||||
# frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ', R:' + l1_cache[command]) # we'll get only 1 frame: fc, ff or sf
|
||||
# if raw_command[Fc].startswith('1'):
|
||||
# frsp = self.send_raw (raw_command[Fc] + '1')
|
||||
|
||||
if raw_command[Fc][:1] != '2':
|
||||
Fc = Fc + 1
|
||||
|
||||
# analyse response
|
||||
for s in frsp.split('\n'):
|
||||
@ -1433,38 +1451,61 @@ class ELM:
|
||||
continue
|
||||
|
||||
# sending consequent frames according to FlowControl
|
||||
|
||||
cf = min({BS - 1, (Fn - Fc) - 1}) # number of frames to send without response
|
||||
frames_left = (Fn - Fc)
|
||||
cf = min({BS, frames_left}) # number of frames to send without response
|
||||
|
||||
# disable responses
|
||||
if cf > 0:
|
||||
if self.ATR1:
|
||||
frsp = self.send_raw('at r0')
|
||||
self.ATR1 = False
|
||||
# if cf > 0:
|
||||
# if self.ATR1:
|
||||
# frsp = self.send_raw('at r0')
|
||||
# self.ATR1 = False
|
||||
|
||||
while cf > 0:
|
||||
cf = cf - 1
|
||||
burstSizeCommand = ''
|
||||
for f in range(0, cf):
|
||||
burstSizeCommand += raw_command[Fc + f]
|
||||
|
||||
if burstSizeCommand.endswith(raw_command[-1]):
|
||||
if uncutCommand in self.l1_cache.keys():
|
||||
burstSizeCommandRequest = burstSizeCommand + self.l1_cache[uncutCommand]
|
||||
else:
|
||||
burstSizeCommandRequest = burstSizeCommand
|
||||
else:
|
||||
burstSizeCommandRequest = burstSizeCommand + "1"
|
||||
|
||||
# Ensure time gap between frames according to FlowControl
|
||||
tc = time.time() # current time
|
||||
if (tc - tb) * 1000. < ST:
|
||||
time.sleep(ST / 1000. - (tc - tb))
|
||||
target_time = time.clock() + (ST / 1000. - (tc - tb))
|
||||
while time.clock() < target_time:
|
||||
pass
|
||||
tb = tc
|
||||
|
||||
frsp = self.send_raw(raw_command[Fc])
|
||||
Fc = Fc + 1
|
||||
frsp = self.send_raw(burstSizeCommandRequest)
|
||||
Fc = Fc + cf
|
||||
cf = 0
|
||||
if burstSizeCommand.endswith(raw_command[-1]):
|
||||
for s in frsp.split('\n'):
|
||||
if s.strip()[:len(raw_command[Fc - 1])] == raw_command[Fc - 1]: # echo cancelation
|
||||
continue
|
||||
else:
|
||||
responses.append(s)
|
||||
continue
|
||||
|
||||
# now we are going to receive data. st or ff should be in responses[0]
|
||||
if len(responses) != 1:
|
||||
# if len(responses) != 1:
|
||||
# print "Something went wrong. len responces != 1"
|
||||
return "WRONG RESPONSE"
|
||||
# return "WRONG RESPONSE"
|
||||
|
||||
result = ""
|
||||
noErrors = True
|
||||
noerrors = True
|
||||
cFrame = 0 # frame counter
|
||||
nBytes = 0 # number bytes in response
|
||||
nFrames = 0 # numer frames in response
|
||||
|
||||
if len (responses) == 0: # no data in response
|
||||
return ""
|
||||
|
||||
if responses[0][:1] == '0': # single frame (sf)
|
||||
nBytes = int(responses[0][1:2], 16)
|
||||
nFrames = 1
|
||||
@ -1482,15 +1523,12 @@ class ELM:
|
||||
# while len (result) / 2 < nBytes:
|
||||
while cFrame < nFrames:
|
||||
# now we should send ff
|
||||
sBS = hex(min({nFrames - cFrame, MaxBurst}))[2:]
|
||||
frsp = self.send_raw('300' + sBS + '00' + sBS)
|
||||
# sBS = hex(min({nFrames - cFrame, MaxBurst}))[2:]
|
||||
# frsp = self.send_raw('300' + sBS + '00' + sBS)
|
||||
|
||||
# analyse response
|
||||
nodataflag = False
|
||||
for s in frsp.split('\n'):
|
||||
|
||||
if s.strip()[:len(raw_command[Fc - 1])] == raw_command[Fc - 1]: # echo cancelation
|
||||
continue
|
||||
for s in responses:
|
||||
|
||||
if 'NO DATA' in s:
|
||||
nodataflag = True
|
||||
@ -1501,12 +1539,12 @@ class ELM:
|
||||
continue
|
||||
|
||||
if all(c in string.hexdigits for c in s): # some data
|
||||
responses.append(s)
|
||||
# responses.append(s)
|
||||
if s[:1] == '2': # consecutive frames (cf)
|
||||
tmp_fn = int(s[1:2], 16)
|
||||
if tmp_fn != (cFrame % 16): # wrong response (frame lost)
|
||||
self.error_frame += 1
|
||||
noErrors = False
|
||||
noerrors = False
|
||||
continue
|
||||
cFrame += 1
|
||||
result += s[2:16]
|
||||
@ -1517,9 +1555,16 @@ class ELM:
|
||||
|
||||
else: # wrong response (first frame omitted)
|
||||
self.error_frame += 1
|
||||
noErrors = False
|
||||
noerrors = False
|
||||
|
||||
if len(result) / 2 >= nBytes and noErrors and result[:2] != '7F':
|
||||
# Check for negative
|
||||
if result[:2] == '7F': noerrors = False
|
||||
|
||||
# populate L1 cache
|
||||
if noerrors and uncutCommand[:2] in AllowedList:
|
||||
self.l1_cache[uncutCommand] = str(nFrames)
|
||||
|
||||
if noerrors and len(result) / 2 >= nBytes:
|
||||
# split by bytes and return
|
||||
result = ' '.join(a + b for a, b in zip(result[::2], result[1::2]))
|
||||
return result
|
||||
@ -2068,7 +2113,7 @@ class ELM:
|
||||
break
|
||||
|
||||
if self.performanceModeLevel == 3 and mod_globals.opt_obdlink:
|
||||
for level in reversed(range(4,26)): #26 - 1 = 25 parameters per page
|
||||
for level in reversed(range(4,100)): #26 - 1 = 25 parameters per page
|
||||
isLevelAccepted = self.checkPerformaceLevel(level, dataids)
|
||||
if isLevelAccepted:
|
||||
return
|
||||
|
@ -793,7 +793,7 @@ def main():
|
||||
optParser()
|
||||
|
||||
# disable auto flow control
|
||||
mod_globals.opt_cfc0 = True
|
||||
mod_globals.opt_cfc0 = False
|
||||
|
||||
print 'Opening ELM'
|
||||
elm = mod_elm.ELM( mod_globals.opt_port, mod_globals.opt_speed, True )
|
||||
|
Loading…
x
Reference in New Issue
Block a user