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 20 made on Friday July 27, 2007 at 05:36
Sogliphy
Long Time Member
Joined:
Posts:
July 2007
186
sWORDs:

Your SerialCode will return a String containing '\', 'x', '0', '2', ...

What you want is something that returns a String containing '\x02', '\x40', ...

A possible way to do this is like:


function SerialCode(command, parameter0, parameter1, parameter2, parameter3)
{
var stx = 0x02;
var etx = 0x03;
var calc = command + parameter0 + parameter1 + parameter2 +
parameter3 + etx;
return String.fromCharCode( stx, command, parameter0, parameter1,
parameter2, parameter3, etx, (calc >> 8)&0xff, calc & 0xff);
}


and use it like:


mycode = SerialCode(0x40, 0x00, 0x00, 0x00, 0x00);
rs232port2.send(mycode);


Note that you cannot set such a String containing arbitrary binary values as a label (you can, but the result will be garbage - the binary content will be interpreted as ASCII codes)

You could use something like:


function BinaryDump(s)
{
var result = "";
for (var i=0; i<s.length; i++) {
result += "\x" + s.charCodeAt(i).toString(16);
}
return result;
}

mycode = SerialCode(0x40, 0, 0, 0, 0);
panel2.label = BinaryDump(mycode);
rs232port2.send(mycode);



Enjoy.


Hosting Services by ipHouse