Home AMX User Forum NetLinx Studio

atof gives me garbage value

Dear Friends,
I'm not able to convert ascci to float and display it ont he tP.. if done this when the data_event was a string... but now I'm using command. does it have anything to do with it.
data_event[vdvMatrixAudio1]
{


command:
{

STACK_VAR CHAR sTempVar[50]
STACK_VAR FLOAT fPresetVal

//Cheking for XCH-99.7
WHILE(FIND_STRING(data.text,'XCH',1))
{
send_string 0:1:2,"'Test Radio -',data.text,$0d"
TunerBuffer = data.text
fFreq = atoi(TunerBuffer)
sTempVar=REMOVE_STRING(data.text,'XCH',1)
//sTempVar = XCH-
//data.text = 99.7
// fPresetVal = atof(TunerBuffer)

send_string 0:1:2,"'Test Radio(After Parssing)',fFreq,$0d"
send_command dvTP_Drawing_AMFM,"'^TXT-9,0,',fFreq"

}
}
}
data.text is giving the proper string as "XCH-99.7".
The value it gives me after converting is $FF.
Y is it giving me like this

Comments

  • ericmedleyericmedley Posts: 4,177
    I know sometimes you just have to 'crack that nut' but I don't know if I'd get so wrapped up with the conversion from string to float and then back to string.

    If I were doing this I'd just leave the current frequency as a string. The only purpose for converting it to an float is to do math on it. Otherwise you're just manipulating data.

    an easy way to get the channel is:
    define_variable
    volatile current_Freq[6] // XXX.XX
    
    data_event[]
    {
    stirng:  // or command whichever way you're doing it.
      {  
      stack_var buffer[100]
      stack_var junk[1]
      if(find_String(data.text,'XCH-',1))
        {
        buffer=data.text
        junk=remove_string(buffer,'XCH-',1)
        current_Freq=buffer
        //  then you  can test for your specific string...
        }
      }
    }
    
    
  • Spire_JeffSpire_Jeff Posts: 1,917
    Raj wrote: »
    sTempVar=REMOVE_STRING(data.text,'XCH',1)
    //sTempVar = XCH-
    //data.text = 99.7

    In this statement, the variables are not the way you list them. You are only removing the XCH, not XCH- so the values would be:

    sTempVar = XCH
    data.text = -99.7

    This might be throwing off your numbers as I believe that ATOF and ATOI will work with signed values.

    Also, you need to convert back to ASCII when displaying on the touch panels. Change the send_string and send_command lines to this:

    send_string 0:1:2,"'Test Radio(After Parssing)',FTOA(fFreq),$0d"
    send_command dvTP_Drawing_AMFM,"'^TXT-9,0,',FTOA(fFreq)"


    Jeff
  • RajRaj Posts: 53
    no data_event takes place on the real device

    HI jeff and Eric,
    Thanx for tht.. converting it back from float to array did work... thnx...

    Now I wanted to know is it not possible to use the module simultaneously with its real device. i ask you this because, I am using Matrix series audio controllers, AMX module. everything seems alright except tht when I try to use the real device dvGF_Audiocontroller for my string data event it doesnt work. I sending the msg to the diagnostic when the device come online and nop it doesnt work... the module is a working one.
  • ericmedleyericmedley Posts: 4,177
    Raj wrote: »
    HI jeff and Eric,
    Thanx for tht.. converting it back from float to array did work... thnx...

    Now I wanted to know is it not possible to use the module simultaneously with its real device. i ask you this because, I am using Matrix series audio controllers, AMX module. everything seems alright except tht when I try to use the real device dvGF_Audiocontroller for my string data event it doesnt work. I sending the msg to the diagnostic when the device come online and nop it doesnt work... the module is a working one.

    Well, I do that all the time. There are many times I want somethign specific from a device that the module doesn't cover or more often some module that worked with device firmware X but the newer firmware has more bells n whistles and I can send newer stuff.

    You can set up multiple DATA_EVENTS and they'll all fire. There is also a way to pass anything you want to a device through the module. It's called the PASSTHRU command.

    Hope that helps.
    e
  • Spire_JeffSpire_Jeff Posts: 1,917
    If you are using a Duet module, I don't think it will work. The Duet module assumes control of the port and NetLinx does not get any data from it. You would need to use PASSTHRU and PASSBACK instead.

    Jeff
Sign In or Register to comment.