[1943] | 1 | function wl_config_read |
---|
| 2 | configFile = which('wl_config.ini'); |
---|
| 3 | if(isempty(configFile)) |
---|
[2865] | 4 | error('cannot find wl_config.ini. please run wl_setup.m'); |
---|
[1943] | 5 | end |
---|
| 6 | |
---|
[4375] | 7 | readKeys = {'network', '', 'host_address', ''}; |
---|
| 8 | IP = inifile(configFile, 'read', readKeys); |
---|
[1943] | 9 | IP = IP{1}; |
---|
| 10 | |
---|
[4375] | 11 | readKeys = {'network', '', 'host_ID', ''}; |
---|
| 12 | host = inifile(configFile, 'read', readKeys); |
---|
[1943] | 13 | host = host{1}; |
---|
| 14 | |
---|
[4375] | 15 | readKeys = {'network', '', 'unicast_starting_port', ''}; |
---|
| 16 | port_unicast = inifile(configFile, 'read', readKeys); |
---|
[1943] | 17 | port_unicast = port_unicast{1}; |
---|
| 18 | |
---|
[4375] | 19 | readKeys = {'network', '', 'bcast_port', ''}; |
---|
| 20 | port_bcast = inifile(configFile, 'read', readKeys); |
---|
[1943] | 21 | port_bcast = port_bcast{1}; |
---|
| 22 | |
---|
[4375] | 23 | readKeys = {'network', '', 'transport', ''}; |
---|
| 24 | transport = inifile(configFile, 'read', readKeys); |
---|
[1943] | 25 | transport = transport{1}; |
---|
| 26 | |
---|
[4375] | 27 | readKeys = {'network', '', 'max_transport_payload_size', ''}; |
---|
| 28 | max_transport_payload_size = inifile(configFile, 'read', readKeys); |
---|
| 29 | max_transport_payload_size = max_transport_payload_size{1}; |
---|
[1998] | 30 | |
---|
[1943] | 31 | fprintf('\n\nContents of wl_config.ini:\n'); |
---|
[4375] | 32 | fprintf('(located at %s)\n', configFile') |
---|
[1943] | 33 | |
---|
[1944] | 34 | fprintf('--------------------------------------\n') |
---|
| 35 | fprintf('| Host IP Address |%12s|\n',IP); |
---|
[1966] | 36 | |
---|
| 37 | if(ispc) |
---|
| 38 | [status, tempret] = system('ipconfig /all'); |
---|
| 39 | elseif(ismac||isunix) |
---|
| 40 | [status, tempret] = system('ifconfig -a'); |
---|
| 41 | end |
---|
| 42 | tempret = strfind(tempret,IP); |
---|
| 43 | |
---|
| 44 | if(isempty(tempret)) |
---|
| 45 | fprintf('\b *No interface found. Please ensure that your network interface is connected and configured with static IP %s\n',IP); |
---|
| 46 | end |
---|
| 47 | |
---|
[4375] | 48 | fprintf('-----------------------------------------\n') |
---|
| 49 | fprintf('| WARPLab Host ID |%12s|\n', host); |
---|
| 50 | fprintf('-----------------------------------------\n') |
---|
| 51 | fprintf('| Unicast Starting Port |%12s|\n', port_unicast); |
---|
| 52 | fprintf('-----------------------------------------\n') |
---|
| 53 | fprintf('| Broadcast Port |%12s|\n', port_bcast); |
---|
| 54 | fprintf('-----------------------------------------\n') |
---|
| 55 | fprintf('| Transport |%12s|\n', transport); |
---|
| 56 | fprintf('-----------------------------------------\n') |
---|
| 57 | fprintf('| Max Payload Size (bytes) |%12s|\n', max_transport_payload_size); |
---|
| 58 | fprintf('-----------------------------------------\n') |
---|
[1943] | 59 | |
---|
| 60 | end |
---|