Changeset 498 for vtcross/trunk/src
- Timestamp:
- 10/03/09 18:48:33 (15 years ago)
- Location:
- vtcross/trunk/src
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/cross-examples/python/gnuradio-examples/benchmark_dsa.py
r493 r498 66 66 def main(): 67 67 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 69 72 n_rcvd = 0 70 73 n_right = 0 … … 137 140 UpdateParameterPerformance(currentParameters,1,o,1) 138 141 except: 139 print "fail"140 142 else: 141 143 # Get the average communication time … … 170 172 if ok: 171 173 (pktno,) = struct.unpack('!H', payload[0:2]) 172 174 (sync_signal,) = struct.unpack('!s', payload[2]) 173 175 (data_channel,) = struct.unpack('!H', payload[3:5]) 174 176 … … 198 200 ############################################################## 199 201 200 n_rcvd += 1201 if ok:202 n_right += 1202 n_rcvd += 1 203 if ok: 204 n_right += 1 203 205 204 206 mods = modulation_utils.type_1_mods() 205 207 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" 206 213 207 214 #setting up the tx options parser … … 220 227 parser_tx.add_option("","--from-file", default=None, 221 228 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"); 222 233 223 234 expert_grp_tx = parser_tx.add_option_group("Expert_tx") … … 268 279 parser_rx.add_option("-T", "--threshold", type="eng_float", default=1.5e8, 269 280 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 271 286 272 287 … … 290 305 else: 291 306 print "[[ Using the CROSS DSA Cognitive Engine ]]" 307 print "[[ VTCROSS shell located at " + crossShellHost + ":" + crossShellPort + " ]]" 308 SetCrossShellLocation(crossShellHost, crossShellPort) 292 309 else: 293 310 print "[[ Using the RANDOM channel selection algorithm ]]\n\n" -
vtcross/trunk/src/include/vtcross/libvtcross.h
r411 r498 27 27 28 28 #include <stdint.h> 29 #include <string> 29 30 30 31 #include "components.h" 31 32 #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 */ 38 void SetCrossShellLocation(std::string hostname, std::string port); 32 39 33 40 -
vtcross/trunk/src/lib/socketcomm/socketcomm.cpp
r411 r498 85 85 server = gethostbyname(serverName); 86 86 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"); 88 88 89 89 portNumber = atoi(serverPort); … … 91 91 socketFD = socket(AF_INET, SOCK_STREAM, 0); 92 92 if(socketFD < 0) 93 ERROR(1, " Error opening socket\n");93 ERROR(1, "SocketComm::ClientSocket - Error opening socket\n"); 94 94 95 95 memset((void *) &serv_addr, 0, sizeof(serv_addr)); … … 100 100 101 101 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"); 103 103 104 104 return socketFD; -
vtcross/trunk/src/libvtcross/libvtcross.cpp
r412 r498 22 22 23 23 #include <cstdlib> 24 #include <string> 24 25 25 26 #include "vtcross/common.h" … … 27 28 #include "vtcross/libvtcross.h" 28 29 29 30 uint32_t 31 ConnectToRemoteComponent() 32 { 33 // TODO why is this hardcoded like this?? 34 return ClientSocket("localhost", "40000"); 35 } 30 using 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. */ 36 string shellHostname; 37 string shellPort; 38 39 40 uint32_t 41 ConnectToShell() 42 { 43 return ClientSocket(shellHostname.c_str(), shellPort.c_str()); 44 } 45 46 47 void 48 SetCrossShellLocation(string hostname, string port) 49 { 50 shellHostname = hostname; 51 shellPort = port; 52 } 53 36 54 37 55 // TODO the following three functions all do exactly the same thing. Why not … … 42 60 char buffer[256]; 43 61 44 uint32_t socketfd = ConnectTo RemoteComponent();62 uint32_t socketfd = ConnectToShell(); 45 63 SendMessage(socketfd, "get_number_observables"); 46 64 … … 57 75 char buffer[256]; 58 76 59 uint32_t socketfd = ConnectTo RemoteComponent();77 uint32_t socketfd = ConnectToShell(); 60 78 SendMessage(socketfd, "get_number_utilities"); 61 79 … … 72 90 char buffer[256]; 73 91 74 uint32_t socketfd = ConnectTo RemoteComponent();92 uint32_t socketfd = ConnectToShell(); 75 93 SendMessage(socketfd, "set_active_mission"); 76 94 … … 88 106 char buffer[256]; 89 107 90 uint32_t socketfd = ConnectTo RemoteComponent();108 uint32_t socketfd = ConnectToShell(); 91 109 SendMessage(socketfd, "get_number_parameters"); 92 110 … … 117 135 char buffer[256]; 118 136 119 uint32_t socketFD = ConnectTo RemoteComponent();137 uint32_t socketFD = ConnectToShell(); 120 138 SendMessage(socketFD, "request_optimization"); 121 139 … … 170 188 char var[50]; 171 189 172 uint32_t socketFD = ConnectTo RemoteComponent();190 uint32_t socketFD = ConnectToShell(); 173 191 SendMessage(socketFD, "update_performance"); 174 192