WinForms test app.

  • 1
  • Idea
  • Updated 3 years ago
Here is a link to a basic test program that I wrote a few months ago that I have shared with several people off forum. It was written in C# with Visual Studio 2010. Bu, it should work with
later versions of Visual Studio as well. You will need to un-reference the Flexlib dll's and re-reference to the latest version(s) you may or may not have on your system. It does not include a panadapter or waterfall. But, it gives enough info, that hopefully, it will help others wanting to try to write their own programs for the 6000 Series radios.
The title on the app's main form, (it's only form) says K1PGV's test program. That is because the original beginning of this program came from code generously shared by Peter. BUT, all of the sloppy coding is my doing and not Peter's! I hope this helps others as I have been helped.
 james
 WD5GWY

https://www.dropbox.com/s/ran9z0mjk3t0jpo/WorkingCSharpFlexExample.zip?dl=0
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes

Posted 3 years ago

  • 1
Photo of Robbie - KI4TTZ

Robbie - KI4TTZ

  • 480 Posts
  • 77 Reply Likes
Very nice!  It compiled with no problems.  Loaded the app, and it actually crashed when I clicked "connect", although it detected my flex serial number.  Haven't spent any time trying to debug it yet but I probably will soon.  Been wanting to do a little more in C# so this is a great excuse to get me into it.
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Be sure you ReReference all of the dll's in Flexlib. This particular version was built with an earlier version of Flexlib, so that could cause the program to crash.
James
WD5GWY
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Windows Firewall will cause the same problem. I don't have my Flex hooked up right now, But, I have had that issue in the past. Debugging is half the fun!
james
WD5GWY
Photo of Robbie - KI4TTZ

Robbie - KI4TTZ

  • 480 Posts
  • 77 Reply Likes
Ok, ran it again with the debug stuff enabled.  The crash is coming from:

private void radio_SliceAdded(Slice slice)
        {
            
            slice.PropertyChanged += new PropertyChangedEventHandler(slice_PropertyChanged);// makes freqtxtbx show freq from SSDR 
            slicefreqTextbox.Text = slice.Freq.ToString();   //display freq on new slice
            slicemodeTextbox.Text = _thisRadio.ActiveSlice.DemodMode.ToString();    //display mode on new slice
^^ that last line.  I assume that DemodMode.tostring() isn't there when it is called, but not entirely sure why yet.  Timing issue?
Photo of Robbie - KI4TTZ

Robbie - KI4TTZ

  • 480 Posts
  • 77 Reply Likes
Oh, it works when SSDR isn't running.  I'm gonna go read more of the code to get a better understanding of how it works. :-)
Photo of Robbie - KI4TTZ

Robbie - KI4TTZ

  • 480 Posts
  • 77 Reply Likes
Ok, got it working.  I just added a check for null around the relevant code to prevent the null reference.

private void radio_SliceAdded(Slice slice)
        {
            
            slice.PropertyChanged += new PropertyChangedEventHandler(slice_PropertyChanged);// makes freqtxtbx show freq from SSDR 
            slicefreqTextbox.Text = slice.Freq.ToString();   //display freq on new slice
            if (_thisRadio.ActiveSlice != null)
            {
                slicemodeTextbox.Text = _thisRadio.ActiveSlice.DemodMode.ToString();    //display mode on new slice
                textRFpower.Text = _thisRadio.RFPower.ToString() + " Watts";
                _thisSlice = slice;
                // Below allows reading S Meter data
                _thisSlice.SMeterDataReady += OnSMeterDataReady;
                // below gets current slice's band info
                string bandinfo = slice.Panadapter.Band;
                lblBand.Text = bandinfo + " Meters";
                // Slice bandwidth
                txtBW.Text = _thisRadio.ActiveSlice.FilterHigh.ToString() + " High " +
                    _thisRadio.ActiveSlice.FilterLow.ToString() + "Low";
            }
           
        }
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Nice fix! Cannot wait to get back to coding. My 6300 is on it's way to Flex land to be traded in for a 6500! (Merry Christmas, Happy Birthday etc. etc. to me!) Until the new one arrives next week and I get back, next Friday, (I drive a truck from Arkansas to Arizona during the week) I cannot play with coding for the Flex.
    As for the program only working with SSDR offline, it should work if you already have SSDR running before you start the test program. In fact, it should work (as it did) without SSDR running as well. The only time you may run into issues is if you are trying to have a panadapter/waterfall as well. Then,  at the top of the program listings where is shows  API.*** = xyz;  If you are trying to do a panadapter and a waterfall, then you need to add this line:
API.IsGUI = true;

