import minimalmodbus

def find_slaveaddress(portname):
    instrument = minimalmodbus.Instrument(portname, slaveaddress=247)
    instrument.serial.baudrate = 9600
    instrument.serial.timeout = 0.2

    for address in range(0x01, 0xf8):
        instrument.address = address
        try:
            value = instrument.read_register(0x13b3)
            print(value)
        except:
            pass

