If You Haven't Tried the API Yet...

  • 4
  • Idea
  • Updated 2 years ago
  • (Edited)
.. and you're hesitating because there's no written documentation, and the CAT sample is sort of wonky and complicated...

...well, that's where I was until this morning.

After spending less than an hour playing, I advise anyone who might be hesitating to just jump right in! Connecting to the radio and doing "stuff" using FlexLib is really pretty easy.

I want to thank Enzo, whose posting of that little snippet of C# WinForms code made me see how I should get started.  [ETA]AND for the advice about dealing with Windows Firewall.

And I want to thank Eric, whose posting of the getting started steps (from 7 months ago) helped me move just a little further forward.

I'm not saying I've accomplished anything really meaningful yet... but I can connect to the radio, and read properties back (like Callsign and Nickname).  Simple, yes, but these are precisely the kind of activities that you need to grok to be sure you understand the way the library works.

So... if you're on the fence, and scratching your head or feeling like you don't know where to start... I advise you to just dive in and start to play.  There's really nothing to it.

de Peter 
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes

Posted 4 years ago

  • 4
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
OK, I have been doing that for over a week. Making no progress - I think. Using DELPHI 6 I am able to to get a balloon - it looks familiar- to show up in the lower right corner of the screen. It may pop up almost immediately or after a few shot seconds. Have no way of knowing if that means anything. I attempt to send a message to the radio /computer but no results. Using a TCP/IP scheme. Have no idea what the format would be for the command message. Been swiping pieces of code off the internet. Image is what I see at start up. Port is 4992. Comment?      TU Vern
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
Vern,

Looks like you successfully opened a socket to the radio - this is what you will see if SmartSDR is running and then a client connects.

All the commands to the radio are in plain text - if you use WireShark or similar you can see the commands that are sent to the radio and the associated responses.  Its (time consuming but) easy to see what commands are necessary to do what.

Another approach, although still not in Delphi that may help you is to visit the Objective-C interface library I've written and is available from a link on github:

https://github.com/n5ac/smartsdr-objective-c

The two files that will help you most are Radio.m and Slice.m - there are methods in both of these files that who you the syntax of the API commands.   Look for routines that begin with cmd in Radio.m and Slice.m.

From this you will see the commands you need to send.

You will also have to build a response/subscription parser to deal with getting status, command responses etc from the radio.

If you have telnet on your computer, you can telnet to port 4992 on the radio and type in commands interactively.

Each command needs to be look like:

C1|sub slice all

Where the C says its a command, 1 is a sequence number and "sub slice all" is a request to subscribe to status messages for all slices.

The FlexRadio wiki covers how to make commands and what to expect back from the radio as responses.  However, it doesn't cover all of the current commands sets.

As Steve says below, let us know what you are trying to go and we can get you up to speed.

BTW, the parser for the radio is embedded also in the Radio.m file - look for routines that begin with 'parse'.


Stu K6TU
Photo of Steve - N5AC

Steve - N5AC, VP Engineering

  • 1007 Posts
  • 969 Reply Likes
Vern, if you will post what you are sending, what you are trying to do and what you are getting back, we'll help you figure out what's wrong.
Photo of Bill W2PKY

Bill W2PKY

  • 438 Posts
  • 76 Reply Likes
Hello Steve, has FRS considered developing a programming seminar to be presented at Ham Fests where FRS is attending? I.E. Orlando
Photo of Dan -- KC4GO

Dan -- KC4GO

  • 337 Posts
  • 68 Reply Likes
Count me in....

Dan --- KC4GO
Photo of Walt

Walt

  • 236 Posts
  • 74 Reply Likes
And please POST a video ( and any software files) of this for the rest of us that can't afford to go to these hamfests - or need to hear it a few times over before it sinks in.

Cheers 
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Needless  to say, thank you to all !

I am getting nothing back, after the display of the balloon, that is visibly displayed. I set a stop point (my words - not Borlands) in my IDE for that procedure that should receive and display data but it is never activated.

