I am a beginner in Python (FYI) and trying to communicate with the Gefran 800P programmer/controller using minimalmodbus library (Python + Mac). I am using USB to RS485 Serial Converter Cable (http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_USB_RS485_CABLES.pdf) to communicate with the Gefran device. Pins from the rear of the device (15+17(Rx+Tx) & 16+18(Gnd+Gnd)) are connected to Data +(A) and Data -(B) of the converter cable, respectively (RS485-2wired connection). I don't know the slave address for this device and there is no where mentioned about the address in the manual (http://www.primusthai.com/marketing/Gefran%20800%20(Controller).pdf).
I have tried:
- Changing address of the slave form 0 to 247 and I always get the same message.
- Tried checking for different register address and played around with function codes (3&4), played around with the programmer settings making sure both parameters in the code and the device are the same. Nothing works! Maybe I am missing something. Looking forward for your help. I am really stuck at this point for more than a week now!
Below is my code and when I run it, it gives me an error "ValueError: Too short Modbus RTU response (minimum length 4 bytes). Response: '\x00' ".
import minimalmodbus
import serial
import sys
import time
import sh
minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL = False
print "scanning for addresses..."
for i in range(1,247):
programmer = minimalmodbus.Instrument('/dev/tty.usbserial-FT0C9E5S', i, 'rtu')
print "address is", i
programmer.mode = minimalmodbus.MODE_RTU
programmer.serial.timeout = 8
programmer.handle_local_echo = False
# If RS-485 adapter has local echo enabled
programmer.serial.bytesize = 8
programmer.precalculate_read_size = True
programmer.serial.baudrate = 9600
programmer.serial.parity = minimalmodbus.serial.PARITY_NONE
programmer.debug = True
print "all parameters set... now reading"
print programmer
try:
setpoint = programmer.read_register(79,1,4)
print setpoint
print "This is the address", i
except sh.ErrorReturnCode_1:
print "no response"