forked from ubnt-marty/eng_test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
radiot.py
2209 lines (1947 loc) · 82.2 KB
/
radiot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
import sys
import telnetlib
import socket
import time
import datetime
import re
import itertools
sys.path.append('/mnt/shared/test/py/obj/')
import utils02 as utils
class RadioT(object):
"""Telnet Command Interface
Attributes:
radioTCount A class variable that counts instaniated RadioT objects.
debug A flag to enable debugging print statements <False|True>.
radio_id Interger ID of radio object instantiation.
ip Radio IP address.
username Radio user name for Telnet and HTTP.
password Radio user password for Telnet and HTTP.
tPort Telnet port number.
tTimeout Telnet timeout.
tRadio Radio's Telnet handle.
tPrompt Radio's Telnet prompt (example: r2s2top login:).
loginPrompt Radio's log-in prompt (example: login:).
radioPrompt Radio's command prompt (example: #).
devicename get only, Radio's device name (example: r2s2top) taken from the Telnet log-in prompt.
firmware_version get only, Radio's fw version taken from /usr/lib/version.
radio_type get only, Radio's type (AF, AF02, AF06,...) taken from /usr/lib/version.
build_number get only taken from /usr/lib/version.
version_number get only (2.2) taken from /usr/lib/version.
local_mac get only, return example: 04:18:D6:51:00:66
fpga_version get only, return example: 141212v4
status get only, Radio's mode and operational status.
status_device_name
status_operating_mode
status_rf_link_status
status_link_name
o status_security
status_version
o status_uptime
status_link_uptime
status_remote_mac
o status_remote_ip
o status_date
status_duplex
status_frequency
status_channel_width
status_duty_cycle
status_regulatory_domain
status_chain_0_signal_strength
status_chain_1_signal_strength
status_remote_chain_0_signal_strength
status_remote_chain_1_signal_strength
status_local_modulation_rate
status_remote_modulation_rate
status_tx_capacity
status_rx_capacity
status_tx_power
status_remote_tx_power
status_dac_temp_0
status_dac_temp_1
status_distance_feet
status_distance_miles
status_distance_meters
status_distance_kilometers
# <Wireless> Basic Wireless Settings
wireless_wireless_mode mode get, set <master|slave>
wireless_link_name linkname get, set <string>
wireless_country_code countrycode get, set (156 (China), 276 (Germany), 840 (United States), 8191, )
wireless_country_dom countrydom get, set (none, fcc, etsi, other,...)
wireless_duplex duplex get, set <half|full>
wireless_channel_bandwidth channelbandwidth get, set <50|40|30|20|10>
wireless_tx_channel_bandwidth txchannelbandwidth get, set <50|40|30|20|10>
wireless_rx_channel_bandwidth rxchannelbandwidth get, set <50|40|30|20|10>
wireless_master_tx_duty_cycle dutycycle get, set <25|33|50|67|75>
wireless_output_power powerout get, set integer valude in dBm
wireless_antenna_gain antennagain get, set integer value in dBi
wireless_cable_loss get, set integer value in dB
wireless_maximum_modulation_rate speed get, set <0x|1x|2x|4x|6x|8x|10x>
wireless_automatic_rate_adaption modcontrol get, set <manual|automatic>
wireless_rx_gain rxgain get, set <low,high>
# <Wireless> Frequency Settings
wireless_tx_frequency txfrequency get, set float in GHz or integer in MHz
wireless_tx_frequency_1 tx1frequency get, set float in GHz or integer in MHz
wireless_rx_frequency rxfrequency get, set float in GHz or integer in MHz
wireless_rx_frequency_1 rx1frequency get, set float in GHz or integer in MHz
wireless_tx_frequency_2 tx2frequency get, set float in GHz or integer in MHz
wireless_rx_frequency_2 rx2frequency get, set float in GHz or integer in MHz
wireless_tx_frequency_3 tx3frequency get, set float in GHz or integer in MHz
wireless_rx_frequency_3 rx3frequency get, set float in GHz or integer in MHz
# <Wireless> Wireless Security
! wireless_key_type get, set <hex|ascii> NO AF COMMAND
wireless_key key get, set string (0000:0000:0000:0000:0000:0000:0000:0000)
# <Advanced> Wireless Settings
advanced_gps_clock_sync gps get, set <off|on>
# <Advanced> DATA Port Ethernet Settings
advanced_data_speed dpcntl get, set <auto|10Mbps-Half|100Mbps-Half|10Mbps-Full|100Mbps-Full>
advanced_data_link dpstat get only (set returns a warning).
advanced_flow_control flowcntl get, set <off|on>
advanced_multicast_filter mcastfilter get, set <off|on>
advanced_track_radio_link carrierdrop get, set <off|timer|link>
advanced_link_off_duration carrierdropto get, set integer
advanced_link_off_spacing carrierdropspc get, set integer
# AF Commands
af_minfreq minfreq get only
af_maxfreq maxfreq get only
"""
radioTCount = 0
def __init__(self, ipaddr, user, passwd, debug=False):
RadioT.radioTCount += 1
self.debug = debug
self.radio_id = RadioT.radioTCount
self.radio_interface = 'telnet'
self.ip = ipaddr
self.username = user
self.password = passwd
self.tRadio = None
self.tPort = 23
self.tTimeout = 5
self.loginPrompt = 'login: '
self.tLoggedIn = False
self.radioPrompt = '#'
self.width = 900
self.height = 800
self.hLoggedin = None
self.__status = None
self.__rflinkstatus = None
self.__linkuptime = None
self.__fpgaver = None
self.__lmac = None
self.__rmac = None
self.__dfsdom = None
self.__rxpower0 = None
self.__rxpower1 = None
self.__rrxpower0 = None
self.__rrxpower1 = None
self.__txmodrate = None
self.__rtxmodrate = None
self.__txcapacity = None
self.__rxcapacity = None
self.__rpowerout = None
self.__temp0 = None
self.__temp1 = None
self.__feet = None
self.__miles = None
self.__meters = None
self.__kilometers = None
self.__afaf = None
self.__afemac = None
self.__rainfade = None
self.__rainstat = None
self.__rain = None
self.__wirelessmode = None
self.wireless_modes = ('master','slave','reset','spectral','hwtest')
self.__firmware_version = None
self.__radio_type = None
self.__buildnumber = None
self.__linkname = None
self.__countrycode = None
self.__countrydom = None
self.__duplex = None
self.__channelbandwidth = None
self.__txchannelbandwidth = None
self.__rxchannelbandwidth = None
self.__dutycycle = None
self.__speed = None
self.__version_number = None
self.__powerout = None
self.__antennagain = None
self.__cableloss = None
self.__speed = None
self.__modcontrol = None
self.__rxgain = None
self.__txfrequency = None
self.__tx1frequency = None
self.__rxfrequency = None
self.__rx1frequency = None
self.__tx2frequency = None
self.__rx2frequency = None
self.__tx3frequency = None
self.__rx3frequency = None
self.__keytype = None
self.__key = None
self.__gps = None
self.__dpcntl = None
self.__dpstat = None
self.__flowcntl = None
self.__mcastfilter = None
self.__carrierdrop = None
self.__carrierdropto = None
self.__carrierdropspc = None
self.__minfreq = None
self.__maxfreq = None
self.country_code_dict = {'32': 'argentina', '36': 'australia', '48': 'bahrain', '52': 'barbados', '84': 'belize', '68': 'bolivia', '76': 'brazil', '96': 'brunei darussalam', '124': 'canada', '152': 'chile', '156': 'china', '170': 'colombia', '188': 'costa rica', '208': 'denmark', '214': 'dominican republic', '218': 'ecuador', '222': 'el salvador', '8191': 'engineering', '246': 'finland', '276': 'germany', '300': 'greece', '308': 'grenada', '316': 'guam', '320': 'guatemala', '340': 'honduras', '344': 'hong kong', '352': 'iceland', '356': 'india', '360': 'indonesia', '368': 'iraq', '372': 'ireland', '388': 'jamaica', '404': 'kenya', '410': 'korea republic', '422': 'lebanon', '438': 'liechtenstein', '446': 'macau', '458': 'malaysia', '484': 'mexico', '504': 'morocco', '524': 'nepal', '554': 'new zealand', '566': 'nigeria', '578': 'norway', '512': 'oman', '586': 'pakistan', '591': 'panama', '598': 'papua new guinea', '604': 'peru', '608': 'philippines', '620': 'portugal', '630': 'puerto rico', '634': 'qatar', '643': 'russia', '682': 'saudi arabia', '702': 'singapore', '710': 'south africa', '724': 'spain', '144': 'sri lanka', '158': 'taiwan', '764': 'thailand', '780': 'trinidad and tobago', '804': 'ukraine', '826': 'united kingdom', '840': 'united states', '858': 'uruguay', '860': 'uzbekistan', '862': 'venezuela'}
#self.config_section = section
#self.config = ConfigParser.ConfigParser()
#dataset = self.config.read(configfile)
#if len(dataset) == 0:
# raise ValueError, "Failed to open file: %s" % configfile
#try:
# self.ip = self.config.get('%s' % self.config_section, 'IP')
# self.username = self.config.get('%s' % self.config_section, 'User_Name')
# self.password = self.config.get('%s' % self.config_section, 'Password')
#except ConfigParser.NoSectionError, err:
# raise ConfigParser.NoSectionError, 'ConfigParser NoSectionError: %s' % err
#except ConfigParser.NoOptionError, err:
# raise ConfigParser.NoOptionError, 'ConfigParser NoOptionError: %s' % err
if debug == True:
print 'Finished __init__'
def __del__(self):
RadioT.radioTCount -= 1
def tLogin(self):
""" Sets and returns tLoggedIn = True|False"""
if self.debug == True:
print 'tLogin()'
print ' username = %s' % self.username
print ' password = %s' % self.password
print ' radioPrompt = %s' % self.radioPrompt
self.tRadio.write(self.username + "\n")
self.usernameresults = self.tRadio.read_until("Password:", 10)
self.tRadio.write(self.password + "\n")
self.loginresults = self.tRadio.read_until(self.radioPrompt, 10)
self.loginelements = self.loginresults.split()
if self.debug == True:
print ' loginresults = %s' % self.loginresults
#print 'login elements = ', self.loginelements
if self.loginelements[1] == 'incorrect':
self.tLoggedIn = False
return self.tLoggedIn
else:
#self.radiotype = self.firmware_version.split('.')[0]
#self.buildnumber = self.getBuildnumber()
#self.versionnumber = self.getVersionNumber()
# print ' version # = %s' % self.versionnumber
self.tLoggedIn = True
return self.tLoggedIn
def tLogout(self):
self.tRadio.close()
self.tLoggedIn = False
if self.debug == True:
print 'tLogout()'
def tConnect(self):
""" Returns True or False. If True, sets devicename."""
if self.debug == True:
print 'tConnect()'
print ' IP Address = %s' % self.ip
print ' Telnet Port = %s' % self.tPort
print ' Telnet Timeout = %s' % self.tTimeout
print ' Login Prompt = %s' % self.loginPrompt
try:
self.tRadio = telnetlib.Telnet(self.ip, self.tPort, self.tTimeout)
self.tPrompt = self.tRadio.read_until(self.loginPrompt, self.tTimeout)
#print 'Telnet prompt: %s' % self.tPrompt
self.devicename = self.tPrompt.split()[0]
#print 'devicename: %s' % self.devicename
return True
except:
if self.debug == True:
print 'Radio %s (%s) telnet connection failure' % (self.radio_id, self.ip)
return False
########
def wireless_mode_get(self):
self.cmd = 'af get mode'
#print self.cmd
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__wirelessmode = self.results
except:
print
print "EXCEPTION: wireless_mode_get() failed."
print
self.__wirelessmode = None
return self.__wirelessmode
def wireless_mode_set(self, value):
if str(value.lower()) not in self.wireless_modes:
print
print 'ERROR: radio mode assignment (%s) failure, setting must be master|slave|reset|spectral|hwtest.' % value
print
return False
self.cmd = 'af set mode %s' % value.lower()
#print self.cmd
try:
self.results = self.sendcmd(self.cmd)
except:
print "EXCEPTION: af set mode %s failed." % value
return True
wireless_wireless_mode = property(wireless_mode_get, wireless_mode_set)
def link_name_get(self):
self.cmd = 'af get linkname'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__linkname = self.results
except:
print 'EXCEPTION: af get linkname failed.'
self.__linkname = None
return self.__linkname
def link_name_set(self, value):
self.cmd = 'af set linkname %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set linkname %s failed.' % value
wireless_link_name = property(link_name_get, link_name_set)
def country_code_get(self):
if self.debug == True:
print "self.cmd = 'af get countrycode'"
self.cmd = 'af get countrycode'
try:
self.results = self.sendcmd(self.cmd).split()[3]
if self.debug == True:
print 'start sleep(5)'
time.sleep(5)
print 'done sleep(5)'
self.__countrycode = self.results
except:
print
print 'EXCEPTION: af get countrycode failed.'
print
sys.exit(1)
self.__countrycode = None
return self.__countrycode
def country_code_set(self, value):
self.countrycode_value = str(value).lower() # value can be an integer or country name
self.countrycode = None
self.countryname = None
if self.countrycode_value.isdigit():
if self.countrycode_value in self.country_code_dict.keys():
self.countrycode = self.countrycode_value
self.countryname = self.country_code_dict[self.countrycode_value]
else:
for self.cc, self.name in self.country_code_dict.items():
if self.name == self.countrycode_value:
self.countrycode = self.cc
break
if self.countrycode == None:
print
print 'ERROR: countrycode (%s) not found.' % self.countrycode_value
print
else:
self.cmd = 'af set countrycode %s' % self.countrycode
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set countrycode %s failed.' % self.countrycode_value
wireless_country_code = property(country_code_get, country_code_set)
def country_name_get(self):
self.cmd = 'af get countrycode'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__countrycode = self.results
if self.results in self.country_code_dict.keys():
self.__countryname = self.country_code_dict[self.results]
except:
print 'EXCEPTION: country_name, af get countrycode failed.'
self.__countryname = None
return self.__countryname
def country_name_set(self, value):
try:
self.wireless_country_code = value
except:
return False
return True
country_name = property(country_name_get, country_name_set)
def country_dom_get(self):
self.cmd = 'af get countrydom'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__countrydom = self.results
except:
print 'EXCEPTION: af get countrydom failed.'
self.__countrydom = None
return self.__countrydom
def country_dom_set(self, value):
if str(value.lower()) not in ('none','fcc','etsi','acma','apla'):
print
print 'ERROR: countrydom assignment (%s) failure, setting must be none|fcc|etsi|acma|apla.' % value
print
return
self.cmd = 'af set countrydom %s' % value.lower()
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set countrydom %s failed.' % value
wireless_country_dom = property(country_dom_get, country_dom_set)
def duplex_get(self):
# Returns: half,full
self.cmd = 'af get duplex'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__duplex = self.results
except:
print 'EXCEPTION: af get duplex failed.'
self.__duplex = None
return self.__duplex
def duplex_set(self, value):
if str(value.lower()) not in ('half', 'full'):
print
print 'ERROR: duplex assignment (%s) failure, setting must be half|full.' % value
print
return
self.cmd = 'af set duplex %s' % value.lower()
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set duplex %s failed.' % value
wireless_duplex = property(duplex_get, duplex_set)
def channel_bandwidth_get(self):
# Returns channel bandwidth for both channels: 50MHz 50MHz
if self.radio_type.lower() == 'af' and self.version_number < '2.1':
self.__channelbandwidth = '100'
else:
self.cmd = 'af get channelbandwidth' # Returns: 100MHz 100MHz
try:
self.results = self.sendcmd(self.cmd).split()[3][:-3]
self.__channelbandwidth = self.results
except:
print 'EXCEPTION: af get channelbandwidth failed.'
self.__channelbandwidth = None
return self.__channelbandwidth
def channel_bandwidth_set(self, value):
if self.radio_type.lower() == 'af' and str(value) != '100':
print
print 'ERROR: wireless_channel_bandwidth assignment failure, AF setting must be 100.'
print
return
else:
if self.radio_type.lower() != 'af' and str(value) not in ('50', '40', '30', '20', '10'):
print
print 'ERROR: wireless_channel_bandwidth assignment (%s) failure, setting must be 50|40|30|20|10.' % value
print
return
self.cmd = 'af set channelbandwidth %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set channelbandwidth %s failed.' % value
#if self.wait == True:
# self.waitOperational()
wireless_channel_bandwidth = property(channel_bandwidth_get, channel_bandwidth_set)
def tx_channel_bandwidth_get(self):
if self.radio_type.lower() == 'af' and self.version_number < '2.1':
self.__txchannelbandwidth = '100'
else:
self.cmd = 'af get txchannelbandwidth' # Returns: 100MHz
try:
self.results = self.sendcmd(self.cmd).split()[3][:-3]
self.__txchannelbandwidth = self.results
except:
print 'EXCEPTION: af get txchannelbandwidth failed.'
self.__txchannelbandwidth = None
return self.__txchannelbandwidth
def tx_channel_bandwidth_set(self, value):
if self.radio_type.lower() == 'af' and str(value) != '100':
print
print 'ERROR: wireless_tx_channel_bandwidth assignment failure, AF setting must be 100.'
print
return
else:
if str(value) not in ('50', '40', '30', '20', '10'):
print
print 'ERROR: wireless_tx_channel_bandwidth assignment (%s) failure, setting must be 50|40|30|20|10.' % value
print
return
self.cmd = 'af set txchannelbandwidth %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set txchannelbandwidth %s failed.' % value
#if self.wait == True:
# self.waitOperational()
wireless_tx_channel_bandwidth = property(tx_channel_bandwidth_get, tx_channel_bandwidth_set)
def rx_channel_bandwidth_get(self):
# AF cmd not available before 19206
# GUI not available before 19233
if self.radio_type.lower() == 'af' and self.version_number < '2.1':
self.__rxchannelbandwidth = '100'
else:
self.cmd = 'af get rxchannelbandwidth' # Returns: 100MHz
try:
self.results = self.sendcmd(self.cmd).split()[3][:-3]
self.__rxchannelbandwidth = self.results
except:
print 'EXCEPTION: af get rxchannelbandwidth failed.'
self.__rxchannelbandwidth = None
return self.__rxchannelbandwidth
def rx_channel_bandwidth_set(self, value):
if self.radio_type.lower() == 'af' and str(value) != '100':
print
print 'ERROR: wireless_rx_channel_bandwidth assignment failure, AF setting must be 100.'
print
return
else:
if str(value) not in ('50', '40', '30', '20', '10'):
print
print 'ERROR: wireless_rx_channel_bandwidth assignment (%s) failure, setting must be 50|40|30|20|10.' % value
print
return
self.cmd = 'af set rxchannelbandwidth %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set rxchannelbandwidth %s failed.' % value
#if self.wait == True:
# self.waitOperational()
wireless_rx_channel_bandwidth = property(rx_channel_bandwidth_get, rx_channel_bandwidth_set)
def master_tx_duty_cycle_get(self):
# Returns: 25, 33, 50, 67, 75
# Only officially available for af06
# Some engineering releases for af and af02 contain af commands for dutycycle
self.cmd = 'af get dutycycle'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__dutycycle = self.results
except:
print 'EXCEPTION: af get dutycycle failed.'
self.__dutycycle = None
return self.__dutycycle
def master_tx_duty_cycle_set(self, value):
if self.radio_type.lower() != 'af06':
print
print 'ERROR: wireless_master_tx_duty_cycle assignment failure, radio must be type AF06.'
print
return
else:
if str(value) not in ('25', '33', '50', '67', '75'):
print
print 'ERROR: wireless_master_tx_duty_cycle assignment (%s) failure, setting must be 25|33|50|67|75.' % value
print
return
self.cmd = 'af set dutycycle %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set dutycycle %s failed.' % value
#if self.wait == True:
# self.waitOperational()
wireless_master_tx_duty_cycle = property(master_tx_duty_cycle_get, master_tx_duty_cycle_set)
def output_power_get(self):
self.cmd = 'af get powerout'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__powerout = self.results
except:
print 'EXCEPTION: af get powerout failed.'
self.__powerout = None
return self.__powerout
def output_power_set(self, value):
self.cmd = 'af set powerout %s' % str(value)
try:
result = self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set powerout %s failed.' % value
return None
wireless_output_power = property(output_power_get, output_power_set)
def antenna_gain_get(self):
# Not available: af
# Available: af02, af06
self.cmd = 'af get antennagain'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__antennagain = self.results
except:
print 'EXCEPTION: af get antennagain failed.'
self.__antennagain = None
return self.__antennagain
def antenna_gain_set(self, value):
# Not available: af, af02
# Available: af06
self.cmd = 'af set antennagain %s' % str(value)
try:
self.result = self.sendcmd(self.cmd)
if 'error' in str(self.result).lower():
print
print 'ERROR: af set antennagain %s failed.' % value
print
except:
print 'EXCEPTION: af set antennagain %s failed.' % value
return None
wireless_antenna_gain = property(antenna_gain_get, antenna_gain_set)
def cable_loss_get(self):
# Not available: af
# Available: af02, af06
self.cmd = 'af get cableloss'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__antennagain = self.results
except:
print 'EXCEPTION: af get cableloss failed.'
self.__antennagain = None
return self.__antennagain
def cable_loss_set(self, value):
# Not available: af
# Available: af02, af06
self.cmd = 'af set cableloss %s' % str(value)
try:
self.result = self.sendcmd(self.cmd)
if 'error' in str(self.result).lower():
print
print 'ERROR: af set cableloss %s failed.' % value
print
except:
print 'EXCEPTION: af set cableloss %s failed.' % value
return None
wireless_cable_loss = property(cable_loss_get, cable_loss_set)
def maximum_modulation_rate_get(self):
# Returns: 0x, 1x, 2x, 4x, 6x, 8x, 10x
self.cmd = 'af get speed'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__speed = self.results
except:
print 'EXCEPTION: af get speed failed.'
self.__speed = None
return self.__speed
def maximum_modulation_rate_set(self, value):
if str(value) not in ('0x', '1x', '2x', '4x', '6x', '8x', '10x'):
print
print 'ERROR: wireless_maximum_modulation_rate assignment (%s) failure, setting must be 0x|1x|2x|4x|6x|8x|10x.' % value
print
return
self.cmd = 'af set speed %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set speed %s failed.' % value
wireless_maximum_modulation_rate = property(maximum_modulation_rate_get, maximum_modulation_rate_set)
def automatic_rate_adaption_get(self):
# Returns: manual, automatic
self.cmd = 'af get modcontrol'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__modcontrol = self.results
except:
print 'EXCEPTION: af get modcontrol failed.'
self.__modcontrol = None
return self.__modcontrol
def automatic_rate_adaption_set(self, value):
if str(value) not in ('manual', 'automatic'):
print
print 'ERROR: wireless_automatic_rate_adaption assignment (%s) failure, setting must be manual|automatic.' % value
print
return
self.cmd = 'af set modcontrol %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set modcontrol %s failed.' % value
wireless_automatic_rate_adaption = property(automatic_rate_adaption_get, automatic_rate_adaption_set)
def rx_gain_get(self):
# Returns: low, high
self.cmd = 'af get rxgain'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__speed = self.results
except:
print 'EXCEPTION: af get rxgain failed.'
self.__speed = None
return self.__speed
def rx_gain_set(self, value):
if str(value) not in ('low', 'high'):
print
print 'ERROR: wireless_rx_gain assignment (%s) failure, setting must be low|high.' % value
print
return
self.cmd = 'af set rxgain %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set rxgain %s failed.' % value
wireless_rx_gain = property(rx_gain_get, rx_gain_set)
def tx_frequency_get(self):
# Returns: 5.752GHz
self.cmd = 'af get tx1frequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__txfrequency = self.results
except:
print 'EXCEPTION: af get txfrequency failed.'
self.__txfrequency = None
return self.__txfrequency
def tx_frequency_set(self, value):
self.cmd = 'af set tx1frequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set txfrequency %s failed.' % value
print
except:
print 'EXCEPTION: af set txfrequency %s failed.' % value
wireless_tx_frequency = property(tx_frequency_get, tx_frequency_set)
def tx_frequency_1_get(self):
# Returns: 5.752GHz
self.cmd = 'af get tx1frequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__tx1frequency = self.results
except:
print 'EXCEPTION: af get tx1frequency failed.'
self.__tx1frequency = None
return self.__tx1frequency
def tx_frequency_1_set(self, value):
self.cmd = 'af set tx1frequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set tx1frequency %s failed.' % value
print
except:
print 'EXCEPTION: af set tx1frequency %s failed.' % value
wireless_tx_frequency_1 = property(tx_frequency_1_get, tx_frequency_1_set)
def rx_frequency_get(self):
# Returns: 5.752GHz
self.cmd = 'af get rxfrequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__rxfrequency = self.results
except:
print 'EXCEPTION: af get rxfrequency failed.'
self.__rxfrequency = None
return self.__rxfrequency
def rx_frequency_set(self, value):
self.cmd = 'af set rxfrequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set rxfrequency %s failed.' % value
print
except:
print 'EXCEPTION: af set rxfrequency %s failed.' % value
wireless_rx_frequency = property(rx_frequency_get, rx_frequency_set)
#def rx_frequency_1_get(self):
# # Returns: 5.752GHz
# self.cmd = 'af get rx1frequency'
# try:
# self.results = self.sendcmd(self.cmd).split()[3]
# self.__rx1frequency = self.results
# except:
# print 'EXCEPTION: af get rx1frequency failed.'
# self.__rx1frequency = None
# return self.__rx1frequency
#def rx_frequency_1_set(self, value):
# self.cmd = 'af set rx1frequency %s' % value
# try:
# self.results = self.sendcmd(self.cmd)
# if 'error' in str(self.results).lower():
# print
# print 'ERROR: af set rx1frequency %s failed.' % value
# print
# except:
# print 'EXCEPTION: af set rx1frequency %s failed.' % value
wireless_rx_frequency_1 = property(rx_frequency_get, rx_frequency_set)
def tx_frequency_2_get(self):
# Returns: 5.752GHz
self.cmd = 'af get tx2frequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__tx2frequency = self.results
except:
print 'EXCEPTION: af get tx2frequency failed.'
self.__tx2frequency = None
return self.__tx2frequency
def tx_frequency_2_set(self, value):
self.cmd = 'af set tx2frequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set tx2frequency %s failed.' % value
print
except:
print 'EXCEPTION: af set tx2frequency %s failed.' % value
wireless_tx_frequency_2 = property(tx_frequency_2_get, tx_frequency_2_set)
def rx_frequency_2_get(self):
# Returns: 5.752GHz
self.cmd = 'af get rx2frequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__rx2frequency = self.results
except:
print 'EXCEPTION: af get rx2frequency failed.'
self.__rx2frequency = None
return self.__rx2frequency
def rx_frequency_2_set(self, value):
self.cmd = 'af set rx2frequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set rx2frequency %s failed.' % value
print
except:
print 'EXCEPTION: af set rx2frequency %s failed.' % value
wireless_rx_frequency_2 = property(rx_frequency_2_get, rx_frequency_2_set)
def tx_frequency_3_get(self):
# Returns: 5.752GHz
self.cmd = 'af get tx3frequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__tx3frequency = self.results
except:
print 'EXCEPTION: af get tx3frequency failed.'
self.__tx3frequency = None
return self.__tx3frequency
def tx_frequency_3_set(self, value):
self.cmd = 'af set tx3frequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set tx3frequency %s failed.' % value
print
except:
print 'EXCEPTION: af set tx3frequency %s failed.' % value
wireless_tx_frequency_3 = property(tx_frequency_3_get, tx_frequency_3_set)
def rx_frequency_3_get(self):
# Returns: 5.752GHz
self.cmd = 'af get rx3frequency'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__rx3frequency = self.results
except:
print 'EXCEPTION: af get rx3frequency failed.'
self.__rx3frequency = None
return self.__rx3frequency
def rx_frequency_3_set(self, value):
self.cmd = 'af set rx3frequency %s' % value
try:
self.results = self.sendcmd(self.cmd)
if 'error' in str(self.results).lower():
print
print 'ERROR: af set rx3frequency %s failed.' % value
print
except:
print 'EXCEPTION: af set rx3frequency %s failed.' % value
wireless_rx_frequency_3 = property(rx_frequency_3_get, rx_frequency_3_set)
def key_type_get(self):
# Returns: hex, ascii
self.cmd = 'af get keytype'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__keytype = self.results
except:
print 'EXCEPTION: af get keytype failed.'
self.__keytype = None
return self.__keytype
def key_type_set(self, value):
if str(value) not in ('hex', 'ascii'):
print
print 'ERROR: wireless_key_type assignment (%s) failure, setting must be hex|ascii.' % value
print
return
self.cmd = 'af set keytype %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set keytype %s failed.' % value
wireless_key_type = property(key_type_get, key_type_set)
def key_get(self):
# Returns: 0000:0000:0000:0000:0000:0000:0000:0000 in hex mode
# Returns: in ascii mode
self.cmd = 'af get key'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__key = self.results
except:
print 'EXCEPTION: af get key failed.'
self.__key = None
return self.__key
def key_set(self, value):
self.cmd = 'af set key %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set key %s failed.' % value
wireless_key = property(key_get, key_set)
def gps_clock_sync_get(self):
# Returns: off, on
self.cmd = 'af get gps'
try:
self.results = self.sendcmd(self.cmd).split()[3]
self.__gps = self.results
except:
print 'EXCEPTION: af get gps failed.'
self.__gps = None
return self.__gps
def gps_clock_sync_set(self, value):
if str(value) not in ('off', 'on'):
print
print 'ERROR: gps_clock_sync_set assignment (%s) failure, setting must be off|on.' % value
print
return
self.cmd = 'af set gps %s' % value
try:
self.sendcmd(self.cmd)
except:
print 'EXCEPTION: af set gps %s failed.' % value