Esempio n. 1
0
def CONNECT_TO_METER():

    try:
        client = None
        METER_PORT = find_tty_usb(ID_VENDOR, ID_PRODUCT)        #reading to which port rs485(client) is connected
        client = ModbusClient(retries = RETRIES, method=COM_METHOD, port=METER_PORT, baudrate=BAUD_RATE, stopbits=STOP_BITS, parity=PARITY, bytesize=BYTE_SIZE, timeout=TIME_OUT)
        client.connect()
        return client

    except Exception as e:
        lgr.error('Error while connecting client: ', exc_info = True)
        print "Error while connecting client: \n"+e.__str__()
Esempio n. 2
0
def CONNECT_TO_METER():

    try:
        client = None
        METER_PORT = find_tty_usb(ID_VENDOR, ID_PRODUCT)        #reading to which port rs485(client) is connected
        client = ModbusClient(retries = RETRIES, method=COM_METHOD, port=METER_PORT, baudrate=BAUD_RATE, stopbits=STOP_BITS, parity=PARITY, bytesize=BYTE_SIZE, timeout=TIME_OUT)
        client.connect()
        return client

    except Exception as e:
        print "Could not connect to client: \n" + e.__str__()
        log_file=open(DATA_BASE_PATH+"RealtimeLOG.txt","a")
        log_file.write(str(time.time())+" Could not connect to client: \n"+e.__str__()+"\n")
        log_file.close()
Esempio n. 3
0
def CONNECT_TO_METER():

    try:
        client = None
        METER_PORT = find_tty_usb(
            ID_VENDOR,
            ID_PRODUCT)  #reading to which port rs485(client) is connected
        client = ModbusClient(retries=RETRIES,
                              method=COM_METHOD,
                              port=METER_PORT,
                              baudrate=BAUD_RATE,
                              stopbits=STOP_BITS,
                              parity=PARITY,
                              bytesize=BYTE_SIZE,
                              timeout=TIME_OUT)
        client.connect()
        return client

    except Exception as e:
        lgr.error('Error while connecting client: ', exc_info=True)
        print "Error while connecting client: \n" + e.__str__()