Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
app-notes:can-tcpsockets-parsing [2018/02/05 12:38]
preisig [Peaksystem PCAN-FMS Simulator]
app-notes:can-tcpsockets-parsing [2021/08/04 09:14] (current)
Line 3: Line 3:
  
 ===== Environment setup ===== ===== Environment setup =====
-{{:internal:​can_environment.jpg}}+{{:​can_environment.jpg}}
  
-The above graphic illustrates how the test environment was built and what data gets transmitted. First to be able to simulate a CAN bus in a local environment PC1 runs [[https://​www.peak-system.com/​PCAN-FMS-Simulator-2.246.0.html|Peak System PCAN-FMS Simulator]] to generate CAN Frames based on the FMS Standard (supports FMS v 1.0 – 3.0). The generated frames are transmitted over [[https://​www.peak-system.com/​PCAN-USB.199.0.html|Peak System PCAN-USB]] into a Netmodule Router (NB2800 used in this example). Two example scripts on the router work with the incoming CAN traffic and send it back out over TCP, where [[http://​sockettest.sourceforge.net/​|SocketTest]] runs an PC2 as a simple TCP server. SocketTest is a tool based on Java that allows testing of UDP and TCP client and server sockets. In our case SocketTest is configured as a TCP server that is listening on Port 2000. +The above graphic illustrates how the test environment was setup and what data gets transmitted. First to be able to simulate a CAN bus in a local environment PC1 runs [[https://​www.peak-system.com/​PCAN-FMS-Simulator-2.246.0.html|Peak System PCAN-FMS Simulator]] to generate CAN Frames based on the FMS Standard (supports FMS v 1.0 – 3.0). The generated frames are transmitted over [[https://​www.peak-system.com/​PCAN-USB.199.0.html|Peak System PCAN-USB]] into a Netmodule Router (NB2800 used in this example). Two example scripts on the router work with the incoming CAN traffic and send it back out over TCP, where [[http://​sockettest.sourceforge.net/​|SocketTest]] runs an PC2 as a simple TCP server. SocketTest is a tool based on Java that allows testing of UDP and TCP client and server sockets. In our case SocketTest is configured as a TCP server that is listening on Port 2000. 
  
 ===== Setup the CAN Interface on the Router ===== ===== Setup the CAN Interface on the Router =====
 To use the CAN Interface on the Router first you need to enable the CAN Interface with the correct Bitrate (250kBits used). To use the CAN Interface on the Router first you need to enable the CAN Interface with the correct Bitrate (250kBits used).
  
-{{:internal:​netbox-can-setup.jpg?​600|}}+{{:​netbox-can-setup.jpg?​600|}}
  
 ===== Peaksystem PCAN-FMS Simulator ===== ===== Peaksystem PCAN-FMS Simulator =====
Line 17: Line 17:
  
 ===== Incoming RAW CAN Frames on the Router: ===== ===== Incoming RAW CAN Frames on the Router: =====
-The first and most simple test on the router ​was to use candump provided by the can-utils package to verify a working environment and to see the generated CAN traffic. Login to your router (over ssh or telnet) and run ''​candump <​can-interface>''​+The first and most simple test on the router ​is to use candump provided by the can-utils package to verify a working environment and to see the generated CAN traffic. Login to your router (over ssh or telnet) and run ''​candump <​can-interface>''​
  
 By default, candump provides the following information:​ By default, candump provides the following information:​
  
-{{:internal:​candump.jpg}}+{{:​candump.jpg}}
  
 Interface, CAN Identifier, DLC and DATA  Interface, CAN Identifier, DLC and DATA 
  
 ===== Forward CAN Frames over TCP Sockets (can-tcp-broadcast.are) ===== ===== Forward CAN Frames over TCP Sockets (can-tcp-broadcast.are) =====
-To show a possible use of forwarding CAN Frames over Ethernet can-tcp-broadcast.are provides a TCP client that broadcasts all incoming CAN Frames to one or several servers that can be passed as arguments. The SDK API already provides several functions to interact with CAN (see ftp://​share.netmodule.com/router/​public/​system-software/​latest/​NB_SDK_API_Manual.pdf). ​+To show a possible use of forwarding CAN Frames over Ethernet can-tcp-broadcast.are provides a TCP client that broadcasts all incoming CAN Frames to one or several servers that can be passed as arguments. The SDK API already provides several functions to interact with CAN (see https://​share.netmodule.com/​public/​system-software/​latest/​NB_SDK_API_Manual.pdf). ​
 The function start_can() sets required attributes to the can interface and sets up a raw socket descriptor that is used in the main part of the script. Additionally filtering of CAN Identifiers is possible via nb_can_setfilter() to specify which CAN frames shall be filtered out and which shall be passed to upper layers. The function start_can() sets required attributes to the can interface and sets up a raw socket descriptor that is used in the main part of the script. Additionally filtering of CAN Identifiers is possible via nb_can_setfilter() to specify which CAN frames shall be filtered out and which shall be passed to upper layers.
 +
 +//Please be aware// that extended use of filtering or processing on the router itself may affect the overall processing power. An advice would be, to do data processing on a more powerful backend according to ones needs. ​
 +
  
 <code c from can-tcp-broadcast.are>​ <code c from can-tcp-broadcast.are>​
Line 93: Line 96:
 On the receiving end SocketTest listens on TCP port 2000 and displays the raw CAN frames: On the receiving end SocketTest listens on TCP port 2000 and displays the raw CAN frames:
  
-{{:internal:​sockettest-candump.jpg?​600|}} +{{:​sockettest-candump.jpg?​600|}}
- +
-This way data processing could be done on a more powerful backend according to ones needs. Please be sure to check the load of the router to assure normal operation of the device. +
 ===== Simple CAN Frame parsing (simple-can-parser.are) ===== ===== Simple CAN Frame parsing (simple-can-parser.are) =====
 An additional test was made to show a simple way of parsing CAN Frames. The example is based on checking for a specific PGN (parameter group number) and then get a SPN (supect parameter name) to display its value in human readable format which then gets logged in a file.  An additional test was made to show a simple way of parsing CAN Frames. The example is based on checking for a specific PGN (parameter group number) and then get a SPN (supect parameter name) to display its value in human readable format which then gets logged in a file.