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.

Why does this c# code not work now?

Options
Gary L. Robinson
Gary L. Robinson Member ✭✭
edited June 2020 in SmartSDR API
I recently upgraded my Flex 6400 to smartsdr 2.6.2 and all is generally well.  All my own client apps seem to work fine.  However, I wanted to do a small auto cq program (a new project) and it's been a while since I have worked with the flexlib code.  So, I am a little rusty.

The code below is borrowed from my own code that still works in several of my own client programs.  But when the code below is compiled it never fires the event - API_RadioAdded(Radio radio) when I have smartsdr running and I start my client.

I am not sure just what is happening since this code has and still is working in my other client apps for my 6400.  Is it safe to assume that the 2.6.2 update has entailed a new way to do this or am I missing something silly that I have forgotten?  Getting old is not fun :-)

So, why does this code below NOT fire the API_RadioAdded event when I start it AND my smartsdr program is already running?  No errors, warnings, or problems with compiling.

+++++++++++++

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

//GLR0916 added this using statement
using Flex.Smoothlake.FlexLib;
using Flex.UiWpfFramework;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using System.IO;
using System.Globalization;

using System.Media;
//GLR0424
using System.Diagnostics;

namespace AutCQFlex
{
    public partial class MainForm : System.Windows.Forms.Form
    {
        public Radio curRadio = null;


        //GLR707
        //WMPLib.WindowsMediaPlayer Player;
        //public string acqpath = "autocq";
        //public string fqacqpath;
        //public string[] acqFiles;
        //public string[] acqQualifiedFiles;
        //public int acqCBSelectedIndex;
        //public bool justEnded = false;
        //int ecode = 0;
 
        //GLR0430
        //bool startAutoPlayTimer;
        //int autoPlayInterval;
        //int curTickCount;

        public NumberFormatInfo nfi;

        public MainForm()
        {
            InitializeComponent();

            nfi = new CultureInfo("en-US", false).NumberFormat;

            API.RadioAdded += new API.RadioAddedEventHandler(API_RadioAdded);
            API.RadioRemoved += new API.RadioRemovedEventHandler(API_RadioRemoved);

            API.ProgramName = "AutCQFlex";

            API.Init();
        }


        private void MainForm_Load(object sender, EventArgs e)
        {
            CheckForIllegalCrossThreadCalls = false;
        }


        //RADIO-SLICE-PANADAPTER EVENT HANDLERS
        //RADIO-SLICE-PANADAPTER EVENT HANDLERS
        private void API_RadioRemoved(Radio radio)
        {
            //int lp = 0;
        }

        private void API_RadioAdded(Radio radio)
        {
            curRadio = radio;

            if (radio.Connect())
            {
                /*
                radio.SliceAdded += new Radio.SliceAddedEventHandler(radio_SliceAdded);
                radio.SliceRemoved += new Radio.SliceRemovedEventHandler(radio_SliceRemoved);
                radio.PanadapterAdded += new Radio.PanadapterAddedEventHandler(radio_PanadapterAdded);
                radio.PanadapterRemoved += new Radio.PanadapterRemovedEventHandler(radio_PanadapterRemoved);
                radio.PropertyChanged += new PropertyChangedEventHandler(radio_PropertyChanged);
                radio.ForwardPowerDataReady += new Radio.MeterDataReadyEventHandler(radio_ForwardPowerDataReady);
                radio.SWRDataReady += new Radio.MeterDataReadyEventHandler(radio_SWRDataReady);
                radio.PATempDataReady += new Radio.MeterDataReadyEventHandler(radio_PATempDataReady);
                radio.VoltsDataReady += new Radio.MeterDataReadyEventHandler(radio_VoltsDataReady);

                radio.MicDataReady += new Radio.MeterDataReadyEventHandler(radio_MicDataReady);
                radio.MicPeakDataReady += new Radio.MeterDataReadyEventHandler(radio_MicPeakDataReady);

                radio.TxBandSettingsAdded += new Radio.TxBandSettingsAddedEventHandler(radio_TxBandSettingsAdded);
                radio.TxBandSettingsRemoved += new Radio.TxBandSettingsRemovedEventHandler(radio_TxBandSettingsRemoved);
                */
            }

        }
    }
}

Answers

  • Ha Gei
    Ha Gei Member ✭✭✭
    edited June 2020
    Options
    I remember, the structures of the api changed. Sure someone else knows more. I reworked the arduino code for the italian smartsdr control unit with the 7 Inch Touchpad. There i had to increase the buffer size for the transfer data structures..but this is 8 month ago. I also made a small C# test prog here that worked, and i remember i needed a lib that was made for 2.6 and above. 
    So look in that direction...


  • Jim Shaffer
    Jim Shaffer Member ✭✭
    edited June 2020
    Options
    I see a couple of things here.
    First, I wouldn't do the connect out of the RadioFound interrupt handler.
    Secondly, and this is definitely a problem, you're establishing the interrupt handlers after the connect().  That could result in missed interrupts.
  • James Whiteway
    edited June 2020
    Options
    Jim is probably correct. But, I have had similar issues and it was because I forgot to re reference to the latest dll's of the API and rebuild my project. James WD5GWY
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited June 2020
    Options
    James, I referenced the latest DLL's so that is not the problem.  BTW, the code I used 6 years ago was from Eric KE5DTO and with no problem.  And my installed version of my main app STILL uses the same code - and still works perfectly - even after I re-referenced the new 2.6.2 DLL's. 

    BUT any new program I start just does NOT work - meaning NOT firing the RadioAdded event.  I also tried using the curRadioList = API.RadioList code which did not work.

    But, as I said, my main home brew program and all my other small programs ALL STILL work.  And have NO problems with the same basic type code as I posted.

    I suspect, though, that IF I uninstalled them and reinstalled them they might NOT work hihi  

    Anyhow,  SO FAR, I can NOT create a NEW gui app that can see or connect to the radio.  I use Visual Studio 2017 and c#  - Windows Forms App (.NET Framework).

    I know Flex says NOT to revert to earlier versions of firmware BUT if I can't figure out what's going on - I may consider doing it anyway. 

    ---Gary WB8ROL
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited June 2020
    Options
    Getting old and having memory problems is a bummer.  I FINALLY figured out what my problem was - Windows Firewall.  After searching all over the flex postings I found that I had the SAME problem 2 years ago - and Mark W3II answered my posting then AND it was the same problem now.   Like I said, getting older and forgetful is no fun.  Anyhow, now all is well and works.  And I still hate Windows hihi

    ---Gary WB8ROL
  • James Whiteway
    edited June 2020
    Options
    Glad to know I'm not the only one this sort of thing happens to! Glad you got it fixed. James WD5GWY

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.