ModbusClientCommon.cin

Changed timer to support EilDll

ModbusStructs.cin
  Removed header from all structs

ModbusProtocol.cpp
  Fixed data length issue (l. 353)
  More precise info in InspectProtocol()
  New getter: GetAddrNCount()
This commit is contained in:
Jonny007-MKD 2014-06-02 12:16:23 +00:00
parent 95304c9216
commit 13c03dd807
11 changed files with 334 additions and 286 deletions

View file

@ -1,4 +1,4 @@
;CANoe Version |4|7|1|38833 ModbusNet
;CANoe Version |4|7|1|38817 ModbusNet
Version: 8.2.40 Build 40
32 PRO
10
@ -67,25 +67,24 @@ DialogBegin
1
285 569 816 1103
SymbolExplorerDialogBegin
1
HistoryBegin
1 0
HistoryEnd
FiltersBegin
Begin
3 0 -1
3 0 2
5
Bus statistic signals
( 1 ( 1 ( 0 ) 0 ) 0 )
Busstatistik Signale
( 1 ( 1 ( 0 ) 0 ) 0 )
Modbus
( 2 ( 0 ) 0)
TE0001
( 2 ( 2 ( 0 ) 0 ) 0 )
TE0002
( 2 ( 2 ( 0 ) 0 ) 0 )
Busstatistik Signale
( 1 ( 0 ) 0 )
SymbSelHeaderMgrBegin
1 6
0 1 278 0 0
@ -214,7 +213,7 @@ Begin
Modbus
Systemvariablen
( 1 ( 1 ( 0 ) 2 ( 0 ) 0 ) 3 ( 1 ( 2 ( 3 ( 0 ) 0 ) 0 ) 0 ) 0 )
( 1 ( 1 ( 0 ) 0 ) 0 )
SymbSelHeaderMgrBegin
1 4
0 1 200 0 0
@ -333,7 +332,7 @@ SymbSelHeaderMgrEnd
End
FiltersEnd
1 12
1 0
SymbolExplorerDialogEnd
DialogEnd
@ -742,9 +741,9 @@ Begin_Of_Multi_Line_String
Copyright (c) 2001-2006 Actipro Software LLC. All rights reserved.
http://www.ActiproSoftware.com/Products/DotNet/
--><ToolWindowLayout Version="1.0"><LayoutData><HostContainerControl><ToolWindowContainer Dock="Right" Size="645, 393" SelectedToolWindowGuid="859d3aae-7aff-47f2-8ca4-bb7d01f32282"><ToolWindow Key="{224229E5-10CA-425F-8B6F-C213CD04C44F}" Guid="859d3aae-7aff-47f2-8ca4-bb7d01f32282" DockedSize="641, 358" FloatingLocation="347, 323" FloatingSize="890, 483" HasOptions="False" ImageIndex="-1" Text="Simulationsaufbau" TitleBarText="Simulationsaufbau"><AutoHideStateInfo RootDock="Right" /><DockedInsideHostStateInfo RootDock="Right" IsAttached="False"><DockedBy Guid="ac9be154-bd12-4ff9-b255-03e05277dbe2" RootDock="Bottom" DockOperationType="TopOuter" IsTopMost="True" /><DockedBy Guid="7f29b491-3ada-4572-b140-b422651d6fed" RootDock="Top" DockOperationType="BottomOuter" IsTopMost="True" /></DockedInsideHostStateInfo><DockedOutsideHostStateInfo IsAttached="False" /></ToolWindow></ToolWindowContainer><ToolWindowContainer Dock="Left" Size="448, 393" SelectedToolWindowGuid="87323901-fe96-4011-a82f-
--><ToolWindowLayout Version="1.0"><LayoutData><HostContainerControl><ToolWindowContainer Dock="Right" Size="645, 393" SelectedToolWindowGuid="859d3aae-7aff-47f2-8ca4-bb7d01f32282"><ToolWindow Key="{224229E5-10CA-425F-8B6F-C213CD04C44F}" Guid="859d3aae-7aff-47f2-8ca4-bb7d01f32282" DockedSize="641, 358" FloatingLocation="347, 323" FloatingSize="890, 483" HasOptions="False" ImageIndex="-1" Text="Simulationsaufbau" TitleBarText="Simulationsaufbau"><AutoHideStateInfo RootDock="Right" /><DockedInsideHostStateInfo RootDock="Right" IsAttached="False"><DockedBy Guid="ac9be154-bd12-4ff9-b255-03e05277dbe2" RootDock="Bottom" DockOperationType="TopOuter" IsTopMost="True" /><DockedBy Guid="7f29b491-3ada-4572-b140-b422651d6fed" RootDock="Top" DockOperationType="BottomOuter" IsTopMost="True" /></DockedInsideHostStateInfo><DockedOutsideHostStateInfo IsAttached="False" /></ToolWindow></ToolWindowContainer><ToolWindowContainer Dock="Left" Size="386, 393" SelectedToolWindowGuid="87323901-fe96-4011-a82f-
kPersistNoLineBreak
0e1b8627507a"><ToolWindow Key="{E6849C53-63F6-4A32-9B1C-7018D50DDE09}" Guid="87323901-fe96-4011-a82f-0e1b8627507a" DockedSize="444, 161" FloatingLocation="6, 66" FloatingSize="677, 213" HasOptions="False" ImageIndex="-1" Text="Daten" TitleBarText="Daten"><AutoHideStateInfo RootDock="Left" /><DockedInsideHostStateInfo RootDock="Left" IsAttached="False"><DockedBy Guid="ac9be154-bd12-4ff9-b255-03e05277dbe2" RootDock="Bottom" DockOperationType="TopOuter" IsTopMost="True" /><DockedBy Guid="7f29b491-3ada-4572-b140-b422651d6fed" RootDock="Top" DockOperationType="BottomOuter" IsTopMost="True" /></DockedInsideHostStateInfo><DockedOutsideHostStateInfo IsAttached="False" /></ToolWindow></ToolWindowContainer><ToolWindowContainer Dock="Bottom" Size="1192, 285" SelectedToolWindowGuid="ac9be154-bd12-4ff9-b255-03e05277dbe2"><ToolWindow Key="{28077F35-C142-4ACC-B040-1BF0AB026C11}" Guid="ac9be154-bd12-4ff9-b255-03e05277dbe2" DockedSize="201, 281" FloatingLocation="111, 442" FloatingSize="1192, 514" Has
0e1b8627507a"><ToolWindow Key="{E6849C53-63F6-4A32-9B1C-7018D50DDE09}" Guid="87323901-fe96-4011-a82f-0e1b8627507a" DockedSize="382, 161" FloatingLocation="6, 66" FloatingSize="677, 213" HasOptions="False" ImageIndex="-1" Text="Daten" TitleBarText="Daten"><AutoHideStateInfo RootDock="Left" /><DockedInsideHostStateInfo RootDock="Left" IsAttached="False"><DockedBy Guid="ac9be154-bd12-4ff9-b255-03e05277dbe2" RootDock="Bottom" DockOperationType="TopOuter" IsTopMost="True" /><DockedBy Guid="7f29b491-3ada-4572-b140-b422651d6fed" RootDock="Top" DockOperationType="BottomOuter" IsTopMost="True" /></DockedInsideHostStateInfo><DockedOutsideHostStateInfo IsAttached="False" /></ToolWindow></ToolWindowContainer><ToolWindowContainer Dock="Bottom" Size="1192, 285" SelectedToolWindowGuid="ac9be154-bd12-4ff9-b255-03e05277dbe2"><ToolWindow Key="{28077F35-C142-4ACC-B040-1BF0AB026C11}" Guid="ac9be154-bd12-4ff9-b255-03e05277dbe2" DockedSize="201, 281" FloatingLocation="111, 442" FloatingSize="1192, 514" Has
kPersistNoLineBreak
Options="False" ImageIndex="-1" Text="Trace" TitleBarText="Trace"><AutoHideStateInfo RootDock="Bottom" /><DockedInsideHostStateInfo RootDock="Bottom" IsAttached="False" /><DockedOutsideHostStateInfo IsAttached="False" /></ToolWindow></ToolWindowContainer><ToolWindowContainer Dock="Top" Size="1192, 227" SelectedToolWindowGuid="7f29b491-3ada-4572-b140-b422651d6fed"><ToolWindow Key="{8F3DFCAC-9CCB-45C2-AF10-5DEC039B5956}" Guid="7f29b491-3ada-4572-b140-b422651d6fed" DockedSize="201, 223" FloatingLocation="6, 433" FloatingSize="300, 180" HasOptions="False" ImageIndex="-1" Text="Write" TitleBarText="Write"><AutoHideStateInfo RootDock="Top" /><DockedInsideHostStateInfo RootDock="Top" IsAttached="False" /><DockedOutsideHostStateInfo IsAttached="False" /></ToolWindow></ToolWindowContainer></HostContainerControl><AutoHide Dock="Left" /><AutoHide Dock="Right" /><AutoHide Dock="Top" /><AutoHide Dock="Bottom" /><TabbedDocuments Orientation="Horizontal" /><FloatingContainers /><Hidden><ToolWindow K
kPersistNoLineBreak
@ -926,7 +925,7 @@ VBusStatisticBox 14 Begin_Of_Object
VBoxRoot 15 Begin_Of_Object
1
1
1 0 0 1 -1 -1 -1 -1 0 350 662 692
1 0 0 1 -1 -1 -1 -1 0 89 662 431
Bus statistic
1
@ -934,15 +933,16 @@ MDI_DOCK_INFO_END
5
1
6
0 1 -1 -1 -1 -1 0 350 662 692
6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
0 1 -1 -1 -1 -1 0 89 662 431
6 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
END_OF_DOCK_INFO
0
0
0
1
0 1 -1 -1 -1 -1 2 22 668 368
0
1
1188 696
95 389
END_OF_DESKTOP_DATA
6
0 1 -1 -1 -1 -1 780 375 999 611
@ -1022,7 +1022,7 @@ VUniqueBox 16 Begin_Of_Object
VBoxRoot 17 Begin_Of_Object
1
1
1 1 0 1 -1 -1 -1 -1 1 375 779 615
1 1 1 1 0 218 -1 -1 196 115 786 460
Graphic
1
@ -1030,15 +1030,16 @@ MDI_DOCK_INFO_END
5
1
6
0 1 0 0 -1 -1 196 115 786 460
6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
1 2 0 218 -1 -1 196 115 786 460
6 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
END_OF_DOCK_INFO
0
1
1
2 3 -1 -1 -1 -1 243 246 837 595
0
0
0
999 591
1
95 389
END_OF_DESKTOP_DATA
6
0 1 -1 -1 -1 -1 1 375 779 615
@ -1107,10 +1108,10 @@ Expanded
True
Int32
SplitterWidth
237
234
Int32
SplitterHeight
237
80
APPDIR Vector.CANalyzer.Graphic.DLL
Vector.CANalyzer.Graphic, Version=8.2.40.0, Culture=neutral, PublicKeyToken=null
Vector.CANalyzer.Graphic.Position
@ -1194,7 +1195,7 @@ End_Of_Serialized_Data 15
End_Of_Object VPredefinedSignalObject 15
[MeasurementObject]
Eth 1::Rx Bus load
"%" 1 800080 0. 100. -100. 100. 20 -5 0 0 36000000 1 1 0 0
"%" 1 800080 -2.3237864 -1.8705227 -100. 100. 0.02 -5 0 0 36000000 1 1 0 0
VPredefinedSignalObject 15 Begin_Of_Object
1
VHostSignal 16 Begin_Of_Object
@ -1245,7 +1246,7 @@ End_Of_Serialized_Data 15
End_Of_Object VPredefinedSignalObject 15
[MeasurementObject]
Eth 1::Tx Bus load
"%" 1 80 0. 100. -100. 100. 20 -5 0 0 36000000 1 1 0 0
"%" 1 80 -2.3237864 -1.8705227 -100. 100. 0.02 -5 0 0 36000000 1 1 0 0
VPredefinedSignalObject 15 Begin_Of_Object
1
VHostSignal 16 Begin_Of_Object
@ -1296,7 +1297,7 @@ End_Of_Serialized_Data 15
End_Of_Object VPredefinedSignalObject 15
[MeasurementObject]
Eth 1::Rx Packet rate
"pkt/s" 1 800000 0. 10000. -100. 100. 2000 -5 0 0 36000000 1 1 0 0
"pkt/s" 1 800000 0. 10000. -100. 100. 500 -5 0 0 36000000 1 1 0 0
VPredefinedSignalObject 15 Begin_Of_Object
1
VHostSignal 16 Begin_Of_Object
@ -1347,9 +1348,9 @@ End_Of_Serialized_Data 15
End_Of_Object VPredefinedSignalObject 15
[MeasurementObject]
Eth 1::Tx Packet rate
"pkt/s" 1 808000 0. 10000. -100. 100. 2000 -5 0 0 36000000 1 1 0 0
"pkt/s" 1 808000 0. 10000. -100. 100. 500 -5 0 0 36000000 1 1 0 0
[GraphWindow:x_x_x_x_x_x_WindowBk_Grid_AxisBk_XAxisFr_YAxisFr_x_x_x_x_x_x]
0 100000 100000 200000 36000000 1 ffffff b2b2b2 ffffff 0 0 0 0 1 1 1 0
0 26415.43074 26415.43074 200000 36000000 1 ffffff b2b2b2 ffffff 0 0 0 0 1 1 1 0
0 30 5000
0
0 100
@ -1380,14 +1381,42 @@ Grafik-Fenster
1
[End_of_Export]
12
18 16 143 20 18 55 55 55 55 55 57 13
237
26 25 143 20 18 55 55 55 55 55 57 13
234
0
0
1
0
0
0
-11
0
0
0
0
0
0
0
400
0
Tahoma
0
1
0
0
0
-11
0
0
0
34
0
0
0
400
0
Tahoma
0
1
1
0
@ -1403,7 +1432,7 @@ Grafik-Fenster
0
0
0
128
913
0 10
1
2
@ -1454,9 +1483,9 @@ Eth 1::Packet rate [pkt/s]
0
1 12
1 1 1 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9 10 11
18 16 163 55 55 55 55 55 57 57 82 30
237 237
0 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1
26 25 163 55 55 55 55 55 57 57 82 30
234 80
End_Of_Object VSignalObjectStreamer 14
End_Of_Object VGraphBoxConf 13
VDOLine 13 Begin_Of_Object
@ -2622,7 +2651,7 @@ End_Of_Object VTNColumnData 16
VTNColumnData 16 Begin_Of_Object
3
6
29
27
7
Payload Length
1
@ -3860,7 +3889,7 @@ MDI_DOCK_INFO_END
1
6
0 1 -1 -1 -8 -30 -138 106 539 323
6 1 0 0 0 0 0 0 677 213 0 0 1 8084 1904 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 6 66 1 0 0 0 1 444 0 59420 1
6 1 0 0 0 0 0 0 677 213 0 0 1 8084 1904 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 6 66 1 0 0 0 1 382 0 59420 1
END_OF_DOCK_INFO
1
2
@ -4602,7 +4631,7 @@ End_Of_Object VGrMnBox 3
VDOLocalInfoStruct 3 Begin_Of_Object
3
1
199
203
VDAOBus 4 Begin_Of_Object
1
1
@ -4714,7 +4743,7 @@ End_Of_Object VIPBStackSetting 8
NDebugger::VDebuggerHost 8 Begin_Of_Object
2
0
27
29
NDebugger::VFile 9 Begin_Of_Object
1
<VFileName V4 QL> 1 "ModbusTcpCommon.cin"
@ -4850,6 +4879,16 @@ NDebugger::VFile 9 Begin_Of_Object
<VFileName V4 QL> 1 "include\CAPL\include\ModbusStructs.cin"
42
End_Of_Object NDebugger::VFile 9
NDebugger::VFile 9 Begin_Of_Object
1
<VFileName V4 QL> 1 "include\CAPL\include\EilDllCommon.cin"
43
End_Of_Object NDebugger::VFile 9
NDebugger::VFile 9 Begin_Of_Object
1
<VFileName V4 QL> 1 "include\CAPL\include\ModbusEilDllClientCommon.cin"
44
End_Of_Object NDebugger::VFile 9
VNETStandaloneComponent 9 Begin_Of_Object
1
VNETControlBox 10 Begin_Of_Object
@ -4859,23 +4898,24 @@ VUniqueBox 11 Begin_Of_Object
VBoxRoot 12 Begin_Of_Object
1
3
1 -1 2 3 -1 -1 -8 -30 171 76 688 306
Debugger - Client_2
1 -1 0 1 -1 -1 -1 -1 35 -12 567 364
Debugger - Programm: Client_2 [Debugging ausgeschaltet]
1
MDI_DOCK_INFO_END
5
1
6
2 3 -1 -1 -1 -1 171 76 688 306
6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
0 1 -1 -1 -1 -1 35 -12 567 364
6 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
END_OF_DOCK_INFO
0
-1
1
0 1 -1 -1 -1 -1 6 66 542 446
0
0
0
859 382
1
157 389
END_OF_DESKTOP_DATA
6
0 1 0 0 -1 -1 171 76 688 306
@ -5089,7 +5129,7 @@ VSimulinkModelViewerConfiguration 7 Begin_Of_Object
End_Of_Object VSimulinkModelViewerConfiguration 7
1
0
657298843
1716208489
0
NodeSignalPanelBustypeCount 0
End_Of_Object VSimulationNode 6
@ -5122,7 +5162,7 @@ VBoxRoot 9 Begin_Of_Object
1
3
1 1 1 1 0 166 -8 -30 61 86 1093 577
Ethernet Packet Builder
1
MDI_DOCK_INFO_END
@ -5200,105 +5240,11 @@ EOF_MBSSDATA
1
0 1
<IPPlugIn.PacketBuilder DefaultBusProtocolId="256" DefaultDestMacIdSelection="107" DefaultDestinationIPAddress="192 . 168 . 1 . 100" DefaultDestinationIPv6Address="0:0:0:0:0:0:0:0" DefaultDestinationMacId="FF:FF:FF:FF:FF:FF" DefaultDestinationPort="502" DefaultSourceIPAddress="192 . 168 . 1 . 10" DefaultSourceIPv6Address="0:0:0:0:0:0:0:0" DefaultSourceMacId="02:00:4C:4F:4F:50" DefaultSourcePort="2000" DefaultSrcMacIdSelection="1" Name="Ethernet Packet Builder">
<IPPlugIn.VPersistentFrameWrapper AssignedChannelId="Eth 1" DestMacIdConfStateSel="111" FrameDescription="MB/UDP" FrameIsValid="1" InitialPacketType="5" PDBData="3 0 1651797619 1 3 1 1651797619 1 10 1 1651797619 1 8 0 1651797619 1 11 0 1651797619 1 4 0 1651797619 1 5 0 1651797619 1 5 1 1651797619 1 9 1 1651797619 1 " RawFrameData=" 0-30-de- 7-9a-fd- 0-19-db-cb-83-dd- 8- 0-45- 0- 0-27- 0- 0- 0- 0-40-11-f7-72-c0-a8- 1- 1-c0-a8- 1- 2-d5-66- 1-f6- 0-13-67-b5-30-30- 0- 0- 0- 5-ff-2b- e- 1- 0- 0- 0- 2- 0- 0- 0- 6-" RawFrameLength="60" SrcMacIdConfStateSel="105" WlanAddr1MacIdConfStateSel="111" WlanAddr2MacIdConfStateSel="111" WlanAddr3MacIdConfStateSel="111" WlanAddr4MacIdConfStateSel="111"/>
<IPPlugIn.SE id="102" intVal="0" key="1919247220"/>
<IPPlugIn.SE id="102" index="1" intVal="986" key="1919247220"/>
<IPPlugIn.SE id="102" index="2" intVal="0" key="1919247220"/>
<IPPlugIn.SE id="102" index="3" intVal="507" key="1919247220"/>
<IPPlugIn.SE id="102" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="102" intVal="199" key="1936292453"/>
<IPPlugIn.SE id="102" intVal="437" key="1920231791"/>
<IPPlugIn.SE id="1004" intVal="1145393987" key="1952540511"/>
<IPPlugIn.SE id="1004" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" intVal="218" key="2003072104"/>
<IPPlugIn.SE id="1004" index="1" intVal="1397708114" key="1952540511"/>
<IPPlugIn.SE id="1004" index="1" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="1" intVal="156" key="2003072104"/>
<IPPlugIn.SE id="1004" index="2" intVal="1145394004" key="1952540511"/>
<IPPlugIn.SE id="1004" index="2" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="2" intVal="156" key="2003072104"/>
<IPPlugIn.SE id="1004" index="3" intVal="1347571540" key="1952540511"/>
<IPPlugIn.SE id="1004" index="3" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1005" index="18" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="1005" index="19" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="20" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="1005" index="20" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="19" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="18" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1004" index="3" intVal="125" key="2003072104"/>
<IPPlugIn.SE id="1004" index="4" intVal="1397316165" key="1952540511"/>
<IPPlugIn.SE id="1004" index="4" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="4" intVal="108" key="2003072104"/>
<IPPlugIn.SE id="1004" index="5" intVal="1348029508" key="1952540511"/>
<IPPlugIn.SE id="1004" index="5" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="5" intVal="108" key="2003072104"/>
<IPPlugIn.SE id="1004" intVal="0" key="1886352249"/>
<IPPlugIn.SE id="1004" intVal="0" key="1886352248"/>
<IPPlugIn.SE id="1004" intVal="0" key="7499639"/>
<IPPlugIn.SE id="125" intVal="0" key="7562604"/>
<IPPlugIn.SE id="102" index="1" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="102" index="1" intVal="531" key="1936292453"/>
<IPPlugIn.SE id="102" index="1" intVal="397" key="1920231791"/>
<IPPlugIn.SE id="1005" intVal="0" key="1886352249"/>
<IPPlugIn.SE id="1005" intVal="0" key="1886352248"/>
<IPPlugIn.SE id="1005" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="1" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="1" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="2" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="2" index="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="2" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="2" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="3" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="3" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="4" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="4" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="5" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="5" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="6" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="6" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="7" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="7" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="8" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="8" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="9" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="9" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="3" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="3" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="4" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="5" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="6" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="7" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="8" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="9" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="10" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="11" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="10" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="10" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="11" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="11" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="1005" index="12" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="12" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="13" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="13" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="14" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="14" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="15" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="15" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="16" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="16" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="17" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="17" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="102" index="2" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="102" index="2" intVal="219" key="1936292453"/>
<IPPlugIn.SE id="102" index="2" intVal="164" key="1920231791"/>
<IPPlugIn.SE id="127" intVal="0" key="1651534958"/>
<IPPlugIn.SE id="1003" intVal="0" key="1886352249"/>
<IPPlugIn.SE id="1003" intVal="0" key="1886352248"/>
<IPPlugIn.SE id="1003" intVal="0" key="2003072104"/>
<IPPlugIn.VPersistentFrameWrapper AssignedChannelId="Eth 1" DestMacIdConfStateSel="111" FrameDescription="MB/UDP" FrameIsValid="1" InitialPacketType="5" PDBData="5 0 1651797619 1 9 1 1651797619 1 5 1 1651797619 1 4 0 1651797619 1 11 0 1651797619 1 8 0 1651797619 1 3 0 1651797619 1 10 1 1651797619 1 3 1 1651797619 1 " RawFrameData=" 0-30-de- 7-9a-fd- 0-19-db-cb-83-dd- 8- 0-45- 0- 0-27- 0- 0- 0- 0-40-11-f7-72-c0-a8- 1- 1-c0-a8- 1- 2-d5-66- 1-f6- 0-13-67-b5-30-30- 0- 0- 0- 5-ff-2b- e- 1- 0- 0- 0- 2- 0- 0- 0- 6-" RawFrameLength="60" SrcMacIdConfStateSel="105" WlanAddr1MacIdConfStateSel="111" WlanAddr2MacIdConfStateSel="111" WlanAddr3MacIdConfStateSel="111" WlanAddr4MacIdConfStateSel="111"/>
<IPPlugIn.SE id="5" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" index="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" index="3" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="4" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="4" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="4" index="2" intVal="0" key="1702391908"/>
@ -5309,10 +5255,104 @@ EOF_MBSSDATA
<IPPlugIn.SE id="4" index="7" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="4" index="8" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="4" index="9" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" index="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="5" index="3" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1003" intVal="0" key="2003072104"/>
<IPPlugIn.SE id="1003" intVal="0" key="1886352248"/>
<IPPlugIn.SE id="1003" intVal="0" key="1886352249"/>
<IPPlugIn.SE id="127" intVal="0" key="1651534958"/>
<IPPlugIn.SE id="3" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="102" index="2" intVal="164" key="1920231791"/>
<IPPlugIn.SE id="102" index="2" intVal="219" key="1936292453"/>
<IPPlugIn.SE id="102" index="2" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="3" index="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="3" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="4" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="5" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="6" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="7" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="8" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="9" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="10" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="11" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="1005" index="12" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="13" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="14" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="15" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="16" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="17" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="17" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="16" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="15" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="14" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="13" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="12" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="11" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="10" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="3" index="10" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="3" index="11" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="2" index="1" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="2" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="3" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="4" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="5" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="6" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="7" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="8" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="9" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="9" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" index="8" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="7" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="6" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="5" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="4" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="3" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="2" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="2" index="2" intVal="0" key="1702391908"/>
<IPPlugIn.SE id="1005" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="1" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="1005" index="1" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" intVal="0" key="1886352248"/>
<IPPlugIn.SE id="1005" intVal="0" key="1886352249"/>
<IPPlugIn.SE id="125" intVal="0" key="7562604"/>
<IPPlugIn.SE id="102" index="1" intVal="397" key="1920231791"/>
<IPPlugIn.SE id="102" index="1" intVal="531" key="1936292453"/>
<IPPlugIn.SE id="102" index="1" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1004" intVal="0" key="7499639"/>
<IPPlugIn.SE id="1004" intVal="0" key="1886352248"/>
<IPPlugIn.SE id="1004" intVal="0" key="1886352249"/>
<IPPlugIn.SE id="1004" intVal="218" key="2003072104"/>
<IPPlugIn.SE id="1004" index="1" intVal="156" key="2003072104"/>
<IPPlugIn.SE id="1004" index="2" intVal="156" key="2003072104"/>
<IPPlugIn.SE id="1004" index="3" intVal="125" key="2003072104"/>
<IPPlugIn.SE id="1004" index="4" intVal="108" key="2003072104"/>
<IPPlugIn.SE id="1004" index="5" intVal="108" key="2003072104"/>
<IPPlugIn.SE id="1004" index="5" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="5" intVal="1348029508" key="1952540511"/>
<IPPlugIn.SE id="1004" index="4" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="4" intVal="1397316165" key="1952540511"/>
<IPPlugIn.SE id="1004" index="3" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="3" intVal="1347571540" key="1952540511"/>
<IPPlugIn.SE id="1004" index="2" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="2" intVal="1145394004" key="1952540511"/>
<IPPlugIn.SE id="1004" index="1" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" index="1" intVal="1397708114" key="1952540511"/>
<IPPlugIn.SE id="1004" intVal="1" key="1986622303"/>
<IPPlugIn.SE id="1004" intVal="1145393987" key="1952540511"/>
<IPPlugIn.SE id="102" intVal="437" key="1920231791"/>
<IPPlugIn.SE id="102" intVal="199" key="1936292453"/>
<IPPlugIn.SE id="102" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="102" intVal="0" key="1919247220"/>
<IPPlugIn.SE id="102" index="1" intVal="986" key="1919247220"/>
<IPPlugIn.SE id="102" index="2" intVal="0" key="1919247220"/>
<IPPlugIn.SE id="102" index="3" intVal="507" key="1919247220"/>
<IPPlugIn.SE id="1005" index="18" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="18" intVal="1" key="1633907830"/>
<IPPlugIn.SE id="1005" index="19" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="19" intVal="0" key="1633907830"/>
<IPPlugIn.SE id="1005" index="20" intVal="1" key="1702391908"/>
<IPPlugIn.SE id="1005" index="20" intVal="1" key="1633907830"/>
</IPPlugIn.PacketBuilder>
End_Of_Object VSSPlugInConfiguration 6
NULL
@ -5348,7 +5388,7 @@ NULL
End_Of_Object VDOLocalInfoStruct 3
0.000000
0 0
1 1 0 59420 1 176 1 2882400001 639 815 319 694 2882400002 0 0 0 0 0 0 1 2882400001 1280 1280 321 321 2882400002 0 0 0 1437687448 0 0 3
1 1 0 59420 1 176 1 2882400001 639 815 319 694 2882400002 0 0 0 0 0 0 1 2882400001 1280 1280 321 321 2882400002 0 0 0 0 0 0 3
SS_BEGIN_COMMON_INFO
1
0
@ -5360,14 +5400,12 @@ Ether1
11
1
1
504289040 1 0 1 0 1 1 0 81 42 2000 1
492214664 1 0 1 0 1 1 0 0 0 2000 1
SS_BEGIN_COMMON_INFO
1
3
2
Channels
1
Databases
1
Misc
1
SS_END_COMMON_INFO
@ -5471,7 +5509,7 @@ End_Of_Serialized_Data 2
End_Of_Object VWriteBox 2
VWinStore 2 Begin_Of_Object
1
22 2 3 -1 -1 -1 -1 -10088 -10000 -9070 -9233
22 2 3 -32088 -32000 -1 -1 -10088 -10000 -9070 -9233
End_Of_Child_List
End_Of_Object VWinStore 2
VWinStore 2 Begin_Of_Object
@ -5792,6 +5830,7 @@ End
FiltersEnd
1 1
END_OF_WORKSPACE_MEMBER_DATA
END_OF_WORKSPACE_MEMBER
1
@ -6365,7 +6404,7 @@ VUniqueBox 4 Begin_Of_Object
VBoxRoot 5 Begin_Of_Object
1
3
1 1 1 1 160 166 -1 -1 172 63 788 501
1 1 0 1 -1 -1 -1 -1 4 7 620 445
Startwerte
1
@ -6373,15 +6412,16 @@ MDI_DOCK_INFO_END
5
1
6
1 1 160 166 -1 -1 172 63 788 501
6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
0 1 -1 -1 -1 -1 4 7 620 445
6 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 32767 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0
END_OF_DOCK_INFO
0
1
0
1
0 1 -1 -1 -1 -1 242 174 862 616
0
1
963 193
95 389
END_OF_DESKTOP_DATA
6
0 1 0 0 -1 -1 199 118 815 556

