Home AMX User Forum AMX General Discussion

Anthem serial command with variable

Hi

I try to send a serial commande trough variable in an Anthem TLP1

the string has to look that TFP13 meaning set band1 (FM1) preset 3

I tried
//VARIABLE 
CHAR  nTUNER_PRESET_NUM
CHAR  nTUNER_PRESET_BAND

//CODE
BUTTON_EVENT [dvTP_TUNER,13]
{
	PUSH:
		{
		nTUNER_PRESET_BAND = 1
		}
}

BUTTON_EVENT [dvTP_TUNER,14]
{
	PUSH:
		{
		nTUNER_PRESET_BAND = 2
		}
}

BUTTON_EVENT [dvTP_TUNER,1]
{
	PUSH:
		{
		nTUNER_PRESET_NUM = 1
		}
}

BUTTON_EVENT [dvTP_TUNER,2]
{
	PUSH:
		{
		nTUNER_PRESET_NUM = 2
		}
}

BUTTON_EVENT [dvTP_TUNER,3]
{
	PUSH:
		{
		nTUNER_PRESET_NUM = 3
		}
}
BUTTON_EVENT [dvTP_TUNER,4]
{
	PUSH:
		{
		nTUNER_PRESET_NUM = 4
		}
}

BUTTON_EVENT [dvTP_TUNER,5]
{
	PUSH:
		{
		nTUNER_PRESET_NUM = 5
		}
}

BUTTON_EVENT [dvTP_TUNER,16]
{
	PUSH:
		{
		SEND_STRING dvTLP1, "'TFP',nTUNER_PRESET_BAND,nTUNER_PRESET_NUM,$0A"
		SEND_COMMAND dvTP_TUNER,"'@TXT',70,nPREAMP_BUFF"
    CLEAR_BUFFER nPREAMP_BUFF

		}
}



But I get an invalid parameter from TLP1

Any cue?

Comments

  • JohnMichnrJohnMichnr Posts: 279
    Denis wrote: »
    Hi

    I try to send a serial commande trough variable in an Anthem TLP1

    the string has to look that TFP13 meaning set band1 (FM1) preset 3

    I tried
    BUTTON_EVENT [dvTP_TUNER,16]
    {
    	PUSH:
    		{
    		SEND_STRING dvTLP1, "'TFP',nTUNER_PRESET_BAND,nTUNER_PRESET_NUM,$0A"
    		SEND_COMMAND dvTP_TUNER,"'@TXT',70,nPREAMP_BUFF"
        CLEAR_BUFFER nPREAMP_BUFF
    
    		}
    }
    
    
    

    But I get an invalid parameter from TLP1

    Any cue?

    don't you just need the itoa? if I am reading your post correctly
      SEND_STRING dvTLP1, "'TFP',itoa(nTUNER_PRESET_BAND),itoa(nTUNER_PRESET_NUM),$0A"
    


    or am I missing something?
  • PhreaKPhreaK Posts: 966
    Currently nTUNER_PRESET_BAND and nTUNER_PRESET_NUM are integers. When you use them to concatenate the string you are sending to the tuner they need to be converted to their ASCII equivalents. Thankfully the NetLinx function ITOA makes this nice and easy. If you use the code JohnMichnr suggested it should fix your issues.
  • DenisDenis Posts: 163
    Nice!

    Thanks guys.

    I tried ITOA but here is my error
    SEND_STRING dvTLP1, "'TFP',itoa(nTUNER_PRESET_BAND), (nTUNER_PRESET_NUM),$0A"
    
  • PhreaKPhreaK Posts: 966
    Denis wrote: »
    Nice!

    Thanks guys.

    I tried ITOA but here is my error
    SEND_STRING dvTLP1, "'TFP',itoa(nTUNER_PRESET_BAND), (nTUNER_PRESET_NUM),$0A"
    

    Close. ITOA is a function that takes an integer as its parameter (which is the value inside the parethesis) and will return the ascii equivelent (which will sit where the ITOA is called from). Because you are converting two decimal values you need to call it twice:
    SEND_STRING dvTLP1, "'TFP',ITOA(nTUNER_PRESET_BAND),ITOA(nTUNER_PRESET_NUM),$0A"
    
Sign In or Register to comment.