Here is a list that I copied from an article, I believe, on this site. All Commands ( that may be stretching it) have a semicolon at the end which I have tried with and without. Not sure these will allow me to do what I want. One thing I would like to do is read the current displayed  frequency from the FLEX-6500. I see nothing in the list here that gives me a hint that I can.

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

Using 'ClientSocket' as my TCP/IP  client- right or wrong. Noting current, as is obvious.
Enough said! An apology: I have not had formal training in my Programming language (DELPHI) and I am 85 yeas of age. Does that explain anything?

Vern
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
Don't feel bad Vern, I'm banging my head against the wall with this one as well ! I am attempting to do the same as you in Visual Basic.NET ( VS 2010) and every time I run my program that tries to
find the radio, it hits a break in the FlexLib api saying I am making a Null Reference to an object that doesn't exist! It doesn't help that I've not written hardly any code in 5 years! :-)
Good luck!
james
WD5GWY
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes

Guys,

I don't speak Delphi, and VB.Net is just another flavor of C# ... there are even translators online that will convert from one to the other.

Here's what I've written so far -- it's pure hackery, but it DOES work.  It finds the radio, connects, and displays properties.

Hopefully this will get you started, at least a bit.

de Peter K1PGV


using System;

using System.ComponentModel;

using System.Windows.Forms;

using Flex.Smoothlake.FlexLib;


    private Radio _thisRadio;
 
    public Form1()
    {
        InitializeComponent();
 
        API.RadioAdded += API_RadioAdded;
        API.RadioRemoved += API_RadioRemoved;
        API.ProgramName = "PGVTest";
        API.Init();
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        CheckForIllegalCrossThreadCalls = false;
    }
 
    private void API_RadioAdded(Radio radio)
    {
        Console.WriteLine("API_RadioAdded Fired: " + radio);
        _thisRadio = radio;
 
        modelTextBox.Text = radio.Model;
        serialTextBox.Text += radio.Serial;
 
        radio.SliceAdded += radio_SliceAdded;
        radio.SliceRemoved += radio_SliceRemoved;
        radio.PanadapterAdded += radio_PanadapterAdded;
        radio.PanadapterRemoved += radio_PanadapterRemoved;
 
        //
        // The properties, such as Nickname and Callsign, can't be read
        // successfully until you've received a PropertyChanged event
        // for that property... this is done after connect.
        //
        radio.PropertyChanged += radio_PropertyChanged;
 
        radio.Connect();
    }
 
    private void radio_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        Console.WriteLine(sender + " sends >>> " + e.PropertyName);
 
        if (e.PropertyName.Equals("Nickname"))
        {
            nickameTextBox.Text = _thisRadio.Nickname;
        }
 
        if (e.PropertyName.Equals("Callsign"))
        {
            callsignTextBox.Text = _thisRadio.Callsign;
        }
    }
 
    private void radio_PanadapterRemoved(Panadapter pan)
    {
        Console.WriteLine("radio_PanadapterRemoved fired\n");
    }
 
    private void radio_PanadapterAdded(Panadapter pan, Waterfall fall)
    {
        Console.WriteLine("radio_PanadapterAdded fired\n");
        pan.PropertyChanged += panadapter_PropertyChanged;
    }
 
    private void panadapter_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        Console.WriteLine("panadapter_PropertyChanged fired\n");
    }
 
    private void radio_SliceRemoved(Slice slice)
    {
        Console.WriteLine("radio_SliceRemoved fired\n");
    }
 
    private void slice_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        Console.WriteLine("slice_PropertyChanged fired\n");
    }
 
    private void radio_SliceAdded(Slice slice)
    {
        Console.WriteLine("radio_SliceAdded fired\n");
        slice.PropertyChanged += slice_PropertyChanged;
    }
 
    private void API_RadioRemoved(Radio radio)
    {
        Console.WriteLine("API_RadioRemovfed Fired: " + radio);
        _thisRadio = null;
    }
 
    private void button1_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }
}
Photo of k3Tim

