[Tinyos-2-commits] CVS: tinyos-2.x/support/sdk/c README, 1.1.2.1, 1.1.2.2 sfsend.c, 1.1.2.1, 1.1.2.2

David Gay idgay at users.sourceforge.net
Tue Jun 6 08:12:58 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/support/sdk/c
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8975

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	README sfsend.c 
Log Message:
make sfsend do something useful


Index: README
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/support/sdk/c/Attic/README,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** README	4 May 2006 21:11:58 -0000	1.1.2.1
--- README	6 Jun 2006 15:12:56 -0000	1.1.2.2
***************
*** 41,47 ****
  - sfsend: send a packet (specified on the command line) to a serial forwarder
  
  
  For more information on using ncg and mig with C, see the nescc-mig and
  nescc-ncg man pages.
  
! For more information on serial communication to and from motes, see TEP113.
--- 41,51 ----
  - sfsend: send a packet (specified on the command line) to a serial forwarder
  
+ Note that sflisten prints, and sfsend sends, raw packets. In particular,
+ the first byte indicates the packet type (e.g., 00 for the AM-over-serial
+ packets). For more information on serial communication to and from motes,
+ see TEP113.
  
  For more information on using ncg and mig with C, see the nescc-mig and
  nescc-ncg man pages.
  
! 

Index: sfsend.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/support/sdk/c/Attic/sfsend.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** sfsend.c	16 Feb 2006 01:20:01 -0000	1.1.2.1
--- sfsend.c	6 Jun 2006 15:12:56 -0000	1.1.2.2
***************
*** 5,15 ****
  #include "sfsource.h"
  
  int main(int argc, char **argv)
  {
!   int fd,j=0;
  
!   if (argc != 3)
      {
!       fprintf(stderr, "Usage: %s <host> <port> - dump packets from a serial forwarder\n", argv[0]);
        exit(2);
      }
--- 5,35 ----
  #include "sfsource.h"
  
+ void send_packet(int fd, char **bytes, int count)
+ {
+   int i;
+   unsigned char *packet;
+ 
+   packet = malloc(count);
+   if (!packet)
+     exit(2);
+ 
+   for (i = 0; i < count; i++)
+     packet[i] = strtol(bytes[i], NULL, 0);
+       
+   fprintf(stderr,"Sending ");
+   for (i = 0; i < count; i++)
+     fprintf(stderr, " %02x", packet[i]);
+   fprintf(stderr, "\n");
+ 
+   write_sf_packet(fd, packet, count);
+ }
+ 
  int main(int argc, char **argv)
  {
!   int fd;
  
!   if (argc < 4)
      {
!       fprintf(stderr, "Usage: %s <host> <port> <bytes> - send a raw packet to a serial forwarder\n", argv[0]);
        exit(2);
      }
***************
*** 21,43 ****
        exit(1);
      }
-   for (;;)
-     {
-       int i=0,lenp;
-       unsigned char packet[100];
  
!       packet[i++] = 0xff; // addr low byte
!       packet[i++] = 0xff; // addr high byte
!       packet[i++] = 0x04; // AM id
!       packet[i++] = 0xbc; // group id
!       lenp = i++;         // length
!       packet[i++] = j;    // payload
!       packet[i++] = 0xbe; // payload
!       packet[i++] = 0xef; // payload
  
!       packet[lenp] = i-5; // length, don't include header
!       
!       fprintf(stderr,"Sending packet %d...\n",++j);
!       write_sf_packet(fd,packet,i);
!       sleep(1);
!     }
  }
--- 41,47 ----
        exit(1);
      }
  
!   send_packet(fd, argv + 3, argc - 3);
  
!   close(fd);
  }



More information about the Tinyos-2-commits mailing list