相关文章推荐
仗义的竹笋  ·  UnmanagedType Enum ...·  1 月前    · 
傻傻的小蝌蚪  ·  HTMLCanvasElement: ...·  8 月前    · 
买醉的野马  ·  Java动态任务监控 ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am using python minimamlmodbus library using this library i want to achieve slave and master communication in which i am going to be slave and the instrument will be master

I have successfully achieve master and slave communication using minimalmodbus in which,master was me and slave was the instrument.

i have used the following code to achieve master and slave communication

            ser=minimalmodbus.Instrument(port_to_connect,1,'ascii')
            ser.serial.baudrate=baudrate
            ser.serial.bytesize=8
            ser.serial.parity=serial.PARITY_NONE
            ser.serial.stopbits=1
            ser.debug=False
            ser.serial.timeout=3
            #gui()
            while self._stopped:
                time.sleep(1)
                data=ser.read_string(4096,33,3)
                print(str(data))
            self.finished.emit()
            self._stopped=True 

I want the instrument to be master and the python interface be slave is it possible.

Minimalmodbus can only be used as a Modbus master, unfortunately. I think that Pymodbus is useful for implementing a Modbus slave. See https://pymodbus.readthedocs.io

Disclaimer: I am the maintainer of Minimalmodbus

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.