Author |
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: September 30 2008 at 19:27 | IP Logged
|
|
|
I have a new Marantz SR5003. It has an RS-232 control interface. Anybody know how to set up PH to use a "generic" RS-232 device?
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: September 30 2008 at 21:00 | IP Logged
|
|
|
There are two ways: Raw COMM plugin (take a look in the help file) or do it yourself in a macro. I suggest the first one!
If you want to go the second way, take a look at my CID macro.
|
Back to Top |
|
|
smarty Super User
Joined: May 21 2006 Location: United States
Online Status: Offline Posts: 728
|
Posted: September 30 2008 at 21:02 | IP Logged
|
|
|
I assume you mean, how do I send rs-232 commands to control the device.
First you have to open the Serial Com port you want to use. For exmaple, I use....
ph_comopen({COM NUM AVR LIVRM},{COM NUM AVR LIVRM},9600,"N", 8, 1, 1, 0, 0, 0, 0, 1, 1, "?","COM PORT AVR LIVE RM")
....in my start-up macro (the port always stays open) to open the COM port of choice.
Once the port is opened and configured such that the external device can communicate (see the device's RS-232 protocal's), then, all you have to do is send commands out the port you opened. Like this:
ph_comsendstring({COM NUM AVR LIVRM},"!1MVL4B\013")
For two way control, you have to specify what macro to call when there are incoming bytes on the COM port. From my example above, I use "COM PORT AVR LIVE RM". This macro reads the com port and intreprets what the device sends back. Search the forum for TonyNo's CID macro (not plugin) to see how to make a macro to read the incoming com port traffic.
Hope this helps get you started in the right direction.
__________________ Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: October 01 2008 at 05:30 | IP Logged
|
|
|
Silly me, and I thought this would be defined much like my X-10 or Redrat controllers. . .
I've been using PH for years and I have no clue about "start-up macros", where would that be set-up?
The ph_comopen command looks like I may need to include some specific info to my system. For instance: I'll be using COM 3, so would that be
"ph_comopen({COM 3 AVR LIVRM},{COM 3 AVR LIVRM},9600,"N", 8, 1, 1, 0, 0, 0, 0, 1, 1, "?","COM PORT AVR LIVE RM")"
what is the "AVR LIVRM" all about?
I checked out the hook-up with windows hyper-terminal and it was important to open the port at:
9600 baud
No Parity
8 bit
1 stop
No Handshake
Where in the string do I insure "handshake" is set to "None"?
In the case of IR devices a table of strings is created by name so in macro command would be IR then you would specify Device and Name of command. Is there a way to Name the device and command functions so that the actual control macros are easier to read?
Can I assume that in ph_comsendstring example, that you so kindly provided, that I would need to put my specific info in place of "COM NUM AVR LIVRM"? Is the "!1MVL4B\013" is the actual command string? Which in the case of my Marantz Amp would look more like "@VOL:1"? How do I control line terminators. Is the \013 a Carriage return?
Thanks for your help!
Bob
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: October 01 2008 at 05:46 | IP Logged
|
|
|
Looking at Tony's suggestion:
In the "Raw COMM" "Launch Data (ActiveX Classname): PH_Socket.phsocket" my take a little more specific explanation for this idiot. If a "plug-in" is used how is the macro interface accomplished? Can I get a Device Name / Function Name style of control?
Bob
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: October 01 2008 at 06:43 | IP Logged
|
|
|
If you just need to send commands to the Marantz, and not handle responses, then you don't need the plugin or to look into the CID macro.
You first need to open the port with ph_comopen(), then you can write to it (send commands) with ph_comsendstring.
The startup macro reference assumed that you already had one. In that case, you would put the ph_comopen command in there, otherwise, you can put it in a new macro to be run manually.
From the Help file...
Quote:
ph_comopen ( comnum, comport, bps, parity, databits, stopbits, rthreshold, sthreshold, handshaking, inputmode, nulldiscard, rtsenable, dtrenable, parityreplace, id )
Argument Description
comnum The number of the COM control you are referencing. Valid values are 1 thru 5.
comport The COM port you wish to open. Typically a number from 1 to 8 but can be higher.
bps The speed at which the port should be opened. A typically value would be 9600.
parity The parity the port should be opened. Valid values are "E", "O", and "N".
databits The number of bits within a byte that represent data. Typical values would be 7 with even or odd parity and 8 with no parity.
stopbits The number of stop bits. Typically 1.
rthreshold The number of bytes to receive in the incoming buffer before the receive macro is fired. A value of 1 will cause the receive macro to execute every time a character is received (Assuming the characters are read as soon as they are received).
sthreshold The number of bytes to store in the outgoing buffer before actually being sent out the COM port. A value of 0 will force bytes to be sent immediately.
handshaking The value to use for handshaking. Use 0 for no handshaking, 1 for XON/OFF handshaking, 2 for RTS/CTS handshaking, and 3 for both XON/OFF and RTS/CTS handshaking.
inputmode The manner in which to receive data. Use 0 for text data, 1 for binary data.
nulldiscard Use a 0 to include null characters (ASCII 0) in the incoming buffer. Any other value will cause null characters to be discarded.
rtsenable Use a 0 to disable the RTS line. Any other value will enable the RTS line.
dtrenable Use a 0 to disable the DTR line. Any other value will enable the DTR line.
parityreplace The character to be used to replace an invalid character when a parity error occurs. Typically this would be set to "?".
id The ID of a macro to be called when characters are received. |
|
|
For your system, this should do it:
ph_comopen( 1, 3, 9600, "N", 8, 1, 1, 0, 0, 1, 0, 1, 1, "?", "" )
This would send your volume command:
ph_comsendstring( 1, "@VOL:1\013" )
The "\013" is the carriage return. You can also use "\x0d".
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: October 01 2008 at 08:05 | IP Logged
|
|
|
Tony
Thanks for your prompt help. I'm getting close, but I still don't have this startup thing going.
I created a Macro "STARTUP" and in that is the ph_comopen command as a formula.
When I start PH the port isn't active until I manually run the "STARTUP" Macro.
What else do I need to do to get the com port active at boot time?
Bob
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: October 01 2008 at 08:11 | IP Logged
|
|
|
Create a trigger with Trigger Type as System Process and Trigger ID as Startup. Then make Action your macro.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: October 01 2008 at 11:49 | IP Logged
|
|
|
Thanks Guys! I think I've got it
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: October 01 2008 at 13:39 | IP Logged
|
|
|
Good going!
|
Back to Top |
|
|
|
|