Data format error when writing to a register

Hi i have some simple code which reads and writes to a Sofar inverter. Its written C# using NModbus. Yesterday it was working fine but today its giving me an error when writing to an address. Acceptable values should be 0 to 3, 0 works but 1,2&3 give an invalid data format error. Given it was working yesterday but not today i'm a bit lost...


public void TestWriteRegister()
{
SerialPort port = new("COM2")
{
// configure serial port
BaudRate = 9600,
DataBits = 8,
Parity = Parity.None,
StopBits = StopBits.One
};
port.Open();

ModbusFactory factory = new();
IModbusMaster master = factory.CreateRtuMaster(port);

var res = master.ReadHoldingRegisters(1, 0x1200, 1);

master.WriteMultipleRegisters(1, 0x1200, [(ushort)1]);
res = master.ReadHoldingRegisters(1, 0x1200, 1);
}
 
Why do you suspect that the problem is in your code?

Is the device powered up?
Is the comm cable still connected?
Is the comm network still functional, from one end to the other? Are there junction boxes en-route that have flooded or been damaged?
Did the device get a firmware update?
Was maintenance performed yesterday on the device?
What changed when the maintenance was performed?
What else happened in the past 24 hours that have changed something affecting comms?
 
Hi Thanks for the reply, I think i got it figured out somehow. Poking a value into a discharge register seems to have confused it, managed to reset it from the Sofar interface and it seems to be working again. I'm guessing its needs to be in certain modes (Auto, Time of Use, Timed or Passive), before some registers can be altered correctly without upsetting stuff.
 
Top