public:can-utils_tipps
                Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
can-utils Tipps
Senden - cansend
einzelne Botschaft senden: cansend vcan0 244#00000011F6 Botschaft wiederholt senden (eventuell mit sleep verzögern): while true; do cansend vcan0 244#00000011F6; done while true; do cansend can0 123#4444; sleep 0.1; done bestimmte Botschaften aus Logfile senden (geht auch mit canplayer): candump vcan0 | grep " 244 " | while read line; do cansend vcan0 244#00000011F6; done
Senden - canplayer
alle Botschaften wie geloggt auf entsprechenden Interface senden: canplayer -I can.log.log canplayer -I can.log.log -l 1 # nur einmal abspielen oder canplayer vcan0=can0 < candump-2013-05-06_190603.log
canplayer - Hilfe
Usage: canplayer <options> [interface assignment]*
Options:              -I <infile>  (default stdin)
                      -l <num>     (process input file <num> times)
                                   (Use 'i' for infinite loop - default: 1)
                      -t           (ignore timestamps: send frames immediately)
                      -g <ms>      (gap in milli seconds - default: 1 ms)
                      -s <s>       (skip gaps in timestamps > 's' seconds)
                      -x           (disable local loopback of sent CAN frames)
                      -v           (verbose: print sent CAN frames)
Interface assignment:  0..n assignments like <write-if>=<log-if>
e.g. vcan2=can0 ( send frames received from can0 on vcan2 )
extra hook: stdout=can0 ( print logfile line marked with can0 on stdout )
No assignments => send frames to the interface(s) they had been received from.
Lines in the logfile not beginning with '(' (start of timestamp) are ignored.
Senden - caribou
Fuzzer Modus
./cc.py -i vcan0 fuzzer mutate 0b4 ....1111 -delay 0.1
- -i vcan0 wählt ein alternatives Interface wenn man nicht das default Interface verwenden will aus .canrc
- sendet die 0b4 und mutiert die Datenbytes D0 und D1
- -delay stellt die zykluszeit auf 100 ms
Gateway
gateway:
 (Regel löschen)
 sudo cangw -D -s vcan0 -d vcan1 -e -f 244:C00007FF -m SET:IL:333.4.1122334455667788
 244=> nach vcan 1 als 333 weiterreichen ohne Daten zu ändern (nur ID und DLC)
neue Regel hinzufügen:
 sudo cangw -A -s vcan0 -d vcan1 -e -f 244:C00007FF -m SET:ILD:333.4.1122334455667788
                                                             ^ =set Data
                                                            ^  = set Len
                                                           ^   = set ID
 ==> jetzt nach Daten Änderung
 sudo cangw -A -s vcan0 -d vcan1 -e -f 244:C00007FF -m AND:D:244.5.11223300FF667788
 D3 filtern
 und löschen:
 sudo cangw -D -s vcan0 -d vcan1 -e -f 244:C00007FF -m AND:D:244.5.11223300FF667788
 nochmal nur D3 filtern (war DLC=5):
 sudo cangw -A -s vcan0 -d vcan1 -e -f 244:C00007FF -m AND:D:244.5.FFFFFF00FF667788
 Filter Test:
  sudo cangw -A -s vcan0 -d vcan1 -e -f 244~244                                          ??? alles aus 244 routen
  sudo cangw -A -s vcan0 -d vcan1 -e -f 244:C00007FF -m AND:D:244.8.FFFFFFFF00667788     // und jetzt D5 filter
noch 2 Beispiele:
1) alles außerr 0x466 routen: sudo cangw -A -s can0 -d can1 -f 466~7ff 2)alles außerr 1B8 routen: sudo cangw -A can0 -f 1B8~C00007FF -d can1 D0,D2,D3 lassen, D1=22 setzen sudo cangw -A -s can0 -d can1 -f 1B8:C00007FF -m AND:D:1B8.4.FF00FFFF4455667788 -m OR:D:1B8.4.0022000000000000
cangw - hilfe
Usage: cangw [options]
Commands:  -A (add a new rule)
           -D (delete a rule)
           -F (flush / delete all rules)
           -L (list all rules)
Mandatory: -s <src_dev>  (source netdevice)
           -d <dst_dev>  (destination netdevice)
Options:   -t (preserve src_dev rx timestamp)
           -e (echo sent frames - recommended on vcanx)
           -i (allow to route to incoming interface)
           -u <uid> (user defined modification identifier)
           -l <hops> (limit the number of frame hops / routings)
           -f <filter> (set CAN filter)
           -m <mod> (set frame modifications)
           -x <from_idx>:<to_idx>:<result_idx>:<init_xor_val> (XOR checksum)
           -c <from>:<to>:<result>:<init_val>:<xor_val>:<crctab[256]> (CRC8 cs)
           -p <profile>:[<profile_data>] (CRC8 checksum profile & parameters)
Values are given and expected in hexadecimal values. Leading 0s can be omitted.
<filter> is a <value><mask> CAN identifier filter
   <can_id>:<can_mask> (matches when <received_can_id> & mask == can_id & mask)
   <can_id>~<can_mask> (matches when <received_can_id> & mask != can_id & mask)
<mod> is a CAN frame modification instruction consisting of
<instruction>:<can_frame-elements>:<can_id>.<can_dlc>.<can_data>
 - <instruction> is one of 'AND' 'OR' 'XOR' 'SET'
 - <can_frame-elements> is _one_ or _more_ of 'I'dentifier 'L'ength 'D'ata
 - <can_id> is an u32 value containing the CAN Identifier
 - <can_dlc> is an u8 value containing the data length code (0 .. 8)
 - <can_data> is always eight(!) u8 values containing the CAN frames data
The max. four modifications are performed in the order AND -> OR -> XOR -> SET
Example:
cangw -A -s can0 -d vcan3 -e -f 123:C00007FF -m SET:IL:333.4.1122334455667788
Supported CRC 8 profiles:
Profile '1' (1U8)       - add one additional u8 value
Profile '2' (16U8)      - add u8 value from table[16] indexed by (data[1] & 0xF)
Profile '3' (SFFID_XOR) - add u8 value (can_id & 0xFF) ^ (can_id >> 8 & 0xFF)
candump
- candump (Farbe, alles, Filter alle IDs und ERRORFrames anzeigen)
candump -cae can0,0:0,#FFFFFFFF
todo… obiges dirket auf den Wiki-Seiten hinzufügen
public/can-utils_tipps.1568706243.txt.gz · Zuletzt geändert:  von geier99
                
                