# CAN-bus read and filter

**URL:** https://mangoh.discourse.group/t/can-bus-read-and-filter/1262
**Category:** IoT Cards
**Created:** [March 21, 2018, 1:52pm UTC](https://mangoh.discourse.group/t/can-bus-read-and-filter/1262 "2018-03-21T13:52:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![raxsix](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@raxsix](https://mangoh.discourse.group/u/raxsix)
#### Post date: [March 21, 2018, 1:52pm UTC](https://mangoh.discourse.group/t/can-bus-read-and-filter/1262/1 "2018-03-21T13:52:49Z")

</div>

I have CAN Bus IoT Module installed and connected to CAN traffic generator. If I enter to the target module (WP7502) over the ssh and type ifconfig then I can see that CAN is working

> 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:6683 errors:0 dropped:0 overruns:0 frame:0  
> TX packets:373 errors:0 dropped:0 overruns:0 carrier:0  
> collisions:0 txqueuelen:10  
> RX bytes:53464 (52.2 KiB) TX bytes:2984 (2.9 KiB)

I need to filter out messages and send them to MQTT server  
What is the simplest way to read and filter CAN messages?

---

<div class="post-metadata">

### Author: ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)
#### Post date: [March 21, 2018, 4:52pm UTC](https://mangoh.discourse.group/t/can-bus-read-and-filter/1262/2 "2018-03-21T16:52:57Z")

</div>

Hello,

I use SocketCAN with Linux to manage CANBUS connection with the IoT CARD.  
You can find source code on Google.

Socket CAN include filtering messaging.

It’s easy to implement.

Francis.

---

<div class="post-metadata">

### Author: ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)
#### Post date: [March 21, 2018, 9:16pm UTC](https://mangoh.discourse.group/t/can-bus-read-and-filter/1262/3 "2018-03-21T21:16:34Z")

</div>

Look my reply on this topic :

> [@CAN IoT Card driver](https://mangoh.discourse.group/t/can-iot-card-driver/997/30):
>
> Finally, saw the can0 line with ifconfig command after all those steps: echo 2 \> /sys/class/gpio/export echo out \> /sys/class/gpio/gpio2/direction echo 1 \> /sys/class/gpio/gpio2/value // Enable level shifter on the CAN IoT card echo 13 \> /sys/class/gpio/export echo out \> /sys/class/gpio/gpio13/direction echo 1 \> /sys/class/gpio/gpio13/value modprobe can modprobe can-dev modprobe can-raw modprobe mcp251x ip link set can0 type can bitrate 125000 triple-sampling on ifconfig can0 up …
