Example for sending messages to wireless gateway

CAN to WLAN Gateways in a plastic housing with a flange
Post Reply
arasbm
Posts: 6
Joined: Mon 29. May 2017, 19:50

Example for sending messages to wireless gateway

Post by arasbm » Thu 20. Jul 2017, 00: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/viewt ... 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, 19:50

Re: Example for sending messages to wireless gateway

Post by arasbm » Thu 20. Jul 2017, 01: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!

S.Michaelsen
Hardware Development
Hardware Development
Posts: 87
Joined: Fri 10. Sep 2010, 13:11

Re: Example for sending messages to wireless gateway

Post by S.Michaelsen » Thu 20. Jul 2017, 08: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

arasbm
Posts: 6
Joined: Mon 29. May 2017, 19:50

Re: Example for sending messages to wireless gateway

Post by arasbm » Thu 20. Jul 2017, 19: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!

S.Michaelsen
Hardware Development
Hardware Development
Posts: 87
Joined: Fri 10. Sep 2010, 13:11

Re: Example for sending messages to wireless gateway

Post by S.Michaelsen » Fri 21. Jul 2017, 07: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

Post Reply