65 | | my_node.send_user_command(CMDID_USR_QUEUE_STATUS, args=None) |
66 | | |
| 65 | #Define a user command ID |
| 66 | USER_CMDID_TX_QUEUE_STATUS = 100 |
| 67 | |
| 68 | #Define method for sending command and processing the response |
| 69 | def get_tx_queue_status(node, queue_id=None): |
| 70 | |
| 71 | if(queue_id is not None): |
| 72 | #Arguments must be a list of ints - listify/cast the scaler queue_id |
| 73 | args = [int(queue_id)] |
| 74 | else: |
| 75 | args = None |
| 76 | |
| 77 | resp = node.send_user_command(USER_CMDID_TX_QUEUE_STATUS, args) |
| 78 | |
| 79 | #Response should be list of ints with 2 values per queue |
| 80 | # Each pair of response values is (queue_id, queue_occupancy) |
| 81 | # Sanity check the response, then convert to a list of 2-tuples and return |
| 82 | if(len(resp) % 2 != 0): |
| 83 | print('ERROR: Tx Queue Status command response lenth ({0} values) was not even!'.format(len(resp))) |
| 84 | return |
| 85 | else: |
| 86 | #Group each pair of response values into 2-tuple and return list of 2-tuples |
| 87 | ret = zip(*[iter(resp)]*2) |
| 88 | |
| 89 | return ret |
| 90 | }}} |
| 91 | |
| 92 | 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. |
| 93 | |
| 94 | To use this function: |
| 95 | |
| 96 | {{{ |
| 97 | |
| 98 | #Assume n0 is a wlan_exp node object that has already been initialized |
| 99 | q_stat = get_tx_queue_status(n0) |
| 100 | |
| 101 | #Print the queue status response |
| 102 | if(q_stat): |
| 103 | print('Tx Queue Status for node {0}'.format(n0.sn_str)) |
| 104 | print('ID Occupancy') |
| 105 | |
| 106 | for q_id,q_occ in q_stat: |
| 107 | print('{0:2d} {1:3d}'.format(q_id, q_occ)) |
| 108 | else: |
| 109 | print('No Tx Queue Status received for {0}'.format(n0_str)) |