SdrDx Docs -> ipc
         Previous <—> Next                  HomeContentsIndex                  Guide                 BETA DOCUMENTATION

Beta Address: http://blish.org/sdrdxdoc/ipc.html

6.0 - Interprocess Communication

Warning: Running TCP and/or UDP servers with SdrDx can significantly increase demand on the computer's CPU resources. If your machine is not a modern multicore machine, you may find that running a TCP or UDP server reliably with SdrDx is beyond its ability.

6.1 - Invoking External Commands or Scripts

Pressing EX1, EX2, EX3 or EX4 will invoke an external script or command in your home directory (folder) under OS X if there is one with the name "ss", or another name you set by right-clicking on any EX button. Each button provides a parameter; EX2 provides a "2", EX1 provides a "1" and so on. You can also invoke "ss" from the keyboard using ^ g, ^ I, ^ N and ^ O, resulting in the same action. Those keys provide the parameters 1, 2, 3 and 4 respectively.

Basically, what SdrDx does when you type ^ n or press EX3 is the same thing as if you had typed the following while cd'd to your home directory:

ss 3

What this allows you to do is launch any single arbitrary program action four different ways. Possible uses include commanding the immediate tuning or rotation of an antenna, starting a server for a particular radio, immediate sharing spectrum, demodulator region or scope images on a social site, tuning SdrDx according to an external database of frequencies, switching antennas... the possibilities are wide open.

If you are considering building server software that sends and/or responds to TCP messages from SdrDx, you should also be sure to check out the general purpose TCP commands. Note that sample server software in Python is provided further down this page.

Note:

Running Windows XP?

Oh, the pain. What you have to do here to make EX1 through EX4 work is:

  1. Install Python 2.7 (NOT Python 3 !!!!) as shown here
  2. Add the Python install directory to your path, also as shown in the above video
  3. Create a batch file, perhaps sdrdx.bat that contains one of the following two one-line launchers for your Python script:
    python sdrdx.py %1
         (or, for no CMD window, change the Python extension to .pyw and use..)
    START python sdrdx.pyw %1
  4. Create a Python script, perhaps sdrdx.py or sdrdx.pyw, that does what you want with the incoming parameter of 1 to 4:




    • That script uses four spaces for each level of indentation. Indentation matters in Python; make sure you write yours the same way.
    • Replace the flex.exe in each of the four places above to launch the applications you want, or replace the os.system() calls entirely with your own Python actions.
    • If you want to use a complete path to an .exe file, note that when you enter backslashes into a Python string, you need to enter two for each instance, as the backslash is an escape character. So for a path like c:\mydir\myprog.exe, the Python string has to be like this:

           os.system("c:\\mydir\\myprog.exe")
  5. Right-click EX1 and enter sdrdx.bat into the dialog that opens, then click OK to accept this.


  6. ...and then the EX1 though EX4 functions will work.

6.2 - TCP: Purpose

The TCP interface services allow external programs to somewhat reliably:

  1. Remain aware of SdrDx's user-directed operations
  2. Command SdrDx to do things

External programs that might want to be informed about SdrDx's user directed operations would include logging programs that record frequency, signal strength, time and so forth; look up the tuned frequency in a database of broadcast stations; command an amateur radio transceiver to follow the changes made within SdrDx; command an antenna rotor to turn to a particular heading based upon a tuned frequency; command a preselector to tune or an antenna switch to select based upon a tuned frequency.

External programs that might want to command SdrDx's actions, particularly with regard to tuning and demodulator mode, would include programs that cause SdrDx to follow changes made at an amateur radio transceiver or shortwave receiver, programs that set frequency and mode at certain times, and so on.

Rather than try to build all these things directly into SdrDx, which would both be an endless undertaking and one that would be almost impossible without all of the hardware involved, the approach here is to provide the information required — and receive it — in a general form that can be taken advantage of by external software. This way, anyone can easily support any hardware or software they like, without requiring further changes from SdrDx.

6.3 - UDP: Purpose

