Example for sending messages to wireless gateway

CAN to WLAN Gateways in a plastic housing with a flange

Example for sending messages to wireless gateway

Postby arasbm » Wed 19. Jul 2017, 23:43

I am trying to make a virtual CAN gateway for Linux that uses Socket CAN in C++. I am able to receive packets on UDP port and relay them to vcan0. However I am a bit stuck on packaging CAN messages I am receiving on vcan0 into UDP packages and sending them to the PCAN wireless gateway. I have studied the example C# app (https://www.peak-system.com/forum/viewtopic.php?f=156&t=1340) but that code only handles receiving messages not sending. I have also looked at the developer documentation. I think all the information I need is in developer doc, but I would appreciate a bit more help with this. Do you have an example code for sending CAN messages over UDP to PCAN wireless gateway?

My second question is, do I need to create a second route in the PCAN wireless for receiving messages?

This decive is pretty amazing so far. I cant wait to finish my virtual gateway. So far it is performing very well 8-)

Thank you!
arasbm
 
Posts: 6
Joined: Mon 29. May 2017, 18:50

Re: Example for sending messages to wireless gateway

Postby arasbm » Thu 20. Jul 2017, 00:56

To follow up with a bit more specifi information. Here is my code for opening remote socket:
Code: Select all
    socket = new QUdpSocket(this);
    qInfo() << "setting remote address: " << remoteGatewayAddress.setAddress("192.168.10.99");
    socket->bind(remoteGatewayAddress, 50001);

    if(socket->state() != socket->BoundState) {
        qInfo() << "UdpSender: Error! can not open connection ";
    } else {
        qInfo() << "UdpSender: Bound to Remote UDP Socket. Lets send!";
    }


On the PCAN wireless gateway I have made a new route for IP->CAN using Local IP - Port:50001. But I get the error above "UdpSender: Error! can not open connection ". And on the PCAN online interface the light remains yellow for the newly created route.

Hope it is a bit more clear what I am trying to achieve. Any help is much appreciated!
arasbm
 
Posts: 6
Joined: Mon 29. May 2017, 18:50

Re: Example for sending messages to wireless gateway

Postby S.Michaelsen » Thu 20. Jul 2017, 07:03

Hi,
did you disable the handshake mechanism as described in chapter 1.3 of the developer documentation? The status light should get blue then instead of yellow…

Best Regards,
Stephan
S.Michaelsen
Hardware Development
Hardware Development
 
Posts: 69
Joined: Fri 10. Sep 2010, 12:11

Re: Example for sending messages to wireless gateway

Postby arasbm » Thu 20. Jul 2017, 18:49

Hi Stephan,
That was part of the problem. You are right, I forgot to turn hanshake off for the second route. I have disabled the handshake now and the route status icon is blue. However, I still can not bind to the port from my app. Is there anything else I am missing?
If you have a simple sample code for sending messages from PC to the PCAN wireless gateway, that would be much appreciated.

Thanks!
arasbm
 
Posts: 6
Joined: Mon 29. May 2017, 18:50

Re: Example for sending messages to wireless gateway

Postby S.Michaelsen » Fri 21. Jul 2017, 06:30

Hi,

there are small C examples to send / receive messages to / from the gateways. Please write a short mail to our support with a reference to this thread so that they can send them to you.

BR,
Stephan
S.Michaelsen
Hardware Development
Hardware Development
 
Posts: 69
Joined: Fri 10. Sep 2010, 12:11


Return to PCAN-Wireless Gateway



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