I have my projector (Epson 3020) up-and-running with the Runco plugin. However, I also want to be able to poll the status of the projector. With the Runco, the command “op status ?” is sent to receive the current projector status. With the Epson the command is “pwr?” to do the same thing. I have used iTest from Global Cache to verify the response I get to “pwr?”, and it works fine. However, the response is formatted a bit differently that the Runco’s. The author of the plugin used the trim and split functions to pull out the code, and that wasn’t working. Instead, I decided to use the “includes” parameter to simply check for the value to see if the projector was on (01 in my case). I tested the code in a javascript editor and it worked as expected. However, when I incorporate it into the plugin and tie the value to a label the label displays “Unknown”. The code should constrain the values to simply “On” or “Off”, so I’m a bit confused. Here’s my code:
flushReceiveBuffer();
socket.send("pwr?\r");
sleep(250); // sleep briefly just to make sure we get the whole response
response = socket.receive({ timeout: 500 });
responseVal=response.includes('01');
switch(responseVal) {
case false: // cooling down, off
powerStatus = "Off";
break;
case true: // displaying
powerStatus = "On";
break;
default:
// unknown/unhandled status (or an error), default to off
powerStatus = "Off";
break;
}
Seems like any error or unhandled status should set the value of powerStatus to “Off”, but it is showing “Unknown” instead. Any help would be appreciated!
I would prefer to not use a boolean, but in this case I really only care if the projector is in one of two states–on or off (which is what it basically is in the Runco code, which breaks it down to “On” or “Off” even though there are 4 cases). When I sent the “pwr?” command via iTest it was responding with only three variables. When the projector was off it returned “P???0C?”, when it was warming up it returned “PWR=02”, and when on returned “PWR=01”. The last two were expected, but when off I don’t know why it didn’t return “PWR=00”, which is supposedly what it should do via the 3020 ESC codes I was sent by Epson. Also, in iTest, it seemed to have a carriage return and a colon on the next line. The “includes” allowed me to bypass all of that and simply look for “01”.