예제 #1
0
    import queue
except ImportError:
    import Queue as queue


def assemble_radio_packet(transmitter_id):
    return RadioPacket.create(rorg=RORG.BS4,
                              rorg_func=0x20,
                              rorg_type=0x01,
                              sender=transmitter_id,
                              CV=50,
                              TMP=21.5,
                              ES='true')


init_logging()
communicator = SerialCommunicator()
communicator.start()
print('The Base ID of your module is %s.' %
      enocean.utils.to_hex_string(communicator.base_id))

if communicator.base_id is not None:
    print('Sending example package.')
    communicator.send(assemble_radio_packet(communicator.base_id))

# endless loop receiving radio packets
while communicator.is_alive():
    try:
        # Loop to empty the queue...
        packet = communicator.receive.get(block=True, timeout=1)
예제 #2
0
def main():
    '''
    PyMulti main
    '''
    print('PyMulti...')
    logger = logging.getLogger('enocean.PyMulti.main')

    try:
        import queue
    except ImportError:
        import Queue as queue

    #init_logging(level=logging.NOTSET)
    #init_logging(level=logging.DEBUG)
    #init_logging(level=logging.INFO)
    init_logging(level=logging.WARNING)

    sc = SystemControl()
    sc.setup()
    #usage = Usage()
    #usage.printall()

    logger.debug('jsfile:<%s>' % sc.json_file)

    eep = Profile(sc.json_file)
    eep.convert()

    for k, v in sc.point_lists.items():
        eep.add_outitems(k, 1)

    #eep.print_outitems()
    #eep.print_datafields()
    #print()

    #print('flags')
    #sc.print_flagall()
    #print()

    #print('points')
    #sc.print_pointall()
    #print()

    #print('json_file')
    #print(sc.json_file)
    #print()

    communicator = SerialCommunicator(port='/dev/ttyUSB0')
    communicator.start()

    # endless loop receiving radio packets
    while communicator.is_alive():
        try:
            # Loop to empty the queue...
            packet = communicator.receive.get(block=True, timeout=1)

            #if packet.packet_type == PACKET.RADIO_ERP2:
            #    print('Packet ERP2: %02X' % packet.rorg)

            #print('*** packet ***')
            #print(packet)
            #print('***        ***')

            if packet.packet_type == PACKET.RADIO_ERP2:
                if packet.rorg == RORG.VLD:
                    #print('ERP2 VLD found')

                    if len(packet.data) == 15:
                        # shuld be a multi sensor
                        #print('@%s' % ([hex(o) for o in packet.data]))
                        eep.operation(sc, packet.data[5:])

                elif packet.rorg == RORG.BS4:
                    print('ERP2 4BS found')
                    ## parse packet with given FUNC and TYPE
                    #for k in packet.parse_eep(0x02, 0x05):
                    #    print('%s: %s' % (k, packet.parsed[k]))

                elif  packet.rorg == RORG.BS1:
                    # alternatively you can select FUNC and TYPE explicitely
                    print('ERP2 1BS found')
                    #packet.select_eep(0x00, 0x01)
                    ## parse it
                    #packet.parse_eep()
                    #for k in packet.parsed:
                    #    print('%s: %s' % (k, packet.parsed[k]))

                elif packet.rorg == RORG.RPS:
                    print('ERP2 RPS found')
                    #for k in packet.parse_eep(0x02, 0x02):
                    #for k in packet.parse_eep(0x02, 0x04): #Japan, 928MHz (F6-02-04)
                    #    print('%s: %s' % (k, packet.parsed[k]))

                elif packet.rorg == RORG.UTE:
                    print('ERP2 UTE found')

                else:
                    print('ERP2 unkown packet')

        except queue.Empty:
            continue
        except KeyboardInterrupt:
            break
        except Exception:
            traceback.print_exc(file=sys.stdout)
            break

    if communicator.is_alive():
        communicator.stop()
예제 #3
0
try:
    import queue
except ImportError:
    import Queue as queue


def assemble_radio_packet(transmitter_id):
    return RadioPacket.create(rorg=RORG.BS4, rorg_func=0x20, rorg_type=0x01,
                              sender=transmitter_id,
                              CV=50,
                              TMP=21.5,
                              ES='true')


init_logging()
communicator = SerialCommunicator()
communicator.start()
print('The Base ID of your module is %s.' % enocean.utils.to_hex_string(communicator.base_id))

if communicator.base_id is not None:
    print('Sending example package.')
    communicator.send(assemble_radio_packet(communicator.base_id))

# endless loop receiving radio packets
while communicator.is_alive():
    try:
        # Loop to empty the queue...
        packet = communicator.receive.get(block=True, timeout=1)

        if packet.packet_type == PACKET.RADIO and packet.rorg == RORG.BS4:
예제 #4
0
from enocean.protocol.constants import PACKET, RORG

try:
    import queue
except ImportError:
    import Queue as queue

#def assemble_radio_packet(transmitter_id):
#    return RadioPacket.create(rorg=RORG.BS4, rorg_func=0x20, rorg_type=0x01,
#                              sender=transmitter_id,
#                              CV=50,
#                              TMP=21.5,
#                              ES='true')

#init_logging(level=logging.NOTSET)
init_logging(level=logging.DEBUG)
#init_logging(level=logging.INFO)
#init_logging(level=logging.WARNING)

communicator = SerialCommunicator(port='/dev/ttyUSB0')
communicator.start()
#print('The Base ID of your module is %s.' % enocean.utils.to_hex_string(communicator.base_id))

#if communicator.base_id is not None:
#    print('Sending example package.')
#    communicator.send(assemble_radio_packet(communicator.base_id))

# endless loop receiving radio packets
while communicator.is_alive():
    try:
        # Loop to empty the queue...