Changes between Version 3 and Version 4 of WARPnet1/BuildClientScripts


Ignore:
Timestamp:
Jun 18, 2010, 2:08:03 PM (14 years ago)
Author:
sgupta
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WARPnet1/BuildClientScripts

    v3 v4  
    77There 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.
    88{{{
     9#!text/x-c
     10#define STRUCTID_CONTROL                                        0x13
     11#define STRUCTID_CONTROL_ACK                            0x14
     12
     13typedef struct {
     14        char structID;
     15        char nodeID;
     16        char txPower;
     17        char channel;
     18        char modOrderHeader;
     19        char modOrderPayload;
     20        short reserved;
     21        int pktGen_period;
     22        int pktGen_length;
     23} warpnetControl;
    924}}}
     25
    1026The next is the ControlStruct as seen in `warpnet_client_experiment_structs.py`.
     27
    1128{{{
     29#!text/x-python
     30class ControlStruct(ClientStruct):
     31        txPower = -1
     32        channel = -1
     33        modOrderHeader = -1
     34        modOrderPayload = -1
     35        reserved = 0
     36        packetGeneratorPeriod = 0
     37        packetGeneratorLength = 0
     38       
     39        def __init__(self):
     40                self.structID = STRUCTID_CONTROL
     41                self.txPower = 63
     42                self.channel = 4
     43                self.modOrderHeader = 0
     44                self.modOrderPayload = 2
     45                self.packetGeneratorPeriod = 0
     46                self.packetGeneratorLength = 1300
     47                self.expectedReturnStructID = STRUCTID_CONTROL_ACK
     48       
     49        def prepToSend(self, nodeID):
     50                self.updateDone = False
     51                return struct.pack('!6BHII', self.structID, nodeID, self.txPower, self.channel, self.modOrderHeader, self.modOrderPayload, self.reserved, self.packetGeneratorPeriod, self.packetGeneratorLength)
     52               
     53        def updateFromNode(self, rawData, pcapts):
     54                dataTuple = struct.unpack('!BBH', rawData[0:4])
     55                print "Control struct successfully applied at node %d" % dataTuple[1]
     56
    1257}}}
    1358