'모종의 음모/CAN'에 해당되는 글 11건

  1. 2026.07.24 MCP2515 on rpi .. 2번째
  2. 2026.07.23 obd can
  3. 2025.04.01 DeviceNet CAN
  4. 2025.02.19 candump, cansend와 vcan
  5. 2025.02.18 linux can 테스트(가상 CAN IF)
  6. 2025.02.18 can-utils(cansend, candump)
  7. 2024.01.09 can invader
  8. 2023.10.31 CAN(controller area network)
  9. 2023.10.31 MCP2515 on rpi
  10. 2023.10.30 mcp2515 can
모종의 음모/CAN2026. 7. 24. 14:34

벌써 3년전에 가볍게(?) 해봤었네..

또 까먹다니 이 기억력 어쩔.. ㅠㅠ

그때와 다른건.. 작년 부터 /boot/config.txt의 경로가 달라졌다는 정도?

$ uname -a
Linux raspberrypi 6.12.25+rpt-rpi-v7 #1 SMP Raspbian 1:6.12.25-1+rpt1 (2025-04-30) armv7l GNU/Linux

$ cat /boot/config.txt
DO NOT EDIT THIS FILE

The file you are looking for has moved to /boot/firmware/config.txt

$ cat /boot/firmware/config.txt
[all]
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay

$ sudo ip link set can0 up type can bitrate 125000
$ ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ dmesg | grep -i can
[   12.948060] CAN device driver interface
[   13.070005] mcp251x spi0.0 can0: MCP2515 successfully initialized.

$ lsmod |grep can
can_dev                40960  1 mcp251x

 

loopback 설정. ifconfig 상으로는 별다른 티가 안난다

