Locking ports

Related to the development libraries, released by Curt Binder
Post Reply
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Locking ports

Post by lnevo »

Inspired by binder's port locking within the android app, I wanted to code something tin the ino to make sure some ports (dosers) don't get overridden by mistake. The problem is I can reset th masks as a last step in the loop, but ShowInterface calls Refresh which gets e wifi data and also does the Relay.write. So there would always be a split second where the port was on. Any thoughts or suggestions?
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Locking ports

Post by binder »

I think Roberto has a new override feature that will help address this issue, but I am not 100% positive.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Locking ports

Post by rimai »

The new override is for PWM signals....
Maybe create an array of ports that are locked?
Just like what we have for FeedingModePorts, WaterChangePorts and others?
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

Yeah, another array is fine. Just want to make sure the masks are cleared for anything that should not get masked :)
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Locking ports

Post by rimai »

Cool!!!
Send me another pull request.
Just to make sure that this is not going to increase size on the preloaded code, this feature needs to within a define too, just like you did the other one. :)
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Locking ports

Post by lnevo »

Uhm...not sure how to do the bitwise operations for that...
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Locking ports

Post by binder »

lnevo wrote:Uhm...not sure how to do the bitwise operations for that...
Just use the FeedingPorts or WaterChangePorts as examples. It's pretty straight forward.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Locking ports

Post by lnevo »

Ok need a check on my binary math..I have everything in place just need to verify the following..

OverridePorts = B00110010

RelayMaskOff |= OverridePorts;
RelayMaskOn &= ~OverridePorts;

I think that should do it...

Thanks for the review :)
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Locking ports

Post by lnevo »

This was my test calculations..

/* put code here
override 00000011
|MaskOff 11110010
result 11110011

~override 11111100
&MaskOn 00011001
result 00011000
*/
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Locking ports

Post by lnevo »

Ok the code is ready to go, just need to try and compile it later...

Usage would look like this:

ReefAngel.AddPortOverrides();
ReefAngel.OverridePorts = B00011001; // Ports 1, 4, and 5
ReefAngel.OverridePortsE[0] = Port1bit | Port2Bit;

Now those ports will only work with On(); Off;

Any relay mask applied would be ignore (but still in place...)

Also if you set the variable within the loop() function, you could use a memory flag to enable/disable the lock by changing the variable :)

I'll work on the pull request soon :) and change my ino to use this :)
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

Pull request created.. I hate git.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

lnevo wrote:Ok need a check on my binary math..I have everything in place just need to verify the following..

OverridePorts = B00110010

RelayMaskOff |= OverridePorts;
RelayMaskOn &= ~OverridePorts;

I think that should do it...

Thanks for the review :)
bump
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Locking ports

Post by binder »

I see you used "OverridePorts" as the variable name. This to me sounds like the ports that you can override. I'm thinking this is the opposite of what you were intending. The ports you specify are the ones that are Locked and not able to be overridden, correct? Or do I have this backwards?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

The principle was that if you Override the ports they can not be masked... the override will block the relaymask.

The idea was to override the user input and only allow the programming of the ports via on/off.

Sorry for the confusing naming... the pull request is already put in and the whole process confuses the hell out of me. Feel free to change the names, functions, whatever.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

How about the math? :)
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Locking ports

Post by binder »

lnevo wrote:How about the math? :)
I "think" it looks correct but Roberto should be able to confirm. I always get confused when looking at the relayon/off masks for some reason.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Locking ports

Post by rimai »

Looks good to me.
Have you tested?
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

Nope :) I can't load my code until I get some additional hardware because I've mode a hundred million changes :) But I put the changes right before the Relay.Write and it all compiles. I'm pretty confident :)
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Locking ports

Post by lnevo »

Tested. Working :) Sending you a diff patch because me and git have issues!
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Post by binder »

lnevo wrote:Tested. Working :) Sending you a diff patch because me and git have issues!
nice. way to improvise. :mrgreen:
enigma32
Posts: 74
Joined: Fri Apr 26, 2013 11:48 am
Location: Los Angeles and NYC

Re: Locking ports

Post by enigma32 »

<aside>You're not alone... using git is like having my teeth pulled</aside> ;)
Current setup:
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel
Post Reply