Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
Need the latest SmartSDR, Power Genius, Tuner Genius and Antenna Genius Software?
SmartSDR v3.8.19 and the SmartSDR v3.8.19 Release Notes | SmartSDR v2.12.1 and the SmartSDR v2.12.1 Release Notes
SmartSDR v1.12.1 and the SmartSDR v1.12.1 Release Notes
Power Genius XL Utility v3.8.8 and the Power Genius XL Release Notes v3.8.8
Tuner Genius XL Utility v1.2.11 and the Tuner Genius XL Release Notes v1.2.11
Antenna Genius Utility v4.1.8
SmartSDR v3.8.19 and the SmartSDR v3.8.19 Release Notes | SmartSDR v2.12.1 and the SmartSDR v2.12.1 Release Notes
SmartSDR v1.12.1 and the SmartSDR v1.12.1 Release Notes
Power Genius XL Utility v3.8.8 and the Power Genius XL Release Notes v3.8.8
Tuner Genius XL Utility v1.2.11 and the Tuner Genius XL Release Notes v1.2.11
Antenna Genius Utility v4.1.8
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.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.
Why does this c# code not work now?
Gary L. Robinson
Member ✭✭
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);
*/
}
}
}
}
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);
*/
}
}
}
}
0
Answers
-
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...
0 -
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.0 -
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 WD5GWY0
-
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 WB8ROL0 -
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 WB8ROL0 -
Glad to know I'm not the only one this sort of thing happens to! Glad you got it fixed. James WD5GWY0
Leave a Comment
Categories
- All Categories
- 289 Community Topics
- 2.1K New Ideas
- 535 The Flea Market
- 7.5K Software
- 6K SmartSDR for Windows
- 146 SmartSDR for Maestro and M models
- 360 SmartSDR for Mac
- 249 SmartSDR for iOS
- 231 SmartSDR CAT
- 172 DAX
- 352 SmartSDR API
- 8.8K Radios and Accessories
- 7K FLEX-6000 Signature Series
- 29 FLEX-8000 Signature Series
- 851 Maestro
- 44 FlexControl
- 847 FLEX Series (Legacy) Radios
- 798 Genius Products
- 417 Power Genius XL Amplifier
- 278 Tuner Genius XL
- 103 Antenna Genius
- 243 Shack Infrastructure
- 166 Networking
- 404 Remote Operation (SmartLink)
- 130 Contesting
- 631 Peripherals & Station Integration
- 125 Amateur Radio Interests
- 870 Third-Party Software