Decode a CAN frame in node.js web server

This forum covers issues concerning multiple software products.

Decode a CAN frame in node.js web server

Postby flobig » Mon 27. Feb 2017, 13:15

Hello,
I would like to communicate between the PCAN Ethernet Gateway and my own web application on my computer. To do so, I deactivated the handshake as explained in the user manual. However, I am not able to make my application work and to decode the CAN data that is encapsulated in the Ethernet frame. I can read some data but it's completely encoded and the server cannot display an understandable message in log. I did look at the C# example you provided but in my case I have to write this driver in node.js. I tried using a raw-socket package but it’s not clear to me... Would you have by any chance an application example in JavaScript or know what the problem might be ? Thanks in advance.
Attachments
Capture1.PNG
When trying to decode the CAN frame
Capture1.PNG (54.17 KiB) Viewed 1425 times
flobig
 
Posts: 4
Joined: Mon 27. Feb 2017, 13:00

Re: Decode a CAN frame in node.js web server

Postby U.Wilhelm » Mon 27. Feb 2017, 15:54

We have no JavaScript sample (very uncommon language for analyzing CAN Frames..) But the Data Structure is very simple and very well explained - see PCAN-Gateways Developer Documentation PDF, page 9.
Develop_Gateway_Doku.JPG
Develop_Gateway_Doku.JPG (65.28 KiB) Viewed 1419 times

It must be a problem with your Datatypes you use.
For me it looks as you simply print out the Data as ASCII Code...but these are binary Data !

Please check this first:
• Switch Handshake of the used system off
• Define ONE route from CAN1 to IP: xxx.xxx.xxx, set Handshake off, use UDP, port yyy
• Create CAN Traffic on the CAN1
• Open on the target PC with the IP xxx.xxx.xxx. (don’t care if Linux, Windows, iOS, UNIX etc…) your Wireshark Tool. Listen in WireShark on the defined port yyy
We also offer a wire shark LUA extension so that yopu could "sniff" also the traffic using Wireshark and see how the packate is build. See here: http://www.peak-system.com/produktcd/
Product-CD.jpg
Product-CD.jpg (22.66 KiB) Viewed 1419 times

You will see the incoming Messages from the CAN Gateway – that’s all – the rest is your own software.
Here you find a screen of a simple incoming UDP Stream on port 52000 to IP 10.1.12.78 in WireShark (using the Injector – but you also could run without)
WireShark_Sample.jpg
WireShark_Sample.jpg (256.01 KiB) Viewed 1419 times
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 1039
Joined: Fri 10. Sep 2010, 18:34
Location: Darmstadt

Re: Decode a CAN frame in node.js web server

Postby flobig » Tue 28. Feb 2017, 14:48

Thank you for your response. I think I understand what my problem is. The reason why I am using JavaScript is because I need to communicate between the gateway and a web application. The tricky part for me is developing a driver-like application to enable the Ethernet communication between my web application and the Gateway, and of course decoding/encoding the data in the CAN frame.
flobig
 
Posts: 4
Joined: Mon 27. Feb 2017, 13:00


Return to Software



This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy