[Tinyos-commits] CVS: tinyos-1.x/tools/src/sf sf.c, 1.6, 1.7 sfsource.c, 1.5, 1.6 sfsource.h, 1.3, 1.4

David Gay idgay at users.sourceforge.net
Mon Dec 13 11:43:46 PST 2004


Update of /cvsroot/tinyos/tinyos-1.x/tools/src/sf
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5650

Modified Files:
	sf.c sfsource.c sfsource.h 
Log Message:
bug fix (oops)
platform cleanup (more)


Index: sf.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tools/src/sf/sf.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** sf.c	20 Nov 2004 02:49:38 -0000	1.6
--- sf.c	13 Dec 2004 19:43:43 -0000	1.7
***************
*** 16,20 ****
  int server_socket;
  int packets_read, packets_written, num_clients;
- int platform;
  
  struct client_list
--- 16,19 ----

Index: sfsource.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tools/src/sf/sfsource.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** sfsource.c	20 Nov 2004 02:40:37 -0000	1.5
--- sfsource.c	13 Dec 2004 19:43:43 -0000	1.6
***************
*** 10,13 ****
--- 10,15 ----
  #include "sfsource.h"
  
+ uint32_t platform;
+ 
  int saferead(int fd, void *buffer, int count)
  {
***************
*** 88,95 ****
  }
  
! extern int platform; 
  
  int init_sf_source(int fd)
  /* Effects: Checks that fd is following the serial forwarder protocol
     Returns: 0 if it is, -1 otherwise
   */
--- 90,100 ----
  }
  
! extern uint32_t platform; 
  
  int init_sf_source(int fd)
  /* Effects: Checks that fd is following the serial forwarder protocol
+      Sends 'platform' for protocol version '!', and sets 'platform' to
+      the received platform value.
+    Modifies: platform
     Returns: 0 if it is, -1 otherwise
   */
***************
*** 97,101 ****
    char check[2], us[2];
    int version;
!   char nonce[4];
    /* Indicate version and check if serial forwarder on the other end */
    us[0] = 'T'; us[1] = '!';
--- 102,106 ----
    char check[2], us[2];
    int version;
!   unsigned char nonce[4];
    /* Indicate version and check if serial forwarder on the other end */
    us[0] = 'T'; us[1] = '!';
***************
*** 113,122 ****
      case ' ': break;
      case '!': 
!       nonce[0] = (char)  (platform        & 0xff);
!       nonce[1] = (char) ((platform >>  8) & 0xff);
!       nonce[2] = (char) ((platform >> 16) & 0xff);
!       nonce[3] = (char) ((platform >> 24) & 0xff);
        if (safewrite(fd, nonce, 4) != 4)
  	return -1;
        break;
      }
--- 118,130 ----
      case ' ': break;
      case '!': 
!       nonce[0] = platform;
!       nonce[1] = platform >>  8;
!       nonce[2] = platform >> 16;
!       nonce[3] = platform >> 24;
        if (safewrite(fd, nonce, 4) != 4)
  	return -1;
+       if (saferead(fd, nonce, 4) != 4)
+ 	return -1;
+       platform = nonce[0] | nonce[1] << 8 | nonce[2] << 16 | nonce[3] << 24;
        break;
      }

Index: sfsource.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tools/src/sf/sfsource.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** sfsource.h	12 Feb 2004 01:19:37 -0000	1.3
--- sfsource.h	13 Dec 2004 19:43:43 -0000	1.4
***************
*** 2,8 ****
--- 2,11 ----
  #define SFSOURCE_H
  
+ extern uint32_t platform;
+ 
  int open_sf_source(const char *host, int port);
  /* Returns: file descriptor for serial forwarder at host:port, or
       -1 for failure
+      (see init_sf_source for description of platform handling)
   */
  
***************
*** 11,14 ****
--- 14,20 ----
       Use this if you obtain your file descriptor from some other source
       than open_sf_source (e.g., you're a server)
+      Sends 'platform' for protocol version '!', and sets 'platform' to
+      the received platform value.
+    Modifies: platform
     Returns: 0 if it is, -1 otherwise
   */



More information about the Tinyos-commits mailing list