Hello Tim, Hello Martin,
As stated before, I got it working, but I was now trying to extend with reading out a register.
(Today still a variable resistor, but I will replace it with the digital temperature sensors, with I2C bus as done by Martin later on)
But there it goes wrong. When checking the wireshark trace, it seems there is an issue at the arduino side.
My code is as follows. (rather easy) and using the mudbus of Martin.
void loop()
{
Mb.Run();
Mb.R[0] = analogRead(A2);
//Digital inputs
Mb.C[0] = digitalRead(3); //pin 7 to Mb.C[7]
Mb.C[1] = digitalRead(5);
Mb.C[2] = digitalRead(6);
Mb.C[3] = digitalRead(7);
//Digital outputs
digitalWrite(8, Mb.C[4]); //pin 8 from Mb.C[8]
digitalWrite(9, Mb.C[5]);
}
In the wireshark trace, I get 2 issues. (trace atached)
- The arduino seems to have it difficult with 2 modbus/TCP messages in one TCP segment.
- The arduino simply doesn't answer to the request for the register.
arduino difficult with 2 modbus/TCP messages in one TCP segment
It seems proview changed the behaviour compared to my previous project.
Now it puts 2 modbus/tcp messages (MBAP header + function code + data) within one TCP segment.
The first modbus/tcp has function code 1 read coils, the second has function 15, force multiple coils.
As far as I know Martin developed the code. (or at least the extension made for function code 15)
It would be nice if you could have a look. I will look further into the c-code as well.
I had a look at the specs as weel, and couldn't find in a first glance if it is allowed to have 2 modbus/tcp messages within one tcp segment.
Arduino simply doesn't answer to "read input registers"
When checking the trace, it seems proview send out all correctly,but no answer from arduino.
I will sart some debugging myself, but as you have expirenece with it, help (or a good direction) is appriciated.
Tim, just let me know how your trip was, and if you could see the projects of Martin. We could get a beer afterwards, but a little bit less then last time.
Thansk already for your support and best regards,
Wout