Author |
|
narc Groupie
Joined: November 21 2006 Location: United States
Online Status: Offline Posts: 49
|
Posted: January 25 2007 at 01:03 | IP Logged
|
|
|
I have a for you all
How to I open up the serial port and trigger an event (OnComm in VB, I think) so that I can parse the string that arrived when it arrived?
If not possible, what is the most processor economical way of tapping PH on the shoulder (triggering it) from an outside application? I figure I can write a simple VB app to open the comm port, then OnComm can hand the string off to PH to process.
- jason
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 25 2007 at 07:35 | IP Logged
|
|
|
The CallerID macro opens the com port and responds to incoming data. Take a look at that thread.
|
Back to Top |
|
|
narc Groupie
Joined: November 21 2006 Location: United States
Online Status: Offline Posts: 49
|
Posted: January 25 2007 at 11:27 | IP Logged
|
|
|
Got it! So you do a ph_comopen and specify the macro to be called when characters are received. Then in the macro you do ph_comrecvchar() to process the characters.
Looks great. Just one problem. I see that PH only supports comm 1-5, but I have lots of USB->Serial adapters on my HA server. I need support for comm 1-15'ish. Is there a way to work around this limitation?
- jason
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: January 25 2007 at 12:34 | IP Logged
|
|
|
Jason,
The ph_com??? functions support any COM port. The 1 thru 5 is the number of the COM control (I know, it's confusing). You can think of it as PowerHome has an array of 1 to 5 COM controls available for use. Each of those 5 COM controls can open whatever COM port number you like. It sounds as if the biggest problem you'll have is the current limitation of only 5 user COM controls. You can of course reuse them, but if you need more than 5 open at any one time, you'll have a problem.
I plan to fix this though with the next beta. The generic plugin interface will allow me to create a general COM port plugin (or any other user to as well) and then a user can open this plugin as many times as they need.
Dave.
|
Back to Top |
|
|
narc Groupie
Joined: November 21 2006 Location: United States
Online Status: Offline Posts: 49
|
Posted: January 25 2007 at 15:22 | IP Logged
|
|
|
Oh I see... makes sense. Com1-Com5 is a handle to an actual comm port. Ok, I can live with that.
I do look forward to the next beta because having more than 5 handles would rock.
- jason
|
Back to Top |
|
|
onhiatus Senior Member
Joined: May 12 2004 Location: United States
Online Status: Offline Posts: 279
|
Posted: January 29 2007 at 15:40 | IP Logged
|
|
|
Jason, it's also super easy to send a windows message to PH. I ended up going this route when I needed to parse a serial stream as powerhome macros can get pretty messy.
Basically you set up a trigger in powerhome and do whatever you want with the data sent. See Topic: Using windows messaging to send to PH for more info...
|
Back to Top |
|
|