View file

@ -10,8 +10,8 @@ variables
{
msTimer gtRead;
message Client_2_RecBits rb;
message Client_2_Ex81 ex;
//message Client_2_RecBits rb;
//message Client_2_Ex81 ex;
}
// Get information of local network interface such like ip address
@ -20,14 +20,13 @@ on preStart
{
writeClear(0);
setStartdelay(10);
OutputDebugLevel = Warning;
OutputDebugLevel = Debug;
}
on start
{
ModbusInit();
// Read serial code, additional stuff is done in OnModbusReceiveRegisters
// This has to be done by MakeConfig to properly size the arrays
//ModbusReadRegisters(0x2011, 1);
@ -36,8 +35,8 @@ on start
//ModbusReadRegisters(0x2031, 64);
//ModbusReadRegisters(0x2032, 64);
//ModbusReadRegisters(0x2033, 63);
if (@sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::OutputBits > 0)
ModbusReadBits(0x200, @sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::OutputBits);
//if (@sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::OutputBits > 0)
// ModbusReadBits(0x200, @sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::OutputBits);
setTimerCyclic(gtRead, 1, @sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Config::Interval);
}

View file

@ -7,7 +7,7 @@ includes
variables
{
const word gMaxPacketLength = 259; //__size_of(struct ModbusReqWriteRegisters);
const word gMaxPacketLength = __size_of(struct ModbusReqWriteRegisters);
msTimer gtRobin; // Timer that sends the packets and watches for timeouts
word gTxID = 0x0000; // Transaction Identifier for Modbus. Used as index for gQueue
@ -15,6 +15,7 @@ variables
// Global storage for pending and sent requests, associated by TxID
struct QueueElement
{
byte FuncCode;
word TimeoutTicks;
byte Timeouts;
word Length;
@ -48,32 +49,23 @@ void ModbusInit()
ModbusConnectTo(ip, @sysvar::Config::Modbus::Port);
}
void ModbusMakeHeader(struct ModbusApHeader mbap, word length)
{
EthSetTokenInt(gPacket, "modbus", "TxId", gTxID++);
}
// REGION: ModbusReadBits -------------------------------------------------------------
/// <ModbusReadBits>
void ModbusReadBits(word address, word count)
{
const byte length = 12; //__size_of(struct ModbusReqRead);
const byte length = __size_of(struct ModbusReqRead);
const byte funcCode = 0x01;
byte buffer[4] = {0x0B, 0x22, 0x00, 0x02};
struct ModbusReqRead mbr;
ModbusMakeHeader(mbr.Header, length);
// Payload
EthSetTokenInt(gPacket, "modbus", "FuncCode", funcCode);
EthResizeToken(gPacket, "modbus", "data" , 4*8);
EthSetTokenData(gPacket, "modbus", "data" , 4, buffer);
mbr.Address = address;
mbr.Count = count;
writeDbg(MbDebug, "Sending 'Read Bits' (0x01) command. Addr: 0x%04X, Count: %d", address, count);
EthCompletePacket(gPacket);
EthOutputPacket(gPacket);
memcpy_h2n(buffer, mbr);
ModbusSend(buffer, length, funcCode);
}
/// <ModbusReadBits>
@ -120,17 +112,14 @@ void ModbusReadRegisters(word address, word count) // 16 bit
const byte funcCode = 0x03;
byte buffer[length];
struct ModbusReqRead mbr;
ModbusMakeHeader(mbr.Header, length);
// Payload
mbr.Header.FuncCode = funcCode; // [1] Function Code; 3: Read Holding Registers (AI), 4: Read Input Registers (AIO), seems to be the same for WAGO 750-881
mbr.Address = address; // [2] Start address
mbr.Count = count; // [2] Number of items; 1:max 125=0x7D
writeDbg(MbDebug, "Sending 'Read Registers' (0x03) command. Addr: 0x%04X, Count: %d", address, count);
memcpy_h2n(buffer, mbr);
ModbusSend(buffer, length, mbr.Header.TxID);
ModbusSend(buffer, length, funcCode);
}
/// <ModbusReadRegisters>
@ -170,16 +159,13 @@ void ModbusWriteBit(word address, byte value)
if (value >= 1)
value = 0xFF;
ModbusMakeHeader(mbw.Header, length);
// Payload
mbw.Header.FuncCode = funcCode; // [1] Function Code; 5: Write Single Coil (DO)
mbw.Address = address; // [2] Output address
mbw.Value = value << 8; // [2] Output value (0x0000: Off, 0xFF00: On)
writeDbg(Debug, "Sending 'Write Bit' (0x05) command. Addr: 0x%04X, Value: 0x%02X", address, value);
memcpy_h2n(buffer, mbw);
ModbusSend(buffer, length, mbw.Header.TxID);
ModbusSend(buffer, length, funcCode);
}
/// <ModbusWriteBit>
@ -214,16 +200,13 @@ void ModbusWriteRegister(word address, int value)
byte buffer[length];
struct ModbusReqWriteSingle mbw;
ModbusMakeHeader(mbw.Header, length);
// Payload
mbw.Header.FuncCode = funcCode; // [1] Function Code; 5: Write Single Register (AO)
mbw.Address = address; // [2] Output address
mbw.Value = value; // [2] Output value
writeDbg(MbDebug, "Sending 'Write Register' (0x06) command. Addr: 0x%04X, Value: 0x%02X", address, value);
memcpy_h2n(buffer, mbw);
ModbusSend(buffer, length, mbw.Header.TxID);
ModbusSend(buffer, length, funcCode);
}
/// <ModbusWriteRegister>
@ -265,9 +248,7 @@ void ModbusWriteBits(word address, word count, byte values[])
dataLength = _ceil(count / 8.0);
overallLength = maxLength - 1968/8 + dataLength;
ModbusMakeHeader(mbw.Header, overallLength);
// Payload
mbw.Header.FuncCode = funcCode; // [1] Function Code; 15: Write Multiple Bits (DOs)
mbw.Address = address; // [2] Output address
mbw.Count = count; // [2] Number of items; 1:max 1968=0x7B0
mbw.ByteCount = dataLength; // [1] Number of bytes; = ceil(count/8)
@ -276,7 +257,7 @@ void ModbusWriteBits(word address, word count, byte values[])
writeDbg(MbDebug, "Sending 'Write Bits' (0x0F) command. Addr: 0x%04X, Count: %d", address, count);
memcpy_h2n(buffer, mbw);
ModbusSend(buffer, overallLength, mbw.Header.TxID);
ModbusSend(buffer, overallLength, funcCode);
}
/// <ModbusWriteBits>
@ -357,9 +338,6 @@ void ModbusWriteRegisters(word address, word count, word values[])
dataLength = 2 * count;
overallLength = maxLength - 2*123 + dataLength;
ModbusMakeHeader(mbw.Header, overallLength);
// Payload
mbw.Header.FuncCode = funcCode; // [1] Function Code; 16: Write Multiple Registers (AOs)
mbw.Address = address; // [2] Output address
mbw.Count = count; // [2] Number of items; 1:max 123=0x7B
mbw.ByteCount = dataLength; // [1] Number of bytes; = 2 * count
@ -368,7 +346,7 @@ void ModbusWriteRegisters(word address, word count, word values[])
mbw.Data[i] = values[i];
memcpy_h2n(buffer, mbw);
ModbusSend(buffer, overallLength, mbw.Header.TxID);
ModbusSend(buffer, overallLength, funcCode);
}
/// <ModbusWriteRegisters>
@ -404,15 +382,12 @@ void ModbusWriteMasks(word address, word and, word or)
byte buffer[length];
struct ModbusReqWriteMasks mbw;
ModbusMakeHeader(mbw.Header, length);
// Payload
mbw.Header.FuncCode = funcCode; // [1] Function Code; 22: Mask Write Registers (AO)
mbw.Address = address; // [2] Output address
mbw.And = and; // [2] AND mask
mbw.Or = or; // [2] OR mask
memcpy_h2n(buffer, mbw);
ModbusSend(buffer, length, mbw.Header.TxID);
ModbusSend(buffer, length, funcCode);
}
/// <ModbusWriteMasks>
@ -453,9 +428,6 @@ void ModbusReadWriteRegisters(word readAddress, word readCount, word writeAddres
dataLength = 2 * writeCount;
overallLength = maxLength - 2*121 + dataLength;
ModbusMakeHeader(mbw.Header, overallLength);
// Payload
mbw.Header.FuncCode = funcCode; // [1] Function Code; 16: Write Multiple Registers (AOs)
mbw.ReadAddress = readAddress; // [2] Input address
mbw.ReadCount = readCount; // [2] Number of items; 1:max 125=0x7D
mbw.WriteAddress = writeAddress;// [2] Output address
@ -466,7 +438,7 @@ void ModbusReadWriteRegisters(word readAddress, word readCount, word writeAddres
mbw.Data[i] = values[i];
memcpy_h2n(buffer, mbw);
ModbusSend(buffer, overallLength, mbw.Header.TxID);
ModbusSend(buffer, overallLength, funcCode);
}
/// <ModbusReadWriteRegisters>
@ -677,10 +649,14 @@ void OnModbusReceive2Exceptions(byte exCode, struct ModbusApHeader mbap)
// ------------------------------------------------------------------------------------
// REGION: ModbusSend -----------------------------------------------------------------
/// <-ModbusSend>
void ModbusSend(byte buffer[], word length, word TxID)
void ModbusSend(byte buffer[], word length, byte funcCode)
{
struct QueueElement qe;
word TxID;
TxID = gTxID++;
qe.FuncCode = funcCode;
qe.Length = length;
memcpy(qe.Buffer, buffer, length);
@ -715,6 +691,8 @@ on timer gtRobin
{
writeDbg(ConnInfo, "Packet 0x%04X timed out! Retrying...", TxID);
gQueueSent[TxID].TimeoutTicks = 0;
EthSetTokenInt(gPacket, "modbus", "TxId", TxID);
EthSetTokenInt(gPacket, "modbus", "FuncCode", gQueueSent[TxID].FuncCode);
ModbusSnd(gQueueSent[TxID].Buffer, gQueueSent[TxID].Length); // resend it
reqError = Timeout;
ModbusRecv();

View file

@ -13,21 +13,18 @@ variables
// Read Data from the host. We only need the start address and the number of bits/registers we want to read
_align(1) struct ModbusReqRead
{
struct ModbusApHeader Header;
word Address;
word Count;
};
// Write a single value to a bit/register
_align(1) struct ModbusReqWriteSingle
{
struct ModbusApHeader Header;
word Address;
word Value;
};
// Write several values to a bit/register starting with Address
_align(1) struct ModbusReqWriteBits
{
struct ModbusApHeader Header;
word Address;
word Count;
byte ByteCount;
@ -36,7 +33,6 @@ variables
// Write several values to bits starting with Address
_align(1) struct ModbusReqWriteRegisters
{
struct ModbusApHeader Header;
word Address;
word Count;
byte ByteCount;
@ -45,7 +41,6 @@ variables
// Write AND and OR masks to a holding register
_align(1) struct ModbusReqWriteMasks
{
struct ModbusApHeader Header;
word Address;
word And;
word Or;
@ -53,7 +48,6 @@ variables
// Read and write multiple registers
_align(1) struct ModbusReqReadWriteRegisters
{
struct ModbusApHeader Header;
word ReadAddress;
word ReadCount;
word WriteAddress;
@ -66,35 +60,30 @@ variables
// Receive several bit values
_align(1) struct ModbusResReceiveBits
{
struct ModbusApHeader Header;
byte ByteCount;
byte Data[250]; // Max length: 2000 bits
};
// Receive several register values
_align(1) struct ModbusResReceiveRegisters
{
struct ModbusApHeader Header;
byte ByteCount;
word Data[125]; // Max length: 125 registers
};
// Confirm the write of a single bit/register
_align(1) struct ModbusResConfirmSingle
{
struct ModbusApHeader Header;
word Address;
int Value;
word Value;
};
// Confirm the write of several bits/registers
_align(1) struct ModbusResConfirmMultiple
{
struct ModbusApHeader Header;
word Address;
word Count;
};
// Confirm the write of AND and OR mask
_align(1) struct ModbusResConfirmMasks
{
struct ModbusApHeader Header;
word Address;
word And;
word Or;

View file

@ -350,7 +350,7 @@ VDEF ModbusProtocol::GetToken( const NIPB::VProtocolToken /*in*/ *protocolToken,
else if (tokenId == mFuncCode)
return MakeHeaderToken( protocolToken, mFuncCode, 56, 8, token );
else if (tokenId == NIPB::kData)
return this->MakePayloadToken( protocolToken, NIPB::kData, this->kHeaderBitLength, protocolToken->bitLength, token );
return this->MakePayloadToken( protocolToken, NIPB::kData, 0, protocolToken->bitLength, token );
else if (tokenId == NIPB::kHeader)
return this->MakeHeaderToken( protocolToken, NIPB::kHeader, 0, this->kHeaderBitLength, token );
else
@ -385,7 +385,7 @@ VDEF ModbusProtocol::InspectProtocol ( const NIPB::VProtocolToken /*in*/ *protoc
return NIPB::kError;
NIPB::IFormatter *formatter = 0;
ULONG val;
ULONG valA, valB;
// TODO: Make InspectProtocol nice and smooth
switch(type)
@ -396,21 +396,21 @@ VDEF ModbusProtocol::InspectProtocol ( const NIPB::VProtocolToken /*in*/ *protoc
{
formatter->FormatString( "MB: [" );
val = GetTxId( packetData, packetLength, *protocolToken );
formatter->FormatUnsigned(val, 2, 10);
valA = GetTxId( packetData, packetLength, *protocolToken );
formatter->FormatUnsigned(valA, 2, 10);
formatter->FormatString( "] " );
val = GetFuncCode( packetData, packetLength, *protocolToken );
if (val > 0x80)
valA = GetFuncCode( packetData, packetLength, *protocolToken );
valB = GetFirstDataByte( packetData, packetLength, *protocolToken ); // Exception Code OR number of bytes
if (valA > 0x80)
{
formatter->FormatString( "(0x" );
formatter->FormatUnsigned( val & 0x0F, 1, 16 );
formatter->FormatUnsigned( valA & 0x0F, 1, 16 );
val = GetExCode( packetData, packetLength, *protocolToken );
formatter->FormatString( ") Ex 0x" );
formatter->FormatUnsigned( val, 1, 16);
switch (val) // exCode
formatter->FormatString( ") Ex" );
formatter->FormatUnsigned( valB, 1, 10);
switch (valB) // exCode
{
case 0x01:
formatter->FormatString( ": Illegal func code!" );
@ -442,21 +442,56 @@ VDEF ModbusProtocol::InspectProtocol ( const NIPB::VProtocolToken /*in*/ *protoc
}
else
{
switch (val) // funcCode
switch (valA) // funcCode
{
case 0x01:
case 0x02:
formatter->FormatString( "Read bits" );
if (protocolToken->bitLength == BY2BI(valB+1)) // if the first byte gives the count of following bytes --> response
{
formatter->FormatString( "Read bits response" );
}
else
{
formatter->FormatString( "Read " );
valB = GetAddrNCount( packetData, packetLength, *protocolToken );
formatter->FormatUnsigned( valB & 0xFFFF, 2, 10 );
formatter->FormatString( " bits from 0x" );
formatter->FormatUnsigned( valB >> 16, 2, 16 );
}
break;
case 0x03:
case 0x04:
formatter->FormatString( "Read regs" );
if (protocolToken->bitLength == BY2BI(valB+1)) // if the first byte gives the count of following bytes --> response
{
formatter->FormatString( "Read regs response" );
}
else
{
formatter->FormatString( "Read " );
valB = GetAddrNCount( packetData, packetLength, *protocolToken );
formatter->FormatUnsigned( valB & 0xFFFF, 2, 10 );
formatter->FormatString( " regs from 0x" );
formatter->FormatUnsigned( valB >> 16, 2, 16 );
}
break;
case 0x05:
formatter->FormatString( "Write bit" );
formatter->FormatString( "Set bit 0x" );
formatter->FormatUnsigned( valB >> 16, 2, 16 );
valB = GetAddrNCount( packetData, packetLength, *protocolToken );
formatter->FormatString( " to " );
if (valB & 0xFFFF > 0xFF00)
formatter->FormatString( "1" );
else
formatter->FormatString( "0" );
break;
case 0x06:
formatter->FormatString( "Write reg" );
formatter->FormatString( "Set reg 0x" );
formatter->FormatUnsigned( valB >> 16, 2, 16 );
valB = GetAddrNCount( packetData, packetLength, *protocolToken );
formatter->FormatString( " to " );
formatter->FormatUnsigned( valB & 0xFFFF, 2, 10 );
break;
case 0x0F:
formatter->FormatString( "Write bits" );
@ -472,7 +507,7 @@ VDEF ModbusProtocol::InspectProtocol ( const NIPB::VProtocolToken /*in*/ *protoc
break;
default:
formatter->FormatString( "[0x" );
formatter->FormatUnsigned(val, 1, 16);
formatter->FormatUnsigned(valA, 1, 16);
formatter->FormatString( "]" );
break;
}
@ -486,8 +521,8 @@ VDEF ModbusProtocol::InspectProtocol ( const NIPB::VProtocolToken /*in*/ *protoc
if (inspector->SelectField( NIPB::kFieldLabel, &formatter ) == NIPB::kOK)
formatter->FormatString( "ModbusDetail" );
val = GetContentId( packetData, packetLength, *protocolToken );
FormatUnsigned( inspector, "TxIDDetail", mTxId, val, 2 );
valB = GetContentId( packetData, packetLength, *protocolToken );
FormatUnsigned( inspector, "TxIDDetail", mTxId, valB, 2 );
break;
}
@ -504,7 +539,7 @@ VDEF ModbusProtocol::InspectProtocol ( const NIPB::VProtocolToken /*in*/ *protoc
//! Returns the content ID
/*!
*/
ULONG ModbusProtocol::GetContentId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
ULONG ModbusProtocol::GetContentId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
{
ULONG ip = GetIp( packetData, packetLength, protocol );
BYTE funcCode = GetFuncCode( packetData, packetLength, protocol );
@ -516,7 +551,7 @@ ULONG ModbusProtocol::GetContentId( const BYTE *packetData, ULONG packetLength,
//! Returns the TxID
/*!
*/
WORD ModbusProtocol::GetTxId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
WORD ModbusProtocol::GetTxId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
{
ULONG offset = BI2BY(protocol.headerBitOffset);
@ -530,11 +565,11 @@ WORD ModbusProtocol::GetTxId( const BYTE *packetData, ULONG packetLength, const
//! Returns the FuncCode
/*!
*/
BYTE ModbusProtocol::GetFuncCode( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
BYTE ModbusProtocol::GetFuncCode( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
{
ULONG offset = BI2BY(protocol.headerBitOffset) + 7;
if (offset+1 < packetLength)
if (offset < packetLength)
{
return packetData[offset];
}
@ -548,7 +583,7 @@ BYTE ModbusProtocol::GetFuncCode( const BYTE *packetData, ULONG packetLength, co
//! Returns the DestinationIP
/*!
*/
ULONG ModbusProtocol::GetIp( const BYTE * /*packetData*/, ULONG /*packetLength*/, const NIPB::VProtocolToken &/*protocol*/ )
ULONG ModbusProtocol::GetIp( const BYTE * /*packetData*/, ULONG /*packetLength*/, const NIPB::VProtocolToken &/*protocol*/ )
{
// TODO: GetDestIp
/*NIPB::VToken *ipv4DestIp;
@ -569,11 +604,15 @@ ULONG ModbusProtocol::GetIp( const BYTE * /*packetData*/, ULONG /*packetLength*/
return 0xC0A80102;
}
BYTE ModbusProtocol::GetExCode( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
/*--------------------------------------------------------------------*/
//! Returns the first byte of the payload
/*!
*/
BYTE ModbusProtocol::GetFirstDataByte( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
{
ULONG offset = BI2BY(protocol.bitOffset);
if (offset+1 < packetLength)
if (offset < packetLength)
{
return packetData[offset];
}
@ -583,6 +622,29 @@ BYTE ModbusProtocol::GetExCode( const BYTE *packetData, ULONG packetLength, cons
}
}
/*--------------------------------------------------------------------*/
//! Returns the first two words of the payload
/*!
*/
ULONG ModbusProtocol::GetAddrNCount( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol )
{
ULONG offset = BI2BY(protocol.bitOffset);
ULONG value;
if (offset+3 < packetLength)
{
value = packetData[offset] << 8 | packetData[offset+1]; // LE/BE
value <<= 16;
offset += 2;
value |= packetData[offset] << 8 | packetData[offset+1]; // LE/BE
return value;
}
else
{
return 0;
}
}
/*--------------------------------------------------------------------*/
//! Fill a VToken structure.
/*!

View file

@ -141,11 +141,12 @@ public:
// Methods
//
public:
ULONG GetContentId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
WORD GetTxId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
ULONG GetIp( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
BYTE GetFuncCode( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
BYTE GetExCode( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
ULONG GetContentId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
WORD GetTxId( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
ULONG GetIp( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
BYTE GetFuncCode( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
BYTE GetFirstDataByte( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
ULONG GetAddrNCount( const BYTE *packetData, ULONG packetLength, const NIPB::VProtocolToken &protocol );
static NIPB::VResult MakeHeaderToken( const NIPB::VProtocolToken /*in*/ *protocolToken, NIPB::VTokenId /*in*/ tokenId, ULONG /*in*/ offset, ULONG /*in*/ length, NIPB::VToken /*out*/ *token );
static NIPB::VResult MakePayloadToken( const NIPB::VProtocolToken /*in*/ *protocolToken, NIPB::VTokenId /*in*/ tokenId, ULONG /*in*/ offset, ULONG /*in*/ length, NIPB::VToken /*out*/ *token );

View file

@ -35,7 +35,7 @@ STDAPI DllRegisterAddOn( NIPB::IAddOnRegistrar* registrar )
// UDP is used.
//
ModbusProtocolAddOn *mbpao = new ModbusProtocolAddOn();
if (registrar->RegisterProtocol( "modbus", mbpao, "udp", ModbusProtocol::kServerPort, 0xFFFFFFFF ) != NIPB::kOK)
if (registrar->RegisterProtocol( "modbus", mbpao, "udp", ModbusProtocol::kServerPort, ModbusProtocol::kClientPort ) != NIPB::kOK)
{
log << "Could not register UDP 502 -> 50002\n";
log.close();

View file

@ -3,43 +3,22 @@ Initializing Defining fields MyProtocolId = 4896.
InitProtocol.
CompleteProtocol: Modbus->bitLength = 32, --> Length = 6.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 12
Data = 00 01 00 00 00 06 ff 01 00 00 00 00
Data = 00 01 00 00 00 06 ff 01 00 00 00 02
--> byteOffset = 50, byteLength = 4
--> ContentId = 1020001.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 9
Data = 00 01 00 00 00 03 ff 81 03
--> byteOffset = 50, byteLength = 1
--> ContentId = 1020081.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 10
Data = 00 01 00 00 00 04 ff 01 01 00
--> byteOffset = 50, byteLength = 2
--> ContentId = 1020001.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 12
Data = 00 01 00 00 00 06 ff 01 00 00 00 00
Data = 00 01 00 00 00 06 ff 01 00 00 00 02
--> byteOffset = 50, byteLength = 4
--> ContentId = 1020001.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 9
Data = 00 01 00 00 00 03 ff 81 03
--> byteOffset = 50, byteLength = 1
--> ContentId = 1020081.
CompleteProtocol: Modbus->bitLength = 32, --> Length = 6.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 12
Data = 00 02 00 00 00 06 ff 01 00 00 00 00
--> byteOffset = 50, byteLength = 4
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 10
Data = 00 01 00 00 00 04 ff 01 01 00
--> byteOffset = 50, byteLength = 2
--> ContentId = 1020001.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 9
Data = 00 02 00 00 00 03 ff 81 03
--> byteOffset = 50, byteLength = 1
--> ContentId = 1020081.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 12
Data = 00 02 00 00 00 06 ff 01 00 00 00 00
--> byteOffset = 50, byteLength = 4
--> ContentId = 1020001.
ParsePacket topProtocolToken->tokenId = 352 byteOffset = 42, byteLength = 9
Data = 00 02 00 00 00 03 ff 81 03
--> byteOffset = 50, byteLength = 1
--> ContentId = 1020081.