Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
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.

API Help

K1ESE
K1ESE Member ✭✭✭
edited May 2020 in SmartSDR API
I want to access the API to turn a relay output off and on.

This works -

ampline$ = "tx1"
        handle = TCPOpen(radioaddress$, 4992)
        temp =TCPPrint(handle, "C0|interlock "; ampline$; "_enabled=f")

It turns off.

This doesn't -

ampline$ = "tx1"
        handle = TCPOpen(radioaddress$, 4992)
        temp =TCPPrint(handle, "C0|interlock "; ampline$; "_enabled=f")

It doesn't turn back on.

Please, what did I mess up?

K1ESE

Answers

  • John Mikucki
    John Mikucki Member ✭✭
    edited April 2020
    Did you mean to say "_enabled=t" (true) in the second snippet?
  • John G3WGV
    John G3WGV Member ✭✭
    edited April 2020
    Not an expert on the FlexAPI but your two sample code fragments, as written here are identical. If that's what you really have, then I suspect you need to change "_enabled=f" to "_enabled=t".
  • K1ESE
    K1ESE Member ✭✭✭
    edited April 2020
    Yes, I copied wrong from the program.  

    This doesn't work -
      temp =TCPPrint(handle, "C3|interlock "; ampline$; "_enabled=t")

    I'm guessing I have messed up the syntax somehow.


  • John G3WGV
    John G3WGV Member ✭✭
    edited April 2020
    Do you issue commands C1 and C2 before issuing the C3 that doesn't work? There may be something going wrong in the intermediate code that you've not shown. Do you close the TCP/IP connection after each command?
  • K1ESE
    K1ESE Member ✭✭✭
    edited April 2020
    As long as you asked...

    Liberty Basic Code -

        ' TCP/IP socket functions by by Alex Davies
       open "mesock32.dll" for dll as #me

    [setup.main.Window]
        nomainwin
        WindowWidth = 200
        WindowHeight = 146
        UpperLeftX=500
        UpperLeftY=200
        loadbmp "Tune", "C:Tune Antenna Tuner SafelyTune.bmp"
        loadbmp "Stop", "C:Tune Antenna Tuner SafelyStop.bmp"

        '-----Begin GUI objects code
        bmpbutton #main.start,"C:Tune Antenna Tuner SafelyTune.bmp",[startClick], UL, 0,  0
        'button #main.reconn, "    RESET    ", [reconnClick], UL, 0, 76 , 184, 30
        '-----End GUI objects code


    open "TS" for window as #main
        'print #main.reconn, "!font ms_sans_serif 14 bold"

        print #main, "trapclose [quit]"

        'read .ini file for address, RCA TX line, tune power
        open "C:Tune Antenna Tuner SafelyTATS.ini" for input as #tuncfg
        line input #tuncfg, radioaddress$
        line input #tuncfg, ampline$
        input #tuncfg, tunepower$
        close #tuncfg

        tuneflag=0

    '    handle = TCPOpen(radioaddress$, 4992)
    '    temp =TCPPrint(handle, "C4|transmit set tunepower=0")

    [main.inputLoop]
        wait

    [startClick]

        if tuneflag = 0 then
            handle = TCPOpen(radioaddress$, 4992)
            temp =TCPPrint(handle, "C0|interlock "; ampline$; "_enabled=f")
            'temp =TCPPrint(handle, "C1|transmit set tunepower=";tunepower$)
            temp =TCPPrint(handle, "C1|transmit tune on")
            print #main.start, "bitmap Stop"
            tuneflag=1

        else

            temp =TCPPrint(handle, "C2|transmit tune off")
            'temp =TCPPrint(handle, "C4|transmit set tunepower=";tunepower$)
            temp =TCPPrint(handle, "C3|interlock "; ampline$; "_enabled=T")
            temp = TCPClose(handle)
            print #main.start, "bitmap Tune"
            tuneflag=0

        end if
        wait
    '[reconnClick]
    '    temp = TCPClose(handle)
    '    handle = TCPOpen(radioaddress$, 4992)
    '    wait

    [quit]
        temp = TCPClose(handle)
        close #me
        close #main
        end

    ''''Function TCPOpen()''''''''''
    Function TCPOpen(address$,Port)
    Timeout=1000
    calldll #me, "Open", address$ As ptr,_
    Port As Long,_
    Timeout As Long, re As Long
    TCPOpen=re
    End Function

    ''''Function TCPReceive$()''''''''''
    Function TCPReceive$(handle)
    buffer=4096
    all=0
    calldll #me, "ReceiveA" ,handle As Long,_
    buffer As Long,_
    all As Long, re As long
    if re<>0 then TCPReceive$ = winstring(re)
    End Function

    ''''Function TCPPrint()''''''''''
    Function TCPPrint(handle,text$)
    calldll #me, "PrintA", handle As Long,_
    text$ As ptr,re As Long
    TCPPrint=re
    End Function

    ''''Function TCPClose()''''''''''
    Function TCPClose(handle)
    calldll #me, "CloseA",handle As Long,_
    TCPClose As Long
    End Function



  • KD0RC
    KD0RC Member, Super Elmer Moderator
    edited May 2020
    Is the issue that you used a capital "T" instead of lower case "t"? 73, Len, KD0RC

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.