Commit 34142359 authored by Claes Sjofors's avatar Claes Sjofors Committed by Claes Sjöfors

Modbus TCP slave, configuration for little endian

parent 9d8cea8c
......@@ -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");
......
......@@ -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++) {
......
......@@ -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 = "_X21"
Attr NextAix = "_X23"
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
......
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