Revision a7721fb9
Added by David Sorber about 13 years ago
| 525.743/code/rpi_client.py | ||
|---|---|---|
|
for idx in xrange(NUM_SENSORS):
|
||
|
print '\t Sensor %d: %d' % (idx + 1, temps[idx])
|
||
|
|
||
|
# Create the SensorReading object before we sort the temps
|
||
|
reading = SensorReading(now, temps[0], temps[1], temps[2],
|
||
|
temps[3], relay_state)
|
||
|
|
||
|
# Sort all the temperature readings for easier manipulation
|
||
|
temps.sort(reverse=True)
|
||
|
|
||
| ... | ... | |
|
if DEBUG:
|
||
|
print 'Sending reading to server...',
|
||
|
sys.stdout.flush()
|
||
|
reading = SensorReading(now, temps[0], temps[1], temps[2],
|
||
|
temps[3], relay_state)
|
||
|
try:
|
||
|
s.sendall(cPickle.dumps(reading))
|
||
|
if DEBUG:
|
||
Fixing a bug that I just noticed while doing a dry run. The client sorts the temps before creating the SensorReading object so the correct temps don't correspond to the correct sensors on the server. The fix was simply to create the SensorReading object sooner before the temps are sorted.