BeagleBone Black: Qt 5.3 fails to send datagrams in UDP



  • I cross-compiled Qt 5.3 for BeagleBone Black (running Debian Linux) and I am trying to send some datagrams to broadcast via UDP.

    Here is my code:

    @ #include <QCoreApplication>
    #include <QUdpSocket>
    #include <QDebug>

    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        QUdpSocket socket;
    
        QByteArray d = QString("Hello, world!").toLatin1();
        int r = socket.writeDatagram(d, QHostAddress::Broadcast, 1111);
    
        qDebug() << r;
        qDebug() << socket.error();
        qDebug() << socket.errorString();
    
        return a.exec&#40;&#41;;
    }@
    

    Unluckily it does not work and the output of the program is:

    @-1
    QAbstractSocket::NetworkError
    "Unable to send a message"@

    So the writeDatagram primitive fails. The same exact code works perfectly fine when compiled for my desktop PC... So I am assuming that the code is good and probably there is something specifically related to BBB.

    I also tried to send the datagram to a specific IP address (instead of broadcast) but it does not change: BBB seems to be not able to send UDP packets at all...

    Any ideas about that? Is there something to be configured on BBB for letting this work?



  • Have you check the ip of the bbb?



  • Here is my BBB network setup:

    debian@arm:/home/root$ ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP ql
    en 1000
    link/ether 1c:ba:8c:da:47:78 brd ff:ff:ff:ff:ff:ff
    inet 192.168.79.13/24 brd 255.255.255.255 scope global eth0
    valid_lft forever preferred_lft forever
    inet6 fe80::1eba:8cff:feda:4778/64 scope link
    valid_lft forever preferred_lft forever
    3: usb0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOW
    N qlen 1000
    link/ether 56:08:c7:ca:c0:44 brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.2/30 brd 192.168.7.3 scope global usb0
    valid_lft forever preferred_lft forever

    It seems good to me... Am I wrong?



  • It seems that on Linux you have to bind on a given interface for broadcasting packets out ot if...

    You can read the full story "here":http://stackoverflow.com/questions/24866807/beaglebone-black-qt-5-3-fails-to-send-datagrams-in-udp?noredirect=1#comment38645537_24866807


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.