k3Tim

  • 805 Posts
  • 149 Reply Likes
Hey Peter,

Many thanks for posting the above code! With the above and help of my twin (Mr. Windows UI) we (he in actuallity) was able to get it working.

There was one exception thrown due to an illegal cross threading.  The following line of code:

 CheckForIllegalCrossThreadCalls = false;

was copied from:

Form1_Load()

to:

API_RadioAdded()

and then no exception occurred. Running on Visual Studio 2015, C#. As it looks like Form1_Load is not called does anyone know is this due to change in WPF or something else?

  _..--
k3Tim
Photo of James Whiteway

James Whiteway

  • 847 Posts
  • 183 Reply Likes
It may be a setting you have in Visual Studio conflicting with the illegal crossthreads setting. It really should be set to "true" in order to catch threading problems.
I have run Peter's code (and used it as a base to start my own program) and it does work. I have run it in VS 2010 and VS 2015. It could be an issue with WPF, if you are using this in a WPF program instead of a WinForms app.
If you are using Winforms, Form load has to load in order for your program to work.
james
WD5GWY
Photo of k3Tim

k3Tim

  • 805 Posts
  • 149 Reply Likes
Hi  James

I'll check that out.  The top level installer / project file did not work since VS 2015 was several editions removed from the project version  used for the Flex API.

Than ks

Tim
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes
James us correct. The example I posted us a WinForms app, and a WPF app.

Disabling the check for illegal cross-threading updates is expeditious, but not "the right thing to do" for production code. We've discussed this several times here in the forum previously.

Glad to hear you've taken the dive into the SPI and FlexLib. It really IS fun, easy, and can be super useful!

Peter
K1PGV
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Peter, I'm a struggler! I am unable to make use of FlexLib -- get it to play along with your sample code (maybe massaged by James). I am getting the 4 FlexLib files to show in the Solution Explorer references (not the CAT file). But it does not compile. Using Visual Studio 2012 (& 2015). I put your file in a blank page. Is it a page? I remove everything on the page, including the using statements and then paste your program onto the page. It now has your using statements, etc. Then I compile. Lots of errors. I try to remove the most errors I can but never get them all. On a scale of 1 to 10 my understanding of C# is 1 or less. Done lots of reading. I have given you only tidbits to think about if you think about it at all. I may be closer than I think to success!!

Vern  
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
Thanks Peter! That really does help. As I said earlier, it's been a while since I have written any code. And I have written a couple of small applications in the past in C#. But, having been several years ago, it seems as though I keep having a "Senior Moment" ( I'm 64) when trying to get things to work in C# or VB.NET. I have found a couple of C# to VB.NET converters and the code generated looks promising. I'm sure it's just something simple I'm overlooking!
Thanks,
james
WD5GWY
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
Peter, you are my coding hero!!! I got the C# example you posted working!!! Just had to clean up a couple of things that I copied that did not need to be there! I really do appreciate your help.
Now to getting my VB.NET code working correctly.
Thanks again!
james
WD5GWY
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
Get an odd error that does not prevent the code from running, (this shows in the Immediate Window) 
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll

But, when I close the application it goes away! Maybe it has something to do with the Windows Firewall that I popped up the first time.
james
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
In the Debugging Options in Visual Studio 2010, I set it up to Debug Exceptions and to throw and exception when it encountered a problem. So, in : Flex.SmoothLake.Vita.VitaSocket it threw this
exception:

System.Net.Sockets.SocketException occurred
  HResult=-2147467259
  Message=Only one usage of each socket address (protocol/network address/port) is normally permitted
  Source=System
  ErrorCode=10048
  NativeErrorCode=10048
  StackTrace:
       at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
  InnerException:

Here is where it occurred:

  socket.Bind(new IPEndPoint(IPAddress.Any, port));

