[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestNetwork
tn-injector.c, NONE, 1.1.2.1 Makefile, 1.1.2.2,
1.1.2.3 TestNetwork.h, 1.1.2.1, 1.1.2.2 TestNetworkAppC.nc,
1.1.2.4, 1.1.2.5
Phil Levis
scipio at users.sourceforge.net
Fri Jun 2 13:51:18 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestNetwork
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3699
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
Makefile TestNetwork.h TestNetworkAppC.nc
Added Files:
Tag: tinyos-2_0_devel-BRANCH
tn-injector.c
Log Message:
--- NEW FILE: tn-injector.c ---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "sfsource.h"
#include "serialpacket.h"
#include "test_network_msg.h"
#include "set_rate_msg.h"
#include "TestNetworkC.h"
int main(int argc, char **argv)
{
int fd,i;
if (argc != 5) {
fprintf(stderr, "Usage: %s <host> <port> <seqno> <rate> - change sample rate (ms/sample)\n", argv[0]);
exit(2);
}
fd = open_sf_source(argv[1], atoi(argv[2]));
if (fd < 0) {
fprintf(stderr, "Couldn't open serial forwarder at %s:%s\n",
argv[1], argv[2]);
exit(1);
}
uint8_t len = DISSEMINATION_MESSAGE_SIZE + SPACKET_SIZE + sizeof(uint16_t);
void* storage = malloc(len);
tmsg_t* serialMsg = new_tmsg(storage, len);
void* payload = storage + (spacket_data_offsetbits(0) / 8);
tmsg_t* dataMsg = new_tmsg(payload, DISSEMINATION_MESSAGE_SIZE + sizeof(uint16_t));
void* data = payload + (dissemination_message_data_offsetbits(0) / 8);
spacket_header_type_set(serialMsg, DISSEMINATION_MESSAGE_AM_TYPE);
spacket_header_length_set(serialMsg, DISSEMINATION_MESSAGE_SIZE + sizeof(uint16_t));
dissemination_message_key_set(dataMsg, SAMPLE_RATE_KEY);
dissemination_message_seqno_set(dataMsg, atoi(argv[3]));
uint16_t* rate = (uint16_t*)data;
*rate = (uint16_t)atoi(argv[4]);
printf("Writing packet:\n ");
for (i = 0; i < len; i++) {
printf("0.2x ", ((uint8_t*)storage)[i]);
}
printf("\n");
write_sf_packet(fd,storage,len);
}
Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestNetwork/Attic/Makefile,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** Makefile 23 May 2006 20:42:13 -0000 1.1.2.2
--- Makefile 2 Jun 2006 20:51:13 -0000 1.1.2.3
***************
*** 1,5 ****
COMPONENT=TestNetworkAppC
! CFLAGS += -I$(TOSDIR)/lib/net -I$(TOSDIR)/lib/net/collection \
! -I$(TOSROOT)/apps/tests/TestDissemination
include $(MAKERULES)
--- 1,34 ----
COMPONENT=TestNetworkAppC
! CFLAGS += -I$(TOSDIR)/lib/net -I$(TOSDIR)/lib/net/collection
!
! TFLAGS = -I$(TOSDIR)/../apps/tests/TestDissemination \
! -I$(TOSDIR)/../support/sdk/c \
! -I$(TOSDIR)/types \
! -I.
!
! LIBMOTE = $(TOSDIR)/../support/sdk/c/libmote.a
! BUILD_EXTRA_DEPS += tn-injector #tn-listener
! LISTEN_OBJS = collection_msg.o test_network_msg.o tn-listener.o $(LIBMOTE)
! INJECT_OBJS = set_rate_msg.o tn-injector.o $(LIBMOTE)
!
! tn-listener: $(LISTEN_OBJS)
! gcc -v $(CFLAGS) $(TFLAGS) -o $@ $(LISTEN_OBJS)
!
! tn-injector: $(INJECT_OBJS)
! gcc -v $(CFLAGS) $(TFLAGS) -o $@ $(INJECT_OBJS)
!
! %.o: %.c
! gcc $(CFLAGS) $(TFLAGS) -c -o $@ $<
!
!
! test_network_msg.c:
! mig -o test_network_msg.h c -target=$(PLATFORM) $(CFLAGS) $(TFLAGS) TestNetwork.h TestNetworkMsg
!
! set_rate_msg.c:
! mig -o set_rate_msg.h c -target=$(PLATFORM) $(CFLAGS) $(TFLAGS) $(TOSDIR)/lib/net/DisseminationEngine.h dissemination_message
!
! collection_msg.c:
! mig -o collection_msg.h c -target=$(PLATFORM) $(CFLAGS) $(TFLAGS) $(TOSDIR)/lib/net/collection/ForwardingEngine.h collection_header
!
include $(MAKERULES)
Index: TestNetwork.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestNetwork/Attic/TestNetwork.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** TestNetwork.h 19 May 2006 21:27:34 -0000 1.1.2.1
--- TestNetwork.h 2 Jun 2006 20:51:13 -0000 1.1.2.2
***************
*** 2,6 ****
#define TEST_NETWORK_H
! typedef nx_struct {
nx_uint16_t data;
} TestNetworkMsg;
--- 2,8 ----
#define TEST_NETWORK_H
! #include "TestNetworkC.h"
!
! typedef nx_struct TestNetworkMsg {
nx_uint16_t data;
} TestNetworkMsg;
Index: TestNetworkAppC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/TestNetwork/Attic/TestNetworkAppC.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** TestNetworkAppC.nc 26 May 2006 16:06:15 -0000 1.1.2.4
--- TestNetworkAppC.nc 2 Jun 2006 20:51:13 -0000 1.1.2.5
***************
*** 10,23 ****
* @version $Revision$ $Date$
*/
configuration TestNetworkAppC {}
implementation {
components TestNetworkC, MainC, LedsC, ActiveMessageC;
! components new DisseminatorC(uint16_t, 0x1) as Object16C;
! components new CollectionSenderC(0);
components TreeCollectionC as Collector;
components new TimerMilliC();
components new DemoSensorC();
! components new SerialAMSenderC(0);
TestNetworkC.Boot -> MainC;
--- 10,24 ----
* @version $Revision$ $Date$
*/
+ #include "TestNetwork.h"
configuration TestNetworkAppC {}
implementation {
components TestNetworkC, MainC, LedsC, ActiveMessageC;
! components new DisseminatorC(uint16_t, SAMPLE_RATE_KEY) as Object16C;
! components new CollectionSenderC(CL_TEST);
components TreeCollectionC as Collector;
components new TimerMilliC();
components new DemoSensorC();
! components new SerialAMSenderC(CL_TEST);
TestNetworkC.Boot -> MainC;
***************
*** 30,34 ****
TestNetworkC.ReadSensor -> DemoSensorC;
TestNetworkC.RootControl -> Collector;
! TestNetworkC.Receive -> Collector.Receive[0];
TestNetworkC.UARTSend -> SerialAMSenderC.AMSend;
}
--- 31,35 ----
TestNetworkC.ReadSensor -> DemoSensorC;
TestNetworkC.RootControl -> Collector;
! TestNetworkC.Receive -> Collector.Receive[CL_TEST];
TestNetworkC.UARTSend -> SerialAMSenderC.AMSend;
}
More information about the Tinyos-2-commits
mailing list