#!/usr/bin/python
import argparse, sys, time

"""
This program mimics the operation of the arduino receiver:
it emits temperatures measurements using the same formatting as the receiver.
Fake temperature measurements can be generated in whatever way.
"""

def delaying_iterator(iterator, interval=1.5):
  for thing in iterator:
    yield thing
    time.sleep(interval)

def emit(iterator):
  for line in iterator:
    sys.stdout.write(line)
    sys.stdout.flush()

def main(args):
  if not args.fake_input_file:
    raise ValueError("need fake input file")
  with open(args.fake_input_file, 'r') as fake_input:
    emit(delaying_iterator(iter(fake_input)))

if __name__ == '__main__':
  parser = argparse.ArgumentParser()
  parser.add_argument('--fake_input_file', help='file from which to read fake inputs')
  main(parser.parse_args())

@@ -294,9 +294,9 @@
 val=
-1
+0
 .5):
@@ -466,96 +466,165 @@
 def 
-main(args):%0A  if not args.fake_input_file:%0A    raise ValueError(%22need 
+alternating(v1, v2):%0A  idx = 0%0A  values = %5Bv1, v2%5D%0A  while True:%0A    yield values%5Bidx%5D%0A    idx = (idx + 1) %25 2%0A%0Adef main(args):%0A  if args.
 fake
- 
+_
 input
- 
+_
 file
-%22)%0A
+:%0A  
   wi
@@ -677,16 +677,18 @@
 ut:%0A    
+ 
+ 
 emit(del
@@ -720,16 +720,88 @@
 input)))
+%0A  if args.alternating:%0A    emit(delaying_iterator(alternating(10, 20)))
 %0A%0Aif __n
@@ -945,16 +945,137 @@
 nputs')%0A
+  parser.add_argument('--alternating', help='made up data that just alternates between two values', action='store_true')%0A
   main(p

add alternating fake receiver