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

Login:
Pass:
 
 

Original thread:
Post 12 made on Sunday June 29, 2008 at 09:58
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
I just pulled and glanced at the CAM RS232 spec. Yes they do send binary values. They use only three characters for transmission control (F0, F1, F7). The check sum includes a byte count.

First off, the version of ShowHex I published above leaves a lot to be desired (I must be getting very old)

Here is a proper version:

function ShowHEX(a) { var b=""; var c=""; var i=0; for(i=0; i < a.length; i++)
{ if(a.charCodeAt(i).toString(16).length==1)
b+="0"+a.charCodeAt(i).toString(16).toUpperCase()+" ";
else b+=a.charCodeAt(i).toString(16).toUpperCase()+" ";}
return b; }

In summary, what I think you are having trouble with is the code:

volume1=26; chk=28; // 28 decimal =1C hex
"\xF0\x00\x00\x7F\x00\x00\x70\x05\x02\x02\x00\x00\xF1\x21\x00" + (volume1/2).toString(16) + "\x00\x00\x00\x01" + chk.toString(16) + "\xF7";

I ran the following code:

var volume1=26; var chk=28; // 28 decimal =1C hex
var testcase="\xF0\x00\x00\x7F\x00\x00\x70\x05\x02\x02\x00\x00\xF1\x21\x00" + (volume1/2).toString(16) + "\x00\x00\x00\x01" + chk.toString(16) + "\xF7";
System.print("testcase="+ShowHEX(testcase))
stop

What I get on my debug display is:

testcase=F0 00 00 7F 00 00 70 05 02 02 00 00 F1 21 00 64 00 00 00 01 31 63 F7
ProntoScript error: ReferenceError: stop is not defined
Offending activity script: Tag: 'SSActivity'
Offending line #11: "stop"

I then decided to just skin the cat.

var chr=new Array()
chr=["\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F",
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F",
"\x20", "\x21", "\x22", "\x23", "\x24", "\x25", "\x26", "\x27", "\x28", "\x29", "\x2A", "\x2B", "\x2C", "\x2D", "\x2E", "\x2F",
"\x30", "\x31", "\x32", "\x33", "\x34", "\x35", "\x36", "\x37", "\x38", "\x39", "\x3A", "\x3B", "\x3C", "\x3D", "\x3E", "\x3F",
"\x40", "\x41", "\x42", "\x43", "\x44", "\x45", "\x46", "\x47", "\x48", "\x49", "\x4A", "\x4B", "\x4C", "\x4D", "\x4E", "\x4F",
"\x50", "\x51", "\x52", "\x53", "\x54", "\x55", "\x56", "\x57", "\x58", "\x59", "\x5A", "\x5B", "\x5C", "\x5D", "\x5E", "\x5F",
"\x60", "\x61", "\x62", "\x63", "\x64", "\x65", "\x66", "\x67", "\x68", "\x69", "\x6A", "\x6B", "\x6C", "\x6D", "\x6E", "\x6F",
"\x70", "\x71", "\x72", "\x73", "\x74", "\x75", "\x76", "\x77", "\x78", "\x79", "\x7A", "\x7B", "\x7C", "\x7D", "\x7E", "\x7F"]


and ran the following code:

var volume1=26; var chk=28; // 28 decimal =1C hex
var testcase="\xF0\x00\x00\x7F\x00\x00\x70\x05\x02\x02\x00\x00\xF1\x21\x00" + chr[volume1/2] + "\x00\x00\x00\x01" + chr[chk] + "\xF7";
System.print("Hex="+ShowHEX(testcase))
stop

Producing the following:

Hex=F0 00 00 7F 00 00 70 05 02 02 00 00 F1 21 00 0D 00 00 00 01 1C F7 ProntoScript error: ReferenceError: stop is not defined
Offending activity script: Tag: 'SSActivity'
Offending line #28: "stop"


Which I believe is what you want.


Javascript definately has issues dealing and representing basic character codes and converting numbers to pure characters.

for example var a=13; a.toString16() does produce the letter d but as a string. the ordinal code for the letter d in ASCII is 100 so what actually ends up in the byte is the decimal integer 100 which has the hex value of 64. That is why showHEX shows it as 64. if you do a=28, a.tostring(16) what you get is the sequence 1C as a string which is stored as two bytes "1" "c" which have ordinal ascii code values of 49 and 63 which showHEX properly shows as 31 63. if you try a=13; "0x"+a.toString(16) you get 3 bytes "0","x","d".

The chr array as shown above will properly handle any integer in the range 0-127 and could be expanded to handle 0-255 and automatically add the needed F1 code and the inverted value (as required by the Russound protocol) to produce values in the range 128-255. I leave that as an exercise to the reader.

I hope this helps you resolve your problem. Feel free to use the chr array and be sure to update the ShowHEX function if you are using it.

Last edited by Barry Gordon on June 29, 2008 10:05.


Hosting Services by ipHouse