Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
f2b57547
Commit
f2b57547
authored
Apr 01, 2019
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modbus TCP slave, configuration for little endian
parent
57dff021
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
7 deletions
+30
-7
otherio/lib/rt/src/rt_io_m_mb_module.c
otherio/lib/rt/src/rt_io_m_mb_module.c
+10
-2
otherio/lib/rt/src/rt_io_m_mb_tcp_slave.c
otherio/lib/rt/src/rt_io_m_mb_tcp_slave.c
+6
-3
otherio/wbl/mcomp/src/otherio.wb_load
otherio/wbl/mcomp/src/otherio.wb_load
+14
-2
No files found.
otherio/lib/rt/src/rt_io_m_mb_module.c
View file @
f2b57547
...
...
@@ -86,6 +86,7 @@ static pwr_tStatus IoCardRead(
io_sCardLocalMsg
*
local
;
pwr_sClass_Modbus_Module
*
op
;
pwr_sClass_Modbus_TCP_Slave
*
slave
;
pwr_eByteOrderingEnum
byteorder
=
pwr_eByteOrderingEnum_BigEndian
;
op
=
(
pwr_sClass_Modbus_Module
*
)
cp
->
op
;
local
=
((
io_sCardLocal
*
)
cp
->
Local
)
->
msg
;
...
...
@@ -102,9 +103,12 @@ static pwr_tStatus IoCardRead(
local
->
interval_cnt
++
;
}
if
(
slave
->
ByteOrderingLE
)
byteorder
=
pwr_eByteOrderingEnum_LittleEndian
;
if
(
slave
->
Status
==
MB__NORMAL
)
{
io_bus_card_read
(
ctx
,
rp
,
cp
,
slave
->
Inputs
,
NULL
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
byteorder
,
pwr_eFloatRepEnum_FloatIntel
);
}
// printf("Method Modbus_Module-IoCardRead\n");
return
IO__SUCCESS
;
...
...
@@ -120,6 +124,7 @@ static pwr_tStatus IoCardWrite(
pwr_sClass_Modbus_Module
*
op
;
pwr_sClass_Modbus_TCP_Slave
*
slave
;
pwr_eByteOrderingEnum
byteorder
=
pwr_eByteOrderingEnum_BigEndian
;
op
=
(
pwr_sClass_Modbus_Module
*
)
cp
->
op
;
local
=
((
io_sCardLocal
*
)
cp
->
Local
)
->
msg
;
...
...
@@ -138,8 +143,11 @@ static pwr_tStatus IoCardWrite(
return
IO__SUCCESS
;
}
if
(
slave
->
ByteOrderingLE
)
byteorder
=
pwr_eByteOrderingEnum_LittleEndian
;
if
(
slave
->
Status
==
MB__NORMAL
)
{
io_bus_card_write
(
ctx
,
cp
,
slave
->
Outputs
,
pwr_eByteOrderingEnum_BigEndian
,
io_bus_card_write
(
ctx
,
cp
,
slave
->
Outputs
,
byteorder
,
pwr_eFloatRepEnum_FloatIntel
);
}
// printf("Method Modbus_Module-IoCardWrite\n");
...
...
otherio/lib/rt/src/rt_io_m_mb_tcp_slave.c
View file @
f2b57547
...
...
@@ -704,7 +704,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
char
name
[
196
];
pwr_tStatus
sts
;
pwr_tCid
cid
;
pwr_eByteOrderingEnum
byteorder
=
pwr_eByteOrderingEnum_BigEndian
;
io_sChannel
*
chanp
;
int
i
;
...
...
@@ -716,6 +716,9 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
rp
->
Local
=
calloc
(
1
,
sizeof
(
io_sRackLocal
));
local
=
rp
->
Local
;
if
(
op
->
ByteOrderingLE
)
byteorder
=
pwr_eByteOrderingEnum_LittleEndian
;
/* Create socket, store in local struct */
sts
=
connect_slave
(
local
,
rp
);
...
...
@@ -763,7 +766,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
io_bus_card_init
(
ctx
,
cardp
,
&
input_area_offset
,
&
input_area_chansize
,
&
output_area_offset
,
&
output_area_chansize
,
pwr_eByteOrderingEnum_BigEndian
,
io_eAlignment_Packed
);
byteorder
,
io_eAlignment_Packed
);
/* Count number of di and do */
for
(
i
=
0
;
i
<
cardp
->
ChanListSize
;
i
++
)
{
...
...
@@ -814,7 +817,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
io_bus_card_init
(
ctx
,
cardp
,
&
input_area_offset
,
&
input_area_chansize
,
&
output_area_offset
,
&
output_area_chansize
,
pwr_eByteOrderingEnum_BigEndian
,
io_eAlignment_Packed
);
byteorder
,
io_eAlignment_Packed
);
/* Count number of di and do */
for
(
i
=
0
;
i
<
cardp
->
ChanListSize
;
i
++
)
{
...
...
otherio/wbl/mcomp/src/otherio.wb_load
View file @
f2b57547
...
...
@@ -2217,7 +2217,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object RtBody $ObjBodyDef 1 08-FEB-2008 10:26:36.84
Body SysBody 08-FEB-2008 10:26:36.85
Attr StructName = "Modbus_TCP_Slave"
Attr NextAix = "_X2
1
"
Attr NextAix = "_X2
3
"
EndBody
!/**
! Description of slave
...
...
@@ -2331,6 +2331,18 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
!/**
! Network format is set to little endian.
! The standard network format for Modbus TCP is big endian. Despite
! this, slaves despite this uses little endian. Setting byte
! ordering to little endian makes it possible to connect to such slaves.
!*/
Object ByteOrderingLE $Attribute 22 29-MAR-2019 11:26:24.84
Body SysBody 29-MAR-2019 11:26:54.23
Attr Flags = 16777216
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! @Summary Error count of the slave.
! ErrorCount will increase every cycle if status is not MB__NORMAL.
! When ErrorCount reaches the ErrorLimit all inputs are reset to zero.
...
...
@@ -5947,7 +5959,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object FirmwareVersion $Attribute 27 05-FEB-2012 16:33:33.69
Body SysBody 05-FEB-2012 16:33:52.27
Attr PgmName = "FirmwareVersion"
Attr Size =
40
Attr Size =
132
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$String132"
EndBody
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment