oppo BDP-103 power state listener
f0ghua
Posts: 16
I am working with an oppo BDP-103 dvd player, and want monitor the power state of the device. Mostly, I use code as following:
DATA_EVENT[dvDVD] { ONLINE : { send_command DATA.DEVICE, 'SET MODE DATA' send_command DATA.DEVICE, 'SET BAUD 9600,N,8,1,485 DISABLE' timeline_create(TL1, gTLPolling, LENGTH_ARRAY(gTLPolling), TIMELINE_ABSOLUTE, TIMELINE_REPEAT) } STRING : { local_var char buf[32] buf = DATA.TEXT select { active (find_string(buf, "@OK ON", 1)) : gblDVDPower = 1 active (find_string(buf, "@OK OFF", 1)) : gblDVDPower = 0 } } } TIMELINE_EVENT[TL1] { switch(timeline.sequence) { case 1 : send_string dvDVD, "'#QPW',$0D" // DVD POWER POLL STRING } }
Then in the BUTTON_EVENT, when push on power button, do on or off action according to the current state 'gblGFPower'.
The problem now is reference to the rs232 manual of BDP-103, both operation command and query command get the same response.
for example, power on operation command is "#PON$0D", the response is '@OK ON$0D'; while power query command is "#QPW$0D", which also success with a same response string "@OK ON$0D".
So if I push the powerOn button, then the DATA_EVENT will get the "@OK ON" string immediately. That is to say, the monitor doesn't work now.
Any idea for doing with such a case?
0
Comments
If so I would send FB when gblDVPower != newDVDPower and then make the latter = the former so it doesn't matter what iniated the responce or you could just track last command sent and ignore responses last command was a query but then why query in the 1st place.
You could also track the FB sent to TPs and only send if sent != current value, maintain values in structs or array so you can update when TPs come on page.
I have added the following code to sync the TP power button state with the variable "gblDVDPower" like this: When receive a response based on command, the device sometimes doesn't power done, so I the query seems better.
My problem is I don't know how to distinguish the query response from command response.
BTW, another problem is sometimes I mentioned that the command has sent to device, but no response back, looks like a retry mechanism is need. Does anybody has experience of such a issue? Any suggestion will be appreciated.
Personally I would figure out why there's a hiccup first and correct it if possible. I wrote an Oppo module some time ago and don't recall coming across this problem so maybe it's firmware related but I wouldn't rule out strange code behavior either.
Also you should concatenate your buf var to just in case you don't get a complete response and then wait for the $0D delimiter before processing and remove up to that $0D to process. After thinking a bit about your code that may be your issue since you're not removing the contents of buf so it's still there during the next string event so which case is going to be correct? The 1st case since both strings may be in the buffer.
Here's what I have, it may be confusing
The reason is that the device sometimes doesn't power on even I get the power on acknowledgment, it maybe in a cooling state and so on. Only query reply can give me a certain state.
Thanks vining, I will try with your solution.
Simon
Thanks Simon, it's the right solution.