Age | Commit message (Collapse) | Author | Files | Lines |
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
* Handle zone2sleep command
* Handle multiple messages received simultaneously in a correct fashion
without dropping messages
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
If we can detect that the clock went backwards to any time before our last
recorded sent command, reset some of our stored time values to reflect the
new value of 'now'. This prevents UTC -> localtime switches on my machine
from locking up the daemon for 6 hours in very odd fashion.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Combine certain allocation requests into a single request by inlining the
character buffer and not asking for exact sizes. In other places, use the
stack rather than a malloc/free cycle within a single function, since we
know these allocations are never bigger than 128 bytes anyway.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Add a timeval_positive helper function that doesn't get confused when
tv_usec is set to 0 (regardless of the value of tv_sec). Use it wherever
possible, and also attempt to reason through our other time value comparison
points to ensure all values are being handled correctly, especially those
that result in a zero in a field or a zero difference.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
We can just use POWER_OFF directly.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
It was really silly to have to reparse the message we just generated.
Instead, special case the six possible power messages and update the status
directly when we find of them.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Allocate a non-const set of structs in place, and simply hash the names
at initialization time in place. This prevents the need for any memory
allocation and thus teardown.
This separates the power statuses from the rest so we can attach some
metadata; this will come into play in a future commit that reworks the
way we do update_power_status().
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
No reason not to allow this as they are only used once when passed into
the handler and then tossed anyway.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
And add a clear macro that saves a bit of verbosity.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This emulates what the normal sleep timer does on the receiver.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
We used to only call write_to_connections in the main loop. Now that
this function has been exposed anyway for use by the zone sleep code, it
makes more sense for this to be called directly in the response parsing
code as necessary. This allows us to skip silly allocation for the
response strings, as well as opens up the possibility of having a single
message from the receiver turn into multiple response messages. We take
advantage of this by adding 'OK:dbvolume:-44' type responses in addition
to the 'OK:volume:38' messages already there.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
First off, any memory allocator is going to round these off, so might as
well grab the whole chunk of memory by grabbing 32 or 64 bytes at a
time. Second, we don't need to clear it out first, so use malloc.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This was added in anticipation of the zone sleep commands but ended up going
completely unused; remove it.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
No need to do all the add_command() business; just start with the structs
partially initialized and fill in the hashes on initialization. We no longer
have to free anything either.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This is an easy stat to show in the USR1 signal output dump.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This prevents a long-running timer from acting if the receiver is power
cycled, which should clear the timer.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This is done by tracking the timeval we should shut off the zone, and
setting timeouts appropriately so we are woken up at the point where we need
to issue a power off command.
Note that this has some minor shortfalls compared to the "real" main zone
timer on the receiver itself:
* We don't get every-minute updates on the sleep status- this should not be
that hard to implement
* The receiver knows nothing about this timer, so restarting the daemon will
obviously clear it, and we should be smarter about turning it off if the
zone flips off and on to prevent unexpected power-offs.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
These will be used later by the frontend.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Obviously this hasn't been unit tested or the mixups between iterator and
base pointer would have been more obvious.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Before, we were doing concatination of prefix and suffix in the queuing
portion, and deciding whether to actually send the command in the main loop.
Move as much of this logic as possible into one method to make it easier to
accommodate alternate message formats.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This doesn't fire half the time anyway if the program abruptly exits, and
if you are using the serial port you should definitely be setting it up as
you need and not depending on any preexisting configuration.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This is in anticipation of doing the eISCP network-based control, but I
haven't been too happy with the amount of global state for a while. Get it a
bit more wrapped up in this receiver class, which whether we need it or not,
now allows us to send commands to as many receivers as we want.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
This makes a bit more sense since these are all static functions anyway.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Most of the credit for this goes elsewhere, but I worked it into the
now-existent option parsing framework and listening code. Note that you can
listen on both a UNIX socket and an INET one; there is also only minor
changes necessary to support listening on arbitrary numbers of both.
Original-work-by: Jasmin Buchert <jbuchert@gmail.com>
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Inspiration from Jasmin Buchert again on this one.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Rather that just doing one per select() loop, we can run down the whole
queue to find the first one that we should send.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Move listeners and connections to variable length linked lists instead of
fixed compile-time sized arrays. This gives everything a bit more
flexibility at the cost of a bit more code, but overall it should be a good
step to take. Buffers and structures are allocated on an as-needed basis,
and once they are allocated they will be reused until program exit. There is
still an upper limit on connections at 200 to prevent any kind of DoS
attack, but it could really be raised as high as one wants, and the select()
call is going to be the first thing to topple.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|
|
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
|