Not sure why the exception is thrown, but, if I turn off Debug Exceptions in Visual Studio, the app works, but, in the Immediate Window the original exception info is posted. Once I click the button to close the app, the Immediate Window closes.I don't know if this is an issue on my LAN or what.
Hope Steve or someone at Flex reads this.
james
WD5GWY
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes
I'm glad that mess of a code snippet was helpful to you.  Yay!

In terms of the exception, if you take a look at the comments in the source, you'll see that this exception is anticipated.

The code is trying to find a socket number that's not in use... in the exception handler (the "catch" clause) they increment the port number and then loop (using the "while") to retry the bind operation.

So... things are working as they should.

Moral of the story: Don't enable "Debug Exceptions" in Visual Studio unless you really want to walk through every exception, even ones that are handled.  Even with this off, if an exception is raised that's not handled, the debugger will stop and let you know.
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
 I appreciate the explanation and the code snippet. It does help a lot.
(and I turned off  "Debug Exceptions".)
james
WD5GWY
 
Photo of Ken - NM9P

Ken - NM9P, Elmer

  • 3870 Posts
  • 1177 Reply Likes
You guys are starting to inspire me to try my hand at this.  I have NO experience in any of the modern programming languages.  The last serious programming I did was FORTRAN and Basic in college (1977-81) and GW-Basic about 20-25 years ago.  

I wrote a CW training program on a Tandy TRS-80 Model 1000 (IBM PC Clone) for my wife to help her get her Novice language and help boost my speed up to pass the 20 wpm for extra.  It was pretty slick, if I do say so myself.

Then in the 90's I wrote a macro translator to program a S-COM 7K repeater controller via the telephone/autopatch modem back end.  I had to translate text commands into DTMF sequences and send them through my 56K modem (remember those)  But The modem truncated the strings after about 30 characters, so I had to trap the strings, and divide them into two separate "send" commands.  it was fun!  

Now I need to find a way to learn C, C++, Delphi, VB or whatever the current craze is.

Steve, et. al.  What would you recommend for an old guy (55) who only has about one more programming language left in him?  oh... and it can't be expensive!  I spent all my money on a 6500 and a tower & T11!

Thanks,

Ken - NM9P
(Edited)
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes

Ken,

For playing with this radio, for either graphic or command-line programs, I'd recommend you learn C# .Net -- You can download Visual Studio C# Express FREE from Microsoft. While the most recent version is Visual Studio 2013, I believe the source code they're distributing is written using VS 2010 (Flex person, please correct me if I'm wrong).

The nice thing about C# is it's easy, but also very rich.  You'll even find some of it reminiscent of BASIC (for example, the string handling is superb... unlike in C/C++).  The nice thing about Visual Studio is that it's a very powerful integrated development environment (IDE)... it'll even create a ready-to-run starter program of whatever type you choose for you. 

There are zillions of "Getting Started" books and tutorials available on both C# and VS.  One that I find particularly good, and very step-by-step, is Beginning Visual C# 2010 (the first few chapters are on the MSFT web site).  This is particularly good because it'll walk you through not only the language, but also the Visual Studio programming environment... and it speaks directly to VS 2010 Express Edition as well.

The only thing that'll bend your brain some, if you've only programmed in languages such as Fortran and BASIC (what are called "procedural" languages) is that C# is an Object Oriented language. It's a slightly different way of thinking about programming than functional languages... but you'll get used to it soon enough.

I say go for it...

de Peter K1PGV

Photo of Ken - NM9P

Ken - NM9P, Elmer

  • 3862 Posts
  • 1174 Reply Likes
OK, you guys talked me into it. I ordered the book and will start playing ASAP. I.e. When I get some free time!
Photo of James Whiteway

James Whiteway

  • 856 Posts
  • 186 Reply Likes
I second Peter's comments. The free version of Visual Studio is very good and contains all of the languages that Microsoft supports. The main differences between the free and paid versions are
advanced team collaboration tools. And there is even (in VS 2013) a Team version that is free.
(still lacks several features of the paid version, but, allows a small group of developers to work together)
  Learning C# isn't really that hard, I just like VB better. And wrapping your head around an Object      Oriented language such as C# or VB.NET, isn't really that hard. A good book like Peter suggested will help. Good luck and join in the fun!
james
WD5GWY
Photo of KY6LA - Howard

KY6LA - Howard, Elmer

  • 3470 Posts
  • 1334 Reply Likes
Ken

Don't feel so bad about being dated

I started programming with wired patch panels, then we built a computer that would read machine language on Paper Tape, then a New High Level Language - Assembler... 

Finally since i could actually program in Assembler, the faculty council deemed that I must be qualified to teach undergrad engineering students that new language - Fortran 1.

Almost all the real time control systems (Traffic Light Control, Airports, Subways, Transit etc)  we designed were developed in the 60's in Assembler or for efficiency in pure Machine Language... Frankly that was tough work....

BASIC came along about a decade later and the so called Object Oriented Languages a couple of decades after that....  


By contrast C# and all these ease of use tools such a Visual C# make programming so EASY that even a totally dated Engineer like me can almost do it....

Good luck... it's fun to try to keep up with the kids....
Photo of Ken - NM9P

Ken - NM9P, Elmer

  • 3870 Posts
  • 1177 Reply Likes
I started my freshman year in college on an HP-9820 overgrown table-top calculator with pen plotter.  The next class was "Concepts in Programming Systems" where we learned just enough assembly language to understand the roots of other compiled languages. Then we moved on to Fortran using punch cards on a Honeywell system.  My Senior year they ditched the whole room of the Honeywell for a much smaller and more powerful HP3000 Series III time-shared system with terminals all over campus in several computer rooms and all faculty and administrative offices.  Students could program in Basic, Fortran, ALGOL, COBOL and others.  I stayed with FORTRAN and BASIC.

Sometime in there my younger brother got a TRS-80 Model 1 (Original Radio Shack computer) and we both learned that version of Basic, using a tape recorder for storage.  It only had 4K of RAM and was a lot of work to get anything working.

In 1982 i purchased a VIC-20 and learned yet another version of basic.  This time I played with ASSY subroutines the hard way and made a semi-dumb terminal program to run RTTY with an MFJ interface.  It worked ok for basic stuff.

Then I finally moved up to the Tandy 1000 original in 1984 and got familiar with GW-Basic.
But I have never messed with Visual Basic and many of the other more structured, or object oriented languages.

I have also played with several different distributions of Linyx - Mepis, Depian, Ubuntu, Puppy, DSL, and finally Mint.  I also played a bit with FREENAS.  But I haven't messed with their programming languages like Perl, et al.

Perhaps there are a few tricks left in this old dog... I will look into C# and download a book.  If noone else will program an interface for my Hercules DJ Controller, perhaps I will be able to some day.  With the API, perhaps I will be able to experiment more with this 6500 than I though.  I love to tinker, perhaps software tinkering is the new wave!

73 DE Ken - NM9P
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Minimal progress!  I get this from 6500 or SmartSDR: 'V1.1.0.0H7E38FC7C'  on each try to connect. The HEX value changes each time. A hint as to what it is?

First try this morning I received a large quantity of data. Never again, just the item noted above. I hope this doesn't mean I have to  re cycle the 'computer' each try? {LOL}

Vern
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 315 Reply Likes

So... let me be sure I understand:  When you call radio.connect() from your RadioAdded event handler, you get this string?

Who's printing it out and where does it appear?

Assuming you have a PropertyChanged event handler for the Radio class, you should start getting calls at that.

Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
The V1.1.1.0 is the version of the API supported by the radio software.  It is separated from the next information by a newline character "\n".

the HXXXXXXXX is the API handle assigned by the radio to you, the client.  Its primary purpose is to show the API handle of the client causing a particular radio status change in Status message.  Status messages begin with S and are followed by a handle - a handle of zero (as in S0) shows a status event emitted from the radio itself.

Stu K6TU
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
TU Gents!

To K1PGV: I can't answer your question smartly because the way you ask it the jargon is not understandable on this end. In my language : the data that I receive from the radio is displayed on a TMemo (Borland talk). That is a window in my program that is blank initially and when the data flows it is displayed on that window. I get the largest volume of data under these conditions: Start my TCP/IP pgm, start SmartSDR. It almost appears like it 'broadcasts' a batch when the SmartSDR starts  i .e.I don't have to do anything for that first batch. Dumb query? Does the SmartSDR and/or the radio have a 'HOST' scheme built in? I  have ClientSocket, ClientType set to "Blocking". 

One other point to bore you with, When I send API.RadioAdded += new &
API.RadioConnect()API - in one sentence. I have the socket set with . it actually opens another slice, but not consistently - 75% of the time. However to see the effect I  have  shut down SmartSDR and bring it up again. Confused? I am. Sorry for confusion,

Vern
Photo of IW7DMH, Enzo

IW7DMH, Enzo

  • 350 Posts
  • 83 Reply Likes
Thank you for your kind words Peter.
I'm glad to know that it was helpful for you other friends.
I think that with the Flex rigs experimenting will be exiciting.
After the SmartSDR API take a look at Ethernet (command) API http://wiki.flexradio.com/index.php?title=SmartSDR_TCP/IP_API. You can send commands to your Flex with a simple telnet console with no need for any HOST application that runs in windows ...
Really powerful and amazing

73' Enzo
iw7dmh
Photo of F4CLB, Jean Louis

F4CLB, Jean Louis

  • 5 Posts
  • 0 Reply Likes
Hello everyone, sorry for my English.

Vern, I coded in delphi xe2 based on a piece of "objective C library" TCPIP program and it works

All the commands in the wiki says (c1 | command)

Just reading the "meter" that I have not managed to do so, they are not in "objective C" and I realized that it must pass through UDP.

If my program bou vou interested, no problem, but the comments are in French.

73 Jean-Louis / F4CLB
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
GM Jean-Louis:  I believe there may be enough similarity between 'xe2 and ';DELPHI 6 that I could get a hint or two. I never upgraded as you can see from my comments. If you want to share I will gladly accept. 

Thank you,

Vern W9HLY
(Edited)
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
To K6TU, F4CLB, K1PGV and all: After Jean-Louis jarred my min and re-reading Stu's info I think I am beginning to get the hang of it. I sent 'C1|sub slice all' and it took.  The changed data was the very data I am initially looking for - the frequency the radio is tune too. Using the Flexcontrol and any movement of the knob will force a dump of the freq changes onto my screen. So it is on-wards and up-wards...

Many thanks friends!

Vern W9HLY
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
Vern,

Glad that got you going!  Holler if you have any questions!
Stu K6TU
Photo of F4CLB, Jean Louis

F4CLB, Jean Louis

  • 5 Posts
  • 0 Reply Likes
Hello,

Vern , if I understood well you succeeded has Read data from the Flex, if it is the case you are in the same point as me.

I think that the code delphi XE is has useless present?
( For information Delphi XE code is not readable to  delphi 6 : unicode ? )

On the other hand, if somebody has the information of the column(section) METER because there is nothing here: http: // wiki.flexradio.com / index.php? Title=SmartSDR_TCP / IP_API

It is to finish my program of CAT more complete than that supplied at present.

Thank you in advance (and thanks to the internet translator HI!)

73 Jean Louis / F4CLB
Photo of Peter K1PGV

Peter K1PGV, Elmer

  • 541 Posts
  • 314 Reply Likes
My interest in this learning project will be to see if I can program an interface/translator for my Hercules DJ Console to control the 6500.  It will require reading the MIDI signals generated by the DJ Console, translating them into API commands and sending them to the 6500.  
That's a fairly ambitious project, especially if you don't already understand how MIDI works.  Good luck in your quest!

C# .Net doesn't have a native MIDI class available, but there are a few available -- there's even one on CodeProject (ugh...) that's been regularly revised and gets good reviews.

You'll certainly learn a lot getting this to work, AND you'll get an awesome sense of accomplishment.

de Peter K1PGV
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
Ken,

If you don't mind C#, then FlexLib is the way to go with this and is pretty straight forward.  FlexLib and the underlying Ethernet API let you fully control the radio.

If you aren't into C#, then you have more work to do as you will have to provide an equivalent for FlexLib in whatever language/platform you want.

Although some of the bozos on this community (no present addressee included in this comment BTW) think that just because a pC and a Mac both use the Intel processor that software can be trivially ported over... we know the issues.

Writing a FlexLib alternative isn't hard - its a lot of code which basically maps to message handling to the radio - but it isn't hard.  It's just work!

If you want to write the Hercules control software in something other than C#, let me know and I will be very happy to talk you through what you need to do - and how much of it you need to deal with the Hercules.

Stu K6TU
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Stu:  Is it possible to acquire the ip address of my FLEX-6500 radio BEFORE connecting to the network. Network might not be the word. I find each day or so the FLEX-6500 is assigned a different ip number.

Vern
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Stu: I should have said "to do it programmatically"! 
Vern
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
Short answer unless you have a piece of gear that allows static IP address assignment to  MAC address is no.

Hoeever, the radio broadcasts its existence in two different frame formats on UDP port 4991 on the IP broadcast address.

This is the way to discover radios on your local LAN segment.  Email me if you want more information on this.

Stu K6TU
Photo of KY6LA - Howard

KY6LA - Howard, Elmer

  • 3470 Posts
  • 1334 Reply Likes
Vern

You can have your router issue a fixed IP to the 6500

All you need is the MAC Address - which is usually discoverable in the Device List inside your router
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
Few off the shelf consumer routers/APs allow assignment of a static IP address.  For those that do, this is a great solution.

Stu K6TU
Photo of Tim - W4TME

Tim - W4TME, Customer Experience Manager

  • 9026 Posts
  • 3427 Reply Likes
Or increase your DHCP lease times on the DHCP server (router).  It sounds like they are really low if you are getting different IPs.  There is nothing wrong with setting it to 14 days or more.
Photo of Vern

Vern

  • 64 Posts
  • 4 Reply Likes
Will act on that later, TU.

Have noted some of the command instructions, shown in the following list http: // wiki.flexradio.com / index.php? Title=SmartSDR_TCP / IP_API, are incomplete or just to difficult for me to understand. I hope it is the later.

Vern
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
The wiki is incomplete.  The real way to understand the API at present is to read the FlexLib code or use Wireshark and watch the interactions between the radio and SmartSDR.

I'm slowly documenting pieces as I go along but it was an after thought on my part to start this...

Stu K6TU
Photo of Ken - NM9P

Ken - NM9P, Elmer

  • 3870 Posts
  • 1177 Reply Likes
BTW... Another post announced that MS has released VIrtual Studio Community 2013 for FREE for hobbyist, education and non-enterprise users.  It was a 11 GB download, but now I am beginning to work my way through the recommended book "Beginning Visual C# 2010."  

So far, after the first two exercises, I am convinced that this is not going to be too much over my head... just enough to challenge and stretch me!

It is going to be fun.  I haven't learned a new programming language since the 90's!  (If you don't count trying to learn various Distros of Linux.)

Thanks, guys, for the encouragement.

Ken - NM9P
Photo of Paul Burton

Paul Burton

  • 96 Posts
  • 14 Reply Likes
If anyone is interested, I have written a small Windows Forms application in Microsoft Visual Studio Express called "Flexit", which uses flexlib.  It connects to the radio and displays the radio information plus the current frequency and mode for the active slice.  It was written as an exercise to get familiar with C#, the development environment, and Flexlib, and I can offer the source and executable as an aid for anyone who is trying to come onboard with this stuff.  It works, but it's just a start.

I don't know how to post the files somewhere which is accesable, so I'll just offer to mail it to anyone who is interested.  You can shoot me an email at paul@aa6z.com.
Photo of Marc Lalonde

Marc Lalonde

  • 344 Posts
  • 85 Reply Likes
Hi   got a dumb question ....     For Slice it have option for "Create" ,"Remove" ,"Tune" ,"List" ,"Set"
but how i actually Read a Slice info for read VFO frequency ???     and opn all above exemple it seem to remove slice then add new one on a knot frequency , but on my side i need to poll radio VFO and read it ..

also a exemple of how discover radio IP may usefull ...

i try to use the Telnet commnad in a Raspberry-Pi for read VFO and Then switch external RF relay trough it GPIO  for route signal the right Transverter 
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
Marc,

You need to use "sub slice all" in order to get status updates about all slices.  Here's an example:
c1|sub slice all
R1|0|

M10000001|Client connected from IP 10.1.1.40

S88FB390B|radio slices=7 panadapters=7 lineout_gain=60 lineout_mute=1 headphone_gain=50 headphone_mute=0 remote_on_enabled=1 pll_done=0 freq_error_ppb=0 cal_freq=15.000 tnf_enabled=1 snap_tune_enabled=1 nickname=K6TU-007 callsign=K6TU

S88FB390B|interlock timeout=0 acc_txreq_enable=0 rca_txreq_enable=1 acc_txreq_polarity=0 rca_txreq_polarity=0 tx1_enabled=1 tx1_delay=0 tx2_enabled=1 tx2_delay=0 tx3_enabled=1 tx3_delay=0 acc_tx_enabled=1 acc_tx_delay=0 tx_delay=0

S88FB390B|slice 0 in_use=1 RF_frequency=14.130000 rit_on=0 rit_freq=0 xit_on=0 xit_freq=0 rxant=ANT1 mode=FM wide=0 filter_lo=-8000 filter_hi=8000 step=100 step_list=50,250,500,2500,3000,5000,10000 agc_mode=off agc_threshold=60 agc_off_level=10 pan=0x40000000 txant=ANT1 loopa=0 loopb=0 qsk=0 dax=0 dax_clients=0 lock=0 tx=1 dax_tx=0 active=1 audio_gain=37 audio_pan=50 audio_mute=0 record=0 play=disabled record_time=0.0 anf=0 anf_level=0 nr=0 nr_level=0 nb=0 nb_level=50 apf=0 apf_level=0 squelch=1 squelch_level=20 diversity=0 diversity_parent=0 diversity_child=0 diversity_index=1342177293 ant_list=ANT1,ANT2,RX_A,RX_B,XVTR mode_list=USB,LSB,AM,CW,DIGU,DIGL,SAM,FM,NFM,DFM fm_tone_mode=OFF fm_tone_value=250.3 fm_repeater_offset_freq=0.020000 tx_offset_freq=0.000000 repeater_offset_dir=SIMPLEX

I have inserted line breaks to make it (a little!) easier to read.

The S88FB390B token at the beginning of the line is S for Status and then the ID handle for this client.  You will need to parse these messages to extract  the information you need.

Radio discovery is done via a UDP Broadcast on port 4992.  There are two formats of discovery packets supported in release 1.3 - the original format and a new VITA-49 encoded packet.  Only the VITA-49 format is supported from release 1.4 forwards.

If you search here on the community, you will find a message from Steve Hicks that includes the format of the VITA-49 discovery packet.  The payload of that packet is in ASCII format and easily extracted without knowledge of the VITA-49 header if you don't need to support that for other reasons.

You should be easily able to do what you describe using PHP, Ruby, Python etc to open two sockets - one for the UDP broadcasts to discover the radio and then the second to create a TCP socket to the radio API command stream.

Hope this helps!
Stu K6TU
Photo of Marc Lalonde

Marc Lalonde

  • 344 Posts
  • 85 Reply Likes
Hi   ho that really great no need to pool and it use Xverter frequency   RF_frequency=1296.098400

that telnet feature was  really amazing ;-)  ,so tat turn my raspberry-pi into band decoder  
  
73! all and have great new year