admin管理员组文章数量:1335595
I'm having problem with minimalmodbus library. The slave does not recognise the functioncode and shows ErrorSlave reported illegal function, I want to request a read on an input register. I'm using the Raspberry Pi 4 Model B. I'm using the Geolux RSS-2-300WL Flow Rate Sensor as a slave.
What i did is mention the functioncode=4.
#!/usr/bin/env python3
# Import all library needed
import minimalmodbus
import serial
import time
import logging
# Configuration of the sensor
geolux = minimalmodbus.Instrument('/dev/ttySC0', 1) #(port number, slave ID)
geolux.serial.baudrate = 9600
geolux.serial.bytesize = 8
geolux.serial.parity = serial.PARITY_EVEN
geolux.serial.stopbits = 1
geolux.serial.timeout = 1
# Main Loop
try:
while True:
try:
# Read raw reading for water level
water_level_raw = geolux.read_register(0x0012,2,functioncode=4) #(address register, byte read)
print(f"Raw water level: {water_level_raw}")
The error is:
The data sheet from the device manual is:
本文标签: pythonminimalmodbus ErrorSlave reported illegal functionStack Overflow
版权声明:本文标题:python - minimalmodbus ErrorSlave reported illegal function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742385017a2464858.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论