Skip to content

mbed-os-snippet-UDPSocket prints wrong time #126

Description

@JojoS62

The example shows the usage of an UDP socket, and this works. But finally, the received time (seconds sind 1970) prints the correct date only by sudden.
https://github.com/ARMmbed/mbed-os-snippet-UDPSocket/blob/18ae5c765b96ca5bcfd9c584c7cc776ff3ef0867/main.cpp#L48
There is a typecast from a 4 byte to an 8 byte pointer, this works only when the upper 4 bytes are zero.
This is a fix for this (PRs doesnt seem to be used):

            time_t now = in_data.secs;
            printf("Time = %s", ctime(&now));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions