Browse code

all memory

gandolf authored on 02/01/2020 05:02:27
Showing 3 changed files
... ...
@@ -1,18 +1,6 @@
1
-Memory Ch,Rx Frequency,Tx Frequency,Offset,Repeater Shift,Mode,Tag,Encoding,Tone,DCS,Clarifier, RxClar, TxClar
2
-1,145.19,,,-RPT,FM,WA7ABU,TONE ENC,100.0 Hz,23,0,OFF,OFF
3
-2,145.29,,,-RPT,FM,WA7ABU,OFF,118.8 Hz,23,0,OFF,OFF
4
-3,444.95,,,+RPT,C4FM,W7ABU,TONE ENC,100.0 Hz,23,0,OFF,OFF
5
-4,145.49,,,-RPT,FM,W7PRA Sa,TONE ENC,136.5 Hz,23,0,OFF,OFF
6
-5,444.825,,,+RPT,FM,W7PRA Ha,DCS,100.0 Hz,23,0,OFF,OFF
7
-6,146.61,,,-RPT,FM,K7ENW,TONE ENC,167.9 Hz,23,0,OFF,OFF
8
-7,442.85,,,+RPT,FM,K7ENW,TONE ENC,167.9 Hz,23,0,OFF,OFF
9
-8,147.16,,,+RPT,FM,W7OSU,TONE ENC,100.0 Hz,23,0,OFF,OFF
10
-9,146.72,,,-RPT,FM,W7PXL,TONE ENC,100.0 Hz,23,0,OFF,OFF
11
-10,146.78,,,-RPT,FM,K7CVO,TONE ENC,156.7 Hz,23,0,OFF,OFF
12
-11,146.52,,,OFF,FM,VHF Call,OFF,100.0 Hz,23,0,OFF,OFF
13
-12,446,,,OFF,FM,UHF Call,OFF,100.0 Hz,23,0,OFF,OFF
14
-20,162.55,,,OFF,FM,WX PDX,OFF,100.0 Hz,23,0,OFF,OFF
15
-21,162.475,,,OFF,FM,WX SLE,OFF,100.0 Hz,23,0,OFF,OFF
16
-22,162.5,,,OFF,FM,WX FLO,OFF,100.0 Hz,23,0,OFF,OFF
17
-23,122.725,,,OFF,AM,ALB CTAF,OFF,100.0 Hz,23,0,OFF,OFF
18
-24,123.075,,,OFF,AM,CVO CTAF,OFF,100.0 Hz,23,0,OFF,OFF
1
+Memory Ch,VFO_A,VFO_B,RepeaterShift,Mode,Tag,Encoding,Tone,DCS,Clarifier,RxClar,TxClar,PreAmp,RfAttn,NB,IFshift,IFwidthIndex,ContourState,ContourFreq,APFstate,APFfreq,DNRstate,DNRalgorithm,DNFstate,NBFstate,NotchState,NotchFreq
2
+1,146.52,,OFF,FM,VHF Call,OFF,100.0 Hz,23,0,OFF,OFF,IPO,NA,OFF,NA,NA,NA,NA,NA,NA,NA,1,NA,WIDE,ON,150
3
+2,145.29,,-RPT,FM,WA7ABU,OFF,118.8 Hz,23,0,OFF,OFF,IPO,NA,OFF,NA,NA,NA,NA,NA,NA,NA,1,NA,WIDE,ON,150
4
+3,162.55,,OFF,FM,WX PDX,OFF,100.0 Hz,23,0,OFF,OFF,IPO,NA,OFF,NA,NA,NA,NA,NA,NA,NA,1,NA,WIDE,ON,150
5
+4,122.725,,OFF,AM,ALB CTAF,OFF,100.0 Hz,23,0,OFF,OFF,IPO,NA,OFF,NA,NA,NA,NA,NA,NA,OFF,1,OFF,WIDE,OFF,150
6
+5,14.25,,OFF,USB,20 Meters,OFF,67.0 Hz,23,0,OFF,OFF,AMP 2,ON,ON,20,14,0,300,0,25,OFF,1,OFF,WIDE,OFF,150
... ...
@@ -55,6 +55,9 @@ ptrDevice = None
55 55
 # CTCSS tone, and DCS code are translated to the repective FT991 parameter
56 56
 # value.
57 57
 
58
+# Binary On / Off state
59
+bState = { 'OFF':'0', 'ON':'1' }
60
+
58 61
 # Modulation modes
