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

Login:
Pass:
 
 

Page 1 of 2
Topic:
Denon 3808 RS232 channel level
This thread has 17 replies. Displaying posts 1 through 15.
Post 1 made on Wednesday January 13, 2010 at 11:20
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
How do I get individual channel levels from my receiver?
I tried cvfl? and cvfr? but I only seem to keep getting the FL channel?
Any ideas?
Post 2 made on Wednesday January 13, 2010 at 12:51
marco0305
Long Time Member
Joined:
Posts:
February 2009
19
Hi raven77m,

I had the same problem with my avc-a1hda which uses the same commands. If you send CV? to the receiver you will get all the channel volumes. Front left,front right, center, SW1,and so on.
The data you receive from the AVR through RS232 has to be parsed. All the data is there but you need to split the received string.
If you display the whole string on a debug panel you'll see the whole string and get an idea of how to process it. Takes a bit more programming.

Marco
Post 3 made on Wednesday January 13, 2010 at 13:06
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
You cannot retrieve volume of individual channels, you must do them as a set. You will have to continue doing match() or receive() until you receive data for the last channel your receiver supports.

var frontLeft = s.match('CV?\r','\r',2000);
var intermediate = s.match(null,'\r',2000);
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Thursday January 14, 2010 at 17:57
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
Thanks for the replies!
I am trying to figure this out without much luck.
I dug this out of the 3808command code...

Public Shared Function ParseChannelVolumeResponse(ByVal m As String) As ReadWriteKeyValuePair(Of Channel, ChannelVolume)

Dim r As ChannelVolume
Dim c As Channel
Dim rx As New Regex("CV(?<1>[A-Z]{1,3})\x20(?<2>\d{2,3})")
Dim kvp As ReadWriteKeyValuePair(Of Channel, ChannelVolume)
Dim ma As Match

ma = rx.Match(m)

If Not IsNothing(ma) AndAlso ma.Success Then

Select Case ma.Groups(1).Value
Case "FL"
c = Channel.LeftFront
Case "C"
c = Channel.Center
Case "FR"
c = Channel.RightFront
Case "SL"
c = Channel.LeftSurround
Case "SR"
c = Channel.RightSurround
Case "SBL"
c = Channel.LeftRear
Case "SBR"
c = Channel.RightRear
Case "SW"
c = Channel.Subwoofer
End Select

r = ChannelVolume.CreateFromDenonCommandValue(ma.Groups(2).Value)

kvp = New ReadWriteKeyValuePair(Of Channel, ChannelVolume)(c, r)

End If

Return kvp

End Function

Am I anywhere close to being on the right track??
I am also trying to get PW? to display either "ON" or "OFF" on a panel instead of "PWON" and "PWSTANDBY".
I think I can get rid of the "PW" in the front by doing something like this...

var r="";
var pattern=/(PW)(.*)/;
var result=s.match(pattern);
if (result!==null) {
r=result[2];
}
else {r="";}
return r;

But I'm not sure how to get "OFF" displayed instead of "STANDBY"?
Thanks for any input!!!
I'm trying!
Post 5 made on Thursday January 14, 2010 at 19:11
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
Why use regular expressions? They do compile and are performant but if you plan on parsing every event/response that comes from Denon, they can be time consuming and have too much overhead (running string through 20 RegExp matches, for example).

I used to use RegExp but am now taking the approach of getting the ascii value of the characters at positions 0 and 1.

var iValue = resp.charCodeAt(0) * 256 + response.charCodeAt(1);

Then, I simply have a switch(iValue) where the case entries are the calculated values I need. For example:

'CV' hashes to an integer value of 0x4356;
'PW' hashes to an integer value of 0x5057;

Then, after I know the iValue of first 2 characters, I then peel off the first 2 characters and look at remaining values as needed.

Example of peel-off using a string "PWOFF":

var s = "PWOFF";
var state = s.substring(2);


That easy and much more performant that RegExp. RegExp IS POWERFUL but like any tool, can be overused and performance of your code will SUFFER!.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 6 made on Friday January 15, 2010 at 00:46
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
Wow, I am even more dumb then I thought.
I think all I need to know yet is What variable goes in the label description?

label = s.match("HERE?\r");

Sorry for all the dumb questions, I'm figuring this out little by little...
Post 7 made on Friday January 15, 2010 at 13:22
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
Take this weekend and play with the puppy. Then come back and ask questions please.

