source: ReferenceDesigns/w3_802.11/c/wlan_mac_high_ibss/wlan_mac_ibss_uart_menu.c

Last change on this file was 6319, checked in by chunter, 5 years ago

1.8.0 release wlan-mac-se

File size: 8.0 KB
Line 
1/** @file wlan_mac_sta_uart_menu.c
2 *  @brief Station UART Menu
3 *
4 *  This contains code for the 802.11 Station's UART menu.
5 *
6 *  @copyright Copyright 2014-2019, Mango Communications. All rights reserved.
7 *          Distributed under the Mango Communications Reference Design License
8 *              See LICENSE.txt included in the design archive or
9 *              at http://mangocomm.com/802.11/license
10 */
11
12/***************************** Include Files *********************************/
13
14// Xilinx SDK includes
15#include "xparameters.h"
16#include "stdio.h"
17#include "stdlib.h"
18#include "string.h"
19
20// WLAN includes
21#include "wlan_mac_802_11_defs.h"
22#include "wlan_mac_queue.h"
23#include "wlan_mac_high.h"
24#include "wlan_mac_packet_types.h"
25#include "wlan_mac_eth_util.h"
26#include "wlan_mac_ibss.h"
27#include "ascii_characters.h"
28#include "wlan_mac_schedule.h"
29#include "wlan_mac_event_log.h"
30#include "wlan_mac_network_info.h"
31#include "wlan_mac_station_info.h"
32#include "wlan_platform_common.h"
33#include "wlan_mac_dl_list.h"
34
35
36//
37// Use the UART Menu
38//     - If WLAN_USE_UART_MENU in wlan_mac_ibss.h is commented out, then this function
39//       will do nothing.  This might be necessary to save code space.
40//
41
42
43#ifndef WLAN_USE_UART_MENU
44
45void uart_rx(u8 rxByte){ };
46
47#else
48
49
50/*************************** Constant Definitions ****************************/
51
52//-----------------------------------------------
53// UART Menu Modes
54#define UART_MODE_MAIN        0
55#define UART_MODE_INTERACTIVE 1
56
57
58/*********************** Global Variable Definitions *************************/
59extern network_info_t*                      active_network_info;
60extern u16 mcast_qid;
61extern u16 mgmt_qid;
62
63/*************************** Variable Definitions ****************************/
64
65static volatile u8 uart_mode = UART_MODE_MAIN;
66static volatile u32 schedule_id;
67static volatile u8 print_scheduled = 0;
68
69/*************************** Functions Prototypes ****************************/
70
71void print_main_menu();
72
73void print_queue_status();
74void print_station_status();
75
76void start_periodic_print();
77void stop_periodic_print();
78
79
80/*************************** Variable Definitions ****************************/
81
82
83/******************************** Functions **********************************/
84
85
86/*****************************************************************************/
87/**
88 * Process each character received by the UART
89 *
90 * The following functionality is supported:
91 *    - Main Menu
92 *      - Interactive Menu (prints all station infos)
93 *      - Print queue status
94 *      - Print all counts
95 *      - Print event log size (hidden)
96 *      - Print Network List
97 *      - Print Malloc info (hidden)
98 *    - Interactive Menu
99 *      - Reset counts
100 *      - Turn on/off "Traffic Blaster" (hidden)
101 *
102 * The escape key is used to return to the Main Menu.
103 *
104 *****************************************************************************/
105void uart_rx(u8 rxByte){
106
107    // ----------------------------------------------------
108    // Return to the Main Menu
109    //    - Stops any prints / LTGs
110    if (rxByte == ASCII_ESC) {
111        uart_mode = UART_MODE_MAIN;
112        stop_periodic_print();
113        print_main_menu();
114        return;
115    }
116
117    switch (uart_mode) {
118
119        // ------------------------------------------------
120        // Main Menu processing
121        //
122        case UART_MODE_MAIN:
123            switch(rxByte){
124
125                // ----------------------------------------
126                // '1' - Switch to Interactive Menu
127                //
128                case ASCII_1:
129                    uart_mode = UART_MODE_INTERACTIVE;
130                    start_periodic_print();
131                break;
132
133                // ----------------------------------------
134                // '2' - Print Queue status
135                //
136                case ASCII_2:
137                    print_queue_status();
138                break;
139
140                // ----------------------------------------
141                // '3' - Print Station Infos with Counts
142                //
143                case ASCII_3:
144                    station_info_print(NULL , STATION_INFO_PRINT_OPTION_FLAG_INCLUDE_COUNTS);
145                break;
146
147                // ----------------------------------------
148                // 'e' - Print event log size
149                //
150                case ASCII_e:
151#if WLAN_SW_CONFIG_ENABLE_LOGGING
152                    event_log_config_logging(EVENT_LOG_LOGGING_DISABLE);
153                    print_event_log_size();
154                    event_log_config_logging(EVENT_LOG_LOGGING_ENABLE);
155#endif //WLAN_SW_CONFIG_ENABLE_LOGGING
156                break;
157
158                // ----------------------------------------
159                // 'a' - Print BSS information
160                //
161                case ASCII_a:
162                    print_network_info();
163                break;
164
165                // ----------------------------------------
166                // 'm' - Display Heap / Malloc information
167                //
168                case ASCII_m:
169                    wlan_mac_high_display_mallinfo();
170                break;
171            }
172        break;
173
174
175        // ------------------------------------------------
176        // Interactive Menu processing
177        //
178        case UART_MODE_INTERACTIVE:
179            switch(rxByte){
180
181                // ----------------------------------------
182                // 'r' - Reset station counts
183                //
184                case ASCII_r:
185#if WLAN_SW_CONFIG_ENABLE_TXRX_COUNTS
186                    txrx_counts_zero_all();
187#endif
188                break;
189            }
190        break;
191
192
193        default:
194            uart_mode = UART_MODE_MAIN;
195            print_main_menu();
196        break;
197    }
198}
199
200
201
202void print_main_menu(){
203    xil_printf("\f");
204    xil_printf("********************** Station Menu **********************\n");
205    xil_printf("[1]   - Interactive Station Status\n");
206    xil_printf("[2]   - Print Queue Status\n");
207    xil_printf("[3]   - Print all Observed Counts\n");
208    xil_printf("\n");
209    xil_printf("[a]   - Display Network List\n");
210    xil_printf("**********************************************************\n");
211}
212
213
214
215void print_station_status() {
216
217    station_info_t* curr_station_info;
218    dl_entry* curr_entry;
219
220    u64 timestamp;
221
222    if(uart_mode == UART_MODE_INTERACTIVE){
223        timestamp = get_system_time_usec();
224        xil_printf("\f");
225
226        if(active_network_info != NULL){
227            curr_entry = active_network_info->members.first;
228
229            while(curr_entry != NULL){
230                curr_station_info = (station_info_t*)(curr_entry->data);
231                xil_printf("---------------------------------------------------\n");
232                if(curr_station_info->hostname[0] != 0){
233                    xil_printf(" Hostname: %s\n", curr_station_info->hostname);
234                }
235                xil_printf(" ID: %02x -- MAC Addr: %02x:%02x:%02x:%02x:%02x:%02x\n", curr_station_info->ID,
236                        curr_station_info->addr[0],curr_station_info->addr[1],curr_station_info->addr[2],curr_station_info->addr[3],curr_station_info->addr[4],curr_station_info->addr[5]);
237
238                xil_printf("     - Last heard from         %d ms ago\n",((u32)(timestamp - (curr_station_info->latest_rx_timestamp)))/1000);
239                xil_printf("     - # of queued MPDUs:      %d\n", queue_length(curr_station_info->QID));
240
241                curr_entry = dl_entry_next(curr_entry);
242            }
243
244            xil_printf("---------------------------------------------------\n");
245            xil_printf("\n");
246            xil_printf("[r] - reset counts\n");
247        }
248    }
249}
250
251void print_queue_status(){
252    dl_entry* curr_entry;
253    station_info_t* curr_station_info;
254    xil_printf("\nQueue Status:\n");
255    xil_printf(" FREE || MCAST|  MGMT|");
256
257    if(active_network_info != NULL){
258        curr_entry = active_network_info->members.first;
259        while(curr_entry != NULL){
260            curr_station_info = (station_info_t*)(curr_entry->data);
261            xil_printf("%6d|", curr_station_info->ID);
262            curr_entry = dl_entry_next(curr_entry);
263        }
264    }
265    xil_printf("\n");
266
267    xil_printf("%6d||%6d|%6d|",queue_num_free(),queue_length(mcast_qid), queue_length(mgmt_qid));
268
269    if(active_network_info != NULL){
270        curr_entry = active_network_info->members.first;
271        while(curr_entry != NULL){
272            curr_station_info = (station_info_t*)(curr_entry->data);
273            xil_printf("%6d|", queue_length(curr_station_info->QID));
274            curr_entry = dl_entry_next(curr_entry);
275        }
276    }
277    xil_printf("\n");
278
279}
280
281void start_periodic_print(){
282    stop_periodic_print();
283    print_station_status();
284    print_scheduled = 1;
285    schedule_id = wlan_mac_schedule_add_event(SCHEDULE_ID_COARSE, 1000000, SCHEDULE_REPEAT_FOREVER, (void*)print_station_status);
286}
287
288void stop_periodic_print(){
289    if (print_scheduled) {
290        print_scheduled = 0;
291        wlan_mac_schedule_remove_event(schedule_id);
292    }
293}
294
295
296
297#endif
298
299
Note: See TracBrowser for help on using the repository browser.