Author |
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: September 15 2006 at 11:46 | IP Logged
|
|
|
I really need help on this one.
I have a Denon receiver (3805) and a speaker selector switch that each have IR capability and RS232 ports. I've been using the receiver's and selector switch's IR capabilities and it works pretty well, but there is no feedback (i.e. I can turn the receiver off, but I don't know for sure if it's actually off). Altho there doesn't seem to be a lot out there on how to use an RS232 port in this situation, from what I can find, using the RS232 would allow me to not only turn the unit on and off (etc) but also allow me to confirm its status. So, question 1 is - is my understanding correct?
Although my receiver has an RS232C port it is not mentioned even once in the manual (although there is a picture of the port). Same for the RS232 port on the speaker switch. I know power-home has COM functions which should do the trick but I am also at a loss as to how to use the functions. I can't find any examples.
Question 2 - is anyone using the RS232 port on their receiver with PH? If yes, can you tell me how and perhaps share your functions or macros?
From the Denon site I found the following protocol specifications here:
http://usa.denon.com/AVR-3805_SerialProtocolv4-0UpdCV_serial protocol.pdf
and an example of a command for Power on:
PWON<CR> (where <CR> means 0x0D)
but I have absolutely no idea how to put this together and make it work from PH.
Is this a worthy effort or should I stick with IR?
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: September 15 2006 at 14:00 | IP Logged
|
|
|
As far as serial communication goes, you can take a look at the latest CID thread.
To start, these formulas open PH port 4 as COM3:9600,8N1 and sends a CID init string ("at#cid=1") followed by a <CR> (\013)...
Code:
ph_comopen( 4, 3, 9600, "N", 8, 1, 1, 0, 0, 1, 0, 1, 1, "?", "CID" )
ph_comsendstring( 4, "at#cid=1\013" ) |
|
|
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: September 16 2006 at 08:14 | IP Logged
|
|
|
Thanks for the reply, TonyNo. So I can get my arms around this one, if anyone else would like to chime in, please do so.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: September 16 2006 at 16:31 | IP Logged
|
|
|
Noel,
I checked out the Denon site and based upon the protocol, I believe the formula below would power on your Denon receiver:
Code:
ph_comopen(1,1,9600,"N",8,1,1,0,0,0,0,0,0,"?","") + ph_comsendstring(1,"PWON\013") + ph_comclose(1)
|
|
|
HTH,
Dave.
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: September 16 2006 at 18:25 | IP Logged
|
|
|
Thanks, Dave. That helps a lot. I am just waiting for my RS232/CAT5 dongle to arrive so I can reach my receiver from my computer and I'll try it out and let you know.
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: October 05 2006 at 18:08 | IP Logged
|
|
|
Using Dave's clear and concise instructions I was able to get the Denon receiver to work through PH. I had used IR extensions and an RF remote control previously. RS232 works quickly and all the time and you don't have to worry about it not working. So, altho IR was good, RS232 is even better.
Of course, there is always more to do. I have an AB8SS Automated Speaker Switcher which I also control using IR through PH using the extension port of a USB-UIRT. This works well when transmitting IR to the switch. But when the USB-UIRT is receiving a command from a remote and then transmitting a command to the speaker switch PH sometimes locks up. There are several work arounds that work okay but not 100%. I have no doubt this is a USB-UIRT issue and not a PH issue.
The speaker selector switch can also be controlled using RS232. I have connected it and can control the switch using it's own simple control program - so I know RS232 is connected correctly and works. When I try to send the appropriate commands through PH, the switch doesn't respond.
These are instructions for the switch followed by what I tried using PH:
"AB8SS
Serial communication:
9600 baud
1 start bit
8 data bits
2 stop bits
no parity
AB8SS uses a bit banger Serial communication. IE: it has no serial buffer
Assumption:computer talking to AB8ss HAS a serial buffer.
To talk to AB8SS we need to get it's attention
Send out ASCII "!" until it echoes back same.
Retry every 100ms for 5 times. If no echo then problem in link.
Once "!" is echoed back send next ascii charachter.
Same for the next until you sent a total of 10 ascii characters. (waiting for echo before you send next)
The last ascii character "*" actually tells AB8SS to execute the command.
If any echo does not match what you sent then send ascii character "-" to terminate string.
You will then need to start all over again sending and waiting of ascii character "!"
I know that I want to send the following string to the switch:
"!060002F*" This particular string turns switch 2 OFF.
If I sent "!050002F9*" I would turn switch 2 ON. These work when I send them through the AB8SS software.
When I try to send them through PH, they do not work. I know that I have to send \033 for "!" and \042 for "*".
Here is what I tried:
ph_comopen(1,1,9600,"N",8,1,1,0,0,0,0,0,0,"?","") [I've also tried ph_comopen(1,1,9600,"N",8,2,1,0,0,0,0,0,0,"?","")]
ph_comsendstring(1,"\033060002F8\042")[This gives me a critical application error message:"
Application Execution Error (R0019) Cannot convert string in ANY variable to blob at line 10 in oncomm event of object ole_comport of uo_comport"]
So I broke this up into two lines as follows:
ph_comsendstring(1,"\033")
ph_comsendstring(1,"060002F8\042")
ph_comclose(1)
This doesn't work. The formulas verify, but nothing happens. I then decided to troubleshoot to see if I get an echo back just when I send "!", so I set up the following macro:
ph_comopen(1,1,9600,"N",8,1,1,0,0,0,0,0,0,"?","")
ph_comsendstring(1,"\033")
TSS ph_comrecvstring(1,10)
ph_comclose(1)
It reports a -3 each time which means nothing is in the buffer so I assume nothing is echoing back.
Since my knowledge in this area is extremely limited I am hoping someone might have a suggestion as to what to try next.
Thanks in advance!!
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 06 2006 at 18:18 | IP Logged
|
|
|
Noel,
Based upon your explanation of the protocol, neither of your methods would work because there is not enough delay between the sending of the characters. Not sure what is causing the Critical error and would have to check that out though.
Anyways, Ive put together a macro adhereing to the protocol you outlined. You would call it with ph_macroparm and would pass it the AB8SS string to use minus the "!" character. Below is the macro code to import:
Code:
insert into macroheader values ('AB8SS CONTROL','AB8SS CONTROL',0,0,1);
insert into macrodetail values ('AB8SS CONTROL',1,38,'',0,'ph_comopen(1,1,9600,"N",8,2,1,0,0,0,0,0, 0,"?","")',0,'');
insert into macrodetail values ('AB8SS CONTROL',2,15,'[LOCAL2]',NULL,'[LOCAL1]',0,'');
insert into macrodetail values ('AB8SS CONTROL',3,15,'[LOCAL3]',NULL,'0',0,'');
insert into macrodetail values ('AB8SS CONTROL',4,26,'',NULL,'ATTN',0,'');
insert into macrodetail values ('AB8SS CONTROL',5,27,'',NULL,'if([LOCAL3] = 5,''END'',''CON1'')',0,'');
insert into macrodetail values ('AB8SS CONTROL',6,26,'',NULL,'CON1',0,'');
insert into macrodetail values ('AB8SS CONTROL',7,38,'',0,'ph_comsendchar(1,33) + ph_addtovar(1,3,1)',0,'');
insert into macrodetail values ('AB8SS CONTROL',8,7,'',NULL,'100',0,'');
insert into macrodetail values ('AB8SS CONTROL',9,27,'',NULL,'if(ph_comrecvchar(1) = 33,''SENDCHAR'',''ATTN'')',0,'');
insert into macrodetail values ('AB8SS CONTROL',10,26,'',NULL,'SENDCHAR',0,'');
insert into macrodetail values ('AB8SS CONTROL',11,15,'[LOCAL4]',NULL,'left("[LOCAL2]",1)',0,'');
insert into macrodetail values ('AB8SS CONTROL',12,15,'[LOCAL2]',NULL,'mid("[LOCAL2]",2)',0,'');
insert into macrodetail values ('AB8SS CONTROL',13,27,'',NULL,'if("[LOCAL4]" = "","END","CON2")',0,'');
insert into macrodetail values ('AB8SS CONTROL',14,26,'',NULL,'CON2',0,'');
insert into macrodetail values ('AB8SS CONTROL',15,38,'',0,'ph_comsendchar(1,asc("[LOCAL4]"))',0,'');
insert into macrodetail values ('AB8SS CONTROL',16,7,'',NULL,'100',0,'');
insert into macrodetail values ('AB8SS CONTROL',17,27,'',NULL,'if(ph_comrecvchar(1) = asc("[LOCAL4]"),''SENDCHAR'',''ERROR'')',0,'');
insert into macrodetail values ('AB8SS CONTROL',18,26,'',NULL,'ERROR',0,'');
insert into macrodetail values ('AB8SS CONTROL',19,38,'',0,'ph_comsendchar(1,45)',0,'');
insert into macrodetail values ('AB8SS CONTROL',20,7,'',NULL,'100',0,'');
insert into macrodetail values ('AB8SS CONTROL',21,26,'',NULL,'END',0,'');
insert into macrodetail values ('AB8SS CONTROL',22,38,'',0,'ph_comclose(1)',0,'');
|
|
|
To send the "switch 2 OFF", use this formula:
Code:
ph_macroparm("AB8SS CONTROL","0600028F*",0,0,0,0)
|
|
|
Let me know how it works out.
Dave.
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: October 06 2006 at 21:40 | IP Logged
|
|
|
Thanks for the putting in the time and writing the macro.
Unfortunately I can't get it to work. I've tried to troubleshoot. It seems the macro doesn't get past line 90. If I play the macro twice the second time it runs ATTN twice but then stops. Never executes any of the code that follows line 90 and only goes back to ATTN if I run the macro a second time and the port hasn't been closed. If I close the port manually and then run the macro again it only runs through ATTN once and then stops. I've tried to verify each of the formulas. Line 50 doesn't verify and
Line 70 in the AB8SS macro throws this error when I try to verify the formula.
So I'm stuck (again). Thanks for the valiant effort!
ph_comsendchar(1,33) + ph_addtovar(1,3,1)
A critical error occurred at 2006-10-06 21:31:31.609. *** *** PowerHome Version: 1.03.4.8 *** Error Number: 19 *** Error Message: Cannot convert string in Any variable to blob at line 10 in oncomm event of object ole_comport of uo_comport. *** Window: uo_comport *** Object: ole_comport *** Event: oncomm *** Line: 10
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: October 07 2006 at 10:10 | IP Logged
|
|
|
I just wanted to add that at the suggestion of the manufacturer of the AB8SS I tried Windows Hyperterminal just to make sure that the connections and commands are okay. It all works with HyperTerminal. I've also tried the ph_combufferrptr and it always reports zero in the buffer. So either:
1. It's not transmitting. (Seems unlikely as the RS232 commands for the Denon receiver work).
2. It's not transmitting "!" correctly. (I've tried many combinations including sendstring and sendchr of !,033,33 etc). Still zero in the buffer.
3. It's not receiving the echoed "!" correctly.
2 or 3 seem the most likely to me.
Hope this narrows down the possibilities.
Thanks!
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 09 2006 at 14:37 | IP Logged
|
|
|
Noel,
I checked out the macro and everything looks ok, the problem appears to be in the critical error that is coming back. This shouldnt be happening and Im not sure what the problem is. Ive analyzed the actual code of the communication object and it just appears to be something flaky either with the MSCOMM control or PowerBuilder's interaction with it. It's the same basic code that is used with every serial based controller within PowerHome.
So, what Ive done is modified the code to remove any ambiguity between the blob and the any variable as well as enclosed the code in try/catch blocks. This will prevent the critical error, but I don't know if it will fix your specific problem until I get this next version out (very soon...it's just a bug fix of what's been reported so far).
Out of your 3 possibilities, I would say that number 3 is the most likely since this is where the critical error is occurring as well. For some reason, the MSCOMM control seems to be choking on receiving the "!" character.
I'll post back when I have a little more info.
Dave.
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: October 09 2006 at 20:15 | IP Logged
|
|
|
Dave, thanks for working on this. I'd agree that #3 is the most likely as I further played with trying to get it to work.
I look forward to the patch/fix to try.
On another note, I wanted to mention that I tried the new ph_ttssetvoice function and it works great. I have a male voice announcing the time every hour and a female "weather" person announcing the temprature. Nice!
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 10 2006 at 14:15 | IP Logged
|
|
|
Noel,
Glad you were able to figure the new TTS function out. I feel bad for not having documented these yet. I'll try to get the help file updated shortly.
Also, I'll be sending you a special "patch" file to test your serial COMM with. I'll be contacting you shortly.
Dave.
|
Back to Top |
|
|
|
|