Recording CAN in Wireshark by PCAN-USB

This forum covers third party software that is for example developed with our APIs
Post Reply
romaniuk
Posts: 5
Joined: Thu 9. May 2019, 06:38

Recording CAN in Wireshark by PCAN-USB

Post by romaniuk » Fri 10. May 2019, 10:11

Hi,
I have CAN network with multiple CANopen devices. Messages in the network are captured by PCAN-USB.
It works fine in PCAN-View software but it is on CAN level. However I need to see CANopen messages that needs protocol decoding. That's why I would like to record CAN messages by Wireshark and write custom plugin for decoding CANopen messages.

How to capture messages in Wireshark when I use PCAN-USB?

Kind regards,
Piotr Romaniuk

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1140
Joined: Fri 10. Sep 2010, 19:34

Re: Recording CAN in Wireshark by PCAN-USB

Post by U.Wilhelm » Fri 10. May 2019, 14:29

For our PC CAN Interfaces we use a own real API (PCAN-Basic for Windows/Linux) that you could use to read/write CAN Frames. What you do with this CAN Frames is up to you.
Wireshark is a Network Protocoll Tool. If you find a way how to get the Data from our API into WireShark (i have no idea) , you could build your own CANopen Protocoll Stack (but belive us - this is hard to do...)
Better way is to use real CAN Open Software Stacks...see ThirdParty CANopen Tools section here in the Forum
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

romaniuk
Posts: 5
Joined: Thu 9. May 2019, 06:38

Re: Recording CAN in Wireshark by PCAN-USB

Post by romaniuk » Fri 10. May 2019, 16:55

Hi,
Thank you for your responce.
Indeed the most critical part is how to have an interface of PCAN-usb that will feed messages to Wireshark.
I would rather avoid writing custom software, it is better to use something that is already available.
In my opinion CAN pretty good fits to network interface - it transports messages that are some kind of packets.
The total CANopen stack is not necessarily for my case, I need only to recognize and decode messages for debug purpose (nevertheles in our devices we are using the stack - I agree it is not trivial).
In Wireshark there is a way of providing extenssions by plugin mechanism - it is called dissector.
Decoding messages is simpler task than full stack implementation.
I can see USB interfaces (via USBcap) in Windows Wireshark, but I don't know (yet) how to filter messages from PCAN-usb hardware.

Kind regards,
Piotr Romaniuk

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1140
Joined: Fri 10. Sep 2010, 19:34

Re: Recording CAN in Wireshark by PCAN-USB

Post by U.Wilhelm » Fri 10. May 2019, 17:21

We know Dissectors and we also wrote some for our CAN to Ethernet Gateways (for UDP/IP Packages).
But this have absolute nothing to do with the real Windows/Linux Device drivers.
The USB Data Stream is not public, and based on our internal communication protocoll for our USB Devices
You will never could use this Data Stream to decode it by your own - the Protocl is not build for endusers and the communication is also protected. It is our internal Data Package format for USB Devices and do much more as send/receice CAN Frames.

Thats why we build real Device Drivers.

Or have you ever capture USB Memory Stick Data with WireShark and Decode the USB Packages to read the files from the USB Stick? Thats exact the same - so use the real API to access to the CAN Data.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

romaniuk
Posts: 5
Joined: Thu 9. May 2019, 06:38

Re: Recording CAN in Wireshark by PCAN-USB

Post by romaniuk » Sun 12. May 2019, 15:09

Thank you for explanation, Uwe.
Regards,
Piotr Romaniuk

romaniuk
Posts: 5
Joined: Thu 9. May 2019, 06:38

Re: Recording CAN in Wireshark by PCAN-USB

Post by romaniuk » Mon 13. May 2019, 11:07

Hi,
in Linux recording CANopen traffic by Wireshark works fine.
There is can interface (provided by kernel SocketCAN) in the system and ready to use dissector for CANopen.

Unfortunately in Windows your driver does not expose such packet interface, so it cannot be captured by Wireshark.
Is there any chance that you extend your Windows driver by this functionality?

I would like to ask you if you have CAN-View software for Linux?

Regards,
Piotr Romaniuk

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1140
Joined: Fri 10. Sep 2010, 19:34

Re: Recording CAN in Wireshark by PCAN-USB

Post by U.Wilhelm » Mon 13. May 2019, 11:26

If you use the community Socket CAN Driver all Socket CAN Tools could be used (also WireShark Dissector) - but we "only" develop the SocjetCAN Kernel Driver to be compatible to the LINUX CAN standard, but do not support any Tools for Socket CAN.

We have a own CharDev based driver that is API compatible with our Windows API, for this CharDev Driver we also support and build Tools (API, PCAN-View for Linux - a NCURSES based Software..)

So You could use the PCAN-View for LINUX, but only when run the CharDev (PEAK-System) driver. If you use the SocketCAN Driver, you must check the community what is available - we do not offer any Test Tools for SocketCAN. Check this page to download the CharDev driver and the PCAN-View for LINUX Tool.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

romaniuk
Posts: 5
Joined: Thu 9. May 2019, 06:38

Re: Recording CAN in Wireshark by PCAN-USB - solution

Post by romaniuk » Wed 15. May 2019, 12:08

Hi,
I used virtual machine on Windows host, where I installed Linux.
Wireshark works fine there with CANopen dissector.
PEAK-System PCAN-usb device is visible there as network interface. :)
vbox-xubuntu-wireshark-pcanusb.png
vbox-xubuntu-wireshark-pcanusb.png (278.13 KiB) Viewed 6691 times
Notes for others who will have the same problem:
1) In order to attach PCAN-usb to VirtualBox add "USB filter from device", edit the filter and clear Product field
2) expose can interface by:
sudo ip link set can0 type can bitrate 250000
sudo ifconfig can0 up
3) start Wireshark as root to see can0 interface

Versions:
host system: Windows 7 Professional
virtual machine: VirtualBox 6.0.8 + Extension Pack
system in virtual machine: Xubuntu 18.04 LTS 64bits
Wireshark 2.6.6

Kind regards,
Piotr Romaniuk,
BornElectric Sp z o. o.

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1140
Joined: Fri 10. Sep 2010, 19:34

Re: Recording CAN in Wireshark by PCAN-USB

Post by U.Wilhelm » Thu 16. May 2019, 10:06

Nice - but as i wrote - it is only possible when using Socket CAN on a LINUX System.
Using a VM could work, some implementations do, some not.. we have different customer feedbacks that running VMs with real CAN Hardware end up in timing problems, loose Frames etc. - but this is up to you if you want to run a VM.

Socket CAN is based on a Network Protocol Stack Implementation (Sockets) and so you could use the WireShark Tool. Keep in mind: You do not "read" USB Packages and do not sniff with WireShark the USB Communication.
You read CAN Driver Data, based on SocketCAN driver implementation for Linux.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Post Reply