Ejemplo n.º 1
0
    fh.setLevel(logging.DEBUG)   # All log messages go to the log file
    sh = logging.StreamHandler()
    sh.setLevel(loglevel)        # Some or all log messages go to the console
    # noinspection PyArgumentList
    logging.basicConfig(handlers=[fh, sh],
                        level=logging.DEBUG,
                        format='%(levelname)s:%(name)s %(created)14.3f - %(message)s')

    from pasd import transport
    from pasd import smartbox

    tlogger = logging.getLogger('T')
    conn = transport.Connection(hostname=None, devicename='COM5', multidrop=False, logger=tlogger, baudrate=19200)

    slogger = logging.getLogger('SB:%d' % 1)
    s = smartbox.SMARTbox(conn=conn, modbus_address=1, logger=slogger)
    print('Polling SMARTbox as "s" on address %d.' % 1)
    s.poll_data()
#    print('Configuring SMARTbox as "s" on address %d.' % 1)
#    s.configure()
#    s.poll_data()
#    print(s)

# System registers
#
# CRC registers.  CRC32 is computed for all registers from ADDRESS to COMMAND, or 10003 - 10125.
# If a command does not write to all registers the CRC is still calculated as if all the registers are initialised with 0
# The CRC is calculated lower byte then upper byte
#
# CRC_LOW 10001
# CRC_HIGH 10002
Ejemplo n.º 2
0
    from sid import mccs

    tlogger = logging.getLogger('T')
    conn = transport.Connection(hostname=args.host,
                                devicename=args.device,
                                port=int(args.portnum),
                                baudrate=19200,
                                multidrop=False,
                                logger=tlogger)

    if args.task.upper() == 'SMARTBOX':
        if args.address is None:
            args.address = 1
        slogger = logging.getLogger('SB:%d' % int(args.address))
        s = smartbox.SMARTbox(conn=conn,
                              modbus_address=int(args.address),
                              logger=slogger)
        print('Polling SMARTbox as "s" on address %d.' % int(args.address))
        s.poll_data()
        print('Configuring SMARTbox as "s" on address %d.' % int(args.address))
        s.configure()
        s.poll_data()
        print(s)
    elif args.task.upper() == 'FNDH':
        if args.address is None:
            args.address = 101
        flogger = logging.getLogger('FNDH:%d' % int(args.address))
        f = fndh.FNDH(conn=conn,
                      modbus_address=int(args.address),
                      logger=flogger)
        print('Polling FNDH as "f" on address %d.' % int(args.address))