59 62
 dMode = { 'LSB':'1', 'USB':'2', 'CW':'3', 'FM':'4', 'AM':'5',
60 63
           'RTTY-LSB':'6', 'CW-R':'7', 'DATA-LSB':'8', 'RTTY-USB':'9',
... ...
@@ -113,9 +116,12 @@ dDcs = { '23':'000', '25':'001', '26':'002', '31':'003', '32':'004',
113 116
          '664':'095', '703':'096', '712':'097', '723':'098', '731':'099',
114 117
          '732':'100', '734':'101', '743':'102', '754':'103' }
115 118
 
116
-# Clarifier state
117
-dRxClar = { 'OFF':'0', 'ON':'1' }
118
-dTxClar = { 'OFF':'0', 'ON':'1' }
119
+# Preamplifier State
120
+dPreamp = { 'IPO':'0', 'AMP 1':'1', 'AMP 2':'2' }
121
+
122
+# Narror band filter state
123
+dNAR = { 'WIDE':'0', 'NARROW':'1' }
124
+
119 125
 
120 126
 #############################################################################
121 127
 # Define 'get' methods to encapsulate FT991 commands returning status info. #
... ...
@@ -135,24 +141,24 @@ def getMemory(memloc):
135 141
 
136 142
     # Parse memory settings string returned by the FT991
137 143
     memloc = sResult[2:5]
138
-    rxfreq = sResult[5:14]
144
+    vfoa = sResult[5:14]
139 145
     clarfreq = sResult[14:19]
140 146
     rxclar = sResult[19]
141 147
     txclar = sResult[20]
142 148
     mode = sResult[21]
143 149
     encode = sResult[23]
144
-    shift = sResult[26]
150
+    rpoffset = sResult[26]
145 151
     tag = sResult[28:40]
146 152
 
147 153
     # Store the memory settings in a dictionary object.
148 154
     dMem['memloc'] = str(int(memloc))
149
-    dMem['rxfreq'] = str(float(rxfreq) / 10**6)
155
+    dMem['vfoa'] = str(float(vfoa) / 10**6)
150 156
     dMem['clarfreq'] = str(int(clarfreq))
151
-    dMem['rxclar'] = dRxClar.keys()[dRxClar.values().index(rxclar)]
152
-    dMem['txclar'] = dTxClar.keys()[dTxClar.values().index(txclar)]
157
+    dMem['rxclar'] = bState.keys()[bState.values().index(rxclar)]
158
+    dMem['txclar'] = bState.keys()[bState.values().index(txclar)]
153 159
     dMem['mode'] = dMode.keys()[dMode.values().index(mode)]
154 160
     dMem['encode'] = dEncode.keys()[dEncode.values().index(encode)]
155
-    dMem['shift'] = dShift.keys()[dShift.values().index(shift)]
161
+    dMem['rpoffset'] = dShift.keys()[dShift.values().index(rpoffset)]
156 162
     dMem['tag'] = tag.strip()
157 163
 
158 164
     return dMem
... ...
@@ -190,10 +196,9 @@ def getRxClarifier():
190 196
     """
191 197
     # An exception will automatically be raised if incorrect data is
192 198
     # supplied - most likely a "key not found" error.
193
-    sCmd = 'RT;'
194
-    sResult = sendCommand(sCmd)
199
+    sResult = sendCommand('RT;')
195 200
     state = sResult[2]
196
-    return dRxClar.keys()[dRxClar.values().index(state)]
201
+    return bState.keys()[bState.values().index(state)]
197 202
 ## end def
198 203
 
199 204
 def getTxClarifier():
... ...
@@ -204,14 +209,182 @@ def getTxClarifier():
204 209
     """
205 210
     # An exception will automatically be raised if incorrect data is
206 211
     # supplied - most likely a "key not found" error.
207
-    sCmd = 'XT;'
208
-    sResult = sendCommand(sCmd)
212
+    sResult = sendCommand('XT;')
209 213
     state = sResult[2]
210
-    return dTxClar.keys()[dTxClar.values().index(state)]
214
+    return bState.keys()[bState.values().index(state)]
215
+## end def
216
+
217
+def getPower():
218
+    """
219
+    Description:  Gets the transmit power level.
220
+    Parameters: none
221
+    Returns: string containing the power in Watts
222
+    """
223
+    sResult = sendCommand('PC;')
224
+    return sResult[2:5]
225
+##end def
226
+
227
+def getPreamp():
228
+    """
229
+    Description:  Gets the state of the Rx preamplifier.
230
+    Parameters: none
231
+    Returns: string containing the state of the preamplifier.
232
+    """
233
+    # Get result of PA0 command
234
+    sResult = sendCommand('PA0;')
235
+    ipo = sResult[3:4]
236
+    return dPreamp.keys()[dPreamp.values().index(ipo)]
237
+## end def
238
+
239
+def getRfAttn():
240
+    """
241
+    Description:  Gets the state of the Rf attenuator.
242
+    Parameters: none
243
+    Returns: string containing the state of the Rf attenuator.
244
+    """
245
+    sResult = sendCommand('RA0;')
246
+    if sResult == '?;':
247
+        return 'NA'
248
+    attn = sResult[3:4]
249
+    return bState.keys()[bState.values().index(attn)]
250
+## end def
251
+
252
+def getNoiseBlanker():
253
+    """
254
+    Description:  Gets the state of the noise blanker.
255
+    Parameters: none
256
+    Returns: string containing the state of the noise blanker.
257
+    """
258
+    sResult = sendCommand('NB0;')
259
+    nb = sResult[3:4]
260
+    return bState.keys()[bState.values().index(nb)]
261
+## end def
262
+
263
+def getIFshift():
264
+    """
265
+    Description:  Gets the value in Hz of IF shift.
266
+    Parameters: none
267
+    Returns: string containing the amount of shift.
268
+    """
269
+    if getRfAttn() == 'NA':
270
+        return 'NA'
271
+    sResult = sendCommand('IS0;')
272
+    if sResult == '?;':
273
+        return 'NA'
274
+    shift = int(sResult[3:8])
275
+    return shift
276
+## end def
277
+
278
+def getIFwidth():
279
+    """
280
+    Description:  Gets the index of the width setting.  IF width settings
281
+                  vary according to the modulation type and bandwidth.
282
+                  Therefore only the index gets saved.
283
+    Parameters: none
284
+    Returns: string containing the amount index number.
285
+    """
286
+    if getRfAttn() == 'NA':
287
+        return 'NA'
288
+    sResult = sendCommand('SH0;')
289
+    width = int(sResult[3:5])
290
+    return width
291
+## end def
292
+
293
+def getContour():
294
+    """
295
+    Description:  Gets the four contour parameters.
296
+    Parameters: none
297
+    Returns: list object containing the four parameters.
298
+    """
299
+    if getRfAttn() == 'NA':
300
+        return [ 'NA', 'NA', 'NA', 'NA' ]
301
+    lContour = []
302
+
303
+    sResult = sendCommand('CO00;')
304
+    lContour.append(int(sResult[4:8]))
305
+
306
+    sResult = sendCommand('CO01;')
307
+    lContour.append(int(sResult[4:8]))
308
+
309
+    sResult = sendCommand('CO02;')
310
+    lContour.append(int(sResult[4:8]))
311
+
312
+    sResult = sendCommand('CO03;')
313
+    lContour.append(int(sResult[4:8]))
314
+    return lContour
315
+## end def
316
+
317
+def getDNRstate():
318
+    """
319
+    Description:  Gets digital noise reduction (DNR) state.
320
+    Parameters: none
321
+    Returns: 0 = OFF or 1 = ON
322
+    """
323
+    sResult = sendCommand('NR0;')
324
+    if sResult == '?;':
325
+        return 'NA'
326
+    state = sResult[3:4]
327
+    return bState.keys()[bState.values().index(state)]
328
+## end def
329
+
330
+def getDNRalgorithm():
331
+    """
332
+    Description:  Gets the algorithm used by the DNR processor.
333
+    Parameters: none
334
+    Returns: a number between 1 and 16 inclusive
335
+    """
336
+    sResult = sendCommand('RL0;')
337
+    algorithm = int(sResult[3:5])
338
+    return algorithm
339
+## end def
340
+
341
+def getDNFstate():
342
+    """
343
+    Description:  Gets digital notch filter (DNF) state.
344
+    Parameters: none
345
+    Returns: 0 = OFF or 1 = ON
346
+    """
347
+    sResult = sendCommand('BC0;')
348
+    if sResult == '?;':
349
+        return 'NA'
350
+    state = sResult[3:4]
351
+    return bState.keys()[bState.values().index(state)]
211 352
 ## end def
212 353
 
354
+def getNARstate():
355
+    """
356
+    Description:  Gets narrow/wide filter (NAR) state.
357
+    Parameters: none
358
+    Returns: 0 = Wide or 1 = Narrow
359
+    """     
360
+    sResult = sendCommand('NA0;')
361
+    if sResult == '?;':
362
+        return 'NA'
363
+    state = sResult[3:4]
364
+    return dNAR.keys()[dNAR.values().index(state)]
365
+## end def
366
+
367
+def getNotchState():
368
+    """
369
+    Description:  Gets the notch filter state and setting.
370
+    Parameters: none
371
+    Returns: a tuple containing state and frequency
372
+             state = 0 (OFF) or 1 (ON)
373
+             frequency = number between 1 and 320 (x 10 Hz)
374
+    """     
375
+    sResult = sendCommand('BP00;')
376
+    if sResult == '?;':
377
+        return ('NA', 'NA')
378
+    state = sResult[6:7]
379
+    state = bState.keys()[bState.values().index(state)]
380
+    sResult = sendCommand('BP01;')
381
+    freq = int(sResult[4:7])
382
+    return (state, freq)
383
+## end def
384
+
385
+
213 386
 #############################################################################
214
-# Define 'set' functions to encapsulate the various FT991 CAT commands.     #
387
+# Define 'set' methods to encapsulate the various FT991 CAT commands.       #
215 388
 #############################################################################
216 389
 
217 390
 def setMemory(dMem):
... ...
@@ -221,13 +394,13 @@ def setMemory(dMem):
221 394
                        defined:
222 395
 
223 396
                        memloc - the memory location to be written
224
-                       rxfreq - receive frequency of VFO-A in MHz
397
+                       vfoa - receive frequency of VFO-A in MHz
225 398
                        clarfreq - clarifier frequency and direction
226 399
                        rxclar - receive clarifier state
227 400
                        txclar - transmit clarifier state
228 401
                        mode - the modulation mode
229 402
                        encode - the tone or DCS encoding mode
230
-                       shift - the direction of the repeater shift
403
+                       rpoffset - the direction of the repeater shift
231 404
                        tag - a label for the memory location
232 405
 
233 406
     Returns: nothing
... ...
@@ -243,7 +416,7 @@ def setMemory(dMem):
243 416
     sCmd += '%0.3d' % iLocation
244 417
 
245 418
     # Validate and append the vfo-a frequency data.
246
-    iRxfreq = int(float(dMem['rxfreq']) * 1E6) # vfo-a frequency in Hz
419
+    iRxfreq = int(float(dMem['vfoa']) * 1E6) # vfo-a frequency in Hz
247 420
     if iRxfreq < 0.030E6 or iRxfreq > 450.0E6:
248 421
         raise Exception('VFO-A frequency must be between 30 kHz and ' \
249 422
                         '450 MHz, inclusive.')
... ...
@@ -259,13 +432,13 @@ def setMemory(dMem):
259 432
     # The following commands will automatically raise an exception if
260 433
     # incorrect data is supplied.  The exception will be a dictionary
261 434
     # object "key not found" error.
262
-    sCmd += dRxClar[dMem['rxclar']]
263
-    sCmd += dTxClar[dMem['txclar']]
435
+    sCmd += bState[dMem['rxclar']]
436
+    sCmd += bState[dMem['txclar']]
264 437
     sCmd += dMode[dMem['mode']]
265 438
     sCmd += '0'
266 439
     sCmd += dEncode[dMem['encode']]
267 440
     sCmd += '00'
268
-    sCmd += dShift[dMem['shift']]
441
+    sCmd += dShift[dMem['rpoffset']]
269 442
     sCmd += '0'
270 443
     sTag = dMem['tag']
271 444
 
... ...
@@ -342,7 +515,7 @@ def setRxClarifier(state='OFF'):
342 515
     """
343 516
     # An exception will automatically be raised if incorrect data is
344 517
     # supplied - most likely a "key not found" error.
345
-    sCmd = 'RT%s;' % dRxClar[state]
518
+    sCmd = 'RT%s;' % bState[state]
346 519
     # Send the completed command.
347 520
     sResult = sendCommand(sCmd)
348 521
     if sResult == '?;':
... ...
@@ -358,7 +531,7 @@ def setTxClarifier(state='OFF'):
358 531
     """
359 532
     # An exception will automatically be raised if incorrect data is
360 533
     # supplied - most likely a "key not found" error.
361
-    sCmd = 'XT%s;' % dTxClar[state]
534
+    sCmd = 'XT%s;' % bState[state]
362 535
     # Send the completed command.
363 536
     sResult = sendCommand(sCmd)
364 537
     if sResult == '?;':
... ...
@@ -386,6 +559,182 @@ def setMemoryLocation(iLocation):
386 559
         return str(iLocation)
387 560
 ## end def
388 561
 
562
+def setPreamp(state='IPO'):
563
+    """
564
+    Description:  Sends a formatted PA command that sets the preamplifier
565
+                  state.
566
+    Parameters: state - string 'IPO', 'AMP 1', 'AMP 2'
567
+    Returns: nothing
568
+    """
569
+    # An exception will automatically be raised if incorrect data is
570
+    # supplied - most likely a "key not found" error.
571
+    sCmd = 'PA0%s;' % dPreamp[state]
572
+    # Send the completed command.
573
+    sResult = sendCommand(sCmd)
574
+    if sResult == '?;':
575
+        raise Exception('setPreAmp error')
576
+## end def
577
+
578
+def setRfAttn(state='NA'):
579
+    """
580
+    Description:  Sends a formatted PA command that sets the RF attenuator
581
+                  state.  Note that attempting to write or read the
582
+                  attenuator for a VHF or UHF band results in an error.
583
+                  Hence the addition of a state 'NA' for NOT APPLICABLE.
584
+    Parameters: state - string 'OFF', 'ON', 'NA'
585
+    Returns: nothing
586
+    """
587
+    if state == 'NA':
588
+        return
589
+    sCmd = 'RA0%s;' % bState[state]
590
+    sResult = sendCommand(sCmd)
591
+    if sResult == '?;':
592
+        raise Exception('setRfAttn error')
593
+## end def
594
+
595
+def setNoiseBlanker(state='OFF'):
596
+    """
597
+    Description:  Sends a formatted NB command that sets the noise blanker
598
+                  state.
599
+    Parameters: state - string 'OFF', 'ON'
600
+    Returns: nothing
601
+    """
602
+    sCmd = 'NB0%s;' % bState[state]
603
+    sResult = sendCommand(sCmd)
604
+    if sResult == '?;':
605
+        raise Exception('setNoiseBlanker error')
606
+## end def
607
+
608
+def setIFshift(shift='NA'):
609
+    """
610
+    Description:  Sends a formatted IS command that sets the amount of
611
+                  IF shift.
612
+    Parameters: state - string 'OFF', 'ON'
613
+    Returns: nothing
614
+    """
615
+    if shift == 'NA':
616
+        return
617
+    shift = int(shift)
618
+    if abs(shift) > 1200:
619
+        raise Exception('setIFshift error: data out of bounds')
620
+    sCmd = 'IS0%0+5d;' % shift
621
+    sResult = sendCommand(sCmd)
622
+    if sResult == '?;':
623
+        raise Exception('setIFshift error')
624
+## end def
625
+
626
+def setIFwidth(index='NA'):
627
+    """
628
+    Description:  Sends a formatted SH command that sets the IF width
629
+                  IF shift.
630
+    Parameters: index of shift - value between 0 and 21, inclusive
631
+    Returns: nothing
632
+    """
633
+    if index == 'NA':
634
+        return
635
+    index = int(index)
636
+    if index < 0 or index > 21:
637
+        raise Exception('setIFwidth error: data out of bounds')
638
+    sCmd = 'SH0%02d;' % index
639
+    sResult = sendCommand(sCmd)
640
+    if sResult == '?;':
641
+        raise Exception('setIFwidth error')
642
+## end def
643
+
644
+def setContour(lParams):
645
+    """
646
+    Description:  Sends a formatted CO command that sets contour parameters
647
+    Parameters: lParams - list object containing the parameters
648
+    Returns: nothing
649
+    """
650
+    if lParams[0] == 'NA':
651
+        return
652
+
653
+    for inx in range(4):
654
+        sCmd = 'CO0%d%04d' % (inx, int(lParams[inx]))
655
+        sResult = sendCommand(sCmd)
656
+        if sResult == '?;':
657
+            raise Exception('setContour error')
658
+## end def
659
+
660
+def setDNRstate(state = 'NA'):
661
+    """
662
+    Description:  Sets the state (on or off) of the digital noise
663
+                  reduction (DNR) processor.
664
+    Parameters:   State = 0 (OFF) or 1 (ON)
665
+    Returns: nothing
666
+    """
667
+    if state == 'NA':
668
+        return
669
+    sCmd = 'NR0%01d' % int(bState[state])
670
+    sResult = sendCommand(sCmd)
671
+    if sResult == '?;':
672
+        raise Exception('setDNR error')
673
+## end def
674
+
675
+def setDNRalgorithm(algorithm = 1):
676
+    """
677
+    Description:  Sets the algorithm used by the digital noise
678
+                  reduction (DNR) processor.
679
+    Parameters:   algorithm - a number between 1 and 16 inclusive
680
+    Returns: nothing
681
+    """
682
+    sCmd = 'RL0%02d' % int(algorithm)
683
+    sResult = sendCommand(sCmd)
684
+    if sResult == '?;':
685
+        raise Exception('setDNR error')
686
+## end def
687
+
688
+def setDNFstate(state = 'NA'):
689
+    """
690
+    Description:  Sets the state (on or off) of the digital notch
691
+                  filter (DNF) processor.
692
+    Parameters:   State = 0 (OFF) or 1 (ON)
693
+    Returns: nothing
694
+    """
695
+    if state == 'NA':
696
+        return
697
+    sCmd = 'BC0%01d' % int(bState[state])
698
+    sResult = sendCommand(sCmd)
699
+    if sResult == '?;':
700
+        raise Exception('setDNF error')
701
+## end def
702
+
703
+def setNARstate( state = 'NA'):
704
+    """
705
+    Description:  Gets narrow/wide filter (NAR) state.
706
+    Parameters: none
707
+    Returns: 0 = Wide or 1 = Narrow
708
+    """
709
+    if state == 'NA':
710
+        return
711
+    sCmd = 'NA0%s' % dNAR[state]
712
+    sResult = sendCommand(sCmd)
713
+    if sResult == '?;':
714
+        raise Exception('setNAR error')
715
+## end def
716
+
717
+def setNotchState( state = ('NA', 'NA') ):
718
+    """
719
+    Description:  Gets the notch filter state and setting.
720
+    Parameters: none
721
+    Returns: a tuple containing state and frequency
722
+             state = 0 (OFF) or 1 (ON)
723
+             frequency = number between 1 and 320 (x 10 Hz)
724
+    """
725
+    if state[0] == 'NA':
726
+        return
727
+    sCmd = 'BP0000%s' % bState[state[0]]
728
+    sResult = sendCommand(sCmd)
729
+    if sResult == '?;':
730
+        raise Exception('setNotch error')
731
+    sCmd = 'BP01%03d' % int(state[1])
732
+    sResult = sendCommand(sCmd)
733
+    if sResult == '?;':
734
+        raise Exception('setNotch error')
735
+## end def
736
+
737
+
389 738
 #############################################################################
390 739
 # Helper functions to assist in various tasks.                              #
391 740
 #############################################################################
... ...
@@ -404,18 +753,29 @@ def parseCsvData(sline):
404 753
         return None
405 754
     # Store the parsed items with the appropriate key in the dictionary object.
406 755
     dChan['memloc'] = lchan[0]
407
-    dChan['rxfreq'] = lchan[1]
408
-    dChan['txfreq'] = lchan[2]
409
-    dChan['offset'] = lchan[3]
410
-    dChan['shift'] = lchan[4]
411
-    dChan['mode'] = lchan[5]
412
-    dChan['tag'] = lchan[6]
413
-    dChan['encode'] = lchan[7]
414
-    dChan['tone'] = lchan[8]
415
-    dChan['dcs'] = lchan[9]
416
-    dChan['clarfreq'] = lchan[10]
417
-    dChan['rxclar'] = lchan[11]
418
-    dChan['txclar'] = lchan[12]
756
+    dChan['vfoa'] = lchan[1]
757
+    dChan['vfob'] = lchan[2]
758
+    dChan['rpoffset'] = lchan[3]
759
+    dChan['mode'] = lchan[4]
760
+    dChan['tag'] = lchan[5]
761
+    dChan['encode'] = lchan[6]
762
+    dChan['tone'] = lchan[7]
763
+    dChan['dcs'] = lchan[8]
764
+    dChan['clarfreq'] = lchan[9]
765
+    dChan['rxclar'] = lchan[10]
766
+    dChan['txclar'] = lchan[11]
767
+    dChan['preamp'] = lchan[12]
768
+    dChan['rfattn'] = lchan[13]
769
+    dChan['nblkr']  = lchan[14]
770
+    dChan['shift'] = lchan[15]
771
+    dChan['width'] = lchan[16]
772
+    dChan['contour'] = [ lchan[17], lchan[18], lchan[19], lchan[20] ]
773
+    dChan['dnrstate'] = lchan[21]
774
+    dChan['dnralgorithm'] = lchan[22]
775
+    dChan['dnfstate'] = lchan[23]
776
+    dChan['narstate'] = lchan[24]
777
+    dChan['notchstate'] = lchan[25]
778
+    dChan['notchfreq'] = lchan[26]
419 779
     return dChan # return the dictionary object
420 780
 ## end def
421 781
 
... ...
@@ -561,7 +921,7 @@ def main():
561 921
     # Instantiate serial connection to FT991
562 922
     begin()
563 923
     # Set and receive a memory channel
564
-    dMem = {'memloc': '98', 'rxfreq': '146.52', 'shift': 'OFF', \
924
+    dMem = {'memloc': '98', 'vfoa': '146.52', 'shift': 'OFF', \
565 925
             'mode': 'FM', 'encode': 'TONE ENC', 'tag': 'KA7JLO', \
566 926
             'clarfreq': '1234', 'rxclar': 'ON', 'txclar': 'ON' \
567 927
            }
... ...
@@ -575,7 +935,7 @@ def main():
575 935
     getMemory(int(dMem['memloc']))
576 936
     print
577 937
     # Set and receive a memory channel
578
-    dMem = {'memloc': '99', 'rxfreq': '146.52', 'shift': 'OFF', \
938
+    dMem = {'memloc': '99', 'vfoa': '146.52', 'shift': 'OFF', \
579 939
             'mode': 'FM', 'encode': 'OFF', 'tag': 'KA7JLO', \
580 940
             'clarfreq': '0', 'rxclar': 'OFF', 'txclar': 'OFF' \
581 941
            }
... ...
@@ -42,6 +42,7 @@ _DEFAULT_MENU_SETTINGS_FILE = 'ft991menu.cfg'
42 42
 _DEFAULT_MEMORY_SETTINGS_FILE = 'ft991mem.csv'
43 43
 _MAX_NUMBER_OF_MENU_ITEMS = 154
44 44
 _MAX_NUMBER_OF_MEMORY_ITEMS = 118
45
+_DEBUG = False
45 46
 
46 47
 # Global definitions
47 48
 
... ...
@@ -262,9 +263,12 @@ def readMemorySettings():
262 263
              contained in the list.
263 264
     """
264 265
     # Define the column headers as the first item in the list.
265
-    lSettings = [ 'Memory Ch,Rx Frequency,Tx Frequency,Offset,' \
266
-                        'Repeater Shift,Mode,Tag,Encoding,Tone,DCS,' \
267
-                        'Clarifier,RxClar,TxClar' ]
266
+    lSettings = [ 'Memory Ch,VFO_A,VFO_B,' \
267
+                  'RepeaterShift,Mode,Tag,Encoding,Tone,DCS,' \
268
+                  'Clarifier,RxClar,TxClar,PreAmp,RfAttn,NB,IFshift,' \
269
+                  'IFwidthIndex,ContourState,ContourFreq,' \
270
+                  'APFstate,APFfreq,DNRstate,DNRalgorithm,DNFstate,' \
271
+                  'NBFstate,NotchState,NotchFreq' ]
268 272
 
269 273
     for iLocation in range(1, _MAX_NUMBER_OF_MEMORY_ITEMS):
270 274
 
... ...
@@ -280,14 +284,31 @@ def readMemorySettings():
280 284
         dMem = ft991.getMemory(iLocation)
281 285
         tone = ft991.getCTCSS()
282 286
         dcs = ft991.getDCS()
287
+        preamp = ft991.getPreamp()
288
+        rfattn = ft991.getRfAttn()
289
+        nblkr = ft991.getNoiseBlanker()
290
+        shift = ft991.getIFshift()
291
+        width = ft991.getIFwidth()
292
+        lContour = ft991.getContour()
293
+        dnrstate = ft991.getDNRstate()
294
+        dnralgorithm = ft991.getDNRalgorithm()
295
+        dnfstate = ft991.getDNFstate()
296
+        narstate = ft991.getNARstate()
297
+        notch = ft991.getNotchState()
283 298
         # getMemory, above, stores data in a dictionary object.  Format
284 299
         # the data in this object, as well as, the DCS code and CTCSS
285 300
         # tone into a comma-delimited string.
286
-        sCsvFormat = '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s' % \
287
-               ( dMem['memloc'], dMem['rxfreq'], '', '', \
288
-                 dMem['shift'], dMem['mode'], dMem['tag'], dMem['encode'], \
301
+        sCsvFormat = '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,' \
302
+                     '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s' % \
303
+               (
304
+                 dMem['memloc'], dMem['vfoa'], '', \
305
+                 dMem['rpoffset'], dMem['mode'], dMem['tag'], dMem['encode'], \
289 306
                  tone, dcs, dMem['clarfreq'], dMem['rxclar'], \
290
-                 dMem['txclar'] )
307
+                 dMem['txclar'], preamp, rfattn, nblkr, shift, width, \
308
+                 lContour[0], lContour[1], lContour[2], lContour[3], \
309
+                 dnrstate, dnralgorithm, dnfstate, narstate, notch[0],
310
+                 notch[1]
311
+               )
291 312
         # Add the comma-delimited string to the list object.
292 313
         lSettings.append(sCsvFormat)
293 314
     return lSettings
... ...
@@ -301,13 +322,14 @@ def writeMemorySettings(lSettings):
301 322
     Returns: nothing
302 323
     """
303 324
     for item in lSettings:
304
-        # Parse the comma-delimited line and store in a dictionary object.
305
-        dItem = ft991.parseCsvData(item)
306
-        # The first item in the memory settings list are the column headers;
307
-        # so ignore this item.  (parseData returns None for this item.)
308
-        if dItem == None:
309
-            continue
310 325
         try:
326
+            # Parse the comma-delimited line and store in a dictionary object.
327
+            dItem = ft991.parseCsvData(item)
328
+            # The first item in the memory settings list are the
329
+            # column headers, so ignore this item.  (parseData returns
330
+            # None for this item.)
331
+            if dItem == None:
332
+                continue
311 333
             # Set the parameters for the memory location.
312 334
             ft991.setMemory(dItem)
313 335
             # Set current channel to memory location being set.
... ...
@@ -322,13 +344,36 @@ def writeMemorySettings(lSettings):
322 344
             # off by sending the 'RT0' and 'XT0' commands.  This situation
323 345
             # is probably due to a bug in the CAT interface.
324 346
             ft991.setRxClarifier(dItem['rxclar'])
325
-            ft991.setTxClarifier(dItem['txclar'])            
347
+            ft991.setTxClarifier(dItem['txclar'])
348
+            # Set Rx preamplifier state
349
+            ft991.setPreamp(dItem['preamp'])
350
+            # Set RF attenuator state
351
+            ft991.setRfAttn(dItem['rfattn'])
352
+            # Set Noise Blanker state
353
+            ft991.setNoiseBlanker(dItem['nblkr'])
354
+            # Set IF shift amount
355
+            ft991.setIFshift(dItem['shift'])
356
+            # Set IF width index
357
+            ft991.setIFwidth(dItem['width'])
358
+            # Set Contour parameters
359
+            ft991.setContour(dItem['contour'])
360
+            # Set DNR state and algorithm
361
+            ft991.setDNRstate(dItem['dnrstate'])
362
+            ft991.setDNRalgorithm(dItem['dnralgorithm'])
363
+            # Set DNF state
364
+            ft991.setDNFstate(dItem['dnfstate'])
365
+            # Set NAR state
366
+            ft991.setNARstate(dItem['narstate'])
367
+            # Set Notch state
368
+            ft991.setNotchState((dItem['notchstate'], dItem['notchfreq']))
326 369
         except Exception, e:
327 370
             print 'Memory settings restore operation failed. Most likely\n' \
328 371
                   'this is due to the backup settings file corrupted or\n' \
329 372
                   'incorrectly formatted. Look for the following error: \n'
330 373
             print e
331
-            exit(1)
374
+            raise
375
+            #exit(1)
376
+    # end for
332 377
 ## end def
333 378
 
334 379
 def readMenuSettings():