6 years, 5 months ago.

Problem with UDPSocket and ticker.attach

Hi, i've a problem with UDPSocket class when I try to send a message inside a ticker.attach. In fact the board enters a sort of loop and does nothing; and so not send the message. Has someone a solution to this problem?

This is the code:

#include "mbed.h"
#include <stdio.h>
#include <string>
#include "EthernetInterface.h"

EthernetInterface eth;
UDPSocket sock;
Endpoint echo_server_pc;

void UdpSend(){ 
    //Read EthDevice
    char out_buffer[] = "Hello"; 
    sock.sendTo(echo_server_pc, out_buffer, sizeof(out_buffer));

int main (void)
    eth.init("","",""); //Not Use DHCP

    echo_server_pc.set_address("", 8080);
    //Start the ticker
    tick.attach_us(&UdpSend, 100*1000);//100ms

I've a K64F board. Thanks

Be the first to answer this question.