Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Com port programing Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
rrockoff
Newbie
Newbie


Joined: June 02 2008
Location: United States
Online Status: Offline
Posts: 13
Posted: March 03 2009 at 13:15 | IP Logged Quote rrockoff

Hi,

I have owned power home for a few years and just started an earnest attempt at integration. From reading posts on the forum, it seems that I have some common equipment. I am trying to integrate the following:
Note: COM 1 and COM 2 are built in PC COM ports. COM 3 - COM 5 are virtual ports connected to a Lantronix ETS16

COM 1 = Onkyo SR805
COM 2 = Olevia 27" LCD TV

COM 3 = ELK M1G
COM 4 = SecuPointer 8 Channel CCTV DVR
COM 5 = Goldline AquaLink for pool HA

USB-UIRT

X-10 CM11A

I can connect to each of the COM port deivces via Hyper Terminal and I can receive responses. Example turn on Onkyo receiver and it shows PWR01. I have also been able to send command to the COM 4 DVR and make it work.

Just to give you an idea of my current feeble programming skills, here is how I am using the DVR:

Manual can be downloaded here
   

MACROS:
DVR_OPEN {formula} ph_comopensimple( 4, 4, "57600,N,8,1", "DVR_GET_DATA" )

DVR_GET_DATA {formula} currently I do not have a formula to receive data. I am able to do what I want by just sending data.

DVR_CH1 {formula} ph_comsendchar(4,49)
DVR_CH2 {formula} ph_comsendchar(4,50)
.
.
.
DVR_ZOOM {formula} ph_comsendchar(4,90)

Then I added buttons to the Control Center pointing to the Macros to be able to manipulate the DVR via a web browser.

Last year I received some great info from TonyNo on how to setup the Aqua Link ( link to forum post ). I am still trying to wrap my mind around how to make it work. I think I need to start with a more simple project and work my way up to the Aqua Link.

If I can get the Onkyo receiver up and running, I think I will have the skill set needed for the rest of the COM port devices. So far I have the following:

Smarty has already posted the Onkyo commands here

MACROS:

OK805_OPEN {formula} ph_comopen( 1, 1, 9600, "N", 8, 1, 1, 0, 0, 0, 0, 1, 1, "?", "OK805_GET_DATA" )

OK805_GET_DATA {formula} I need help with this formula

OK805_PWR_STANDBY {formula} ph_comsendstring(1,"!1PWR00") + ph_comsendstring(1,"\x0D")

OK805_PWR_STANDBY does not change the Onkyo receiver from a powered on state to standby.

Any help would be appreciated.



Edited by rrockoff - March 03 2009 at 13:19
Back to Top View rrockoff's Profile Search for other posts by rrockoff
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: March 03 2009 at 14:53 | IP Logged Quote smarty

Easy question first....to power OFF your receiever, the formula should be:

ph_comsendstring({COM NUM AVR LIVRM},"!1PWR00\013")

Power ON would then be:

ph_comsendstring({COM NUM AVR LIVRM},"!1PWR01\013")

{COM NUM AVR LIVRM} is a global variable I happen to use for my particular com port number.
++++++++++++++++++++++++++++++++++++++++++++++++++
Now, for the harder question (OK805_GET_DATA):

The "OK805_GET_DATA" is the name of the macro that will be called anytime there is data to be read on the open com port => (from this formula) =>ph_comopen( 1, 1, 9600, "N", 8, 1, 1, 0, 0, 0, 0, 1, 1, "?", "OK805_GET_DATA" )