Google and you will find what String.match(RegExp) returns.

var nextLine = mySerialPort.match(null,"\r",2000);

In this case, assumes that you are doing synchronous serial port access and nextLine will contains characters read within 2000ms up to and including the carriage return '\r' or null/empty string if timeout occurs.

If you get a string, you must strip off the trailing '\r' and then strip off the first 2 characters to get "STANDBY".

Please do us a huge favor and go off this weekend and write some test code to see how this all works. If you are still struggling, buy and read the Flanagan book for chapters 1-10, followup by then reviewing the Dev Guide, and then by working through the examples in the Dev Guide.

Not trying to be an ass here. Obviously, I don'k now whether you have a background in software programming. However, I would prefer to not have to teach you javascript or programming in this forum. And, if you continue asking these types of questions where it is likely that you are not connecting the dots (will help if you do homework suggested above) or testing, then, pretty soon, some of us may cease to respond.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 8 made on Friday January 15, 2010 at 15:34
eht123
Long Time Member
Joined:
Posts:
September 2008
33
On January 14, 2010 at 19:11, Lyndel McGee said...
I used to use RegExp but am now taking the approach of getting the ascii value of the characters at positions 0 and 1.

var iValue = resp.charCodeAt(0) * 256 + response.charCodeAt(1);

Then, I simply have a switch(iValue) where the case entries are the calculated values I need. For example:

'CV' hashes to an integer value of 0x4356;
'PW' hashes to an integer value of 0x5057;

I use a similar approach in my Denon comms, for example:

