Changeset 498

Show
Ignore:
Timestamp:
10/03/09 18:48:33 (15 years ago)
Author:
bhilburn
Message:

Numerous changes. A VTCROSS shell can now be remote relative to the radio host platform. The remote server/port is set through a new function in libvtcross, which has also been added as an option to the benchmark_dsa script. Other changes include bug fixes in the benchmark code and some SQL fixes.

Location:
vtcross/trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/cross-examples/python/gnuradio-examples/benchmark_dsa.py

    r493 r498  
    6666def main(): 
    6767 
    68     global stats_array, count_array, time_array, n_rcvd, n_right,sync_status,mode,ch,traffic_flag,n_attempts,return_flag 
     68    global stats_array, count_array, time_array, n_rcvd 
     69    global n_right, sync_status, mode, ch, traffic_flag,  
     70    global n_attempts, return_flag, crossShellHost, crossShellPort 
     71 
    6972    n_rcvd = 0 
    7073    n_right = 0 
     
    137140                    UpdateParameterPerformance(currentParameters,1,o,1) 
    138141                except: 
    139                     print "fail" 
    140142            else: 
    141143                # Get the average communication time 
     
    170172            if ok: 
    171173                (pktno,) = struct.unpack('!H', payload[0:2]) 
    172                    (sync_signal,) = struct.unpack('!s', payload[2])  
     174                (sync_signal,) = struct.unpack('!s', payload[2])  
    173175                (data_channel,) = struct.unpack('!H', payload[3:5]) 
    174176                                   
     
    198200        ############################################################## 
    199201 
    200        n_rcvd += 1 
    201        if ok: 
    202            n_right += 1 
     202        n_rcvd += 1 
     203        if ok: 
     204            n_right += 1 
    203205 
    204206    mods = modulation_utils.type_1_mods() 
    205207    demods = modulation_utils.type_1_demods() 
     208 
     209    # Set default values for the CROSS shell location. These can be overridden 
     210    # via command-line parameters 
     211    crossShellHost = "localhost" 
     212    crossShellPort = "40000" 
    206213 
    207214    #setting up the tx options parser 
     
    220227    parser_tx.add_option("","--from-file", default=None, 
    221228                          help="use file for packet contents") 
     229    parser_tx.add_option("-h", "--hostname", action="store", type="string", dest="crossShellHost", 
     230            default="localhost", help="Set the hostname/IP for the VTCROSS shell"); 
     231    parser_tx.add_option("-p", "--port", action="store", type="string", dest="crossShellPort", 
     232            default="40000", help="Set the port for the VTCROSS shell"); 
    222233  
    223234    expert_grp_tx = parser_tx.add_option_group("Expert_tx") 
     
    268279    parser_rx.add_option("-T", "--threshold", type="eng_float", default=1.5e8, 
    269280                          help="set primary user sensing energy threshold [default=%default]") 
    270  
     281    parser_rx.add_option("-h", "--hostname", action="store", type="string", dest="crossShellHost", 
     282            default="localhost", help="Set the hostname/IP for the VTCROSS shell"); 
     283    parser_rx.add_option("-p", "--port", action="store", type="string", dest="crossShellPort", 
     284            default="40000", help="Set the port for the VTCROSS shell"); 
     285  
    271286 
    272287 
     
    290305        else: 
    291306            print "[[ Using the CROSS DSA Cognitive Engine ]]" 
     307            print "[[ VTCROSS shell located at " + crossShellHost + ":" + crossShellPort + " ]]" 
     308            SetCrossShellLocation(crossShellHost, crossShellPort) 
    292309    else: 
    293310        print "[[ Using the RANDOM channel selection algorithm ]]\n\n" 
  • vtcross/trunk/src/include/vtcross/libvtcross.h

    r411 r498  
    2727 
    2828#include <stdint.h> 
     29#include <string> 
    2930 
    3031#include "components.h" 
    3132#include "containers.h" 
     33 
     34 
     35/* Sets the location of the shell component that the client code will be 
     36 * communicating with. Note that this can be a local or remote destination. 
     37 */ 
     38void SetCrossShellLocation(std::string hostname, std::string port); 
    3239 
    3340 
  • vtcross/trunk/src/lib/socketcomm/socketcomm.cpp

    r411 r498  
    8585    server = gethostbyname(serverName); 
    8686    if(server == NULL) 
    87         ERROR(1, "No server found by that hostname.\n"); 
     87        ERROR(1, "SocketComm::ClientSocket - No server found by that hostname.\n"); 
    8888 
    8989    portNumber = atoi(serverPort); 
     
    9191    socketFD = socket(AF_INET, SOCK_STREAM, 0); 
    9292    if(socketFD < 0)  
    93         ERROR(1, "Error opening socket\n"); 
     93        ERROR(1, "SocketComm::ClientSocket - Error opening socket\n"); 
    9494 
    9595    memset((void *) &serv_addr, 0, sizeof(serv_addr)); 
     
    100100 
    101101    if(connect(socketFD, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)  
    102         ERROR(1, "Error connecting to remote socket.\n"); 
     102        ERROR(1, "SocketComm::ClientSocket - Error connecting to remote socket.\n"); 
    103103 
    104104    return socketFD; 
  • vtcross/trunk/src/libvtcross/libvtcross.cpp

    r412 r498  
    2222 
    2323#include <cstdlib> 
     24#include <string> 
    2425 
    2526#include "vtcross/common.h" 
     
    2728#include "vtcross/libvtcross.h" 
    2829 
    29  
    30 uint32_t 
    31 ConnectToRemoteComponent() 
    32 { 
    33     // TODO why is this hardcoded like this?? 
    34        return ClientSocket("localhost", "40000"); 
    35 } 
     30using namespace std; 
     31 
     32 
     33/* Strings that store the remote (or local) shell location for use within the 
     34 * ConnectToShell() function.  Note that these values must be set with the 
     35 * SetCrossShellLocation public function within the client code. */ 
     36string shellHostname; 
     37string shellPort; 
     38 
     39 
     40uint32_t 
     41ConnectToShell() 
     42{ 
     43    return ClientSocket(shellHostname.c_str(), shellPort.c_str()); 
     44} 
     45 
     46 
     47void 
     48SetCrossShellLocation(string hostname, string port) 
     49{ 
     50    shellHostname = hostname; 
     51    shellPort = port; 
     52} 
     53 
    3654 
    3755// TODO the following three functions all do exactly the same thing.  Why not 
     
    4260    char buffer[256]; 
    4361 
    44     uint32_t socketfd = ConnectToRemoteComponent(); 
     62    uint32_t socketfd = ConnectToShell(); 
    4563    SendMessage(socketfd, "get_number_observables"); 
    4664     
     
    5775    char buffer[256]; 
    5876 
    59     uint32_t socketfd = ConnectToRemoteComponent(); 
     77    uint32_t socketfd = ConnectToShell(); 
    6078    SendMessage(socketfd, "get_number_utilities"); 
    6179     
     
    7290    char buffer[256]; 
    7391     
    74     uint32_t socketfd = ConnectToRemoteComponent(); 
     92    uint32_t socketfd = ConnectToShell(); 
    7593    SendMessage(socketfd, "set_active_mission"); 
    7694 
     
    88106    char buffer[256]; 
    89107 
    90     uint32_t socketfd = ConnectToRemoteComponent(); 
     108    uint32_t socketfd = ConnectToShell(); 
    91109    SendMessage(socketfd, "get_number_parameters"); 
    92110     
     
    117135    char buffer[256]; 
    118136 
    119     uint32_t socketFD = ConnectToRemoteComponent(); 
     137    uint32_t socketFD = ConnectToShell(); 
    120138    SendMessage(socketFD, "request_optimization"); 
    121139 
     
    170188    char var[50]; 
    171189 
    172     uint32_t socketFD = ConnectToRemoteComponent(); 
     190    uint32_t socketFD = ConnectToShell(); 
    173191    SendMessage(socketFD, "update_performance"); 
    174192