$ sudo ip link set can0 up type can bitrate 125000 loopback on
$ sudo ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[링크 : https://forums.raspberrypi.com/viewtopic.php?t=7027&start=225]

 

아무튼 loopback을 활성화 하고 ssh 로 창 두개 열어서 한쪽은 candump 실행해두고

다른 한쪽에서 cansend로 보내면 보내진다.

$ cansend can0 5A1#11.2233.44556677.88
$ candump can0
  can0  5A1   [8]  11 22 33 44 55 66 77 88
  can0  5A1   [8]  11 22 33 44 55 66 77 88

 

$ demsg | tail
[  965.109222] can: controller area network core
[  965.109370] NET: Registered PF_CAN protocol family
[  965.136117] can: raw protocol
[ 1028.671698] mcp251x spi0.0 can0: bus-off

[링크 : https://whiteknight3672.tistory.com/346]

[링크 : https://blog.naver.com/mts90/221644429413]

[링크 : https://wp.mytv.kr/2019/10/31/raspberry-pi-에서-can-통신-사용하기/] 결선도

2023.10.31 - [모종의 음모/CAN] - MCP2515 on rpi

2025.02.19 - [모종의 음모/CAN] - candump, cansend와 vcan

 

+

MCP2515 / TJA1050

 

D0695323C  라고 써있어서

이게 8 MHz 인지 16 MHz 인질 모르겠다. 검색해도 안나온다.

일단 두대를 보니 서로 다른게 써있어서 그냥 시리얼 번호라고 생각하는 중.

 

일단은 3.3V했는데 이러면 외부로 신호는 발생시키지 못할 듯.

 

예전에도 본건 데 전원이 잘못되었다고 개조를 해야 한다고 하는데

지금 다시 읽어보니 라즈베리 파이 gpio 가 3.3V 라서 아두이노와는 다르게 5V로 주면 라즈베리가 데미지 입게된다.

Because MCP2515 must be powered from 3,3V, because MCP2515 is directly connected to Pi GPIO and GPIO only accept 3,3V

[링크 : https://forums.raspberrypi.com/viewtopic.php?t=141052]

 

데이터 시트를 찾아보면

MCP2515는 2.7 V~5.5 V 면 되지만 SPI 도 Vdd 전압 따라가게 되면 흐음..

[링크 : https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf]

 

CAN tranceiver칩은 4.75~5.25V 사이에 전압을 공급해야 한다.

[링크 : https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf]

 

걍 속편하게 SPI 쪽만 레벨 시프터 쓸까? 개조가 나을까..

 

'모종의 음모 > CAN' 카테고리의 다른 글

obd can  (0) 2026.07.23
DeviceNet CAN  (0) 2025.04.01
candump, cansend와 vcan  (0) 2025.02.19
linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can-utils(cansend, candump)  (0) 2025.02.18
Posted by 구차니
모종의 음모/CAN2026. 7. 23. 19:23

can 찾아보게 된 이유가 OBD 통신에 쓴다고 해서 봤던거니 다시 기록!

[링크 : https://clemencyking.tistory.com/m/26]

 

7.29

https://www.instructables.com/Raspberry-Pi-Based-CAN-BUS-Reader/

'모종의 음모 > CAN' 카테고리의 다른 글

MCP2515 on rpi .. 2번째  (0) 2026.07.24
DeviceNet CAN  (0) 2025.04.01
candump, cansend와 vcan  (0) 2025.02.19
linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can-utils(cansend, candump)  (0) 2025.02.18
Posted by 구차니
모종의 음모/CAN2025. 4. 1. 14:34

이거 머 보다가 나온거지 -ㅁ-?

FC-SAN 쪽에서 CIP로 시작한 것 같은데 기억이...

 

The Common Industrial Protocol (CIP) is an industrial protocol for industrial automation applications. It is supported by ODVA.
Previously known as Control and Information Protocol,[1] CIP encompasses a comprehensive suite of messages and services for the collection of manufacturing automation applications – control, safety, synchronization, motion, configuration and information. It allows users to integrate these manufacturing applications with enterprise-level Ethernet networks and the Internet. It is supported by hundreds of vendors around the world,[2] and is media-independent. CIP provides a unified communication architecture throughout the manufacturing enterprise. It is used in EtherNet/IP, DeviceNet, CompoNet and ControlNet.
ODVA is the organization that supports network technologies built on the Common Industrial Protocol (CIP). These also currently include application extensions to CIP: CIP Safety, CIP Motion and CIP Sync.

[링크 : https://en.m.wikipedia.org/wiki/Common_Industrial_Protocol]

 

DeviceNet is a network protocol used in the automation industry to interconnect control devices for data exchange. It utilizes the Common Industrial Protocol over a Controller Area Network media layer and defines an application layer to cover a range of device profiles. Typical applications include information exchange, safety devices, and large I/O control networks.[1]

[링크 : https://en.m.wikipedia.org/wiki/DeviceNet]

'모종의 음모 > CAN' 카테고리의 다른 글

MCP2515 on rpi .. 2번째  (0) 2026.07.24
obd can  (0) 2026.07.23
candump, cansend와 vcan  (0) 2025.02.19
linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can-utils(cansend, candump)  (0) 2025.02.18
Posted by 구차니
모종의 음모/CAN2025. 2. 19. 16:35

 

$ modprobe vcan
modprobe: ERROR: could not insert 'vcan': Operation not permitted

$ sudo modprobe vcan
sudo ip link add dev vcan0 type vcan

$ ifconfig
br-638c83b169eb: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:d5:e6:f1:21  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:40:63:97:cb  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enxf8e43b9b776b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.220.108  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::81f4:65ad:f7cc:2f2c  prefixlen 64  scopeid 0x20<link>
        ether f8:e4:3b:9b:77:6b  txqueuelen 1000  (Ethernet)
        RX packets 3619726  bytes 2156366501 (2.1 GB)
        RX errors 0  dropped 106170  overruns 0  frame 0
        TX packets 1452518  bytes 317915291 (317.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 160829  bytes 14028478 (14.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 160829  bytes 14028478 (14.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.220.107  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::104b:d69c:878f:cfaa  prefixlen 64  scopeid 0x20<link>
        ether 8c:55:4a:28:25:bc  txqueuelen 1000  (Ethernet)
        RX packets 809871  bytes 90255020 (90.2 MB)
        RX errors 0  dropped 99865  overruns 0  frame 0
        TX packets 53067  bytes 6125665 (6.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ ifconfig -a
br-638c83b169eb: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:d5:e6:f1:21  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:40:63:97:cb  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enxf8e43b9b776b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.220.108  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::81f4:65ad:f7cc:2f2c  prefixlen 64  scopeid 0x20<link>
        ether f8:e4:3b:9b:77:6b  txqueuelen 1000  (Ethernet)
        RX packets 3620125  bytes 2156544266 (2.1 GB)
        RX errors 0  dropped 106183  overruns 0  frame 0
        TX packets 1452676  bytes 317938700 (317.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 160841  bytes 14030154 (14.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 160841  bytes 14030154 (14.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vcan0: flags=128<NOARP>  mtu 72
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.220.107  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::104b:d69c:878f:cfaa  prefixlen 64  scopeid 0x20<link>
        ether 8c:55:4a:28:25:bc  txqueuelen 1000  (Ethernet)
        RX packets 809990  bytes 90270371 (90.2 MB)
        RX errors 0  dropped 99877  overruns 0  frame 0
        TX packets 53074  bytes 6126348 (6.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ sudo ifconfig vcan0 up
$ ifconfig
br-638c83b169eb: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:d5:e6:f1:21  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:40:63:97:cb  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enxf8e43b9b776b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.220.108  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::81f4:65ad:f7cc:2f2c  prefixlen 64  scopeid 0x20<link>
        ether f8:e4:3b:9b:77:6b  txqueuelen 1000  (Ethernet)
        RX packets 3620430  bytes 2156573250 (2.1 GB)
        RX errors 0  dropped 106197  overruns 0  frame 0
        TX packets 1452764  bytes 317953427 (317.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 160841  bytes 14030154 (14.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 160841  bytes 14030154 (14.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vcan0: flags=193<UP,RUNNING,NOARP>  mtu 72
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.220.107  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::104b:d69c:878f:cfaa  prefixlen 64  scopeid 0x20<link>
        ether 8c:55:4a:28:25:bc  txqueuelen 1000  (Ethernet)
        RX packets 810099  bytes 90278671 (90.2 MB)
        RX errors 0  dropped 99889  overruns 0  frame 0
        TX packets 53074  bytes 6126348 (6.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[링크 : https://ola-page.tistory.com/66]

 

 

 

$ candump 
candump - dump CAN bus traffic.

Usage: candump [options] <CAN interface>+
  (use CTRL-C to terminate candump)

Options:
         -t <type>   (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)
         -H          (read hardware timestamps instead of system timestamps)
         -c          (increment color mode level)
         -i          (binary output - may exceed 80 chars/line)
         -a          (enable additional ASCII output)
         -S          (swap byte order in printed CAN data[] - marked with '`' )
         -s <level>  (silent mode - 0: off (default) 1: animation 2: silent)
         -l          (log CAN-frames into file. Sets '-s 2' by default)
         -L          (use log file format on stdout)
         -n <count>  (terminate after reception of <count> CAN frames)
         -r <size>   (set socket receive buffer to <size>)
         -D          (Don't exit if a "detected" can device goes down.
         -d          (monitor dropped CAN frames)
         -e          (dump CAN error frames in human-readable format)
         -x          (print extra message infos, rx/tx brs esi)
         -T <msecs>  (terminate after <msecs> without any reception)

Up to 16 CAN interfaces with optional filter sets can be specified
on the commandline in the form: <ifname>[,filter]*

Filters:
  Comma separated filters can be specified for each given CAN interface:
    <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)
    #<error_mask>
         (set error frame filter, see include/linux/can/error.h)
    [j|J]
         (join the given CAN filters - logical AND semantic)

CAN IDs, masks and data content are given and expected in hexadecimal values.
When the can_id is 8 digits long the CAN_EFF_FLAG is set for 29 bit EFF format.
Without any given filter all data frames are received ('0:0' default filter).

Use interface name 'any' to receive from all CAN interfaces.

Examples:
candump -c -c -ta can0,123:7FF,400:700,#000000FF can2,400~7F0 can3 can8

candump -l any,0~0,#FFFFFFFF
         (log only error frames but no(!) data frames)
candump -l any,0:0,#FFFFFFFF
         (log error frames and also all data frames)
candump vcan2,12345678:DFFFFFFF
         (match only for extended CAN ID 12345678)
candump vcan2,123:7FF
         (matches CAN ID 123 - including EFF and RTR frames)
candump vcan2,123:C00007FF
         (matches CAN ID 123 - only SFF and non-RTR frames)

 

$ cansend vcan0
cansend - send CAN-frames via CAN_RAW sockets.

Usage: cansend <device> <can_frame>.

<can_frame>:
 <can_id>#{data}          for 'classic' CAN 2.0 data frames
 <can_id>#R{len}          for 'classic' CAN 2.0 data frames
 <can_id>##<flags>{data}  for CAN FD frames

<can_id>:
 3 (SFF) or 8 (EFF) hex chars
{data}:
 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')
{len}:
 an optional 0..8 value as RTR frames can contain a valid dlc field
<flags>:
 a single ASCII Hex value (0 .. F) which defines canfd_frame.flags

Examples:
  5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311223344 /
  1F334455#1122334455667788 / 123#R / 00000123#R3

 

아래는 데이터 출력 포맷 확인용

인터페이스 / CAN id / 길이 / 데이터(페이로드 길이)

receive send
$ candump vcan0
  vcan0  111   [5]  01 02 03 04 05
$ cansend vcan0 111#010203.04.05
  vcan0  112   [5]  01 02 03 04 05 $ cansend vcan0 112#010203.04.05
  vcan0  112   [0]  $ cansend vcan0 112#
  vcan0  112  [00] $ cansend vcan0 112##1
  vcan0  112  [01]  23 $ cansend vcan0 112##123
  vcan0  112   [0]  remote request $ cansend vcan0 112#R
  vcan0  112   [3]  remote request $ cansend vcan0 112#R3

 

받는 쪽에서 CAN id 제한할 경우, 112를 받도록 설정했기에 113은 무시된다.

   
$ candump vcan0,112:FF $ cansend vcan0 111#R3
  vcan0  112   [3]  remote request $ cansend vcan0 112#R3
  $ cansend vcan0 113#R3
  vcan0  112   [5]  01 02 03 04 05 $ cansend vcan0 112#010203.04.05
  vcan0  112   [6]  01 02 03 04 05 06 $ cansend vcan0 112#010203.04.0506
  vcan0  112   [7]  01 02 03 04 05 06 07 $ cansend vcan0 112#010203.04.0506.07
  vcan0  112   [0]  remote request $ cansend vcan0 112#R
$ cansend vcan0 112#R10
$ cansend vcan0 112#R100
  vcan0  112   [1]  remote request $ cansend vcan0 112#R1
  vcan0  112   [2]  remote request $ cansend vcan0 112#R2
  vcan0  112   [8]  remote request $ cansend vcan0 112#R8

 

그나저나 mask 라는데 이해가 안되네..

123 = 0x7B & 0x7F0 하면 0x7B가 되어야 하니 16개에 대해서 받아들여야 할 거 같은데 왜 119에서 130 까지 12개 받아들여 질까?

$ candump vcan0,123:7F0
  vcan0  120   [0]  remote request
  vcan0  121   [0]  remote request
  vcan0  122   [0]  remote request
  vcan0  123   [0]  remote request
  vcan0  124   [0]  remote request
  vcan0  125   [0]  remote request
  vcan0  126   [0]  remote request
  vcan0  127   [0]  remote request
  vcan0  128   [0]  remote request
  vcan0  129   [0]  remote request
$ cansend vcan0 119#R
$ cansend vcan0 120#R
$ cansend vcan0 121#R
$ cansend vcan0 122#R
$ cansend vcan0 123#R
$ cansend vcan0 124#R
$ cansend vcan0 125#R
$ cansend vcan0 126#R
$ cansend vcan0 127#R
$ cansend vcan0 128#R
$ cansend vcan0 129#R
$ cansend vcan0 130#R

'모종의 음모 > CAN' 카테고리의 다른 글

obd can  (0) 2026.07.23
DeviceNet CAN  (0) 2025.04.01
linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can-utils(cansend, candump)  (0) 2025.02.18
can invader  (0) 2024.01.09
Posted by 구차니
모종의 음모/CAN2025. 2. 18. 16:44

실 장비가 있으면 좋겠지만 없어도

가상 can(virtual can) 장치를 추가해서 테스트 할 수 있다.

 

$ sudo ip link add dev vcan0 type vcan
$ sudo ifconfig vcan0 up

[링크 : https://ola-page.tistory.com/66] socket can

[링크 : https://hn-log.tistory.com/168] CANable

'모종의 음모 > CAN' 카테고리의 다른 글

DeviceNet CAN  (0) 2025.04.01
candump, cansend와 vcan  (0) 2025.02.19
can-utils(cansend, candump)  (0) 2025.02.18
can invader  (0) 2024.01.09
CAN(controller area network)  (0) 2023.10.31
Posted by 구차니
모종의 음모/CAN2025. 2. 18. 16:43

cansend는 보내고

candump는 받는 녀석이다.

 

$ cansend can0 canid#userdata

로 하면 특정 canid로 보낼 수 있고

$ cansend --help
cansend - send CAN-frames via CAN_RAW sockets.

Usage: cansend <device> <can_frame>.

<can_frame>:
 <can_id>#{data}          for 'classic' CAN 2.0 data frames
 <can_id>#R{len}          for 'classic' CAN 2.0 data frames
 <can_id>##<flags>{data}  for CAN FD frames

<can_id>:
 3 (SFF) or 8 (EFF) hex chars
{data}:
 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')
{len}:
 an optional 0..8 value as RTR frames can contain a valid dlc field
<flags>:
 a single ASCII Hex value (0 .. F) which defines canfd_frame.flags

Examples:
  5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311223344 /
  1F334455#1122334455667788 / 123#R / 00000123#R3

 

candump 에서는 아래와 같이 하면 특정 id로만 확인할 수 있다.

$ candump can0,canid 

$ candump --help
candump: invalid option -- '-'
candump - dump CAN bus traffic.

Usage: candump [options] <CAN interface>+
  (use CTRL-C to terminate candump)

Options:
         -t <type>   (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)
         -H          (read hardware timestamps instead of system timestamps)
         -c          (increment color mode level)
         -i          (binary output - may exceed 80 chars/line)
         -a          (enable additional ASCII output)
         -S          (swap byte order in printed CAN data[] - marked with '`' )
         -s <level>  (silent mode - 0: off (default) 1: animation 2: silent)
         -l          (log CAN-frames into file. Sets '-s 2' by default)
         -L          (use log file format on stdout)
         -n <count>  (terminate after reception of <count> CAN frames)
         -r <size>   (set socket receive buffer to <size>)
         -D          (Don't exit if a "detected" can device goes down.
         -d          (monitor dropped CAN frames)
         -e          (dump CAN error frames in human-readable format)
         -x          (print extra message infos, rx/tx brs esi)
         -T <msecs>  (terminate after <msecs> without any reception)

Up to 16 CAN interfaces with optional filter sets can be specified
on the commandline in the form: <ifname>[,filter]*

Filters:
  Comma separated filters can be specified for each given CAN interface:
    <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)
    #<error_mask>
         (set error frame filter, see include/linux/can/error.h)
    [j|J]
         (join the given CAN filters - logical AND semantic)

CAN IDs, masks and data content are given and expected in hexadecimal values.
When the can_id is 8 digits long the CAN_EFF_FLAG is set for 29 bit EFF format.
Without any given filter all data frames are received ('0:0' default filter).

Use interface name 'any' to receive from all CAN interfaces.

Examples:
candump -c -c -ta can0,123:7FF,400:700,#000000FF can2,400~7F0 can3 can8

candump -l any,0~0,#FFFFFFFF
         (log only error frames but no(!) data frames)
candump -l any,0:0,#FFFFFFFF
         (log error frames and also all data frames)
candump vcan2,12345678:DFFFFFFF
         (match only for extended CAN ID 12345678)
candump vcan2,123:7FF
         (matches CAN ID 123 - including EFF and RTR frames)
candump vcan2,123:C00007FF
         (matches CAN ID 123 - only SFF and non-RTR frames)

 

'모종의 음모 > CAN' 카테고리의 다른 글

candump, cansend와 vcan  (0) 2025.02.19
linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can invader  (0) 2024.01.09
CAN(controller area network)  (0) 2023.10.31
MCP2515 on rpi  (0) 2023.10.31
Posted by 구차니
모종의 음모/CAN2024. 1. 9. 11:29

렉서스랑 토요타 차량 두가지 종류가 타이어 옆으로 해서 헤드라이트의 커넥터에 접근이 가능하도록

물리보안적인 측면에서 허술하게 만들어져 발생한 사건으로 보인다.

can이라서 접근성이 좋지 않아 이정도인데

현재~근미래에 can에서 ethernet으로 전환하게 되면 너무 손쉽게 뚫리지 않을까 걱정된다.

기본적으로 통신은 보안채널로 하게 되려나?

 

렉서스 차량 99대와 토요타 랜드크루저 92대가 도난

[링크 : https://v.daum.net/v/1OAq5WD7kL]

 

 

+

BroadR-Reach

 

BroadR-Reach technology is an Ethernet physical layer standard designed for automotive connectivity applications

[링크 : https://en.wikipedia.org/wiki/BroadR-Reach]

 

 

[링크 : https://m.blog.naver.com/lecroykorea/221105708892]

[링크 : https://m.blog.naver.com/lecroykorea/221065291291]

[링크 : https://m.blog.naver.com/lecroykorea/221069260339]

'모종의 음모 > CAN' 카테고리의 다른 글

linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can-utils(cansend, candump)  (0) 2025.02.18
CAN(controller area network)  (0) 2023.10.31
MCP2515 on rpi  (0) 2023.10.31
mcp2515 can  (0) 2023.10.30
Posted by 구차니
모종의 음모/CAN2023. 10. 31. 23:15

TJA1050 입력 전압을 보는데  dominant / recessive란게 나와서 보니

[링크 : https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf]

 

CAN은 H 와 L 라인의 전위차로 0과 1을 구분한다고 한다.

0이  dominant 라는데 어째 0과 1이 반대인 느낌이다?

아무튼 3.3V면 bus state가 recessive로 잡힌다는건가?

[링크 : https://m.blog.naver.com/lagrange0115/221941482740]

 

[링크 : https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf]

'모종의 음모 > CAN' 카테고리의 다른 글

can-utils(cansend, candump)  (0) 2025.02.18
can invader  (0) 2024.01.09
MCP2515 on rpi  (0) 2023.10.31
mcp2515 can  (0) 2023.10.30
CAN 통신 우선순위  (0) 2015.01.23
Posted by 구차니
모종의 음모/CAN2023. 10. 31. 23:05

MCP2515를 라즈베리에서 쓰려면 개조가 필요하다는데

아두이노가 5V IO 레벨이고 라즈베리가 3.3V 레벨이라 그런가? 왜 저렇게 복잡하게 개조하는건진 찾아봐야겠고

집에 16MHz OSC가 있나도 찾아봐야겠다.(12MHz 24MHz는 있는데 16MHz 만 없네 -_-)

[링크 : https://blog.naver.com/mts90/221644429413]

 

반대로 SPI 를 위한 레벨시프터가 있으면 해결되려나?

[링크 : https://www.devicemart.co.kr/goods/view?no=1384307] 2채널 3.3V<->5V 레벨 시프터 / 1000원

 

구매시 16MHz 인지 확인하는것도 방법이려나

[링크 : https://m.blog.naver.com/kimhj9/221790064284]

 

트랜시버의 전압을 바꾸어 주는거라면 라즈베리 끼리 테스트 할때 그냥 3.3V 넣어서

양쪽다 동일 전압레벨로 맞추면 통신이 안되려나?

 

설정 내용을 보니 spi를 통해서 can 통신 장치 추가 까지 문제 없어 보인다.

$ vi /boot/config.txt
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay

$ sudo apt-get install can-utils

$ ls /sys/bus/spi/devices/spi0.0/net
can0

$ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent

$ ls /sys/bus/spi/devices/spi0.0/net/
can0

$ ls /sys/bus/spi/devices/spi0.0/net/can0/
addr_assign_type  carrier_changes  duplex             iflink            operstate       speed         uevent
address           device           flags              link_mode         phys_port_id    statistics
addr_len          dev_id           gro_flush_timeout  mtu               phys_port_name  subsystem
broadcast         dev_port         ifalias            name_assign_type  phys_switch_id  tx_queue_len
carrier           dormant          ifindex            netdev_group      queues          type

// 5. Setup CAN interface, I use 125k baudrate.
$ sudo ip link set can0 up type can bitrate 125000
$ sudo ifconfig
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

[링크 : https://forums.raspberrypi.com/viewtopic.php?t=141052]

 

TJA1050 - High speed CAN tranceiver

[링크 : https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf]

 

'모종의 음모 > CAN' 카테고리의 다른 글

can-utils(cansend, candump)  (0) 2025.02.18
can invader  (0) 2024.01.09
CAN(controller area network)  (0) 2023.10.31
mcp2515 can  (0) 2023.10.30
CAN 통신 우선순위  (0) 2015.01.23
Posted by 구차니
모종의 음모/CAN2023. 10. 30. 19:11

아두이노나 라즈베리 CAN HAT 은 3~4만원은 해서 구매하기 부담스러웠는데

MCP2515 라는 녀석은 CAN to SPI 라고 해야하나?

CAN 통신을 독립적으로 수행해주는 원칩 솔루션이 있으니 다음에 사봐야겠다.

 

[링크 : http://itempage3.auction.co.kr/DetailView.aspx?itemno=B509249430] 3700

[링크 : http://itempage3.auction.co.kr/DetailView.aspx?itemno=C297097222] 2700

 

차량에 OBD 연결하기도 한다는데 의외로 2.54mm 핀 헤더와 잘 맞는듯?

[링크 : https://clemencyking.tistory.com/26]

 

보드가 8MHz와 16Mhz가 있다는데

크리스탈은 4 / 8 / 20 MHz 권장인가?

HS SPI의 경우 10Mbps 라는데 아무래도 클럭 멀티플라이어가 없다면

20MHz를 넣어줘야 HS SPI 로 작동하게 될 것 같긴하네.

[링크 : https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf]

'모종의 음모 > CAN' 카테고리의 다른 글

can-utils(cansend, candump)  (0) 2025.02.18
can invader  (0) 2024.01.09
CAN(controller area network)  (0) 2023.10.31
MCP2515 on rpi  (0) 2023.10.31
CAN 통신 우선순위  (0) 2015.01.23
Posted by 구차니