Changes between Version 9 and Version 10 of 802.11/wlan_exp/Extending
- Timestamp:
- Dec 14, 2015, 10:16:54 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
802.11/wlan_exp/Extending
v9 v10 88 88 === Example Command: Reading Tx Queue Status === 89 89 90 {{{my_node}}} is an instance of a wlan_exp node object that has already been initialized. 90 This example shows how to implement a custom wlan_exp command, including the required Python and C code. The example command retrieves the status of the Tx queues from the WARP node. The upper-level MAC responds to the command with the number of packets currently enqueued in each Tx queue. Because each upper-level MAC (AP, STA, IBSS) handles Tx queues differently the command handler is implemented in the {{{wlan_exp_user_ap_process_cmd()}}} function of the top-level MAC. 91 92 '''Python Code'''[[BR]] 93 94 The first step is to implement a Python method to send the command and process the results. This method is shown below. 91 95 92 96 {{{#!python … … 124 128 This method takes one node object as its argument, sends the {{{USER_CMDID_TX_QUEUE_STATUS}}} command to the node, then parses the response. If the response is valid it returns the list of queue id/occupancy values. 125 129 130 You can implement this method wherever it is callable from your Python script. The easiest place is to include the method at the top of your script, then call it directly during the experiment. 131 132 '''C Code'''[[BR]] 133 126 134 Each upper-level MAC application implements its own callback function for handling application-specific user commands. By default these functions are empty. You must modify the C code to implement the behaviors required for your custom command. 127 135 128 In this example the custom command will query the lengths of Tx queues. 129 Modify the {{{wlan_exp_user_ap_process_cmd()}}} function in {{{wlan_mac_ap.c}}}. 136 Modify the {{{wlan_exp_user_ap_process_cmd()}}} function in {{{wlan_mac_ap.c}}}. Start by defining some local variables at the top of the function: 137 130 138 {{{#!c 131 139 … … 138 146 }}} 139 147 140 Add a new case for the new command ID to the {{{switch(cmd_id)}}} statement: 141 142 {{{#!C 148 149 Next, add a new case for the your command ID to the {{{switch(cmd_id)}}} statement: 150 151 {{{#!c 143 152 case USER_CMDID_TX_QUEUE_STATUS: 144 153 xil_printf("Got Tx queue status cmd\n"); … … 210 219 211 220 break; 212 213 221 }}} 214 222