Warning: Apple has left a horrifying bug in the UDP code of OS X. This bug makes it impossible to open more than one UDP listening client, which defeats the entire purpose of using a broadcast protocol. Until/unless they fix it, the UDP interface can only support one client at a time on the same machine. If you need to support more than one client, or you expect the users of your application to use more than one client, please use the TCP interface (above) instead. The commands are essentially the same (there are a couple of TCP-only commands related to closing the server connection and keeping it alive, that's all.

The UDP interface services allow external programs to:

  1. Remain aware of SdrDx's user-directed operations
  2. Command SdrDx to do things

External programs that might want to be informed about SdrDx's user directed operations would include logging programs that record frequency, signal strength, time and so forth; look up the tuned frequency in a database of broadcast stations; command an amateur radio transceiver to follow the changes made within SdrDx; command an antenna rotor to turn to a particular heading based upon a tuned frequency; command a preselector to tune or an antenna switch to select based upon a tuned frequency.

External programs that might want to command SdrDx's actions, particularly with regard to tuning and demodulator mode, would include programs that cause SdrDx to follow changes made at an amateur radio transceiver or shortwave receiver, programs that set frequency and mode at certain times, and so on.

Rather than try to build all these things directly into SdrDx, which would both be an endless undertaking and one that would be almost impossible without all of the hardware involved, the approach here is to provide the information required — and receive it — in a general form that can be taken advantage of by external software. This way, anyone can easily support any hardware or software they like, without requiring further changes from SdrDx.

Example scripts demonstrate how simple it is to work with both types of operation -- commanding SdrDx to tune and change mode, and obtaining information on the interesting things going on within SdrDx.

Note: If you have an idea for additional data that SdrDx can/should provide, or additional commands that would be useful for SdrDx to accept and act upon, please let me know and I will consider including them. Generally speaking, if I agree they would be useful and do not otherwise compromise the software in any way, I will include them.
Note:
DX ToolBox, version 4.7 or later

Start SdrDx. Start DX ToolBox. Open DX ToolBox Preferences. Select "SdrDx TCP" from the drop-down. Set the TCP Port to 58085. Check "Auto Set UCT Offset" Close the DX ToolBox preferences. At this point, you should see a flashing TCP indicator on the SdrDx control panel.

DX ToolBox's AM Radio Stations map window, SW Schedule window, and Beacons window all talk back and forth with SdrDx.

If you close SdrDx while DX ToolBox is running, and then restart SdrDx, DX ToolBox loses track of the TCP port; to re-open the port, open the DX ToolBox preferences window, and close it with OK; this will re-open DX ToolBox's TCP port.

As a user of DX ToolBox, you can enjoy the ability to dynamically extend its database of stations with my SwDb application; (presently in beta for OS X 10.6 through 10.11) this lets you add new stations to the database as you DX; for instance, it's terrific fun adding all the AM stations you can catch. More about SwDb here.
Note:
RUMLOG

Open Preferences. Go to Transceivers. Select "SdrDx" as a rig.

6.4 - SdrDx Broadcasts (reports to you)...

UDP packets on port 58083 and TCP packets on port 58085. (These ports can be changed from within the NET dialog) These packets contain a single ASCII string that is terminated with a zero byte. Once the zero byte is encountered, the remaining content of the packet may be ignored (it will be all zeros.) Most packets will be 1024 bytes or smaller, with the exception of the spectrum packet.

Each packet will contain from one to many messages. A message is a keyword:data pair separated with a colon (:). Multiple messages are separated with a vertical bar (|). If there is only one message in the packet, there will be no vertical bar character. Vertical bars are only inserted between messages in the same packet.

This section details information SdrDx sends to you under various circumstances.

6.4.1 - Ping report

ping:DecimalNumber

DecimalNumber: Total number of seconds since SdrDx startup.

pings are sent in order to keep the connection alive. Otherwise, TCP services time out.

6.4.2 - Frequency report

freq:DecimalNumber

DecimalNumber: Demodulator Frequency in Hz -- sent in response to any frequency change, including center (because changing center changes demod as well.)

cfreq:DecimalNumber

DecimalNumber: Center Frequency in Hz -- sent in response to any center frequency change

6.4.3 - SDR Name

sdrname:string

string: the name of the currently selected SDR. This is sent in response to a getsdr:0 command.

6.4.4 - Receive state report

rx:DecimalNumber

DecimalNumber: 0 is not receiving, 1 is receiving. Sent in response to the rxq:0 message.

"Receiving" is defined as any SDR running, or in active playback/loop mode.

6.4.5 - Reload Frequency Schedule advice

reloadsked:0

Sent in response to the pingdxtb:0 message.

6.4.6 - Center Frequency report

centf:DecimalNumber

DecimalNumber: Center Frequency in Hz

This is sent only in response to a request in the form of the center:0 message.

6.4.7 - Demodulator Mode report

mode:DecimalNumber

DecimalNumber: 0=AM, 1=SAM, 2=FM, 3=USB, 4=LSB, 5=CWU, 6=CWL, 7=WFM, 8=FSL, 9=FSU

6.4.8 - Meter Data report

meter:String

String: This will contain an ASCII representation of the S-Meter setting. Values are s1, s2 ... s9 and then +10/s9 ... +60/s9

Readings are rounded to the nearest S unit. So for example, from s6.5 to s7.5, you get s7.

6.4.9 - dbm signal Data report

dbmreport:decimalNumber

Returns the signal level in dbm in response to the dbm:0 command. Affected by PEK setting.

6.4.10 - Span Data report

span:DecimalNumber

DecimalNumber: This is the span of the spectrum data in Hz

this message is sent when the span changes, and in response to sspan:0

6.4.11 - Demodulator high edge report

highd:DecimalNumber

DecimalNumber: This is the frequency in Hz for the high demodulator edge

This message is sent in response to demodh:0

6.4.12 - Demodulator low edge report

lowd:DecimalNumber

DecimalNumber: This is the frequency in Hz for the low demodulator edge

This message is sent in response to demodl:0

6.4.13 - aud -- audio packet from SdrDx to you

aud:NNNNNNXXXXXXaauuddiioo

NNNNNN This is a six-digit decimal number indicating how many samples follow.

XXXXXX This is a six-digit decimal number indicating the sample rate.

aauuddiioo is a series of signed 16-bit samples representing part of the current audio stream. This stream can contain any byte, so you have to use NNNNNN to determine if you have received the entire packet.

This message is sent (up to 24 packets worth) in response to audiorq:0

6.4.14 - dbstep report

dbstep:DecimalNumber

DecimalNumber: 0-9

Index indicates dB per step in RF display. 0 is 10 dB, and 9 is 1 dB. Sent in response to dqbstepq:0 and when dB/Div control is adjusted

6.4.15 - maxdb report

maxdb:DecimalNumber

DecimalNumber: -86 to 60 in steps of six

dB level at top of RF display. Sent in response to maxdbq:0 message, and when Max dB control is adjusted

6.4.16 - c report

c:DecimalNumber

DecimalNumber: -64 to 64

Contrast control value for RF display palette. Sent in response to the cq:i command, and when the C slider is adjusted.

6.4.17 - i report

i:DecimalNumber

DecimalNumber: 0-100

Intercept value for RF display palette. Sent in response to the iq:0 command, and when the I slider is addjusted

6.4.18 - GMT Time report

gmt:YYYYmmDDhhMMss

YYYYmmDDhhMMss: This is an ASCII representation of the GMT date and time. The report is always 14 digits.

6.4.19 - Log report (log button pressed)

log:YYYYmmDDhhMMss (same as GMT format)

DecimalNumber:YYYYmmDDhhMMss (GMT DateTime)

This indicates the user has pressed LOG at the specified time, and following (in the same packet, probably) will be freq, mode, and meter data to be used in logging activities.

6.4.20 - Program Termination report

closing:0

The zero is a dummy parameter to make parsing easier. When you receive this message, SdrDx is shutting down.

6.4.21 - Spectrum Data report

spectrum:NNNNdataB()

The spectrum message delivers data you may create a spectrum display from, and/or a waterfall display.

The spectrum message is only sent in response to the gimme command. Only one message is emitted per generated line of waterfall data within SdrDx, regardless of how many gimme commands are received, from any number of clients.

Warning: spectrum will not be sent when SdrDx is minimized (because no waterfall is actually generated in that condition.) You will get the response when SdrDx is returned to its normal active window state.

Once the spectrum message is sent, all pending requests are considered satisfied (because all clients receive the same broadcast message); no further spectrum messages will be sent until a later request is received.

Caution: Normal use would be to send a request, wait for the reply, then loop back and do it again. If you don't get a spectrum packet in response within a very short time, then the packet has been lost, or SdrDx is not running. Make sure you account for both possibilities in your application. It does no harm to continue sending periodic gimme requests -- you'll get exactly one response when SdrDx is eventually started, or you won't get one at all if SdrDx is closed.

The first four characters after the colon (NNNN) represent the length of the data following in decimal. This tells you exactly how many characters are in the following data. 0100 means 100 characters of data. 9874 means nine thousand, eight hundred and seventy-four characters of data (not likely!) The number received is directly related to the window width of SdrDx. You are responsible for scaling this data if your application requires this.

Following this is one byte, B, not counted in NNNN, which represents the S-Meter value, except the ordinals 0, 0x3A and 0x7C.

Note: that the S-Meter value is not the same as the spectrum amplitude at the demodulator frequency. S-Meter determination varies according to the demodulator mode and bandwidth.

The portion of the message that is data is to be taken as unsigned characters nominally indicating a vertical scale value (or palette index) of zero through 255 that will not include the values 0x00, 0x3A, or 0x7C. After the last data character will be a zero character.

The values you receive are dependent upon SdrDx's Max dB and dB/Div settings; you can adjust these in turn via the IPC interface using the setdbstep and setmaxdb commands.

Note: These restrictions on the data allow you to process it using string routines that assume zero-termination (because there will never be a zero in the data), and parse the command for colon and pipe characters, because these will never occur either. In the data, 0's will be 1's, 3A's will be 3B's, and 7C will be 7D. This should not significantly impact spectrum or waterfall display generation.

6.5 - SdrDx Listens for...

This section details commands you can send to SdrDx.

UDP packets on port 58084 and TCP packets on port 58085 (These ports can be changed from within the NET dialog.) These packets must contain a single ASCII string formatted as command:data that is terminated with a zero byte. Once the zero byte is encountered, the remaining content of the packet will be ignored. Packet length must be sufficient to contain the command, its data, and the terminating zero, and neither the command or the data in the packet may exceed 254 bytes (509 bytes in total, as in 254:254) or the command will be ignored.

6.5.1 - getsdr command

getsdr:0

Causes SdrDx to emit an sdrname:string message.

6.5.2 - pickbw command

pickbw:N

N may be 1-7. Selects a bandwidth memory.

6.5.3 - setmcres command

setmcres:N

Sets the mouse click resolution for the current demodulator mode.

6.5.4 - exit command

exit:0

Causes SdrDx to exit.

6.5.5 - locallabels command

locallabels:0

Turns the local DB labels back on after having used the label:string command

6.5.6 - xposition command

xposition:DecimalNumber

DecimalNumber: horizontal position of left edge of SdrDx main window on display. Note: affects only control window if spectrum is in separate window.

6.5.7 - yposition command

yposition:DecimalNumber

DecimalNumber: vertical position of top edge of SdrDx main window on display. Note: affects only control window if spectrum is in separate window.

6.5.8 - textline command

textline:string (alpha, numbers, CR, LF, or space)

This sends a line of text to SdrDx's text display area. Previously sent lines are scrolled; lines will wrap if too long, or if a space is encountered near the end of the line.

INL (Ignore NewLines) works with textline: to format a smooth word-wrap display. Turn it off to obey newline-based formatting in the incoming text stream.

6.5.9 - close command

close:DecimalNumber

DecimalNumber: Ignored

Send this before you close your client connection to SdrDx so it can delete you from its TCP client list.

6.5.10 - getsrate command

getsrate:DecimalNumber

DecimalNumber: Ignored

When you send getsrate:0, SdrDx replies with  srate:X  where  X  is the current sample rate in Hz.

6.5.11 - pingdxtb command

pingdxtb:0

DecimalNumber: Ignored

Send this if you'd like SdrDx to emit reloadsked:0 advice. This feature allows UDP clients that want a TCP-based scheduler to reload; SdrDx will emit the advice on TCP (and UDP) when it receives pingdxtb:0 over UDP. This translation layer is a convenience for UDP based clients.

6.5.12 - screencap command

screencap:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves the spectrum and the waterfall to the desktop as "foo.png".

You can set the path and filename for this command by Right-clickRef

6.5.13 - getband command

getband:FrequencyInKhz

Sending this to SdrDx will result in a returned message that tells you what the band edges are for the shortwave band it is in (or not.) For instance, sending getband:9580 will cause SdrDx to emit bandis:9400 9900 while sending getband:1750 will result in SdrDx returning bandis:0 0

6.5.14 - demodcap command

demodcap:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves a slice of the spectrum and the waterfall around the demod frequency to the desktop as "foo.png".

You can set the path and filename for this command by Right-clickRef

6.5.15 - scopecap command

scopecap:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves the scope to the desktop as "foo.png".

You can set the path and filename for this command by Right-clickRef

6.5.16 - metercap command

metercap:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves the S-Meter to the desktop as "foo.png".

You can set the path and filename for this command by Right-clickRef

6.5.17 - demodcopy command

demodcopy:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves a slice of the spectrum and the waterfall around the demod frequency to the clipboard.

6.5.18 - scopecopy command

scopecopy:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves the scope to the clipboard.

6.5.19 - screencopy command

screendcopy:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves the entire main window to the clipboard.

6.5.20 - metercopy command

metercopy:DecimalNumber

DecimalNumber: Ignored

Under OS X, this saves the S-Meter to the clipboard.

6.5.21 - frontself command

frontself:DecimalNumber

DecimalNumber:Ignored

Brings the SdrDx window to the front, and activates it.

Tip:

What is the frontself command for?

OS X has an OS design error ("feature", no doubt, if you ask Apple) where only one application can receive keystrokes at all; that is the active or "front" application. So in order for OS X scripting to be able to send keystrokes (not IPC messages, but actual keystrokes) to a specific application, there has to be a way to command it to become the active application. If you have two applications, such as DX ToolBox and SdrDx, and you want to issue them both keystroke (not network) commands in order to get something accomplished, then you have to issue network commands to swap between them. So that's what it is there for, to get SdrDx to be active and therefore accept keystrokes from scripting engines under OS X.

6.5.22 - dbstepq command

dbstepq:DecimalNumber

DecimalNumber:Ignored

Sets dbstep:DecimalValue with a range of 0-9, index where 0 is 10 dB and 9 is 1 dB per step in RF display.

6.5.23 - maxdbq command

maxdbq:DecimalNumber

DecimalNumber: Ignored

Sends maxdb:DecimalNumber with a range of -86...60 in steps of six.

6.5.24 - cq command

cq:DecimalNumber

DecimalNumber:Ignored

Sends c:DecimalNumber with a range of -64 to 64 in response.

6.5.25 - audiorq command

audiorq:DecimalNumber

DecimalNumber:Ignored

Sends up to 25 packets of aud:NNNNNNXXXXXXaauuddiioo in response.

6.5.26 - iq command

iq:DecimalNumber

DecimalNumber:Ignored

Sends i:DecimalNumber with a range of 0-100 in response.

6.5.27 - setc command

setc:DecimalNumber

DecimalNumber:0-100

Sets RF palette contrast.

6.5.28 - seti command

seti:DecimalNumber

DecimalNumber:-64 to 64

Sets RF palette intercept.

6.5.29 - keyfunc command

keyfunc:DecimalNumber

DecimalNumber:1 to highest function number

If the parameter is out of range, nothing happens.

Press Ref to view function number assignments. More information on Ref is found here.

Executes any mappable function.

6.5.30 - freq Command

freq:DecimalNumber

Warning: You should almost certainly be using ofreq: instead of freq: because ofreq: obeys the user's center offset setting.

DecimalNumber: Frequency in Hz

Sets demodulator and center frequency.

6.5.31 - ofreq Command

ofreq:DecimalNumber

DecimalNumber: Frequency in Hz

Sets demodulator, incorporating the FSK and CW offsets set with Right-click g CWU, CWL, FSU, and FSL, and also sets the center frequency incorporating the fixed offset setting, set with Right-click CTR.

Note: from an external controller, it works best if you send the demodulator mode prior to sending the frequency; that way, SdrDx knows which, if any, offset to use when the ofreq: command arrives.

6.5.32 - dfreq command

dfreq:DecimalNumber

DecimalNumber: Demodulator Frequency in Hz

dfreq: obeys the FSK and CW offsets set with Right-click CWU, CWL, FSU, and FSL.

Note: To remotely set up distinct center and demodulator frequencies, set the center frequency first with freq:F and then set the demodulator with dfreq:F
Note: from an external controller, it works best if you send the demodulator mode prior to sending the frequency; that way, SdrDx knows which, if any, offset to use when the freq: command arrives.

6.5.33 - rxq command

rxq:DecimalNumber

DecimalNumber: Ignored

Requests receive state. Returns rx:0 for not receiving and rx:1 for receiving.

6.5.34 - center command

center:DecimalNumber

DecimalNumber: Ignored

In response to this message, SdrDx will send "centf:CenterFreq"

6.5.35 - setspan command

setspan:DecimalNumber

DecimalNumber: span frequency in Hz

In response to this command, SdrDx sets the spectrum and waterfall span to the value supplied, as long as the current SDR bandwidth allows for a span that wide. For example, in order to set a span to 50 KHz, you would provide the value 50000 as the value is in Hz, not KHz. These span changes are limited in rate to 200ms.

6.5.36 - sspan command

sspan:DecimalNumber

DecimalNumber: ignored

In response to this command, SdrDx sends span:Decimalnumber

6.5.37 - demodh command

demodh:DecimalNumber

DecimalNumber: ignored

In response to this command, SdrDx sends highd:Decimalnumber

6.5.38 - demodl command

demodl:DecimalNumber

DecimalNumber: ignored

In response to this command, SdrDx sends lowd:Decimalnumber

6.5.39 - setdh command

setdh:DecimalNumber

DecimalNumber: Frequency in Hz

This command sets the high edge of the current demodulator bandwidth.

6.5.40 - setdl command

setdl:DecimalNumber

DecimalNumber: Frequency in Hz

This command sets the low edge of the current demodulator bandwidth.

Note: The assumption made here is that a positive value you provide here is actually negative as if you were in a symmetrical demodulator mode like AM — but if you're not, you may have to provide a negative number here. For instance, to set the low edge of the USB demodulator at 100 Hz, you would send setdl:-100 because the negative assumption is wrong and has to be flipped; SdrDx, making its negative assumption, will flip it back and it will end up positive.

6.5.41 - mode command

mode:DecimalNumber

DecimalNumber: 0=AM, 1=SAM, 2=FM, 3=USB, 4=LSB, 5=CWU, 6=CWL, 7=WFM, 8=FSL, 9=FSU

6.5.42 - scamode command

scamode:DecimalNumber

DecimalNumber: 0 = WFM, 1 = 67 KHz SCA, 2 = 92 KHz SCA

6.5.43 - setdbstep command

setdbstep:DecimalNumber

DecimalNumber: 0...9

0 is 10 dB/step and 9 is 1 dB/step

6.5.44 - setmaxdb command

setmaxdb:DecimalNumber

DecimalNumber: -150...10

6.5.45 - setsdrrfgain command

setsdrrfgain:DecimalNumber

DecimalNumber: 0=0 dB, 1=-10 dB, 2=-20 dB, 3=-30 dB

Note: Effective with RFSPACE SDRs only

6.5.46 - setsdrifgain command

setsdrifgain:DecimalNumber

DecimalNumber: 0=0 dB, 1=6 dB, 2=12 dB, 3=18 dB 4=24 dB

Note: Effective with RFSPACE SDR-IQ only

6.5.47 - run command

run:Flag

Flag may be 0 or 1. Zero means stop; One means Receive.

Caution: When you send the run:1 command, make sure you wait a few seconds before issuing further commands. It can take a few moments for the software to get everything set up and going.

6.5.48 - addmarker command

addmarker:freq

A red circle marker is added (or removed, if it already exists) at the freq specified, unless freq is zero, in which case the marker is added at the current demodulator frequency. There are 50 markers; once the 50th is emplaced, the next one replaces the first one emplaced, and so on.

A nice use of this capability is to send clearmarkers:0 first, then use addmarker:freq multiple times to set up markers for all the frequencies of a particular broadcaster in a band, such as the BBC. Or conversely, when a band is infested with a station you have no interest in, to mark all those so you don't bother to tune in to them.

6.5.49 - clearmarkers command

clearmarkers:0

Erases all markers.

6.5.50 - fcd command

fcd:Flag

Flag may be 0 or 1. Zero means stop; One means Receive.

Caution: When you send the fcd:1 command, make sure you wait a few seconds before issuing further commands. It can take a few moments for the software to get everything set up and going.

6.5.51 - record command

record:Flag

Flag may be 0 or 1. Zero means stop recording; One means start recording.

6.5.52 - label IPC command

label:FinKhzTABStationName[TABStationName][...]

The initial frequencyTABStationName parameters are required. You can add up to 20 additional TABStationName parameters one after another, but keep two things in mind: First, there's a practical limit to how many stations can be displayed on most people's monitors; second, the total number of characters in the message is limited to 256 (any more than that will be clipped, leading to possible error. So don't do that.)

TAB is the ASCII character code 0x09. In Python strings, it is created with a backslash followed by a lower-case "t" character.

When the label command is received, SdrDx will display the information in the message on the main spectrum. The user has fine control over this using a dialog accessed using Right-click DDB.

Duplicate labels are ignored.

These labels exist for one frequency; when you send a new label command, SdrDx forgets the previous one.

Suggested use is to listen to SdrDx so you know what frequency it is tuned to, then send back any information you might have about that frequency.

6.5.53 - mute command

mute:Flag

Flag may be 0 or 1. Zero means mute off; One means mute on.

The mute command allows you to silence audio output.

6.5.54 - rmute command

rmute:Flag Factor

Flag may be 0 or 1. Zero means RF mute off; One means RF mute on.

Factor may range from 0.0 to 1.0. At 0.0, RF is completely muted. At 1.0, RF is not muted at all. At .001, RF is reduced 1000-fold.

the rmute command is designed to reduce or eliminate RF signals upon command. The intended use for this is to reduce the SDR's sensitivity when a transmitter has been commanded to transmit. Nested mute and rmute commands can both silence the audio output and reduce the RF hit.

6.5.55 - gimme command

gimme:DecimalNumber

DecimalNumber: parameter required, but ignored

This command causes SdrDx to issue a spectrum message in response, as soon as there is a new line of spectral / waterfall data. SdrDx must be receiving or no spectrum response message will sent until receive begins.

6.5.56 - savewaterfall command

savewaterfall:Flag

Flag may be 0 or 1. Zero means savewaterfall off; One means savewaterfall on.

6.5.57 - ams command

ams:Flag

Flag may be 0 or 1. Zero means ams off; One means ams on.

6.5.58 - sethpf command

sethpf:freq

freq is a number in Hz from 20 to 5000.

6.5.59 - setlpf command

setlpf:freq

freq is a number in Hz from 20 to 5000.

6.5.60 - hpf command

hpf:Flag

Flag may be 0 or 1. Zero means HPF off; One means HPF on.

6.5.61 - fil command

fil:Flag

Flag may be 0 or 1. Zero means LPF off; One means LPF on.

6.5.62 - pek command

pek:Flag

Flag may be 0 or 1. Zero means pek off; One means pek on.

6.5.63 - lsq command

lsq:Flag

Flag may be 0 or 1. Zero means lsq off; One means lsq on.

6.5.64 - f50 command

f50:Flag

Flag may be 0 or 1. Zero means f50 off; One means f50 on.

6.5.65 - f60 command

f60:Flag

Flag may be 0 or 1. Zero means f60 off; One means f60 on.

6.5.66 - tdm command

tdm:Flag

Flag may be 0 or 1. Zero means tdm off; One means tdm on.

6.5.67 - ring command

ring:Flag

Flag may be 0 or 1. Zero means ring off; One means ring on.

6.5.68 - blanker command

blanker:Flag

Flag may be 0 or 1. Zero means blanker off; One means blanker on.

6.5.69 - txs command

txs:Flag

Flag may be 0 or 1. Zero means txs off; One means txs on.

6.5.70 - dnr command

dnr:Mode

Mode may be 0 or 1. Zero means dynamic noise reduction off; One means on.

6.5.71 - volume command

volume:Value

Value may be from 0 to 99.

6.5.72 - gmt command

gmt:0

In response to this, SdrDx will emit a GMT message back to you with the current date and time.

6.5.73 - meter command

meter:0

In response to this, SdrDx will emit a meter message back to you with the current meter reading, from "s1" to "+60/s9".

6.5.74 - decay command

decay:Value

Value may be from 0 to 9999.

6.5.75 - rfgain command

rfgain:Value

Value may be from -120 to -30.

6.5.76 - txsquelch command

txsquelch:Value

Value may be from -120 to 0.

6.5.77 - squelch command

squelch:Value

Value may be from 0 to 99.

6.5.78 - setgrid command

setgrid:Value

Value may be from 1 to 60.

Sets the number of grid divisions on the spectrum display.

6.5.79 - poll command

poll:0

When SdrDx receives poll:0 it will send freq:X and mode:x in response. This is intended to allow the remote application to determine the initial state of SdrDx, or its state at any other time. Note, however, that SdrDx sends freq:X and mode:X any time they change, so as long as your application is "paying attention", you should generally remain in sync with SdrDx's state. No harm is done by polling, though, and as UDP is not an error-corrected protocol, it's not a bad idea to check every few seconds. The efficiency of this form of polling is very high.

6.6 - Sample Python UDP Client

A sample Python UDP broadcast client (SdrDx-client.py) is provided in the distribution folder. Run the client in an OS X shell and start SdrDx (in either order.) As you change frequency and mode, the client should report those changes in the shell. When you quit SdrDx, the client will exit automatically. Should you encounter problems, you can also exit the client by typing control-c in the shell window where it is running.

#!/usr/bin/python import select, socket # AA7AS - for SdrDx UDP broadcast # this is a sample python script that captures the UDP messages # that are coming from SdrDx. SdrDx tells you what frequency and # mode it has been set to. This, in turn, could be used to tell # another radio to tune to that frequency and mode. # UDP packet from SdrDx is zero terminated, but receiving the # packet makes it seem like the string contains zeros all the # way out to the 1024th character. This function extracts a # python string up to the point where it hits the first zero, # then returns that string. # ----------------------------------------------------------- def zeroterm(msg): counter = 0; for c in msg: if ord(c) != 0: counter += 1 strn = msg[:counter] return strn port = 58083 # port where we expect to get a msg bufferSize = 1024 # room for message # Create port to listen upon # -------------------------- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: s.bind(('', port)) except: print 'failure to bind' s.close() raise s.setblocking(0) # Listen for messages # ------------------- looping = True while looping: try: result = select.select([s],[],[]) except: # you can kill the client here with control-c in its shell s.close() # must close socket print 'Closing, exception encountered during select' # warn raise SystemExit # and quit msg = result[0][0].recv(bufferSize) # actually fetch the UDP data msg = zeroterm(msg) # convert content into python string # in next line, [] contain optional repeats # message format is keyword:data[|keyword:data] # where from 1...n keyword:data pairs may appear, up to 1024 bytes # ---------------------------------------------------------------- try: msgs = msg.split('|') # can be more than one message in packet except: # failed to split msgs = [] # on the other hand, can just be one. :) msgs.append(msg) # so build array with that one. for m in msgs: # now, for every message we have try: keyw,data = m.split(':') # break into keyword and data print keyw + "-->" + data # you'd do something with this except: keyw = '' data = '' if keyw == "closing": # Our client terminates when SdrDx does looping = False # loop stops s.close() # must close socket print 'Normal termination'

6.7 - Sample Python UDP Commander

A sample Python UDP command transmitter (SdrDx-commander.py) is provided in the distribution folder. Start SdrDx and run the commander in an OS X shell, in that order (if you run the commander without SdrDx running, it will send its commands, but SdrDx is not there to listen and so you are wasting your efforts.)

When you run the commander, SdrDx should change to AM mode (if it isn't already in AM mode) and to 1450 KHz (if it isn't there already.)

The Python commander demonstrates how to "talk to" SdrDx using its UDP capabilities.

#!/usr/bin/python # AA7AS - Python example for SdrDx UDP commanding # ----------------------------------------------- from socket import * port = 58084 # port we want to send a message to # Create socket to send with # -------------------------- s = socket(AF_INET, SOCK_DGRAM) s.setsockopt(SOL_SOCKET,SO_BROADCAST,1) # Simple method to send 0-terminated cmd, the idea # being to abstract the socket and 0-termination # details away from the process of commanding the app # --------------------------------------------------- def sendcmd(cmd): global s,port s.sendto(cmd + '\0',('<broadcast>',port)) # Send message # ------------ sendcmd('mode:0') # Select AM Demod sendcmd('freq:1450000') # Tune 1450.000 kHz

6.8 - Sample Python TCP client (integrated)

You can use the following TCP client as an example of how to connect to SdrDx's TCP server, send it commands, and listen for messages from SdrDx. Although the client doesn't do much as-is, it can be very easily extended.

Start SdrDx first, then run the client in a shell.

#!/usr/bin/python import socket, sys, os # AA7AS - SdrDx sample TCP client # For Windows OS so server can run without a window: if sys.executable.endswith("pythonw.exe"): sys.stdout = open(os.devnull, "w"); sys.stderr = open(os.path.join(os.getenv("TEMP"), "stderr-"+os.path.basename(sys.argv0)), "w") host = "127.0.0.1" # IP of server (very likely you need to change this) # 127.0.0.1 is for running on the SAME computer port = 58085 # Default port of SdrDx TCP server # process() takes a single message, breaks it into cmd # and data, then deals with the data as appropriate # THIS is the ONLY routine you should modify; you can # catch any message from SdrDx here and do whatever # you like in response. The example catches the closing # message, and has a commented-out section showing how # to capture the centf message and pass it to an imaginary # SDR tuning command. Catching any other message? Use # those as models. # ---------------------------------------------------- def process(content): try: cmd,data = m.split(':') except: return 1 # malformed command - split across packets? if cmd == 'closing': # catch closing return 0 # stop right now # respond with exit flag # elif cmd == 'centf': # catch change in center frequency # os.system('tune '+data) # you might run a command to set an SDR... return 1 # keep going # otherwise, don't exit # parse() creates an array that contains from zero # to n messages and returns that to the caller # ------------------------------------------------ def parse(msg): try: msgs = msg.split('|') # can be more than one message in packet except: # failed to split msgs = [] # on the other hand, can just be one. :) msgs.append(msg) # so build array with that one. # also possible messages separated by null: ms2 = [] for m in msgs: try: ms = m.split(chr(0)) except: ms2.append(m) else: for mm in ms: if mm != '': ms2.append(mm) return ms2 # hand back assembled list # Create socket # ------------- try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error, msg: sys.stderr.write("[ERROR] %s\n" % msg[1]) sys.exit(1) # Attempt to connect to SdrDx's TCP server # ---------------------------------------- try: s.connect((host,port)) except socket.error, msg: sys.stderr.write("[ERROR] %s\n" % msg[1]) sys.exit(2) s.send("poll:0"+chr(0)) # ask SdrDx for freq, mode # This is the main program loop, where we watch for messages # from SdrDx, and optionally send commands to it (see s.send(), # above for example of sending a command, it's very easy) # # see process(), near top, for example of processing commands # # The structure of the system requires that SdrDx be running # before the client is, so that the TCP server will "be there" # when the attempt to connect is made. # ------------------------------------------------------------ data = '' looping = 1 while looping: try: data = s.recv(4096) except KeyboardInterrupt: # you can safely stop with control-C s.send("close:0"+chr(0)) print '\nclient aborted by user' looping = 0 # stop running data = '' # prevent any pending data from being handled except socket.error, msg: # something went wrong: sys.stderr.write("[ERROR] %s\n" % msg[1]) # say so looping = 0 # stop running data = '' # prevent any pending data from being handled ll = len(data) # how much data do we have? if ll > 0: # if we have any at all, then: msgs = parse(data) # break packets into a list of messages if len(msgs): # if we actually got some messages counter = 1 for m in msgs: looping = process(m) # do whatever needs to be done sys.stdout.write(str(counter)+': '+m+'\n') # log sys.stdout.flush() # force print counter += 1 # counter for log s.close() # close the TCP socket, disconnect from server sys.exit(0) # quit with no error

6.9 - RealBasic UDP

RealBasic is often used to create cross-plaform applications. Using it to catch UDP broadcasts from SdxDx is easy, but it's just a little tricky to send to SdrDx. These are the important points as known at this time:

The following shows how to send to SdrDx:

dim dp as new Datagram dp.Address="192.168.0.17" dp.Port=58084 dp.Data="freq:"+format(freq,"#")+chr(0) UDPSocketSend.Write dp

The following receive code is in the DataAvailable() event for the receive udpsocket:

dim dg as Datagram dg = me.Read dim i,n as integer dim s as string n=CountFields(dg.data,"|") for i=1 to n s=NthField(dg.data,"|",i) if left(s,5)="freq:" then dim freq as Double s=right(s,len(s)-5) freq=val(s) ' This is frequency in Hz freq=freq/1000.0 ' Now in kHz FreqLabel.text=str(freq) ' Sent to UI end next

6.10 - General Purpose TCP Commands

SdrDx can send 25 different user-defined command initiators to TCP clients. These messages are of the form macro:N where N is a number from 1 to 25.

To send one of these, press both Shift and Control along with either an F-KEY from f1 to F15, or a top-row digit from 0 to 9

The idea behind these commands is to give you a means you can use directly from SdrDx's user interface that can directly trigger up to 25 different actions in the receiving script or client. Exactly what they do is up to the receiving client, so you can write in any functionality you like.

Possible uses include switching antennas, initiating antenna tuning sequences, changing SDR settings such as attenuation and/or filtering, and so on.

You can also use any or all of these as macros. In this case, when your script or other client receives a macro:n command, the response would be to send a command sequence back to SdrDx, thereby accomplishing a multi-step task in one step. You can send back any TCP command SdrDx understands to it upon receiving a macro:N command yourself.

The possibilities are limited only by your imagination.



toc    index    guide    changes    keyboard    , previous    . next
Please consider supporting my SdrDx development efforts via a small donation.

Google
Placeholder
         Previous <—> Next                  HomeContentsIndex                  Guide                 BETA DOCUMENTATION