responseCat = response.substr(0,2);
switch (responseCat) {
case "MV":
case "MU":
case "CV":
etc..... (parse each case as needed)

Out of curiosity, why do you convert to integer? Is the switch statement faster that way?
OP | Post 9 made on Friday January 15, 2010 at 15:38
raven77m
Lurking Member
Joined:
Posts:
February 2009
8
I don't mean to be an "ass" either, but I am 32 years old not 11. I don't need you telling me to "study" before I ask questions. If I had an entire weekend to dedicate to reading 10 chapters of a javascript book and writing test code I wouldn't be here asking questions would I? I have spent countless hours reading different forums and I never seen someone trying so hard to help without helping. I spent quite a bit of time in this forum as well. Every post I see from you is arrogant and cryptic. You never just give a straight answer or full example and are always ignorant or telling people to go figure it out themselves. Why? Is this what you do for a living? Is that why you never just give straight answers and want cash to help? I have been reading on here for over a year and you are the only person that is like this.
I am an automation engineer by trade. Even though I have a 4 year degree that cost more then my house and 10 years of PLC programming experience, if I see a coding question in a PLC forum (even from someone without experience) I will GLADLY post a FULL code example without preaching, whining, or telling people to go study and then come back and ask me later.
I also have a few hundred hours of programming in PowerHome home automation software. Go to the PowerHome forum and you will see TONS of people asking questions and TONS of people offering help and full code examples. Nobody there or on any other programming forums I been to are arrogant and ignorant.
If you don't want to help that is fine, then please just don't reply! I seriously doubt the people here asking questions are teenagers. They don't need you telling them to go read and figure it out themselves. They are probably people like me, who don't have the time to spend and are just looking for some code snippets to save some time and get things working. I am not asking anyone to give me 450 lines of code. I already have loads of prontscript in my remote now that I learned from the dev. manual and it's working fine.
I have a 9400 and that is the ONLY thing I use prontoscript for, I don't do it for a living and would never tell someone to stop asking questions and go spend HOURS learning it themselves when all they want is some simple code.
My remote is working fine. All I wanted was to get status feedback from my Denon. I don't NEED it, it would just be nice. I have much better things to do with my weekends then learning prontoscript for my remote. That's why I posted here. It's not that I'm lazy or stupid, I just don't have the time. If I don't get it working it's no big deal and it certainly isn't worth wasting 30Hrs of my life on.
I will give it a try again when I get home tonight but don't worry, if I don't get it I won't be asking for anymore help here. I will just live without it.
Thanks anyway....
Post 10 made on Saturday January 16, 2010 at 03:39
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
On January 15, 2010 at 15:34, eht123 said...
I use a similar approach in my Denon comms, for example:

responseCat = response.substr(0,2);
switch (responseCat) {
case "MV":
case "MU":
case "CV":
etc..... (parse each case as needed)

Out of curiosity, why do you convert to integer? Is the switch statement faster that way?

Yes switch on integer is faster because you are comparing integers, not having to compare strings character by character. If you are only looking at a few things, then string switch is not a killer. However, if you are capturing data for all settings on all zones, then switching on strings or using RegExp to match/test will make your UI somewhat sluggish as you are spending lots of time just processing responses. If you are using RS232, you will also want to see my post below about possibilty of garbled data due to way RS232 is handled on RFX9600.

Last edited by Lyndel McGee on January 16, 2010 04:44.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 11 made on Saturday January 16, 2010 at 03:52
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
Raven77m,

You are correct. My post was whiny and bitchy and sarcastic. I should have posted privately.

Thanks very much for the information on your qualifications, the importance of your time. Much appreciated.

My reason for posting tersely above was to try and teach you to fish. My philosophy is to teach a man to fish, feed him for life. Give a man a fish, feed him one meal. However, based on your response above I guess I will not achieve that goal.

My Qualifications: Age 42, Software engineer for 23+ years. Active forum poster on this site for 9 years.

My time available for forum posts of late has been less than in previous 9 years but I do try to be helpful and provide guidance provided effort is reciprocated on the receiving end.

Now, getting beyond all this...

When you started down the path of asking all the questions regarding how do I do this, I knew up front the magnitude of what you were asking and the amount of code it takes to manage the Denon.

While I cannot provide you full code to process everything in the Denon, I will provide guidance in the form of my past experience writing 3 different version of Denon code.

My first cut at the task was using RS232 and RFX9600 and there was just too much overhead having the poll the serial port for data to keep the buffer drained (denon throws alot of data at you but fortunately lines are delimited by carriage return).

However, if you let that buffer fill up, you WILL lose data (buffer size is 1024 bytes). And with RS232 on RFX9600, every time you send, the receive buffer is cleared so if you send in the middle of a long set of incoming strings (for example, ramping channel level up/down in the midst of receiving the levels for all channels, you can get garbled data on a line and even lose some data. For example, you might receive:

CVCCVFL 50.5\r

as you issued a channel up command for a channel at the time the receiver was in the middle of transmitting full set of channel levels.

Here's an example for you that will hopefully tie all my previous posts on this thread together.

Assuming you have a serial port configured for synchronous access in variable s (by synchronous, that means that you've not assigned onData and onError functions. Also note that on the current page, you have a panel lwith ProntoScript name of 'POWER_STATE'.

// send power query, wait up to 2 seconds for a response.
var line = s.match('PW?','\r',2000);
if (line.length > 3) // check for at least PW + \r.
GUI.widget('POWER_STATE').label = line.substring(2,line.length-1); //strips first 2 characters and trailing \r.

Some additional surprises not documented by Denon:

With regard to sending volume ramps (MVUP/MVDOWN), some Denon receivers (later models) will report 2 lines of text as response vs just one (requires testing of your receiver):

MVMAX 87.5 (+7.5db)
MV72

In this case, you'd need to do what I suggested in post #3 (send/receive using match followed by second match that does not send data) to get the real volume level. I presume from post #4 that you've already figured out how to normalize the volume level you receive to a valid DB for both Channel and Main volumes.

So, looking back at your original example in post #4, I provided post #5 that would replace your r = r[2]. String substring function is what you needed to be using.

FYI, user Tenchi has put up a free module for the TSU9400 on www.prontoprojects.com that was written for TCP/IP access to the denon. This script could be adapted as well as the data extraction/parsing is the same whether you are parsing data from RS232 or TCP/IP.

Also note that the original Denon 232 script provided by Philips (looks like you've reviewed this) does not handle the MVMAX that is sent by newer receivers (they may have added this for the 4806 model).

Best wishes, and best of luck with your endeavors.

Last edited by Lyndel McGee on January 16, 2010 14:22.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 12 made on Saturday January 16, 2010 at 13:52
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
On January 14, 2010 at 17:57, raven77m said...
I am also trying to get PW? to display either "ON" or "OFF" on a panel instead of "PWON" and "PWSTANDBY".
I think I can get rid of the "PW" in the front by doing something like this...

var r="";
var pattern=/(PW)(.*)/;
var result=s.match(pattern);
if (result!==null) {
r=result[2];
}
else {r="";}
return r;

But I'm not sure how to get "OFF" displayed instead of "STANDBY"?
Thanks for any input!!!
I'm trying!

This has really been bugging me. I reread your original post and realized I did not fully understand your question. You had indicated you'd got this bundle of code from the 3808 script from Philips. I missed that originally. My sincerest apologies as with a set of fresh eyes, I can now see that you were asking how to extract the value only of PWON || PWSTANDBY using RegExp.

So, in response to your request for guidance about how to extract the value from the PW RegExp...

I think that you will need to use result = r[1] vs r[2] but I could be wrong. Edit: r[2] is correct as the pattern is /(PW)(.*)/ vs /PW(.*)/. If the latter pattern had been used, then you'd use r[1].

So, now, you simply need to trim carriage return off variable 'r' to get ONLY the value.

r = r.substring(0,r.length-1);

Whenever you get the value for the power state. Assume it is 'ON' or 'STANDBY' in variable r. You need to translate 'STANDBY' to OFF.

You can use an inline if clause to translate standby to off.

GUI.widget('POWER_STATE').label = (r === 'STANDBY' ? 'OFF' : r);

The longer form is:
if (r === 'STANDBY')
r = 'OFF';
GUI.widget('POWER_STATE').label = r;

Again, best wishes.

Lyndel

Last edited by Lyndel McGee on January 16, 2010 17:40.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 13 made on Friday January 14, 2011 at 11:56
maxdgt03
Lurking Member
Joined:
Posts:
January 2011
7
im trying to recieve input status from the reciever and display it on the remote im not a java script expert but have figured alot out for other functions i just cant seem to get this one to work nothing shows up on the textbox on the home page this is a shorter version of the script in didnt add all the case instances but i just wanted to get it to work first before i made it to long

can someone please help me out to figure out what might be wrong with this script
it works if i set a variable to match one of the case instances but wont work from the variable from the serial input



var inputWidget = page("PS_SYSTEM").widget("INPUT");
var e = CF.extender[1];
var s = e.serial[0];
s.bitrate = 9600
s.databits = 8
s.parity = 0; // None
s.stopbits = 1;
INP = s.match("?F\r", "\r", 250);
switch(INP) {
case "FN02" :
inputWidget.label = "Tuner";
break;

case "FN01" :
inputWidget.label = "CD";
break;

case "FN03" :
inputWidget.label = "Tape";
break;
}
Post 14 made on Friday January 14, 2011 at 12:50
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
MaxDgt,

Is this a denon receiver? The reason I ask is that ?F is not a command I have ever seen for a Denon receiver (Marantz, by chance?). If this is not a Denon receiver, please open another thread for your specific vendor rather than possibly introducing confusion by introducing other receiver vendor on a Denon thread.

For Denon, you send 'SI?\r' and you will receive something like 'SICD\r'.

With regard to your script, you did not declare a variable named INP. Not sure if this causes an error but as a best practice, I recommend it.

var INP = s.match("?F\r", "\r", 250);

Please note that Denon specs say to wait 250 ms between commands, not 250 ms for a response as the value above implies. When I did 232 and Denon, I usually wait 1000ms.

To get source on Denon, you'd do:

var INP = s.match("SI?\r", "\r", 1000); // wait up to 1 second for a response

The response you receive, provided nothing else is occurring on the receiver should be as above and can be processed as follows:

if (INP != null)
{
if (INP.length > 3)
// trim off first 2 characters and carriage

INP = INP.substring(2, INP.length);
// here, you can optionally do switch on INP to match proper input and change value.
inputWidget.label = INP;
}
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 15 made on Friday January 14, 2011 at 13:55
maxdgt03
Lurking Member
Joined:
Posts:
January 2011
7
im sorry i should have been more clear i am not actually using a denon im using pio elite this is the correct code and i know im getting a response back from the reciever because if i just send the IMP variable to the inputWidget i get the response variable of FN01 but i want to change the FN01 to something else thats why i wanted to use the case function to change response FN01 to CD for example or something else depending on the response from the reciever
i have tried
var INP = s.match("?F\r", "\r", 250);
instead of the same line without "var" in front of it but it didn't seem to make a difference still no response. Do i have the case function written wrong or something or how do i define it so it uses the variable from the serial response better
any ideas would help thanks
Page 1 of 2


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