[zeromq-dev] No UDP broadcast message received using CZMQ zbeacon on RaspberryPi3
Luca Boccassi
luca.boccassi at gmail.com
Mon Nov 28 15:49:57 CET 2016
Hi,
There is a CZMQ 4.0.x series now, loads of changes have gone in since
3.0.2. I would recommend trying it as the first thing.
https://github.com/zeromq/czmq/releases
On Mon, 2016-11-28 at 12:42 -0200, Rodrigo Madruga wrote:
> Hello all,
>
> I am developing a system that uses CZMQ's zbeacon (broadcast on UDP) for
> app discovery. Beacon sender is Windows box and receiver is RaspberryPi3.
>
> As the subject says, no message is reaching the zbeacon actor.
>
> Using czmq3.0.2 and zmq4.1.6 built directly on pi to rule out
> cross-compiling issues.
>
> Calling just zbeacon_test() returns "OK" without assertions errors.
>
> Broadcast messages are indeed reaching the pi, as shown by tcpdump:
>
> pi at raspberrypi:~ $ sudo tcpdump udp port 5670
> tcpdump: verbose output suppressed, use -v or -vv for full protocol
> decode
> listening on wlan0, link-type EN10MB (Ethernet), capture size 262144
> bytes
> 13:33:56.203230 IP [REDACTED].5670 > 192.168.1.255.5670: UDP, length 22
> 13:34:01.072476 IP [REDACTED].5670 > 192.168.1.255.5670: UDP, length 22
>
> The code used to test is based on zbeacon_test function:
>
> zactor_t *listener = zactor_new (zbeacon, NULL);
> assert (listener);
> zsock_send (listener, "si", "CONFIGURE", 5670);
> hostname = zstr_recv (listener);
> assert (*hostname);
> free (hostname);
>
> zsock_send (listener, "sb", "SUBSCRIBE", "", 0);
>
> zpoller_t *poller = zpoller_new (listener, NULL);
> assert (poller);
> int64_t stop_at = zclock_mono () + 10000; // wait 10 seconds
> while (zclock_mono () < stop_at) {
> long timeout = (long) (stop_at - zclock_mono ());
> if (timeout < 0)
> timeout = 0;
> void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC);
> if (which) {
> char *ipaddress, *received;
> zstr_recvx (which, &ipaddress, &received, NULL);
> printf("From address %s:%s\n", ipaddress, received);
> zstr_free (&ipaddress);
> zstr_free (&received);
> }
> }
> zpoller_destroy (&poller);
>
> // Stop listening
> zstr_sendx (listener, "UNSUBSCRIBE", NULL);
>
> // Destroy the test nodes
> zactor_destroy (&listener);
>
> I cross-compiled a simple Qt app with a QUdpSocket (below) and the messages
> were received without issues:
>
> #include <QtNetwork/QUdpSocket>
>
> TestUDP::TestUDP(QObject *parent) :
> QObject(parent)
> {
> qDebug() << "Binding UDP Socket";
> socket = new QUdpSocket(this);
> socket->bind(QHostAddress::Any, 5670);
> connect(socket, &QUdpSocket::readyRead,this, &TestUDP::readyRead);
> qDebug() << "Ready Read signal connected0, waiting for broadcasts";
> }
>
> void TestUDP::readyRead(){
> QByteArray buffer;
> buffer.resize(socket->pendingDatagramSize());
> //var to store headers from udp
> QHostAddress sender;
> quint16 sender_port;
> socket->readDatagram(buffer.data(),buffer.size(), &sender,
> &sender_port);
> qDebug() << "Message from " << sender << " port " << sender_port;
> qDebug() << "Msg: " << buffer;
> }
>
> Maybe the problem is at the way zbeacon is dealing with the UDP socket...
>
> Has anyone successfully used a zbeacon on RPI3?
>
> Thanks in advance!
>
> Rodrigo Madruga.
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20161128/1315cb4c/attachment.sig>
More information about the zeromq-dev
mailing list