Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Direct SQL to change com port Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: February 28 2013 at 21:29 | IP Logged Quote gg102

I have PH running on two systems, my primary and my backup computer. I want to make the macros/code as transparent as possible. I have code to determine which system it’s running on, and it makes various adjustments accordingly. The last remaining one is to change the port for the CM11A controller. Currently I have to manually go to PH explorer/Setup/Controllers and click “settings” and change the port number then click “DONE”.

So, I got this brain storm to do a direct SQL to automatically change the port.

Let’s say I want to change the X10 controller port from 3 to 5.

If I execute the following direct SQL
Ph_sql(1," select * from ctlrparms where parm = 'port' ")
Formula evaluates to: data(CM11A_1”,”port”,”3”,)
Ok, all good. Port = 3

Then when I do the update:
Ph_sql( 1, “update ctlrparms set value = 5 where parm = 'port' " )
Formula evaluates to: data()

Seemingly all good, BUT if I go to PH explorer/Setup/Controllers and click “settings” I can see the new port of 5, but when I press “DONE” it locks PH. I have to go to the task manager to end the program.

No matter what change I make, 1 to 1, 3 to 5, it locks PH tight.

When I restart PH, it has the old value, not the new one. Seemingly it didn’t update/flush/write the new value.

Am I doing something wrong?
Back to Top View gg102's Profile Search for other posts by gg102
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 28 2013 at 21:49 | IP Logged Quote dhoward

gg102,

Assuming the ID of your CM11A is "CM11A_1", try this formula instead:

Code:

ph_directsql("update ctlrparms set value = '5' where id = 'CM11A_1' and parm = 'port'")


Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: February 28 2013 at 21:52 | IP Logged Quote gg102

Dave, you d'man !

That worked perfectly!

Thank you
Back to Top View gg102's Profile Search for other posts by gg102
 

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