7 years, 2 months ago.

FRDM-K64F UDPSocket methods return -3005 and -3003... why not 0 or -1?

Hi all,

I've implemented the below test app to try and identify the problem. Am i doing something wrong, because not only does UDP not broadcast, it also returns weird numbers. I'm using the K64F with mbed OS 5.3.4. Tried previous 5 versions, with same results.

main.cpp

#include "mbed.h"
#include "EthernetInterface.h"
#include "UDPSocket.h"

DigitalOut led1(LED1);
EthernetInterface eth;
UDPSocket udp;
Serial pc(USBTX, USBRX);
char msg[8] = "GusTest";
uint16_t port = 3648;
const char addr[16] = "255.255.255.255";
int i;

// main() runs in its own thread in the OS
// (note the calls to wait below for delays)
int main()
{
    pc.baud(115200);
    pc.printf("\r\nStarting...\r\n");
    i = eth.connect();
    pc.printf("\r\nConnect code %d IP is: %s\r\n",i, eth.get_ip_address());
    i = udp.bind(addr, port);
    pc.printf("\r\nBind code for %s on port %d = %d\r\n",addr, port, i);
    i = udp.open(&eth);
    pc.printf("\r\nOpen code %d\r\n", i);

    while (true) {
        led1 = !led1;
        i = udp.sendto(addr, port, msg, sizeof(msg));
        pc.printf("\r\nSend Code %d\r\n", i);
        wait(2);
    }
}

Output

Starting...

Connect code 0 IP is: xxx.xxx.xxx.xxx

Bind code for 255.255.255.255 on port 3648 = -3005

Open code 0

Send Code -3003

Send Code -3003

Send Code -3003

Same problem here...

posted by yota news 03 Apr 2017
Be the first to answer this question.