That way, the radio knows to send the panadapter and waterfall data to your client.
But, it won't send it to SSDR at the same time. In fact, if you are using IsGUI = true:
SSDR will not run, you will get a popup box from SSDR saying that the radio is busy.
Hopefully, one of these days, Flex will make it where more than one client can access the GUI data (panadapter and waterfall) at the same time. I suspect they will in the not so distant future so that users of the upcoming Maestro controller can run it and SSDR at the same time if they want to.
james
WD5GWY
Photo of Dan -- KC4GO

Dan -- KC4GO

  • 339 Posts
  • 68 Reply Likes
Thanks for the kick start on my C# education --- Lots of code for me to trace thru...

73's
Dan --- KC4GO
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
@ Robbie. Another reason the program "might" trip up at demodMode is likely an issue with getting data back from the Persistance database in the radio. I have had that happen in the past on a couple of things.
I may have fixed it in a later version of the program.
I will check and see if I have next weekend.
James
WD5GWY
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
What methods did you add the 'if (_thisRadio.ActiveSlice != null)' too? Thought I might have had the same problem. However the first button I am clicking after boot up is 'Connect'. It fails!  I added your if statement [if (_thisRadio.Connect() ]!= null)) but no luck.
Thank you,
Vern    w9HLY
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes

I am posting the error message from clicking Connect. One thing, what do you mean in your comment above when you use the word 'Release'? Hope the error msg answers the question.

Vern


Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Vern, in Visual Studio:


