10/10/25 - It’s been so long since we’ve last seen you!
10/24/22 - In searching for the perfect day, Timmy discovers something unexpected!
9/04/22 - That childhood favorite is back in a new Timmy video.
7/31/22 - It’s time for my second new Just Like Timmy video!
7/12/22 - Why not check out my new YouTube animation channel, Just Like Timmy!
|
|
 |
|
The following page was printed from RemoteCentral.com:
| Topic: | RS232 feedback question This thread has 17 replies. Displaying posts 1 through 15. |
|
| Post 1 made on March 18, 2024 at 21:14 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
I would like to display the current mute status on my Marantz receiver. what am I doing wrong, the code needing to be sent is MU?\r var s = CF.extender[A].serial[1]; s.bitrate = 9600; s.databits = 8; s.parity = 0; s.stopbits = 1; var line = s.match('MU?\r','\r',1000); CF.widget("Mute_Status").label = line;
|
|
| OP | Post 2 made on March 19, 2024 at 16:08 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
The RFX9600 firmware is on the latest. If I add commands to a RS232 component I have no problems sending RS232 commands out, and controlling my receiver, but I just can't seem to get things working from a script, this does not work either, var e = CF.extender[A]; var s = e.serial[1]; s.bitrate = 9600; s.databits = 8; s.parity = 0; s.stopbits = 1; s.send(”MV50\r”);
|
|
| Post 3 made on March 19, 2024 at 16:38 |
|
Joined: Posts: RC XP: | August 2001 13,125 389⭐︎ |
|
|
A try/ catch debug statement around your code would have shown you errors that variable 'A' is not defined. Extender 'A' is hexadecimal representation of extender ID. Character A is treated as a variable and not as a number. Serial ports are referenced using 0 to 3. var e = CF.extender[10]; // or [0x0A] var s = e.serial[1]; This will reference Serial Port 2 on Extender A. Note that every time you send to an extender port, the receive buffer is cleared so using RS232 to constantly receive events from equipment is problematic. I know there are threads about this that I authored long ago. Search for 232 and UART and you can read up about it. IIRC, those were the keywords. From what you are sending, you are talking with a Marantz or Denon unit. I'd highly recommend using TCPIP to port 22 vs doing the RS232 way.
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
| OP | Post 4 made on March 19, 2024 at 17:32 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
Thanks, that works, hear is my code but can't seem to get the "if statement" to work properly, var e = CF.extender[10]; if( e == null ) { Diagnostics.log("Extender 0 is not defined"); } else { var s = e.serial[0]; if( s == null ) { Diagnostics.log("Extender 0 is not a serial extender"); } else { s.bitrate = 9600; s.databits = 8; s.parity = 0; // None s.stopbits = 1; } } var status = s.match('MU?\r','\r',1000); CF.widget("Mute_Status").label = status; if (status === 'MUOFF') { s.send("MUON\r"); } else { s.send("MUOFF\r"); } The widget displays MUOFF so when I try the "IF Statement" it should execute the s.send("MUON\r"); line, but it is not
|
|
| OP | Post 5 made on March 19, 2024 at 17:42 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
I am guessing there is something in the return string that is not viable in the widget, like a space or a carriage return or something, this line does work, if (status.indexOf('MUOFF') > -1)
|
|
| Post 6 made on March 20, 2024 at 17:57 |
|
Joined: Posts: RC XP: | August 2001 13,125 389⭐︎ |
|
|
System.print and Diagnostics.log are your friend Add a widget on your page with ProntoScript name _PS_DEBUG_ (see the dev guide) System.setDebugMask(9); for (var i = 0; i < status.length; i++) { System.print('i:' + i + '=' + status.charCodeAt[i]); } What you will see is the the serial match also returns the carriage return at the end of the string (\r). So status really is 'MUOFF\r' and not 'MUOFF' That'ts why === does not work and your status.indexOf('MUOFF') > -1 does work. :-) Here's what I'd recommend. Download NodeJS as it is a wonderful playground for JavaScript development. It will really help you learn the JavaScript language and the APIs. Also note that the Mozilla website also lets you try out many things directly from a Web Browser. [Link: developer.mozilla.org]
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
| OP | Post 7 made on March 20, 2024 at 20:00 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
so thats why when I tried if (status == 'MUOFF') did not work, it should have been if (status == 'MUOFF\r')
|
|
| OP | Post 8 made on March 20, 2024 at 20:01 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
so this is what I use to determine if my receiver is muted, then send out the appropriate commands.. var e = CF.extender[10]; if( e == null ) { Diagnostics.log("Extender 0 is not defined"); } else { var s = e.serial[0]; if( s == null ) { Diagnostics.log("Extender 0 is not a serial extender"); } else { s.bitrate = 9600; s.databits = 8; s.parity = 0; // None s.stopbits = 1; } } var status = s.match('MU?\r','\r',1000); if (status.indexOf('MUOFF') > -1) { s.send("MUON\r"); } else { s.send("MUOFF\r"); }
|
|
| Post 9 made on March 22, 2024 at 20:13 |
|
Joined: Posts: RC XP: | August 2001 13,125 389⭐︎ |
|
|
FYI, this is the thread where the UART is discussed. And it fits right into what you are trying to do on your remote. [Link: remotecentral.com] and another one too. [Link: remotecentral.com]
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
| OP | Post 10 made on March 24, 2024 at 12:22 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
|
| OP | Post 11 made on September 23, 2024 at 14:37 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
Question along this topic, for my Receiver have that working, but not able to get this to work for my LG TV via RS232, Still on the RFX9600, Receiver is on Serial Port 1 and TV is on port 2, first code works great for the Receiver and displays the power Status of said receiver, but the second code for the LG TV clears the field and displays nothing, should display the power status of the TV var e = CF.extender[10]; if( e == null ) { Diagnostics.log("Extender 0 is not defined"); } else { var s = e.serial[0]; if( s == null ) { Diagnostics.log("Extender 0 is not a serial extender"); } else { s.bitrate = 9600; s.databits = 8; s.parity = 0; // None s.stopbits = 1; } } var status = s.match('ZM?\r','\r',1000); CF.widget("TV_Power").label = status; //////////////////////////////////////////////////
var e = CF.extender[11]; if( e == null ) { Diagnostics.log("Extender 0 is not defined"); } else { var s = e.serial[0]; if( s == null ) { Diagnostics.log("Extender 0 is not a serial extender"); } else { s.bitrate = 9600; s.databits = 8; s.parity = 0; // None s.stopbits = 1; } } var status = s.match('ka 01 ff\r','\r',100); CF.widget("TV_Power").label = status;
|
|
| Post 12 made on September 23, 2024 at 21:45 |
|
Joined: Posts: RC XP: | August 2001 13,125 389⭐︎ |
|
|
Well, if the receiver is on serial port 1 and the TV is on serial port 2, why is it that you have the same serial port being put into variable s each time. e.serial[0] Shouldn't the 2nd line be something like this without the 'var' in front? By putting the var in front of the 2nd line, you are effectively creating a variable 's' that exists only within your else scope. ////////////////////////////////////////////////// var e = CF.extender[11]; if( e == null ) { Diagnostics.log("Extender 11 is not defined"); } else { // LRM here variable 's' is assigned improperly to serial 0 and not serial 1 and also is only visible inside the curly braces (it overshadows the outer 's' var when inside the braces). //var s = e.serial[0]; // try this instead. s = e.serial[1]; // reassign outer scoped 's' to Serial Port 2 on extender 11 if( s == null ) { Diagnostics.log("Extender 0 is not a serial extender"); } else { s.bitrate = 9600; s.databits = 8; s.parity = 0; // None s.stopbits = 1; } } // LRM here, you are doing a match on the first extender's serial port or the wrong // serial port of Extender 11?. // Or the issue could be because of the variable scoping in the braces and 's' being // Extender 0's Serial port 0 vs Extender 11's serial Port 0. var status = s.match('ka 01 ff\r','\r',100); // Because you selected the wrong serial port, you are sending command to your // Denon and not your TV. Your Denon receiver will not understand this command // and after 100ms you will get back an empty string as the extender will timeout. // // May I recommend that you not reuse variable names in the same script for 2 // different pieces of equipment? For example, use E1, E2 and S1, S2 variable // names to avoid issues such as this. // LRM Here, status is the result of the timeout of match above. CF.widget("TV_Power").label = status;
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
| Post 13 made on September 23, 2024 at 21:53 |
|
Joined: Posts: RC XP: | August 2001 13,125 389⭐︎ |
|
|
Try this to see if it works as expected. var e1 = CF.extender[10]; var e2 = CF.extender[11]; var s1; var s2;
if( e1 == null ) { Diagnostics.log("Extender 10 is not defined"); } else { s1 = e1.serial[0]; if( s1 == null ) { Diagnostics.log("Extender 10 is not a serial extender"); } else { s1.bitrate = 9600; s1.databits = 8; s1.parity = 0; // None s1.stopbits = 1; } } var status1 = s1.match('ZM?\r','\r',1000); CF.widget("TV_Power").label = status1; //////////////////////////////////////////////////
if( e2 == null ) { Diagnostics.log("Extender 11 is not defined"); } else { // You mention serial port 2 which would be e2.serial[1] and not e2.serial[0] s2 = e2.serial[1]; if( s2 == null ) { Diagnostics.log("Extender 11 is not a serial extender"); } else { s2.bitrate = 9600; s2.databits = 8; s2.parity = 0; // None s2.stopbits = 1; } } var status2 = s2.match('ka 01 ff\r','\r',100); CF.widget("TV_Power").label = status2;
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
| OP | Post 14 made on September 23, 2024 at 22:55 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
these are two separate scripts used in two different buttons I am trying to use at different times, being put into the same variable for testing purpose only. Just giving the two samples where one works and the other is not
|
|
| OP | Post 15 made on September 23, 2024 at 22:59 |
|
Joined: Posts: RC XP: | June 2020 159 63⭐︎ |
|
|
this works now, thanks var e = CF.extender[10]; if( e == null ) { Diagnostics.log("Extender 10 is not defined"); } else { var s = e.serial[1]; if( s == null ) { Diagnostics.log("Extender 0 is not a serial extender"); } else { s.bitrate = 9600; s.databits = 8; s.parity = 0; // None s.stopbits = 1; } } var status = s.match('ka 01 ff\r','\r',100); CF.widget("TV_Power").label = status;
|
|
 |
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.
|
|