Commit e32c20ea authored by Claes Sjöfors's avatar Claes Sjöfors

Modbus TCP server objects improvments

parent 0122ca72
...@@ -182,7 +182,7 @@ static void* mb_receive(void* data) ...@@ -182,7 +182,7 @@ static void* mb_receive(void* data)
break; break;
} }
addr -= mp->ReadAddress; addr -= mp->ReadRegAddress;
if (addr < 0 || addr + quant * 2 > local_card->output_size) { if (addr < 0 || addr + quant * 2 > local_card->output_size) {
exception_code = 2; exception_code = 2;
...@@ -252,6 +252,8 @@ static void* mb_receive(void* data) ...@@ -252,6 +252,8 @@ static void* mb_receive(void* data)
break; break;
} }
addr -= mp->ReadDigAddress;
offs = addr / 8; offs = addr / 8;
bytes = (addr + quant) / 8 + (((addr + quant) % 8 == 0) ? 0 : 1) - offs; bytes = (addr + quant) / 8 + (((addr + quant) % 8 == 0) ? 0 : 1) - offs;
...@@ -332,7 +334,7 @@ static void* mb_receive(void* data) ...@@ -332,7 +334,7 @@ static void* mb_receive(void* data)
break; break;
} }
addr -= mp->WriteAddress; addr -= mp->WriteRegAddress;
if (addr < 0 || addr + 2 > local_card->input_size) { if (addr < 0 || addr + 2 > local_card->input_size) {
exception_code = 2; exception_code = 2;
...@@ -397,7 +399,7 @@ static void* mb_receive(void* data) ...@@ -397,7 +399,7 @@ static void* mb_receive(void* data)
break; break;
} }
addr -= mp->WriteAddress; addr -= mp->WriteRegAddress;
if (addr < 0 || addr + quant * 2 > local_card->input_size) { if (addr < 0 || addr + quant * 2 > local_card->input_size) {
exception_code = 2; exception_code = 2;
...@@ -459,6 +461,8 @@ static void* mb_receive(void* data) ...@@ -459,6 +461,8 @@ static void* mb_receive(void* data)
break; break;
} }
addr -= mp->WriteDigAddress;
offs = addr / 8; offs = addr / 8;
if (addr < 0 || offs + local_card->di_offset >= local_card->input_size if (addr < 0 || offs + local_card->di_offset >= local_card->input_size
...@@ -535,6 +539,7 @@ static void* mb_receive(void* data) ...@@ -535,6 +539,7 @@ static void* mb_receive(void* data)
exception_code = 2; exception_code = 2;
break; break;
} }
addr -= mp->WriteDigAddress;
offs = addr / 8; offs = addr / 8;
bytes = (addr + quant) / 8 + (((addr + quant) % 8 == 0) ? 0 : 1) - offs; bytes = (addr + quant) / 8 + (((addr + quant) % 8 == 0) ? 0 : 1) - offs;
......
! Generated by wb_print_wbl 02-MAR-2020 23:49:56.61
! Volume OtherIO
! Version V5.7.0
Volume OtherIO $ClassVolume 0.0.250.10 Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00 Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X668" Attr NextOix = "_X668"
...@@ -2331,14 +2334,15 @@ Volume OtherIO $ClassVolume 0.0.250.10 ...@@ -2331,14 +2334,15 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody EndBody
EndObject EndObject
!/** !/**
! Network format is set to little endian. ! Network format is set to little endian.
! The standard network format for Modbus TCP is big endian. Despite ! The standard network format for Modbus TCP is big endian. Despite
! this, slaves despite this uses little endian. Setting byte ! this, slaves despite this uses little endian. Setting byte
! ordering to little endian makes it possible to connect to such slaves. ! ordering to little endian makes it possible to connect to such slaves.
!*/ !*/
Object ByteOrderingLE $Attribute 22 29-MAR-2019 11:26:24.84 Object ByteOrderingLE $Attribute 22 29-MAR-2019 11:26:24.84
Body SysBody 29-MAR-2019 11:26:54.23 Body SysBody 29-MAR-2019 11:26:54.23
Attr Flags = 16777216 Attr PgmName = "ByteOrderingLE"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
...@@ -3356,6 +3360,12 @@ Volume OtherIO $ClassVolume 0.0.250.10 ...@@ -3356,6 +3360,12 @@ Volume OtherIO $ClassVolume 0.0.250.10
! and is the father of channel objects that define the input and ! and is the father of channel objects that define the input and
! output area for the module. ! output area for the module.
! !
! The input area should be organized with registers first (ChanAi, ChanIi),
! and then digital inputs (ChanDi).
!
! Likewise the output area should be organized with registers first (ChanAo, ChanIo),
! and then digital outputs (ChanDo).
!
! @classlink Modbus_TCP_Server otherio_modbus_tcp_server.html ! @classlink Modbus_TCP_Server otherio_modbus_tcp_server.html
!*/ !*/
Object Modbus_TCP_ServerModule $ClassDef 7 25-NOV-2009 11:05:45.82 Object Modbus_TCP_ServerModule $ClassDef 7 25-NOV-2009 11:05:45.82
...@@ -3367,7 +3377,7 @@ Volume OtherIO $ClassVolume 0.0.250.10 ...@@ -3367,7 +3377,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object RtBody $ObjBodyDef 1 25-NOV-2009 11:05:23.49 Object RtBody $ObjBodyDef 1 25-NOV-2009 11:05:23.49
Body SysBody 25-NOV-2009 11:06:00.66 Body SysBody 25-NOV-2009 11:06:00.66
Attr StructName = "Modbus_TCP_ServerModule" Attr StructName = "Modbus_TCP_ServerModule"
Attr NextAix = "_X21" Attr NextAix = "_X23"
EndBody EndBody
!/** !/**
! Description of the object. ! Description of the object.
...@@ -3385,12 +3395,10 @@ Volume OtherIO $ClassVolume 0.0.250.10 ...@@ -3385,12 +3395,10 @@ Volume OtherIO $ClassVolume 0.0.250.10
! The value defines the starting address for the input channels ! The value defines the starting address for the input channels
! of class ChanIi and ChanAi. ! of class ChanIi and ChanAi.
! !
! Note that the address for ReadDiscreteInputs and ReadCoils are
! not affected by the ReadAddress.
!*/ !*/
Object ReadAddress $Attribute 12 04-DEC-2009 16:53:13.17 Object ReadRegAddress $Attribute 12 02-MAR-2020 17:48:30.72
Body SysBody 04-DEC-2009 16:53:32.47 Body SysBody 02-MAR-2020 17:48:52.08
Attr PgmName = "ReadAddress" Attr PgmName = "ReadRegAddress"
Attr Size = 4 Attr Size = 4
Attr TypeRef = "pwrs:Type-$UInt32" Attr TypeRef = "pwrs:Type-$UInt32"
EndBody EndBody
...@@ -3402,12 +3410,34 @@ Volume OtherIO $ClassVolume 0.0.250.10 ...@@ -3402,12 +3410,34 @@ Volume OtherIO $ClassVolume 0.0.250.10
! The value defines the starting address for the output channels ! The value defines the starting address for the output channels
! of class ChanIo and ChanAo. ! of class ChanIo and ChanAo.
! !
! Note that the address for WriteSingleCoil and WriteMultipleCoils
! are not affected by the WriteAddress.
!*/ !*/
Object WriteAddress $Attribute 13 04-DEC-2009 16:53:43.87 Object WriteRegAddress $Attribute 13 02-MAR-2020 17:50:49.91
Body SysBody 04-DEC-2009 16:53:45.81 Body SysBody 02-MAR-2020 17:49:25.67
Attr PgmName = "WriteAddress" Attr PgmName = "WriteRegAddress"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Address for reading digital inputs.
! Address for reading with function code ReadInputs.
! The value defines the starting address for the input channels of class ChanDi
!*/
Object ReadDigAddress $Attribute 21 02-MAR-2020 17:42:32.87
Body SysBody 02-MAR-2020 17:41:32.19
Attr PgmName = "ReadDigAddress"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Address for writing digital outputs.
! Address for reading with function code WriteMultipleCoils.
! The value defines the starting address for the output channels of class ChanDo
!*/
Object WriteDigAddress $Attribute 22 02-MAR-2020 17:50:02.32
Body SysBody 02-MAR-2020 17:50:14.30
Attr PgmName = "WriteDigAddress"
Attr Size = 4 Attr Size = 4
Attr TypeRef = "pwrs:Type-$UInt32" Attr TypeRef = "pwrs:Type-$UInt32"
EndBody EndBody
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment