changeset 110:fb56681ab1d6 scope-refactoring

Parsing header in udp-server.c
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 19 Aug 2015 22:36:45 +0100
parents ad8a93cd7c39
children 9928b6366227
files resources/network/udp-server.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/resources/network/udp-server.c	Tue Aug 18 14:53:16 2015 +0100
+++ b/resources/network/udp-server.c	Wed Aug 19 22:36:45 2015 +0100
@@ -47,8 +47,9 @@
        n = recvfrom(sock,buf,2048,0,(struct sockaddr *)&from,&fromlen);
        if (n < 0) error("recvfrom");
        printf("Received a datagram of size %d: \n", n);
-       for(i=0; i<n/sizeof(float); i+=8)
-	       printf("[%05d]: %+f, %+f, %+f, %+f, %+f, %+f, %+f, %+f\n",i,buf[0+i],buf[1+i],buf[2+i],buf[3+i],buf[4+i],buf[5+i],buf[6+i],buf[7+i]);
+       printf("Header: channel: %d, timestamp: %d\n", (int)buf[0], (int)buf[1]);
+       for(i=2; i<n/sizeof(float); i+=8)
+	       printf("%+f, %+f, %+f, %+f, %+f, %+f, %+f, %+f\n",i,buf[0+i],buf[1+i],buf[2+i],buf[3+i],buf[4+i],buf[5+i],buf[6+i],buf[7+i]);
        n = sendto(sock,"Got your message\n",17,
                   0,(struct sockaddr *)&from,fromlen);
        if (n  < 0) error("sendto");