python-3.x - 我如何使用minimalmodbus在python中实现从属?

标签 python-3.x serial-port modbus minimalmodbus

我正在使用 python minimamlmodbus 库,使用这个库我想实现从站和主站通信,其中我将成为从站,仪器将成为主站

我已经使用minimalmodbus成功实现了主从通信,其中主站是我,从站是仪器。

我使用了以下代码来实现主从通信

            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 

我希望仪器为主,python 接口(interface)为从,这可能吗?

最佳答案

遗憾的是,Minimalmodbus 只能用作 Modbus 主站。我认为 Pymodbus 对于实现 Modbus 从站很有用。请参阅https://pymodbus.readthedocs.io

免责声明:我是 Minimalmodbus 的维护者

关于python-3.x - 我如何使用minimalmodbus在python中实现从属?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55822352/

相关文章:

c# - 串行通信在 Unity 中运行缓慢

c - libmodbus : modbus_mapping_new() not working correctly?

python - Gefran 800P 和 minimalmodbus (Mac) : "ValueError: Too short Modbus RTU response (minimum length 4 bytes). Response: '\x0 0' "

python - 多个服务器 pymodbus 连接问题 Modbus TCP

python-3.x - 如何在Python中使用Gtk中的OpenCV画图

python - 在python中解析双管道分隔文件

python - 运行 python 3.9.4 时,我无法导入 tkinter,但降级到 3.8.2 工作正常

python - 如何在 Tensorflow 中通过改变大小来提供输入

java - jssc没有收到信号

.net - 强制关闭 COM 端口