So, what I do is, I leave the com port always open (I open it in the Startup macro. Therefore any change I make with the IR remote or with rs232 can be reported back to PH. See the attached jpg; this is the macro called by my Onkyo receiever. Hope this helps.


Edited by smarty - March 03 2009 at 14:55


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: March 03 2009 at 15:04 | IP Logged Quote smarty

So, in my case the Global Variable {COMTXT AVR LIVING} now contains the Onkyo response receieved from the com port traffic.

By using some programing, I can intrepret what the receiver is telling me. See pict below:



__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
rrockoff
Newbie
Newbie


Joined: June 02 2008
Location: United States
Online Status: Offline
Posts: 13
Posted: March 04 2009 at 13:32 | IP Logged Quote rrockoff

Smarty,

Thanks for the quick reply. I am able to follow your code until I get to line 130. It looks like you are doing something with xlobby. I don't have this program. I was planning on using control center. Can you give me a little more detail on what you are doing starting with line 130?
Back to Top View rrockoff's Profile Search for other posts by rrockoff
 
rrockoff
Newbie
Newbie


Joined: June 02 2008
Location: United States
Online Status: Offline
Posts: 13
Posted: March 04 2009 at 13:58 | IP Logged Quote rrockoff

One more question. If I am already using [TEMP1] and [LOCAL1] in another macro that collects com port data from a different com port, can it be shared or do I have to use a different variable. I think I do, I just need confirmation.
Back to Top View rrockoff's Profile Search for other posts by rrockoff
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: March 04 2009 at 17:50 | IP Logged Quote smarty

rrockoff wrote:
Smarty,

Thanks for the quick reply. I am able to follow your code until I get to line 130. It looks like you are doing something with xlobby. I don't have this program. I was planning on using control center. Can you give me a little more detail on what you are doing starting with line 130?


I happen to use Xlobby as my graphical "front end". Lines 130 and after are used to process/handle the information that was recieved on the com port. You will have to decide what you want to do with the information for your own set up.

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
ficklma1
Groupie
Groupie


Joined: December 08 2007
Location: United States
Online Status: Offline
Posts: 59
Posted: March 05 2009 at 14:11 | IP Logged Quote ficklma1

Smarty,

I'm starting to get into some of the same things you have already built. Thanks for the good screenshots of your macros.
Would it be possible for you to post the macro's related to your com programming?
I too am using Xlobby (last free version). I've modified the Xlobby plugin 'XScriptNG' to call macros/functions running on my PH server from my Xlobby touch screen client. I then use XSend(like you) to update Xlobby button text, graphics, etc. to reflect changes to lights, thermostats, etc. It's the best way I could integrate PH and Xlobby.

Going back to your com programming. I have a Marantz AV receiver that I'm currently communicating with via RS-232. Right now, I'm just sending commands to it and all of that works great. What I'd like to do now is two-way communication, like you've done with your Onkyo.

I don't know if I have this correct=> ph_comopen( 1, 1, 9600, "N", 8, 1, 1, 0, 0, 0, 0, 1, 1, "?", "MACRO_TO_READ_COM_PORT" ).
Lines 20-120 from your first screenshot is what I have in my "MACRO_TO_READ_COM_PORT" macro and I've changed the port setting in line 50 to the port I'm using.
The macro doesn't seem to fire. It appears the ph_comopen command is not firing the "MACRO_TO_READ_COM_PORT" when data should be coming in.

Any ideas? Do I have it wrong?

Thanks for any help you can give.

Edited by ficklma1 - March 05 2009 at 14:40


__________________
Mark
Back to Top View ficklma1's Profile Search for other posts by ficklma1
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: March 05 2009 at 17:29 | IP Logged Quote smarty

Just a couple of thoughts....
1) Make sure macro logging is turned on (setup:log:check the macro box). A restart is required for this to work.

2) Periodically my com ports do lock up. I handle this by creating a timed event called "serial port maintenance". From this timed event, I call a macro that closes my com ports one by one, and then re-opens them. This seems to "clear their brains", and then they resume working fine (I due this twice per day with the timed event - I never notice it happens, and it keep my com ports alive).

3) Can you see any com traffic with other programs such as hyperterminal? If you can't see anything, it it likely not a PH issue.

My com open formula is:
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") which matches yours.

4) Does you Marantz comunicate at 9600, 8, N, 1?

....Out of ideas....

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
ficklma1
Groupie
Groupie


Joined: December 08 2007
Location: United States
Online Status: Offline
Posts: 59
Posted: March 05 2009 at 19:47 | IP Logged Quote ficklma1

Hi Smarty,

I found this ---> ph_comopen( 1, 3, 9600, "N", 8, 1, 1, 0, 0, 1, 0, 1, 1, "?", "" )

under Marantz Amp

The inputmode setting(tenth parameter in ph_comopen)wasn't set to 1.

Thanks for the quick reply. I now have it working!



Edited by ficklma1 - March 06 2009 at 09:16


__________________
Mark
Back to Top View ficklma1's Profile Search for other posts by ficklma1
 
rrockoff
Newbie
Newbie


Joined: June 02 2008
Location: United States
Online Status: Offline
Posts: 13
Posted: March 06 2009 at 16:24 | IP Logged Quote rrockoff

I'm getting closer. For the past two days I have been working on why the macros for my Onkyo receiver will not run.

I have created the macro called OK805_OPEN with the following formula:
ph_comopen( 1, 1, 9600, "N", 8, 1, 1, 0, 0, 0, 0, 1, 1, "?", "OK805_GET_DATA" )
OK805_OPEN has been added as a trigger to run at startup o reinitialization. Verifying the formula comes back with a status of "2" meaning the com port is open.

I have also created these two macros:

OK805_PWR_ON   formula ph_comsendstring(1,"!1PWR01\013")
OK_PWR_STANDBY formula ph_comsendstring(1,"!1PWR00\013")

I have tried multiple times to run these formulas from the drop down menu of the Macro / Formula Run line found just below the button bar. Every time I run it, nothing happens. The Onkyo receiver does not turn on or off and nothing shows up in the event log. I do however see the macro must have run as it shows up in the Execution Queue of PH Stat. I shut down power home and tried attaching with HyperTerminal. With HyperTerminal I can see !1PWR01 when I power on and !1PWR00 when I power off. I have also gone so far as to tone out my Serial cable to make sure pins 2, 3, and 5 are making good contact on both sides of the cable.

After all of this, I have just discovered that if I choose "Verify" from the menu bar of the Formula Builder page, it correctly turns on and off the receiver.



I am using version 2.1b. Anyone have any ideas on why the macro did not run from the Macro Formula / Run line? I can run other macros controlling my DVR using the same Macro Formula / Run line. The only difference I can find is that I am connecting to the DVR using
ph_comopensimple( 4, 4, "57600,N,8,1", "DVR_GET_DATA" )

Thanks in Advance for any ideas.



Edited by rrockoff - March 06 2009 at 16:28
Back to Top View rrockoff's Profile Search for other posts by rrockoff
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum