the question about the reply and program and button event
yanghua_angel
Posts: 33
DATA_EVENT[SHARP]
{
online:
{
SEND_COMMAND sharp,'SET BAUD 9600,8,N,1 485 DISABLE'
}
STRING:
{
reply=DATA.TEXT
}
}
button_event[tp,2]
{
push:
{
SEND_STRING SHARP,"'VOLM ?',$0D"
//this will change the reply
}
}
(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM
wait 50
{
....
......
SEND_STRING SHARP,"'POWR????',$0D"
wait 5
{C=TV_REPLY}
.....
....
}
I have question about running program and running button_event ,when my program running in the above "wait 50",exactly after running "SEND_STRING SHARP,"'POWR????',$0D"",I push the button
and the reply that i need just be changed,because i push that button ,but i don't want this happen!
anyone has advice????
afte running the button event ,i want it will not do "C=TV_REPLY",instead of doing the whole "wait 50"!!!!
thanks
{
online:
{
SEND_COMMAND sharp,'SET BAUD 9600,8,N,1 485 DISABLE'
}
STRING:
{
reply=DATA.TEXT
}
}
button_event[tp,2]
{
push:
{
SEND_STRING SHARP,"'VOLM ?',$0D"
//this will change the reply
}
}
(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM
wait 50
{
....
......
SEND_STRING SHARP,"'POWR????',$0D"
wait 5
{C=TV_REPLY}
.....
....
}
I have question about running program and running button_event ,when my program running in the above "wait 50",exactly after running "SEND_STRING SHARP,"'POWR????',$0D"",I push the button
and the reply that i need just be changed,because i push that button ,but i don't want this happen!
anyone has advice????
afte running the button event ,i want it will not do "C=TV_REPLY",instead of doing the whole "wait 50"!!!!
thanks
0
Comments
As I look at the code, I think I see what you are trying to do. Are you trying to track power status and volume from the TV? If so, the way I do it is to parse the data in the DATA_EVENT section and store the information in the appropriate variables. If the TV sends back messages that are different for each thing you want to track, it is easier as you don't have to track the last message sent. If the device needs you to remember what was requested, you will have to write some sort of queuing program to hold messages and track the last message sent. (there is a thread that covers some queuing code examples somewhere)
Here is a quick example of parsing the data in the DATA_EVENT:
This is a starting point, but you really should look for a message termination character to insure you are dealing with only one message at a time. If you need to track last message sent, it will get a little more involved.
Jeff
you give that code is ok.i also alread realized it .but it too complex. i have so many device like tv,air_condition,matrix and so on.
i want ask using AMX programe to track the device status is worthy??? it's take so much my time .
i used buffering some time ago.but i found it has no differce from using the variable. anybody can explain the differce between the buffer and variabel .thanks
You are assigning the incoming value directly to your variable. If you haven't processed it yet, the old value is lost. If you buffer it, the old data is kept, and the new data is added, and you can process it all without worrying about a button event causing the old to get overwritten.
i see,thank you very much~~~