atof gives me garbage value
Raj
Posts: 53
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
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
0
Comments
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:
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
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
Jeff