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
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.
Changing bands
Several years ago, I put together a test program, to try and learn C# and the Flexlib api. At the time, version 2 of the api was in use. I had no problem changing bands. Now, after re-referencing the v3.5.8 api everything works, except changing bands.
private void btn17_Click(object sender, EventArgs e)
{
_thisRadio.ActiveSlice.Panadapter.Band = "17";
}
The above no longer works. I get a Null Reference in the Slice Property Changed event:
private void slice_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
// CODE TO DEAL WITH SLICE PROPERTY CHANGES
bool x = _thisRadio.ActiveSlice.Active;
if (x == true)
{
int dummy = 0; dummy++;
slicefreqTextbox.Text = _thisRadio.ActiveSlice.Freq.ToString() + " Mhz";
slicemodeTextbox.Text = _thisRadio.ActiveSlice.DemodMode.ToString();
// gets current Slice volume and sets the volume control on startup
int volume = _thisRadio.ActiveSlice.AudioGain;
tbarVolume.Value = volume;
lblVolAmt.Text = tbarVolume.Value.ToString();
}
}
The very first line of code is where it breaks in Visual Studio. If I put a Breakpoint in the btn17 Click event at:
_thisRadio.ActiveSlice.Panadapter.Band = "17";
and hover the mouse pointer over .Band the tooltip shows 20 meters as that was the current band setting ( the radio is sending the default band, frequency etc on startup till I change it.)
I am not sure what may have changed syntax wise since version 2 in the api that is causing this particular issue. I am pretty certain that I am missing the forest for the trees.
I figure that I am not setting the band properly anymore. But, my 72 year old brain is missing something that is probably very simple.
James
WD5GWY
Best Answers
-
"_thisRadio.ActiveSlice.Panadapter.Band = "17";"
It looks to me like you need to check the different levels here (_thisRadio, ActiveSlice, Panadapter) to ensure those references aren't null. One of them apparently is. When you figure out which one it is, you'll need to work backwards to understand why it is null (e.g. was _thisRadio never set to an object? Is there no ActiveSlice? etc).
You can do a fair amount of this by setting a breakpoint and inspecting each of the variables when the breakpoint is hit. This likely won't explain the "why", but at least it will get you down the road on which part of the line is unexpectedly null.
2 -
Hi James, that code works fine for me. I do handle the following at the beginning of my code. I'm not sure if you just need to establish something in one of these routines.
radio.PropertyChanged += new PropertyChangedEventHandler(radio_PropertyChanged); radio.SliceAdded += new Radio.SliceAddedEventHandler(radio_SliceAdded); radio.SliceRemoved += new Radio.SliceRemovedEventHandler(radio_SliceRemoved); radio.PanadapterAdded += new Radio.PanadapterAddedEventHandler(radio_PanAdded); radio.SlicePanReferenceChange += new Radio.SlicePanReferenceChangeEventHandler(radio_PanRefChg); radio.VoltsDataReady += new Radio.MeterDataReadyEventHandler(_thisRadio_VoltsDataReady); radio.PATempDataReady += new Radio.MeterDataReadyEventHandler(_thisRadio_PATempDataReady); radio.GUIClientAdded += new Radio.GUIClientAddedEventHandler(_thisRadio_GUIClientAdded); radio.GUIClientUpdated += new Radio.GUIClientUpdatedEventHandler(_thisRadio_GUIClientUpdated); radio.GUIClientRemoved += new Radio.GUIClientRemovedEventHandler(_thisRadio_GUIClientRemoved); radio.MessageReceived += new Radio.MessageReceivedEventHandler(_thisRadio_MessageReceived); radio.Connect();
0
Answers
-
Len,
I commented out the code in my Slice property changed event and now the rest of my code is working again. I suspect the root of the problem is in what you posted. I haven't updated that section of code that you posted in quite a long time. Thanks for bringing this to my attention. I have several test programs that I wrote in years past including one that has a waterfall. I managed to mangle the waterfall during what I thought at the time, was cleaning up some unneeded code. That particular test program had code more like what you posted here. The spectrum display works ( as does the test program I managed to mess up now) . It looks like I will have to revisit several things along with trying to get up to speed with changes to the API.
James
WD5GWY
0 -
Hi James, I'm glad that helped. I have an older version of my FlexLib sampler program out on GitHub. I will replace it with my new code that includes the band up and band down buttons. Hopefully, that will provide some insights.
1 -
Hi James, I put the latest code out there. It is in Releases.
0 -
Len,
Thanks for sharing. I like the way you are handling different events. It will definitely give me some needed pointers.
James
WD5GWY
0 -
Excellent! One tricky bit to note... in radio_SliceAdded(Slice slice), there are two new property changed event handlers, one for slice 0 and one for slice 1.
It took me a while to figure this out as it was not intuitive to me (old Fortran, PL/I, COBOL programmer...).
1 -
Len,
I seem to have fixed the band change problem. And I also "borrowed " the way you format the frequency readout as well. Right now though, I only place the frequency reading in a Textbox. I think I can do something a little nicer than that. In my waterfall test program, it has a nicer display of the frequency. It might be time to borrow that code and incorporate it into this test program.
James
WD5GWY
0
Leave a Comment
Categories
- All Categories
- 289 Community Topics
- 2.1K New Ideas
- 534 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
- 230 SmartSDR CAT
- 172 DAX
- 352 SmartSDR API
- 8.8K Radios and Accessories
- 7K FLEX-6000 Signature Series
- 26 FLEX-8000 Signature Series
- 850 Maestro
- 44 FlexControl
- 847 FLEX Series (Legacy) Radios
- 796 Genius Products
- 416 Power Genius XL Amplifier
- 277 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