Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stopping a program
#1
All,
Thanks for all the great software and documentation in the SIP system.

I'm working on a local control plugin using an encoder with pushbutton, and an LCD, directly connected to the RPi. So far the plugin can show station status (which stations are on and the time-to-go), turn a station on or off (manual mode), and start a program. I plan to include the ability to display station solenoid current (using a current transformer, a bit of circuitry, and an I2C-connected A-to-D converter). I know this probably wouldn't have much appeal to people due to the amount of hardware work necessary, but it serves a purpose for me.

I have things working pretty well, and am using http GET to control the SIP system from the plugin.

I have a few questions:
  1. Is the http GET interface the recommended way to control things from a plugin?
  2. Some GET commands need a password, which requires the plugin to know the password. I see the gv module contains a password hash. Is there a way to use this from the GET interface?
  3. I'd like my plugin to be able to stop a currently-running program, but I don't see that capability in the GET command reference. Is there a way to do this?
I also encountered an unhandled exception in sip.py when I accidentally tried to turn on the master station via the http GET api. I know this isn't a valid operation, but thought I'd report it anyway. The error was:
Code:
Unhandled exception in thread started by <function timing_loop at 0x7670d7c8>
Traceback (most recent call last):
  File "sip.py", line 172, in timing_loop
    gv.srvals[masid] = 1
UnboundLocalError: local variable 'masid' referenced before assignment

Thanks a lot for all the work you've all put into this system. I look forward to putting it to use.

Karl
Reply
#2
Hi Karl,

To answer your questions:

1. The http GET interface is a valid way to control SIP. You should also be able to change variables from a plugin.
See the gv_reference.txt file in the SIP folder for a list with descriptions of SIP's variables.

2. A password is only required if password in enabled on the Options page. SIP's password feature provides very minimal security and can be left disabled without a problem. It is only useful for keeping e.g. children from accessing the system. If password in enabled you would need to provide it as plain text in the GET command.

3. The GET command for stopping a program would be /cv?rsn=1  It has the effect of clicking the "stop all stations" button on the home page in auto mode but works in manual mode also. It can be found under "Change controller values"

Thanks for reporting the exception. I pushed a fix for the error you reported to GitHub.

Good luck with your project.

Dan
<p><br></p>
Reply
#3
(2019 Dec 23, 07:40 PM)dan Wrote: 1. The http GET interface is a valid way to control SIP. You should also be able to change variables from a plugin.
See the gv_reference.txt file in the SIP folder for a list with descriptions of SIP's variables.
Dan,

Thanks for the reply.

I am reading some of the gv values, but was hesitant to freely change gv values out of concern for race conditions or other possible problems. My plugin uses a separate thread to monitor hardware switches, and actions happen from that thread.
Are there some gv values that should't be changed from a plugin, or should only be done using locks?

Karl
Reply
#4
I can't think of any restrictions on changing GV values from a plugin.

And for sure any that can be changed with a GET command would not be a problem.

Dan
<p><br></p>
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)