summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2015-04-07Fix up a handful of integer conversion warningsHEADmasterDan McGee4-14/+19
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2015-04-07Fix documentation commentsDan McGee1-2/+1
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2015-04-07Clean up defines to work on more platformsDan McGee3-3/+2
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-22Simplify hash functionDan McGee1-1/+1
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-22Documentation updatesDan McGee3-2/+7
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-22Frontend updatesDan McGee1-86/+147
* Handle zone2sleep command * Handle multiple messages received simultaneously in a correct fashion without dropping messages Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-22Send final sleep update before zone 2/3 power offDan McGee1-0/+2
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-29Work around negative clock changesDan McGee1-10/+26
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>
2012-01-29Reduce number of memory allocationsDan McGee3-22/+22
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>
2012-01-29Memory allocation related cleanupsDan McGee1-7/+21
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-29Convert listeners to a flat arrayDan McGee1-52/+56
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-21Remove unnecessary includesDan McGee1-2/+0
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-21Fix some faulty timeval related math and comparisonsDan McGee3-14/+30
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>
2011-11-20Remove mostly useless methodDan McGee2-10/+1
We can just use POWER_OFF directly. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-20Remove parenthesis around return valuesDan McGee4-62/+62
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-20Update last sent command on success or failureDan McGee1-2/+2
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-20Convert inputs and modes to use hashed values for lookupDan McGee1-69/+87
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-20Small code cleanupsDan McGee4-2/+8
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-20Make strtoupper return voidDan McGee1-4/+3
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-16Revamp the way power status is keptDan McGee4-21/+22
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>
2011-11-16Treat receiver status messages the same way we do commandsDan McGee4-199/+207
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>
2011-11-16Allow manipulation of the passed-in args from the command handlerDan McGee1-29/+25
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>
2011-11-16Consolidate timeval helper functions into util.cDan McGee5-50/+51
And add a clear macro that saves a bit of verbosity. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-16Write zone sleep status messages at 60-second intervalsDan McGee3-17/+64
This emulates what the normal sleep timer does on the receiver. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-16Push write_to_connections() calls deeper into the stackDan McGee3-46/+53
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>
2011-11-16Simplify to-the-byte calloc() allocationsDan McGee1-11/+9
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>
2011-11-15Remove fake command parameterDan McGee1-52/+47
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>
2011-11-15Simplify command setupDan McGee2-98/+54
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>
2011-11-15Simplify some of the zone sleep codeDan McGee2-28/+25
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-14Keep track of sent command and received message countDan McGee3-4/+10
This is an easy stat to show in the USR1 signal output dump. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-11-14Clear zone sleep timer state when power is switched offDan McGee3-13/+18
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>
2011-11-14Implement an in-daemon timer for zone2 and zone3 sleep commandsDan McGee3-60/+174
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>
2011-04-06Remove -fwhopr from compile flagsDan McGee1-3/+2
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-04-06Use fixed point parsing for FM frequenciesDan McGee1-4/+10
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-04-06Fix uninitialized variable warningDan McGee1-1/+1
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Add audyssey and dyneq commandsJasmin Buchert1-0/+2
These will be used later by the frontend. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Fix some problems with address resolutionDan McGee1-6/+5
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>
2011-01-21Move most receiver sending logic into rcvr_send_command()Dan McGee4-103/+89
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>
2011-01-21Remove termios reset codeDan McGee2-9/+0
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>
2011-01-21Receiver global state refactorDan McGee3-229/+293
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>
2011-01-21Re-order functions so we can remove forward declarationsDan McGee1-133/+112
This makes a bit more sense since these are all static functions anyway. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Move a few enums aroundDan McGee2-4/+4
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Add ability to listen on UNIX socketDan McGee1-27/+105
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>
2011-01-21Rename open_listenerDan McGee1-3/+3
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Add help/usage instructionsDan McGee1-1/+33
Inspiration from Jasmin Buchert again on this one. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Discard all commands if receiver power is offDan McGee1-20/+34
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>
2011-01-21Add quit commandDan McGee2-3/+11
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2011-01-21Add sentinal struct to end of opts arrayDan McGee1-0/+1
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2010-10-22Remove arbitrary MAX_* restrictionsDan McGee2-75/+130
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>
2010-10-22Update copyrightsDan McGee4-4/+4
Signed-off-by: Dan McGee <dpmcgee@gmail.com>