23
23
# \author NH
24
24
# \author DA
25
25
# \author MN
26
- # \copyright Copyright (c) 2017 CyberRadio Solutions, Inc. All
27
- # rights reserved.
26
+ # \copyright Copyright (c) 2017-2020 CyberRadio Solutions, Inc.
27
+ # All rights reserved.
28
28
#
29
29
###############################################################
30
30
56
56
# <table>
57
57
# <tr><th>Radio</th><th>Name String</th></tr>
58
58
# <tr><td>\link CyberRadioDriver::radios::ndr301::ndr301 NDR301 \endlink</td><td>"ndr301"</td></tr>
59
- # <tr><td>\link CyberRadioDriver::radios::ndr301ptt::ndr301_ptt NDR301PTT \endlink</td><td>"ndr301ptt "</td></tr>
59
+ # <tr><td>\link CyberRadioDriver::radios::ndr301ptt::ndr301_ptt NDR301PTT \endlink</td><td>"ndr301-ptt "</td></tr>
60
60
# <tr><td>\link CyberRadioDriver::radios::internal::ndr303::ndr303 NDR303 \endlink</td><td>"ndr303"</td></tr>
61
61
# <tr><td>\link CyberRadioDriver::radios::ndr304::ndr304 NDR304 \endlink</td><td>"ndr304"</td></tr>
62
62
# <tr><td>\link CyberRadioDriver::radios::ndr308::ndr308_1 NDR308-1 \endlink</td><td>"ndr308_1"</td></tr>
108
108
description = "CyberRadio Solutions NDR Driver"
109
109
##
110
110
# \brief Driver version number (string).
111
- version = "20.02.14e "
111
+ version = "20.09.04a "
112
112
113
113
# # This section of code inspects the "radio" module for radio handler
114
114
# # objects (objects derived from _radio, thus implementing the IRadio interface)
@@ -252,13 +252,19 @@ def getRadioClass(nameString):
252
252
# \brief Factory method for obtaining a radio handler object from the name
253
253
# of the radio.
254
254
#
255
- # The name string used to identify the radio can be any string returned
256
- # by getSupportedRadios(), but the check is not case-sensitive. The name
257
- # string can also be "auto", in which case the method will attempt to
258
- # auto-detect the type of radio connected to the system. Since radios can
259
- # operate over both TCP and TTY (serial) links, the user needs to supply
260
- # keyword arguments to indicate which devices to scan ("host" to scan over TCP,
261
- # and/or "dev" to scan over TTY -- see below).
255
+ # The name string used to identify the radio can be:
256
+ # * Any string returned by getSupportedRadios() (but the check is not case-
257
+ # sensitive).
258
+ # * "auto", in which case the method will attempt to auto-detect the type of
259
+ # radio connected to the system. Since radios can operate over both
260
+ # Ethernet and TTY (serial) links, the user needs to supply keyword
261
+ # arguments to indicate which devices to scan ("host" to scan over
262
+ # Ethernet and/or "dev" to scan over TTY -- see below).
263
+ # * "server" or "crdd", in which case the method attempts to connect to the
264
+ # radio via the CyberRadio Driver Daemon (crdd). Supply the "host" and/or
265
+ # "port" arguments if CRDD is not running at the default location (local
266
+ # host, port 65432). Also, supply the "clientId" argument if you want
267
+ # crdd to log transactions for this client specially.
262
268
#
263
269
# This method uses keyword arguments to configure the returned radio handler
264
270
# object. It consumes the following keyword arguments:
@@ -278,6 +284,8 @@ def getRadioClass(nameString):
278
284
# on this device if requested, and automatically connect to it.
279
285
# <li> "baudrate": For TTY-connected radios, this is the baud rate for the serial
280
286
# connection. If not provided, this defaults to the standard (921600).
287
+ # <li> "clientId": For connections through crdd, this provides an identifier
288
+ # that crdd can use to identify this client for logging purposes.
281
289
# </ul>
282
290
# If the "host" and "dev" keyword arguments are both provided, then the auto-
283
291
# detection algorithm will try a TCP connection first before falling back to a
@@ -354,10 +362,17 @@ def getRadioObject(nameString, *args, **kwargs):
354
362
radioType = radioType .replace ("ts" , "_ts" )
355
363
radioType = radioType .replace ("-" , "_" )
356
364
radioType = radioType .replace ("__" , "_" )
365
+ # NDR804-PTT weirdness: the model name has a space in it -- DA
366
+ if radioType == "ndr804 ptt" :
367
+ radioType = "ndr804-ptt"
368
+ # NDR301-PTT weirdness: sometimes the model name does not have the dash
369
+ # in it -- DA
370
+ if radioType == "ndr301ptt" :
371
+ radioType = "ndr301-ptt"
357
372
# NDR358 weirdness: the NDR358 Recorder mode variant can self-identify
358
373
# as "NDR358-5", per NH -- DA
359
374
if radioType == "ndr358_5" :
360
- radioType = "ndr358_recorder"
375
+ radioType = "ndr358_recorder"
361
376
# For NDR358 models, read the radio function to identify we should use
362
377
# a handler for a specific variant. Note that we don't have handlers
363
378
# for all potential variants yet. -- DA
@@ -375,6 +390,7 @@ def getRadioObject(nameString, *args, **kwargs):
375
390
if radioType != "" :
376
391
break
377
392
if radioType != "" :
393
+ kwargs ["clientId" ] = None
378
394
obj = getRadioClass (radioType )(* args , ** kwargs )
379
395
if connMode in ["tcp" , "udp" , "https" ]:
380
396
obj .connect (connMode , kwargs .get ("host" ), kwargs .get ("port" , None ))
@@ -383,22 +399,23 @@ def getRadioObject(nameString, *args, **kwargs):
383
399
return obj
384
400
else :
385
401
raise RuntimeError ("Radio not found" )
386
- elif nameString == "server" :
402
+ elif nameString == "server" or nameString == "crdd" :
387
403
connMode = "tcp"
388
404
host = kwargs .get ("host" , "localhost" )
389
- port = kwargs .get ("port" , 31415 )
405
+ port = kwargs .get ("port" , 65432 )
390
406
radioType = ""
391
407
# Use a temporary radio identifier class to determine what kind of radio the
392
408
# server is managing
393
409
tmpHandler = None
394
- # -- Try the non-JSON radio identifier first, since the handshake is just a
410
+ # -- Try the non-JSON radio identifier first, since the handshake is just a
395
411
# line feed. If that doesn't work, then try the JSON identifier.
396
412
for radioIdentifierCls in [radio ._radio_identifier , radio ._radio_identifier_json ]:
397
- tmpHandler = radioIdentifierCls (verbose = False ,
398
- logFile = None ,
413
+ tmpHandler = radioIdentifierCls (verbose = False ,
414
+ logFile = None ,
399
415
timeout = kwargs .get ("timeout" , None ))
400
416
tmpHandler .connect (connMode , host , port )
401
- if tmpHandler .isConnected () or any (["Radio is not connected" in q for q in tmpHandler .connectError ]):
417
+ #if tmpHandler.isConnected() or any(["Radio is not connected" in q for q in tmpHandler.connectError]):
418
+ if tmpHandler .isConnected ():
402
419
break
403
420
# If the radio identifier connected, then identify the radio managed by the server
404
421
# and establish a radio-specific handler.
@@ -410,13 +427,39 @@ def getRadioObject(nameString, *args, **kwargs):
410
427
radioType = radioType .replace ("ts" , "_ts" )
411
428
radioType = radioType .replace ("-" , "_" )
412
429
radioType = radioType .replace ("__" , "_" )
430
+ # NDR804-PTT weirdness: the model name has a space in it -- DA
431
+ if radioType == "ndr804 ptt" :
432
+ radioType = "ndr804-ptt"
433
+ # NDR301-PTT weirdness: sometimes the model name does not have the dash
434
+ # in it -- DA
435
+ if radioType == "ndr301ptt" :
436
+ radioType = "ndr301-ptt"
437
+ # NDR358 weirdness: the NDR358 Recorder mode variant can self-identify
438
+ # as "NDR358-5", per NH -- DA
439
+ if radioType == "ndr358_5" :
440
+ radioType = "ndr358_recorder"
441
+ # For NDR358 models, read the radio function to identify we should use
442
+ # a handler for a specific variant. Note that we don't have handlers
443
+ # for all potential variants yet. -- DA
444
+ if radioType == "ndr358" :
445
+ radioFn = tmpHandler .getConfigurationByKeys (configKeys .RADIO_FUNCTION )
446
+ # radioFn == 0 ==> Receiver mode
447
+ # radioFn == 1 ==> Fast Scan mode
448
+ if radioFn == 2 :
449
+ radioType = "ndr358_coherent"
450
+ # radioFn == 3 ==> Resampler mode
451
+ elif radioFn == 4 :
452
+ radioType = "ndr358_recorder"
453
+ # radioFn == 5 ==> ALT_RX1 mode
413
454
tmpHandler .disconnect ()
414
455
if radioType != "" :
415
456
obj = getRadioClass (radioType )(* args , ** kwargs )
416
- # Make sure that the connection mode used for the server is in
457
+ # Make sure that the connection mode used for the server is in
417
458
# the allowed connection mode list for the radio handler
418
459
if not obj .isConnectionModeSupported (connMode ):
419
460
obj .connectionModes .append (connMode )
461
+ # Set crdd flag
462
+ obj .isCrddConnection = True
420
463
# Connect to the new handler
421
464
obj .connect (connMode , host , port )
422
465
return obj
@@ -426,6 +469,7 @@ def getRadioObject(nameString, *args, **kwargs):
426
469
else :
427
470
raise RuntimeError ("Radio not found" )
428
471
else :
472
+ kwargs ["clientId" ] = None
429
473
obj = getRadioClass (nameString )(* args , ** kwargs )
430
474
if kwargs .get ("host" , None ) and any (obj .isConnectionModeSupported (i ) for i in ("https" ,"tcp" ,"udp" )):
431
475
hostname = kwargs ["host" ]
@@ -1069,9 +1113,13 @@ def getPps(self):
1069
1113
#
1070
1114
# \param checkTime Whether to verify that the time was set properly.
1071
1115
# \param useGpsTime Whether to use the GPS time rather than the system time.
1116
+ # \param newPpsTime A specific UTC date/time to set the radio's clock to
1117
+ # (string). This method supports several formats for the time string,
1118
+ # including YYYY-MM-DD HH:MM:SS and ISO 8601. Set this to None if you
1119
+ # want to use the current system/GPS time.
1072
1120
# \return True if successful, False if the radio does not support
1073
1121
# PPS edge detection and time setting or if the command was unsuccessful.
1074
- def setTimeNextPps (self ,checkTime = False ,useGpsTime = False ):
1122
+ def setTimeNextPps (self ,checkTime = False ,useGpsTime = False , newPpsTime = None ):
1075
1123
raise NotImplementedError
1076
1124
1077
1125
##
@@ -1222,6 +1270,14 @@ def setGpioOutput(self, value):
1222
1270
def setGpioOutputByIndex (self , index , value , duration , loop , go ):
1223
1271
raise NotImplementedError
1224
1272
1273
+ ##
1274
+ # \brief Gets the current bandwith of the given tuner.
1275
+ # \param tuner Tuner index number
1276
+ # \returns The tuner bandwidth, in Hz
1277
+ # \throws ValueError if the tuner does not exist on the radio
1278
+ def getTunerBandwidth (self , tuner ):
1279
+ raise NotImplementedError
1280
+
1225
1281
##
1226
1282
# \brief Gets the name of the radio.
1227
1283
#
@@ -1308,7 +1364,16 @@ def getTunerAttenuationRes(cls):
1308
1364
@classmethod
1309
1365
def getTunerIfFilterList (cls ):
1310
1366
raise NotImplementedError
1311
-
1367
+
1368
+ ##
1369
+ # \brief Gets whether or not the radio supports setting tuner
1370
+ # bandwidth
1371
+ #
1372
+ # \return True if the bandwidth is settable, False otherwise
1373
+ @classmethod
1374
+ def isTunerBandwidthSettable (cls ):
1375
+ raise NotImplementedError
1376
+
1312
1377
##
1313
1378
# \brief Gets the number of wideband DDCs on the radio.
1314
1379
#
0 commit comments