Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Denon response
This thread has 10 replies. Displaying all posts.
Post 1 made on Saturday October 2, 2010 at 09:30
brasch
Long Time Member
Joined:
Posts:
December 2008
87
Hi,

I'm working on response from my Denon receiver. I'm having a little trouble filtering out the letters, e.g. I'm getting the response MV235 instead of the desired 235. I also have a panel tagged VOLUME on the page
I've made a page script that looks like this:
this first part is the actual page script.

var w, volume;
w = widget("VOLUME");
volume = 0;
w.label = volume;


this next part is actually a button script run once to make a query for the volume right away - I use the same script for volume up/down on the hard buttons, with an extra line; s.send("MVUP\r"); for adjusting the volume
var e,s;
e = CF.extender[0];
if (!e) {
Diagnostics.log("Extender 0 is not defined");
} else {
s = e.serial[0];
if (!s) {
Diagnostics.log("Extender 0 is not a serial extender");
} else {
s.bitrate = 9600;
s.databits = 8;
s.parity = 0; // None
s.stopbits = 1;
w.label = s.match("MV?\r","\r",250);
}
}

for filtering out the MV part of the response this should do it:
var volume = parseInt(response.match(/\d{2,3}/)[0]);

but where do I put that line of code to make work?
Post 2 made on Saturday October 2, 2010 at 11:43
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Change:

var e,s;


to:

var e,s,volume,response;


Change:

w.label = s.match("MV?\r","\r",250);

to:

response = s.match("MV?\r","\r",250);
try
{
volume = parseInt(response.match(/\d{2,3}/)[0]);
w.label = volume;
}
catch(e)
{
Diagnostics.log("error in match or parse");
}


Even after you make these changes, you will still be left with a string that is either 2 or 3 digits long which you have to "normalize" by 80 or 50.

Suitable code to do this can be found in the VolumeBar class of the Philips Denon module.

Several key notes/gotchas:

For main volume and subwoofer volume, a value of 99 is --- or Off.
On newer receivers, you can also have 995 which is -80.5db
For channel volumes, you normalize by 50 in that a value of 0db is 50.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 3 made on Saturday October 2, 2010 at 11:47
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
And you really should consider switching to TCP/IP due to implementation of RS232 on RFX9600. Also make sure that if you are using Port 3 or Port 4 for connect to Denon that nothing else is on the other port due to Ports 3 and 4 sharing a single UART (as thread below says, search for UART).

Read more about this here:

[Link: remotecentral.com]
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Saturday October 2, 2010 at 13:51
brasch
Long Time Member
Joined:
Posts:
December 2008
87
I'm using ports 3 and 4 for a videoprocessor and HD DVD player, so those ports are very sparsely used and never at the same time. I've used TCP/IP for the Denon earlier, but there seems to be a small bug in the Denon firmware, so that every time a new device is on the network, it's network connection freezes up. Of course I could get around the problem setting up a network only for A/V equipment, but that's not really a priority right now.

channel volumes is not really something I tamper around with very often - I have a settings page with some simple one way up/down.

Regarding the master volume from Philips, I'm guessing this is the part, where it goes from a number to -x dB:
//Specific Parsing of the volume
Denon.prototype.parseVolume= function(s) {
var r="";
var pattern=/(MV|Z2|Z3)(\d{3}|\d{2})(.*)/;
var result=s.match(pattern);
if (result!==null) {
var vol= parseInt(result[2],10);
if (result[2].length==2) {
if (vol!=99) {r= (vol-80) ;}
else {r=EMPTY;}
}
else {r=(vol/10 - 80) ;}
}
else {r=EMPTY;}
return r;
};

from what I see, in case the number is 2 digits, the volume is the number -80. In case of 3 digits it's the number divided by 10 - 80. Only exception being volume all way down, which is, as you mentioned, --.

so the script would be something like this:

var w, volume;
w = widget("VOLUME");
volume = 0;
w.label = volume;

var e,s,volume,result,response;
e = CF.extender[0];
if (!e) {
Diagnostics.log("Extender 0 is not defined");
} else {
s = e.serial[0];
if (!s) {
Diagnostics.log("Extender 0 is not a serial extender");
} else {
s.bitrate = 9600;
s.databits = 8;
s.parity = 0; // None
s.stopbits = 1;
response = s.match("MV?\r","\r",250);
try
{
result = parseInt(response.match(/\d{2,3}/)[0]);
if (result!==null) {
var volume= parseInt(result[2],10);
if (result[2].length==2) {
if (volume!=99) {r= (volume-80) ;}
else {r=EMPTY;}
}
else {r=(vol/10 - 80) ;}
}
else {r=EMPTY;}
return r;
};
w.label = volume;
}
catch(e)
{
Diagnostics.log("error in match or parse");
}
}
}

or am I complete off the target here?

Post 5 made on Saturday October 2, 2010 at 14:45
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
I recommend avoiding RegExp parsing as you are doing is because you are compiling the RegExp each time you call the function. If you insist on using RegExp, move the pattern declaration and compilation outside of your function.

Based on what you are saying about digit count, I presume the Denon is an older model. If that is the case, then the vol is 2 digits. If I may ask, what model?

Early Denon models were flaky on TCP in that if you send too many commands without waiting for a response, you will blow the TCP/IP stack in the receiver (ie, you must wait for responses or the time interval in the protocol spec). When you blow the stack, you must hard power-cycle the receiver. (mentioned in above linked thread).

Here's a function I use.

// evaluate a volume level and add DB.
function _extractVol(s,bias,min)
{
if (!s || (s == ('' + min)))
return '------ dB';
else if (!s || (s == ('' + min + '5')))
return '-' + bias + '.5 dB';
return ('' + ((s.length==2) ? ((s - 0) - bias) : ((s - 0)/10 - bias)).toFixed(1) + ' dB');
}

Then _extractVolis called to display master/zone volume:

volText = _extractVol("505",80,99);

"505" is string returned from the receiver.

When _extractVol is called to display channel volume, use:

channelVolText = _extractVol("505",50,99);

"505" is string returned from the receiver for channel volume.

If you are Level I certified, you may also want to look at Philips' Denon module and you will see code similar to the above in their VolumeBar class.

Good luck.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 6 made on Saturday October 2, 2010 at 16:01
brasch
Long Time Member
Joined:
Posts:
December 2008
87
well, it's an avr4306, but is probably soon going to be replaced by a new model (4311 is a contender, considering a smaller model though). From what I experience the RFX is a bit sluggish compared to the TCP connection, but as you mention, the TCP is sort of flake - I guess it's a question of priorities. For the whole family, the more sluggish response is more acceptable, than sometimes having to remove the ethernet cable and make a power off. At this point, I'm actually using the Denon module for volume, but I'd like a panel to show the level at all times. The only problem I got with the module, is that there are many lines of code to walk through. With the experience I have with Prontoscript/Javascript at this time, it's a bit hard to figure out what to use and what to skip.

Can you explain clearer what the lines of code you just provided actually does? - at first look it could be russian to me as well
OP | Post 7 made on Saturday October 2, 2010 at 18:33
brasch
Long Time Member
Joined:
Posts:
December 2008
87
thanks for your help Lyndell, I figured it out. It'll be using TCP/IP anyway - that seemed easier to make- don't really know why, but it worked after a bit trial & error
Post 8 made on Sunday October 3, 2010 at 05:45
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
There's a free module for denon tcp done for the 9400 which you could use and change the graphics.

