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 2 of 2
Topic:
ProntoScript library for Sony VPL Projectors
This thread has 18 replies. Displaying posts 16 through 19.
OP | Post 16 made on Saturday December 15, 2012 at 20:50
randman
Long Time Member
Joined:
Posts:
June 2003
424
Need some ProntoScript advice with Hex and OR-ing... I need to calculate the checksum of 5 bytes by OR-ing them (I can do the checksum in Excel, but figured it would be better to do in my ProntoScript library).

So, my 5 bytes are assigned as follows:

B1 = "\x17", B2 = "\x2E", B3 = "\x00", B4 = "\x00", B5 = "\x00";

I tried the following:

checkSum = B1 | B2 | B3 | B4 | B5;

However, it does not work properly.

This works:

checkSum = 0x17 | 0x2E | 0x00 | 0x00 | 0x00;

However, I'm storing the bytes in strings (like in B1, B2, ... B5 above).

How do I do the bitwise OR (i.e. | ) on B1, B2, ... B5? I'd like to assign them like I did above (as opposed to B1 = 0x17; B2 = 0x2E, etc.).

Later, when I want to pass bytes 0 to 7 (B0, .... B7) to Serial.match, how
do I concatenate them together to be one "string"? Doing
B0 || B1 || B2 .... || B7 doesn't work.

Advice?

Thanks!
Post 17 made on Saturday December 15, 2012 at 22:25
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
To build an single ascii character with the value you need, you use String.fromCharCode(checksum).

I sure thought there was an example of building up an array of bytes in Barry's documentation along with a checksum.

I'd take a slightly different approach rather than building variables with string values, do everything as integers which makes it easier to calculate checksums and then build a string at the end.

For example, you are treating these as strings up front.

B1 = "\x17", B2 = "\x2E", B3 = "\x00", B4 = "\x00", B5 = "\x00";


I'd build myself an array and stuff in integer values between 0 and 255 (0x00 and 0xFF).

var bytesToSend = [];
var index = 0;
var index2 = 0;

bytesToSend[index++] = 0x17;
bytesToSend[index++] = 0x2E;
bytesToSend[index++] = 0x00;
bytesToSend[index++] = 0x00;
bytesToSend[index++] = 0x00;

var checksum = 0;
var index2 = 0;
for (index2 = 0; index2 < bytesToSend.length; index2++)
checksum |= bytesToSend[index2];

// Append checksum you just calculated onto end of array.
bytesToSend[index++] = checkSum;

// Build a string from the array (not sure if String.fromCharCode(0x00) will
// add a NUL character to a string. Think it does but you will want to confirm.

var stringToSend = '';
for (index2 = 0; index2 < bytesToSend.length; index2++)
stringToSend += String.fromCharCode(bytesToSend[index2]);

Regards,
Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 18 made on Sunday December 16, 2012 at 14:54
randman
Long Time Member
Joined:
Posts:
June 2003
424
Ah wonderful. Yeah, now that I've ready your reply, Barry's example makes perfect sense. His example assigned decimals to the variables, while your reply assigns hexadecimals to the variables. I suppose it doesn't matter how the vars are assigned. Thanks so much for your help!
OP | Post 19 made on Sunday December 16, 2012 at 15:01
randman
Long Time Member
Joined:
Posts:
June 2003
424
On December 15, 2012 at 00:39, randman said...
What confused me and what I got stuck on for a while is that the projector
does not respond to the power status query while it is in standby mode (I wanted to do my initial debugging while the projector was on standby mode so as to save lamp life :-).

The Sony RS232 protocol interface manual says that "standby" is one of the possible states of the projector, so I only assumed that the projector can be queried while it is in standby mode. But if it's in standby mode, I either get no response (serial.match times out eventually), or, if I send the query right after the previous query, the Sony responds with a NAK error reply.

My previous Marantz projector responds to power status queries while it is in standby, so I assumed the Sony would to. I'll need to play around with this more. Sony has a couple of standby modes, so I'll do more testing....

In case anyone with a Sony projector needs to know in the future, here's the results of my testing:

The Sony supports two standby modes. The "Low" mode uses less power (0.5W). However, in "Low" mode, the projector does not respond to Power Status requests. If you send the power status request 2 times in a reow, the first request times out and the second request replies with a NAK error. The "Standard" standby mode uses more power (8W). However, it responds immediately to Power Status requests (it responds saying the projetor is in standby mode). So, if I want to save power, I can just assume that if the response times out, the projector must be in standby mode (in which case I would send a Power On command, and popup the please wait dialog boxes). Or, I can waste more power (8W instead of 0.5W) and have little or no delay in my macros.
Page 2 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