Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Trunk #82

Merged
merged 2 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions VERSION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Version 3.5-2
- mod_stat fixes

## Version 3.5-0
- **CANBusTriple** change: now you need provide in 'bus' parameter to which BUS of CBT you want to work (read/write). It gives more flexibility
- Inspired by @_db5 and his cool vircar I have decide to create an analog but on CANToolz engine. Now you can emulate a car. You build car from ECU modules and CONTROL modules. ECU modules could be connected via virtual CAN Switch.
Expand Down
32 changes: 20 additions & 12 deletions cantoolz/modules/mod_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,30 +1358,30 @@ def act_detect(self, fn):
key = test_frame.get_text()
idg = test_frame.frame_id
self.new_diff(0, "STAT_CHECK_ACT_" + key)
self.dprint(1, " Send test frame: " + key)
self.dprint(1, " Sending test frame: " + key)
tmp_w = weigths.get(key, 0)
print(1)
#print(1)
while self._action.is_set():
time.sleep(0.01)
print(2)
#print(2)
self._action.set()
self._stat_resend = test_frame
self._action.clear()
print(3)
#print(3)
while 1:
time.sleep(1)
print(4)
#print(4)
if not self._action.is_set():
self._action.set()
print(self._stat_resend)
#print(self._stat_resend)
if self._stat_resend is None:
self._action.clear()
self.dprint(1, " Test frame has been sent: " + test_frame.get_text())
time.sleep(waiting_time)
print(5)
#print(5)
break
self._action.clear()
print(6)
#print(6)
self.dprint(1, " Check changes... ")
self._active = False

Expand All @@ -1399,10 +1399,18 @@ def act_detect(self, fn):
if idg != idf:
looking_bits = orig_bits ^ self.data_set[self._rep_index][idf]['diff']
self.dprint(1, "DIFF BIT ("+hex(idf)+"): " + looking_bits.bin)
for bit in buf1x:
self.dprint(1, "\nCOMPARE with " + bit.bin + " = " + (looking_bits & bit).bin )
if (looking_bits & bit).int != 0:
tmp_w +=1
last_b = orig_bits
chg_b = bitstring.BitArray( b'\x00' * 8)
itr = 0
if len(buf1x) > 1:
for bit in buf1x:
chg_b |= bit ^ last_b
last_b = bit
itr += 1
self.dprint(1, "\nCOMPARE with " + bit.bin + " = " + (looking_bits & chg_b).bin )
if (looking_bits & chg_b).int != 0 and itr > 1:
self.dprint(1, "BINGO")
tmp_w +=1

weigths[key] = tmp_w
self._active = True
Expand Down
19 changes: 18 additions & 1 deletion examples/MIDI_to_CAN_example/CANToolz_config/BMW_F10_MUSIC.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@


# Music actions


{'High light - blink': '0x1ee:2:20ff', 'cmd':'127'},
{'TURN LEFT and RIGHT': '0x2fc:7:31000000000000', 'cmd':'126'},
{'TURN right ON PERMANENT': '0x1ee:2:01ff', 'cmd':'124'},
{'TURN right x3 or OFF PERMANENT':'0x1ee:2:02ff','cmd':'123'},
{'TURN left ON PERMANENT': '0x1ee:2:04ff', 'cmd':'122'},
{'TURN left x3 or OFF PERMANENT':'0x1ee:2:08ff','cmd':'121'},
{'STOP lights': '0x173:8:3afa00022000f2c4', 'cmd':'120'},


{'CLEANER - once':'0x2a6:2:02a1','cmd':'119'},
{'CLEANER x3 + Wasser':'0x2a6:2:10f1','cmd':'118'},
{'Mirrors+windows FOLD':'0x26e:8:5b5b4002ffffffff','cmd':"117"},
{'Mirrors UNfold':'0x2fc:7:12000000000000','cmd':"116"},
{'Windows open':'0x26e:8:49494001ffffffff','cmd':"115"},
{'Windows rear close + Mirrors FOLD':'0x26e:8:405b4002ffffffff','cmd':"114"},
{'Trunk open':'0x2a0:8:88888001ffffffff','cmd':"113"},
{'Trunk close':'0x23a:8:00f310f0fcf0ffff','cmd':"112"}


],
Expand Down
12 changes: 6 additions & 6 deletions examples/can_sniff_replay.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
load_modules = {
'hw_USBtin': {'port':'auto', 'debug':1, 'speed':500}, # IO hardware module # Module for sniff and replay
'mod_stat': {},
'hw_USBtin': {'port':'auto', 'speed':500}, # IO hardware module # Module for sniff and replay
'mod_stat': {"bus":'mod_stat','debug':2},'mod_stat~2': {"bus":'mod_stat'},
'mod_firewall': {}, 'mod_fuzz1':{'debug':2},
'gen_replay': {'debug': 1}# Stats
}

# Now let's describe the logic of this test
actions = [
{'hw_USBtin': {'action': 'read','pipe': 1}}, # Read to PIPE 1
{'mod_firewall': {'black_list': [251159376]}},
{'mod_fuzz1':{'fuzz':[0x6b4],'byte':8}},
{'mod_stat': {'pipe': 1}}, # Write generated packets (pings)
{'gen_replay': {'pipe': 2, 'delay':0.06}},
{'hw_USBtin': {'action': 'write','pipe': 2}},
{'mod_firewall': {'white_bus': ["mod_stat"]}},
{'gen_replay': {}},
{'mod_stat~2': {'pipe': 1}},
{'hw_USBtin': {'action': 'write','pipe': 1}},
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='CANToolz',
version='3.5.1',
version='3.5.2',
author='Alexey Sintsov',
install_requires=[
'pyserial',
Expand Down