This is Visual Studio 2010, but the screen above is similar to 2015 Community Edition. At the top of the page there is a dropdown selection box. In this snapshot I have selected "Debug" that helps when you click the Run button (left pointing green arrow) the program will popup as normal and  you should be able to see some info about your radio in the boxes to the right of the "Connect and Exit" buttons in the program. If you don't see that info either your radio is off or not connected to the same network that the computer that is running Visual Studio and the test app. Or your Firewall is blocking the program from accessing the local network and connecting to the Flex.
  Finally, if you have not Rebuilt the application, (after rereferencing the Flixlib dll's) it is a good possibility that the problem is an incompatibility between dll versions.
But, I would be certain that the computer that you are developing the program on can see your Flex radio. Otherwise, you won't be able to properly debug the program.
james
WD5GWY
(Edited)
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Oh, one other thing, if you are simply copying the exe file to another computer and running it, the program will throw an error as the Flexlib dll's need to be included with the install. In order to use the program on another computer, you will have to create a Setup program in the Build Menu. Then, once you do that, you can copy the newly created setup and all it's associated files to the computer you wish to install on and it should run after installation. You will have to tell Windows Firewall to allow it to run with the first instance (first running) of the program.
james
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes

Yes Charles all my computers (5) on my network are in communication. I pass files/folders back and forth frequently. Is my network ready for the kind of task I am asking; i.e. run my 6500 on another computer in the network.

I thought that DLLs were imbedded - always. Well! The firewall ask it's question, I say OK and your app pops up but never displays any activity, all 'boxes' void of info. Also Charles, with your app present and the FlexLib DLLs present (in the same folder as you app??) and nothing happening to populate the boxes, I bring up SmartSDR and it grabs the 6500 and performs normally. The network in not setup I can only guess.

TU Vern

Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Ok, Vern, it's a real head scratcher!  Dll files are not embedded. But, in an install setup, the Setup Program created by Visual Studio, includes the dll files in either sub-folders or in the same folder that the program will be installed in for Windows.
And at the same time, the installer sets the Path to those files so that the program and Windows, knows where to find the dll's to use them when the  program runs.
  And you have cleared the question about Windows Firewall being the problem. It's not. I'm guessing you can run SSDR on any of the 5 computers on your network and each one (not all running at the same time) can see and operate your Flex 6500. If that's the case, and you get no info in the boxes before clicking Connect, then something else is blocking the test program from seeing your Flex 6500.
Not too sure what it could be. Have you tried using the example program posted by Peter in this thread:
  https://community.flexradio.com/flexradio/topics/if-you-havent-tried-the-api-yet?topic-reply-list[se...

If that works for you, then the test program should work as well. But, who knows? It's 2016, might be hexed!
JAMES
WD5GWY
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
As far as I can see, Robbie added it to the :
radio_sliceAdded event in the code he posted above.
What error message are you getting ?
And, are you running the code with SSDR running first?
Try it without SSDR running. It should run either way. But, it would not for Robbie with SSDR running.
James
WD5GWY
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Yes the program stopped and came up with the attached error message. James, I have run it both with and without the FLEX-6500 running. The results are the same.

Tks for listening.

Vern
Photo of Larry da Ponte

Larry da Ponte

  • 159 Posts
  • 15 Reply Likes
As long as the PC with visual studio is on the same network as your flex, it should be able to connect. The error you see is from your test app, usually caused by setting or getting a property on an object that has not been assigned a value.
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Hi Larry, been a while. My computers can see one another on the network. I move files back and forth on the network regularly. Is that telling me that my app on one computer should be seeing the device (6500) on the other computer RIGHT now  -  if things are implemented correctly??
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes
If your system with VS is on the same network as your radio... Yes. That's the point of the program: You're connecting to the radio over the network. It doesn't matter where SSDR is running no. It also connects to the radio via the network.

If you have a NULL reference exception, you need to debug it. Set a breakpoint and single step through the code and see where the NULL reference occurs.

Hope that helps,

Peter
K1PGV
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes

All 9 buttons, when clicked, show that the '_thisRadio is null' & _thisRadio.xxxxxxx = '_thisRadio.ActiveSlice' threw an exception of type 'System.NullReferenceException'. I set a break point but it ends there - I am weak using the IDE. If there is a setup that permits additional info I am not aware of it.

Yes, I discovered that the data that is generated by the 6500 is available on the LAN. I have two computers listen to the 6500 but the quantity of data they capture over the same time period is not the same. Is that the UDP effect? A wag.

This message shows up in the mix; Additional information: Object reference not set to an instance of an object..

Is my compiler in need of tweaking?

TU Vern

(Edited)
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Vern it means the program cannot see your radio on your network. I'm about certain it is because the wrong version of Flexlib dll's (older version) are being used by the program. As I said at the beginning, the program I posted the link to, was built with an older version of Flexlib. You have to remove all references to the old version and re-reference to the latest version(v 1.5.11) of Flexlib dll's. And then, after referencing the new version, rebuild the program.
Without doing that, the program will not work.
James
WD5GWY
(Edited)
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes

OK James! I think I have but will check and make sure. I will remove anything I have on my computer that deals with FLEXLIB and start over.

Thank you Vern

Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Vern, when I say remove all references to older version of Flexlib, I mean doing so in Visual Studio after you have loaded the program. On the Right upper side in the section called SOLUTION EXPLORER there is a folder called REFERENCES. Expand it by clicking the little White arrow beside the REFERENCES folder.

You'll get a list of all dll files being used by the program. Select ONLY those for FLEXLIB and it's associated files (dll's) . If you are not sure which ones to delete, look in the folder on your hard drive where you have downloaded (and unzipped) the latest version of Flexlib api, from Flex Radio's Downloads page.

That way, you will have the correct names for the dll's you need to delete from the project in Visual Studio.

The go back to Solution Explorer and select a dll and Right Click on it and select DELETE from the drop down menu. Do that for each dll that you need to remove. Then, if you have the latest version of the dll's on your computer, go to the top menu bar in Visual Studio and select PROJECT, ADD REFERENCE.

From the box that pops up, select the tab that say's Explorer, navigate to the folder where you have the latest version of the Flexlib dll's and start adding each of the dll's you removed back to the project. (You'll have to do it one at a time till you have them all)

After you're done with that, go to the BUILD menu and select rebuild. If all goes well, you will not see any build errors in the Immediate window.

Then you can run the program from Visual Studio and it "should" find your radio (if it's on) and clicking Connect should populate the rest of the boxes in the program.

Frequency changes are done by entering the freq in the box below the TUNE button ( 7.200 for example) and then clicking Tune.

Hope this helps. I'm on the road and doing this from memory.

James

WD5GWY
(Edited)
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
James or whoever:    Iconic.ZIP?  Where do I find it? Using FLEXLIB Version 1.6.17,  added 'csproj' files to my project and ZIP file cannot be found. Visual Studio 2012. Believe everything else compiling.
(Edited)
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Found one, installed same and now all is compiling. TU
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Great news Vern. I sometimes forget about iconic.zip. If all else fails, there is always a copy of it in the Smart SDR install folder that you can copy and paste into your project folder to reference in your projects. Just remember, COPY & PASTE. Don't delete it from SSDR's install folder or SSDR won't run!
James
WD5GWY
(Edited)
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
James: Good day! The iconic.zip will not install. I note that "References, Properties has a listing "C:\Users\Vern\Desktop\James 01 WorkingCSharpFlexExample\FLEXLIB library for James Example jan-18-16\ionic.zip.dll". Note the title 'ionic.zip.dll?
That differs from additional info in "ionic.zip 'Reference Proprities'" that says the (name) & identity is 'ionic.zip'. 
In Solution Explorer I right click the program name and click on Add Reference. Then click on iconic.zip.dll. It installs in 
'WorkingCSharpFlexExample, References'. Good or bad?
Vern
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Sorry I missed this post Vern. You did right adding the ionic dll. I apologize for not responding sooner.
James