Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

TxBandSettings Bug ??

W8RJ
W8RJ Member
edited January 2020 in SmartSDR API
If TX Band Settings has RCA TX1 enabled on a band, then I do this

FlexRadio.TX1Enabled = false;   (FlexRadio is the Radio object.)

The key line will not disable the after a band change. The second time I try to disable the key line, it will work. It will also work correctly if I wait about 30 seconds after the band change. I am thinking this is a bug.

If it is a bug, I would think logic to be applied here would be let the key line be disabled no matter what the Tx Band Settings are, and when enabling the key line, let it enable (if tx band settings allows that) and not let the key line get enabled if the TX Band Settings show it disabled.

The other issue I am having is retrieving the current TX Band settings for the radio

Here is a code snippet I have tried

List<string> _list = new List<string>();
TXBandSettings TxBandSettings = new TxBandSettings(FlexRadio, 1);
TxBandSettings.ParseStatusKeyValuePairs(_list);

The list comes back empty. I have tried 20 as the bandID (second parameter) 

What is the bandID ? Is it like 20 for 20 meters or is it just sequential numbers for each band with 160 as 0 ?

If I read  "TxBandSettings.IsRcaTx1Enabled"  it's always false regardless of the TX Band Settings in SmartSDR, whether I do the parse function or not.

What am I doing wrong here?


73
W8RJ
Roger

Comments

  • Mark_W3II
    Mark_W3II Member ✭✭✭
    edited January 2020
    A band change causes many internal values to switch which invokes many radio status messages to the connected clients. There is a time window where the API object value may not have the correct state / value until the radio status message is received and parsed. So when you assign FlexRadio.TX1Enabled = false; the property may not send the TCP command as the value is already false due to the logic "if (_tx1Enabled != value)". This is not a bug since the logic is in place on many object properties so we don't flood the radio with useless commands. The solution is to have a short delay before any additional settings are made when the band is changed. Additionally you can watch the Radio property changed event for "TX1Enabled" then ensure the updated value is set to what you want.  There are several ways to solve this issue. 73
  • Mark_W3II
    Mark_W3II Member ✭✭✭
    edited January 2020

    TX Band Settings should be collected via TX Band Settings events. Create a collection to hold the TxBandSettings objects.  I chose an ObservableCollection since I utilize this collection in a WPF Window DataGrid.

    private ObservableCollection<TxBandSettings> txBandSettings = new ObservableCollection<TxBandSettings>();


    Before radio connection hook events for TX Settings


    fradio.TxBandSettingsAdded += fradio_TxBandSettingsAdded;

    fradio.TxBandSettingsRemoved += fradio_TxBandSettingsRemoved;

    txBandSettings.Clear();


    Before radio disconnect unhook events


    fradio.TxBandSettingsAdded -= fradio_TxBandSettingsAdded;

    fradio.TxBandSettingsRemoved -= fradio_TxBandSettingsRemoved;

    txBandSettings.Clear();




            private void fradio_TxBandSettingsRemoved(TxBandSettings tbs)

            {

                Util.InvokeHelper.BeginInvokeIfNeeded(this.Dispatcher, delegate

                {

                    lock (txBandSettings)

                    {

                        TxBandSettings txb = null;

                        try

                        {

                            if (txBandSettings.Count > 0)

                            {

                                txb = txBandSettings.Where((tb) => { return tb.BandId == tbs.BandId; }).FirstOrDefault();

                            }

                            if (txb != null)

                                txBandSettings.Remove(txb);

                        }

                        catch { }

                    }

                });

            }


            private void fradio_TxBandSettingsAdded(TxBandSettings tbs)

            {

                Util.InvokeHelper.BeginInvokeIfNeeded(this.Dispatcher, delegate

                {


                    lock (txBandSettings)

                    {

                        TxBandSettings txb = null;

                        try

                        {

                            if (txBandSettings.Count > 0)

                            {

                                txb = txBandSettings.Where((tb) => { return tb.BandId == tbs.BandId; }).FirstOrDefault();

                            }

                            if (txb != null & !object.ReferenceEquals(txb, tbs))

                            {

                                txBandSettings.Remove(txb);

                                txb = null;

                            }

                            if (txb == null)

                                txBandSettings.Add(tbs);

                        }

                        catch { }

                    }

                });

            }
  • W8RJ
    W8RJ Member
    edited January 2020
    I appreciate what you're saying that there will be delay after a band change for everything to settle down, but waiting 20 or 30 seconds for the TX1Enabled to act correct is a bit much.

    I have another piece of info. That bug only shows up when the TX Band Settings already are enabled for TX1.


    Here's my code to work around the delay, which manifests another issue.


    OriginalKeyLine = FlexRadio.TX1Enabled;

                                if (OriginalKeyLine)
                                {
                                    Thread.Sleep(500);
                                    FlexRadio.TX1Enabled = false;
                                    int wait = 0;
                                    while (FlexRadio.TX1Enabled && wait < 50)
                                    {
                                        Thread.Sleep(1000);
                                        FlexRadio.TX1Enabled = false;
                                        wait++;
                                    }
                                    RadioState.FlagInfo("Times waited: " + wait.ToString());
                                    }

    First time through it works as expected. Second time (without band change) FlexRadio.TX1Enabled (OriginalKeyLine) shows false, which in reality is enabled and shows enabled in SmartSdR TX Band Settings window. 


    Since I use OrginalKeyLine to set TX1Enabled after the routine, It's going to be always wrong for subsequent times I call the routine.


  • W8RJ
    W8RJ Member
    edited January 2020
    More info.

    The TXBandSettings TX1Enable setting is applied after TxTune or MOX is set, so trying to save the TX1Enabled setting before starting the Tune operation is useless as it will change after I set TxTune. 


    I am working on a driver for RemoteHams.com and I need to read and set the TXBandSettings.Tx1Enabled in the currently running instance of SmartSDR. 






                       

  • Mark_W3II
    Mark_W3II Member ✭✭✭
    edited January 2020
    I would never condone waiting 30 secs for anything; don't wait in a loop, watch events and correct any TX1Enables setting after an update. If you want to discuss over the phone then reach out on the via email on QRZ.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.