I discussed this a bit in a thread on Denon TCP and available modules (Search (Denon TCP Task). Free module at: www.prontoprojects.com.

My module is still in beta and I'm not sure if I'm going to actually publicly license to a large number of users it as it is not a full UI but a framework for building Denon-based UI's and does require an indepth knowledge of Denon Protocol.

It has lots of examples but the underlying code is not user modifiable. That is, you use my framework and put code into widgets that when you press them, they call functions on a denon object instance (ie denon.doSurround('5CH STEREO);)

My framework then handles the responses/events and fills out panel lables with specific ProntoScript names based on the specific event received.
Examples:

MS**** response is parsed and value goes to a widget with ProntoScript name Z1_SURROUND_MODE
MV**** response is parsed and value goes to a widget with ProntoScript name Z1_VOLUME.
MU**** response is parsed and value goes to a widget with ProntoScript name Z1_MUTE (Mute symbol or space) and
Z1_MUTE_TEXT (Text - On or Off).

User SJHart is one of the beta testers and he has been quite successful. You might send him RC Mail to dicuss pros/cons of using my framework.

Last edited by Lyndel McGee on October 3, 2010 05:54.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 9 made on Sunday October 3, 2010 at 10:50
brasch
Long Time Member
Joined:
Posts:
December 2008
87
On October 3, 2010 at 05:45, Lyndel McGee said...
There's a free module for denon tcp done for the 9400 which you could use and change the graphics.

I discussed this a bit in a thread on Denon TCP and available modules (Search (Denon TCP Task). Free module at: www.prontoprojects.com.

My module is still in beta and I'm not sure if I'm going to actually publicly license to a large number of users it as it is not a full UI but a framework for building Denon-based UI's and does require an indepth knowledge of Denon Protocol.

It has lots of examples but the underlying code is not user modifiable. That is, you use my framework and put code into widgets that when you press them, they call functions on a denon object instance (ie denon.doSurround('5CH STEREO);)

My framework then handles the responses/events and fills out panel lables with specific ProntoScript names based on the specific event received.
Examples:

MS**** response is parsed and value goes to a widget with ProntoScript name Z1_SURROUND_MODE
MV**** response is parsed and value goes to a widget with ProntoScript name Z1_VOLUME.
MU**** response is parsed and value goes to a widget with ProntoScript name Z1_MUTE (Mute symbol or space) and
Z1_MUTE_TEXT (Text - On or Off).

User SJHart is one of the beta testers and he has been quite successful. You might send him RC Mail to dicuss pros/cons of using my framework.

I don't really know why I just didn't use the Denon 4306 module right away - I already had it. Seems to work very well, when some of the code i stripped. It's actually a very good example of how to put strings and pictures into a widget.
It's a bit annoying to put the code into every activity and page though.

Since you mention the mute - that's my next problem. I don't really have any use for a widget showing me on or off. The problem would be making it a toggle. Right now my mute hard button sends MUON\r through RS-232 and either volume up or down puts the receiver out of mute mode. I guess the procedure is the same as putting the response into a label - just sending a mute command instead?
OP | Post 10 made on Sunday October 3, 2010 at 12:30
brasch
Long Time Member
Joined:
Posts:
December 2008
87
On the positive side I got the mute working. Only problem is, that the script is in the activity and the mute on/off went beserk - that was expected though. Now I have this page script:

getCurrent()

function getCurrent(){
if (socket.connected == true){
socket.write("MU?\r");
}else{
scheduleAfter(1000,getCurrent)
}
}

and this activity script:

 

ConnectionSetup()

function ConnectionSetup(){

socket = new TCPSocket(false);

socket.connect(CF.widget("IP", "Settings").label,23,3000);

socket.onConnect=onConnect;

socket.onData=onData;

socket.onIOError=onIOError;

socket.onClose=onClose;

}

 

function onConnect()

{

CF.activity().label = CF.page().label ;

};

function onData()

{

myString = socket.read()

if(CF.page().label == "test page"){

ViewInputs(myString)

}

}

function onClose()

{

CF.activity().label = "Connection Closed";

scheduleAfter(5000,ConnectionSetup);

};

function onIOError()

{

CF.activity().label = "Connection Failed";

scheduleAfter(5000,ConnectionSetup);

};

function ViewInputs(sString){

var tmpString;

var aResults = sString.split(String.fromCharCode(13));

var i;

 

for (i=0; i<aResults.length; i++){

tmpString = aResults[i]

//CF.widget("AmpStatus").label = CF.widget("AmpStatus").label + "\n" + "->" +"{ "+aResults[i].substr(0,2)+" } " +aResults[i].substr(2) + "\n" + isNaN(aResults[i].substr(2))

 

if(tmpString == "MUON"){

socket.write("MUOFF\r");

}else if(tmpString == "MUOFF"){

socket.write("MUON\r");
}
}
}

how do I turn the last part of the activity into a button script?

Post 11 made on Sunday October 3, 2010 at 15:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
In your page script, add a command to query the receiver's current mute status and cache that result in an activity level variable. (this would be the value you store into tmpVariable from your loop. In this case, let's assume the variable is called mainMute and will contain either 'ON' or 'OFF'.

i.e. socket.write('MU?\r');

In your socket.onData() function, you will need to process the string returned and if it begins with "MU", you will cache the part past MU and store in your variable named mainMute.

Then, in your button script, do exactly what you are doing but reference a different variable.

if (mainMute === 'ON')
socket.write('MUOFF\r');
else
socket.write('MUON\r');

My module does something similar but in similar fashion. After writing a module for denon 3 times now, I've tried different approaches and found one that I really like. (See note about SJHart above)

I've spent many hours developing what I consider to be a robust solution which I am not prepared to make public domain at this time. I hope you can understand and appreciate that.

Please contact me @ yahoo or via RC Mail if you'd like to discuss further.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse