Steve and Eric sent me source for FlexLib. I spent a couple of days trying to read and and understand it, but it is too difficult to do without having it well commented and documented. One good news is that it has successfully compiled to DLLs.
So now I need to figure out where to start using it. I have made a couple (unsuccessful so far) attempts to at least discover the radio, using FlexLib and feel myself stuck. Did anybody walk this route and can please help?
Also, a request to Flex guys. Is it possible to share some pieces of complete and usable code, which will show how different pieces of FlexLib work? Nothing fancy, just examples in C# Console, with a bit of explanations on input and output params and entry point. Sort of Flex analog to MSDN :)
Any advise is highly appreciated!
That CAT code is what I used to get familiar with FlexLib, but I dropped it in favor of using the TCP API which offers a lot better flexibility. No waiting for a new codebase to compile.
Now I have my own TCP command interpretor / issuer written I simply have to capture commands from SmartSDR with wireshark to see what's going on. Sort of like learning a new language.
I may have the Flexlib test files I created available to let you have. I'm out at the moment though, so will look when I get home.
1. I learned how to read the status of the radio. Receiving model, name and IP. However, the API code first seeks a for a file in Users\Name\Application Data\ Roaming\FlexRadio System\filter.txt. This file does not exist. So I had to /*...*/ parts of the code which refer to this. Is this something left over from development, of is this file still needed? Looking at the code, I don’t think so....
2. When I have my radio running in a normal way with SSDR client open, I can establish second connection to the radio and read / control some radio wide settings. Pretty cool. But I am completely stuck going further to Panadapters and Slices. ObservableCollection for Radio returns nulls for Slices.
Steve and Eric, can you please briefly outline the sequence of actions needed to start getting pans and slices parameters? And how to control them?
Many thanks in advance.
Step 1: Attach to the RadioAdded/RadioRemoved event handlers in the API class. This will allow you to be notified when a radio shows up/goes away.
API.RadioAdded += new API.RadioAddedEventHandler(API_RadioAdded); API.RadioRemoved += new API.RadioRemovedEventHandler(API_RadioRemoved);
Step 2: Set the API.ProgramName to your programs name.
API.ProgramName = "My Program";
Step 3: Call API.Init(). This initializes the Discovery objects to listen for radios that are broadcasting their info over the network.
At this point, you should begin getting RadioAdded/Removed events as the discovery packets are passed through the network.
Once you have a reference to a radio with which you would like to connect, you will want to attach to the event handlers that tell you about the objects within a radio (Panadapters, Slices, etc).
Step 4: Attach to the Radio.SliceAdded/SliceRemoved/PanadapterAdded/PanadapterRemoved/PropertyChanged events.
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);
Step 5: Connect to the radio by calling the Connect function in the radio class on the radio object (received in the RadioAdded event handler).
Once a Slice or Panadapter object arrives that you would like to control (they will show up in the SliceAdded or PanadapterAdded events), you can attach to the PropertyChanged event to get notifications about various parameters within that object. For a Slice, this might be the Frequency, the Demodulation Mode, the Filter Cuts, etc. For a Panadapter this would be the Center Frequency, the Bandwidth, the low/high dBm display levels, etc.
slice.PropertyChanged += new PropertyChangedEventHandler(slice_PropertyChanged);
panadapter.PropertyChanged += new PropertyChangedEventHandler(panadapter_PropertyChanged);
At this point you should have references to Radio, Slice and Panadapter objects that you can use to manipulate the various pieces of the radio.
Thank you very much, this was very helpful! So far I can read properties from slices and pans. One thing which I have noticed. Slices have Index parameter, which is assigned to each new opened slice. I have discovered that, slice A is 0, slice B - 1 and so on. Very convenient to save and address slices. However, I didn't find anything of the kind for Panadapter. Instead it has StreamID parameter. So question is - can Index and StreamID be used as unique identifiers for opened Slices and Panadapters? Or, what is the best way to identify Panadapters and Slices in the external software?
What is the correct procedure to disconnect from radio? I use simple command, like radio.Disconnect(); However, what happens very often, the radio continues to work. It looks like that command is not accepted. I browsed FlexLib, but I didn't find any specific reference. Do I also need to close pan adapters, slices etc. as well?
I think there is a little problem here. Here is the scenario:
I have SSDR running with radio, and at the same time I have other utility which receives audio streams, controls slices, etc. SmartCAT is not running. So there are 2 connections opened at the same time. If I close both connections in either order, 90% of the time radio continues to work - I hear live air, and it does not respond to front panel button push. The only way to turn it off is to press and hold front panel button. Then the radio goes off, but I can still hear short noise "beeps" in the speakers and earphones. If I disconnect, and then connect back power, the noise disappears.
As I said before, I use radio.Disconnect(); command in my utility, but it sure looks like radio does not always recognize this. The other possible scenario that Disconnect command does not stop the thread, which is sending pings to radio. If so, who is responsible for terminating this thread - FlexLib or my utility?
When using radio discover and then Connect sequence, I am sending the name of my external utility. Does radio somehow recognize which client (SSDR or other) is sending command? Can you please look into this?