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

Login:
Pass:
 
 

Topic:
Issue Solved - Trying to send Hex via Serial Port with Prontoscript
This thread has 5 replies. Displaying all posts.
Post 1 made on Saturday June 12, 2010 at 17:50
pjjameso
Long Time Member
Joined:
Posts:
April 2008
73
I am at a loss trying to figure out what i am doing wrong, again! Trying to send a hex command (0x02) out the extender serial port 4, wait for a responce which should be 0x06 0x0D (ACK) or 0x15 (NAK). I would then like to write the responce to a label named 'status'. Im using Barry's Debugger but nothing shows up after the download and jumping to the page. Here is the code. This is being executed in the "HOME" activity, "ROOM" page, 'status' panel.

var debug = true;
System.setDebugMask(debug ? 9 : 0);

CF.widget("status").label = "No Responce";

var e,s;
e = CF.extender[0];

if (!e)
{
System.print("Extender 0 is not defined");
}
else
{
s = e.serial[3];
if (!s)
{
System.print("Extender 0 is not a serial extender");
}
else
{
s.bitrate = 9600;
s.databits = 8;
s.parity = 0;
s.stopbits = 1;
}
}


s.onData = function (v) {status = v;};
s.match("\x02","\x06\x0D",250);

s.onTimeout = function(v) {
System.print("Smarthome timeout");
}
s.onError = function(e) {
System.print("Smarthome " + e);
}

Last edited by pjjameso on June 13, 2010 09:58.
Paul
Post 2 made on Saturday June 12, 2010 at 20:03
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
with match() you basically wait for a response that is ends with "\x06\x0d". If the device you're communicating with, doesen't send this response (f.e. doesent send anything or sends something else, like in the case 0x15) then you will get an empty string in return, because the matched text will not be found and the timeout of match will expire.

Try sending with s.send("\x02",250). This way the extender will not wait for a specific string. Hope this helps (I havent used async communication yet).
OP | Post 3 made on Sunday June 13, 2010 at 09:56
pjjameso
Long Time Member
Joined:
Posts:
April 2008
73
Ive modified the code and it is working. One problem I realized was my fault was that I was looking at Barry's Debugger screen and seeing a - for the responce. Just figured I had coded something wrong, but low and behold when I opend the log it shows (ACK)(CR) just as hoped. Next step is to test for that responce in prontoscript and execute a follow on fuction.

var debug = true;
System.setDebugMask(debug ? 9 : 0);

var e,s;
e = CF.extender[0];

if (!e)
{
System.print("Extender 0 is not defined");
}
else
{
s = e.serial[3];
if (!s)
{
System.print("Extender 0 is not a serial extender");
}
else
{
s.bitrate = 9600;
s.databits = 8;
s.parity = 0;
s.stopbits = 1;
}
}

var receive = "No Responce Yet";

CF.widget("status").label = receive;

s.onData = function (v)
{CF.widget("status").label = "String Received"};

s.match("\x02","\x06\x0D",250);

s.onTimeout = function(v) {
System.print("Smarthome timeout");
}
s.onError = function(e) {
System.print("Smarthome " + e);
}
Paul
Post 4 made on Wednesday June 16, 2010 at 18:23
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
I am not sure which version of the debugger you are using. It was designed for ASCII printable characters. However if you highlight any line in the body of the debugger it will show you, in the text line labeled "W/CC" (for with Control Codes) the standard mneumonic for each ASCII control character that appears in that line. I did that for the obvious reason. All the ASCII control characters have values below 32. I show them as (NUL), (STX), (ETX), (ACK), (CR), (LF) and so on.

If you are interested in that sort of stuff download a copy of the free Textpad text editor. One of its features is that it has a window you can keep open that shows all the ASCII coding. It is the only text editor I use for many reasons.

Hope that helps
Post 5 made on Thursday June 17, 2010 at 16:56
bnokes@AAVViD
Long Time Member
Joined:
Posts:
June 2009
31
This is what this code quality tool showed

http://www.jslint.com/

Error:

Problem at line 35 character 2: Missing semicolon.

}

Problem at line 38 character 2: Missing semicolon.

}

Implied global: System 2,11,18,34,37, CF 4,7, status 30
Post 6 made on Thursday June 17, 2010 at 19:01
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
Neither of which is an error, just a warning. :-)
Lyndel McGee
Philips Pronto Addict/Beta Tester


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