How to use the minimalmodbus.MODE_RTU function in minimalmodbus

To help you get started, we’ve selected a few minimalmodbus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyhys / minimalmodbus / tests / test_deltaDTB4824.py View on Github external
def parse_commandline(argv):
    # Do manual parsing of command line,
    # as none of the modules in the standard library handles python 2.6 to 3.x

    mode = minimalmodbus.MODE_RTU
    baudrate = DEFAULT_BAUDRATE
    portname = DEFAULT_PORT_NAME

    for arg in argv:
        if arg.startswith("-ascii"):
            mode = minimalmodbus.MODE_ASCII

        elif arg.startswith("-rtu"):
            mode = minimalmodbus.MODE_RTU

        elif arg.startswith("-b"):
            if len(arg) < 3:
                _print_out("Wrong usage of the -b option. Use -b9600")
                sys.exit()
            baudrate = int(arg[2:])
github pyhys / minimalmodbus / tests / test_deltaDTB4824.py View on Github external
def parse_commandline(argv):
    # Do manual parsing of command line,
    # as none of the modules in the standard library handles python 2.6 to 3.x

    mode = minimalmodbus.MODE_RTU
    baudrate = DEFAULT_BAUDRATE
    portname = DEFAULT_PORT_NAME

    for arg in argv:
        if arg.startswith("-ascii"):
            mode = minimalmodbus.MODE_ASCII

        elif arg.startswith("-rtu"):
            mode = minimalmodbus.MODE_RTU

        elif arg.startswith("-b"):
            if len(arg) < 3:
                _print_out("Wrong usage of the -b option. Use -b9600")
                sys.exit()
            baudrate = int(arg[2:])

        elif arg.startswith("-D"):
            if len(arg) < 3:
                _print_out(
                    "Wrong usage of the -D option. Use -D/dev/ttyUSB0 or -DCOM4"
                )
                sys.exit()
            portname = arg[2:]

    return portname, mode, baudrate
github samuelphy / energy-meter-logger / read_energy_meter.py View on Github external
def collect_and_store(self):
        #instrument.debug = True
        meters = self.get_meters()
        t_utc = datetime.utcnow()
        t_str = t_utc.isoformat() + 'Z'

        instrument = minimalmodbus.Instrument('/dev/ttyAMA0', 1) # port name, slave address (in decimal)
        instrument.mode = minimalmodbus.MODE_RTU   # rtu or ascii mode
        datas = dict()
        meter_id_name = dict() # mapping id to name

        for meter in meters:
            meter_id_name[meter['id']] = meter['name']
            instrument.serial.baudrate = meter['baudrate']
            instrument.serial.bytesize = meter['bytesize']
            if meter['parity'] == 'none':
                instrument.serial.parity = minimalmodbus.serial.PARITY_NONE
            elif meter['parity'] == 'odd':
                instrument.serial.parity = minimalmodbus.serial.PARITY_ODD
            elif meter['parity'] == 'even':
                instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
            else:
                log.error('No parity specified')
                raise
github Haschtl / RealTimeOpenControl / RTOC / plugins / DPS5020.py View on Github external
#################################################################################
        # os.system("sudo chmod a+rw /dev/ttyUSB0")
        # #######
        # uncomment this line if you do not set device rules:
        # > sudo nano /etc/udev/rules.d/50-myusb.rules
        # > * SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="users", MODE="0666"
        # > [Strg+O, Strg+X]
        # > sudo udevadm control --reload
        # Ref: http://ask.xmodulo.com/change-usb-device-permission-linux.html
        #################################################################################
        try:
            self.__powerSupply = minimalmodbus.Instrument(self.portname, 1)
            self.__powerSupply.serial.baudrate = self.__serialBaudrate
            self.__powerSupply.serial.bytesize = self.__serialByteSize
            self.__powerSupply.serial.timeout = self.__serialTimeOut
            self.__powerSupply.mode = minimalmodbus.MODE_RTU
            # -------------
            return True
        except:
            tb = traceback.format_exc()
            print(tb)
            return False
github Chemios / chemios / chemios / temperature_controllers / _omega.py View on Github external
def __init__(self, port, slave_address):
        self.controller = minimalmodbus.Instrument(port, slave_address, mode=minimalmodbus.MODE_RTU)
        #Try a command to see if the instrument works
        self.controller.read_register(temperature_setpoint_register, numberOfDecimals=1 )
github lambcutlet / DPS5005_pyGUI / source_files / dps_modbus.py View on Github external
def __init__(self, port1, addr, baud_rate, byte_size ):
		self.instrument = minimalmodbus.Instrument(port1, addr) # port name, slave address (in decimal)
		#self.instrument.serial.port          # this is the serial port name
		self.instrument.serial.baudrate = baud_rate   # Baud rate 9600 as listed in doc
		self.instrument.serial.bytesize = byte_size
		self.instrument.serial.timeout = 0.5     # This had to be increased from the default setting else it did not work !
		self.instrument.mode = minimalmodbus.MODE_RTU  #RTU mode
github MFxMF / SDM630-Modbus / plugin.py View on Github external
def onStart(self):
        self.rs485 = minimalmodbus.Instrument(Parameters["SerialPort"], int(Parameters["Mode2"]))
        self.rs485.serial.baudrate = Parameters["Mode1"]
        self.rs485.serial.bytesize = 8
        self.rs485.serial.parity = minimalmodbus.serial.PARITY_NONE
        self.rs485.serial.stopbits = 1
        self.rs485.serial.timeout = 1
        self.rs485.debug = False
                          

        self.rs485.mode = minimalmodbus.MODE_RTU
        devicecreated = []
        Domoticz.Log("Eastron SDM630 Modbus plugin start")
        self.runInterval = int(Parameters["Mode3"]) * 1 
        if 1 not in Devices:
            Domoticz.Device(Name="Voltage L1", Unit=1,TypeName="Voltage",Used=0).Create()
        if 2 not in Devices:
            Domoticz.Device(Name="Voltage L2", Unit=2,TypeName="Voltage",Used=0).Create()
        if 3 not in Devices:
            Domoticz.Device(Name="Voltage L3", Unit=3,TypeName="Voltage",Used=0).Create()
        if 4 not in Devices:
            Domoticz.Device(Name="Current L1,L2,L3", Unit=4,TypeName="Current/Ampere",Used=0).Create()
        if 5 not in Devices:
            Domoticz.Device(Name="Active Power L1", Unit=5,TypeName="Usage",Used=0).Create()
        if 6 not in Devices:
            Domoticz.Device(Name="Active Power L2", Unit=6,TypeName="Usage",Used=0).Create()
        if 7 not in Devices: