#!/usr/bin/python3

import json
from sender import Sender
from reader import Reader

import time
import logging

PORT = '/dev/ttyUSB0'
BAUD = 9600

reader = Reader(port=PORT, baud=BAUD)
sender = Sender(port=PORT, baud=BAUD)
i = int(0)

while(1):
    presence = json.loads(reader.getData())['presence']

    if(presence == True & i < 2):
        sender.alimentar()
        logging.info('ALIMENTADO.\n')
        i + 1

    if(i == 2):
        i = int(0)
        time.sleep(3600)