= Building and Running Client Scripts = Here we will build and run a client script. To see a complete example refer to [wiki:WARPnet/Example the example script]. == Building the Client Script == There are two files that the user control over as the build their custom scripts to control the boards. The first is `warpnet_client_experiment_structs.py`. This file defines the data structures that are sent back and forth between the FPGA design and the client script. The FPGA design and this file must be in sync for data to be accurately transferred between the two. Let us look at an example to understand how this file is built. The following is the ControlStruct that is used to set basic node parameters. First we see the C struct that is stored in the FPGA. {{{ #!c #define STRUCTID_CONTROL 0x13 #define STRUCTID_CONTROL_ACK 0x14 typedef struct { char structID; char nodeID; char txPower; char channel; char modOrderHeader; char modOrderPayload; short reserved; int pktGen_period; int pktGen_length; int pktGen_numPackets; } warpnetControl; }}} The next is the ControlStruct as seen in `warpnet_client_experiment_structs.py`. {{{ #!python class ControlStruct(ClientStruct): txPower = -1 channel = -1 modOrderHeader = -1 modOrderPayload = -1 reserved = 0 packetGeneratorPeriod = 0 packetGeneratorLength = 0 packetGeneratorNumPackets = 0 def __init__(self, logger=None): ClientStruct.__init__(self, logger) self.structID = STRUCTID_CONTROL self.expectedReturnStructID = STRUCTID_CONTROL_ACK self.txPower = 63 self.channel = 4 self.modOrderHeader = 0 self.modOrderPayload = 2 self.packetGeneratorPeriod = 10 self.packetGeneratorLength = 1300 self.packetGeneratorNumPackets = 1000 def prepToSend(self, nodeID): self.updateDone = False return struct.pack('!6BHII', self.structID, nodeID, self.txPower, self.channel, self.modOrderHeader, \ self.modOrderPayload, self.reserved, self.packetGeneratorPeriod, self.packetGeneratorLength) def updateFromNode(self, rawData, pcapts): dataTuple = struct.unpack('!BBH', rawData[0:4]) }}} == Running the Client Script == 1. Once the client script has been written, navigate to the folder where it is located. 1. Run the following: {{{ python experiment.py }}}