Commit 60f6ed3d authored by Claes Sjöfors's avatar Claes Sjöfors

Profibus merged

parent b12b2d08
......@@ -831,7 +831,7 @@ typedef struct T_SET_CONFIGURATION_REQ
max_nr_of_sap_buffers; /* max # of SAP-Buffers (all CR) */
USIGN16 max_nr_of_poll_list_entries; /* max # of Poll-List-Entries
(all CR) */
USIGN16 max_data_buffer_size; /* max size of FMS-/FMA7-PDU-Buffer */
USIGN16 max_data_buffer_size; /* max size of FMS-/FMA7-PDU-Buffer */
} T_SET_CONFIGURATION_REQ;
#endif
......
......@@ -108,7 +108,7 @@ extern "C" {
#define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */
#define MODE_DISTRIBUTOR_DRIVER \
14 /* Command: B_SYSFKT ->function 1 = insert \
*/
*/
#define MODE_PRINT_DRIVER 15 /* Command: B_SYSFKT */
#define MODE_GET_RCS_ERROR 16 /* Command: B_SYSFKT */
......
......@@ -56,8 +56,8 @@
\*----------------------------------------------------------------------------*/
void ConvertAi(pwr_sClass_ChanAi* cop, pwr_tInt16 nobits, pwr_tUInt8 rawvalue8,
pwr_tUInt16 rawvalue16, pwr_tUInt32 rawvalue32, pwr_tFloat32* actvalue_p,
pwr_tEnum representation)
pwr_tUInt16 rawvalue16, pwr_tUInt32 rawvalue32,
pwr_tFloat32* actvalue_p, pwr_tEnum representation)
{
pwr_tFloat32 sigvalue;
......@@ -66,24 +66,30 @@ void ConvertAi(pwr_sClass_ChanAi* cop, pwr_tInt16 nobits, pwr_tUInt8 rawvalue8,
pwr_tFloat32 f_raw = 0.0;
int i;
if (nobits == 32) {
if (nobits == 32)
{
if (representation == PB_NUMREP_SIGNEDINT)
f_raw = (float)((int)rawvalue32);
else
f_raw = (float)rawvalue32;
} else if (nobits == 16) {
}
else if (nobits == 16)
{
if (representation == PB_NUMREP_SIGNEDINT)
f_raw = (float)((short)rawvalue16);
else
f_raw = (float)rawvalue16;
} else if (nobits == 8) {
}
else if (nobits == 8)
{
if (representation == PB_NUMREP_SIGNEDINT)
f_raw = (float)((char)rawvalue8);
else
f_raw = (float)rawvalue8;
}
switch (cop->SensorPolyType) {
switch (cop->SensorPolyType)
{
case 0:
*actvalue_p = cop->SigValPolyCoef0 + cop->SigValPolyCoef1 * f_raw;
break;
......@@ -94,7 +100,8 @@ void ConvertAi(pwr_sClass_ChanAi* cop, pwr_tInt16 nobits, pwr_tUInt8 rawvalue8,
sigvalue = cop->SigValPolyCoef0 + cop->SigValPolyCoef1 * f_raw;
polycoef_p = &cop->SensorPolyCoef2;
actvalue = 0;
for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++)
{
actvalue = sigvalue * actvalue + *polycoef_p;
polycoef_p--;
}
......@@ -124,8 +131,9 @@ void ConvertAi(pwr_sClass_ChanAi* cop, pwr_tInt16 nobits, pwr_tUInt8 rawvalue8,
\*----------------------------------------------------------------------------*/
void ConvertAit(pwr_sClass_ChanAit* cop, pwr_tInt16 nobits,
pwr_tUInt16 rawvalue8, pwr_tUInt16 rawvalue16, pwr_tUInt32 rawvalue32,
pwr_tFloat32* actvalue_p, pwr_tEnum representation)
pwr_tUInt16 rawvalue8, pwr_tUInt16 rawvalue16,
pwr_tUInt32 rawvalue32, pwr_tFloat32* actvalue_p,
pwr_tEnum representation)
{
pwr_tFloat32 Slope;
pwr_tFloat32 Intercept;
......@@ -136,17 +144,22 @@ void ConvertAit(pwr_sClass_ChanAit* cop, pwr_tInt16 nobits,
pwr_tFloat32 sigvalue;
pwr_tFloat32 f_raw = 0.0;
if (nobits == 32) {
if (nobits == 32)
{
if (representation == PB_NUMREP_SIGNEDINT)
f_raw = (float)((int)rawvalue32);
else
f_raw = (float)rawvalue32;
} else if (nobits == 16) {
}
else if (nobits == 16)
{
if (representation == PB_NUMREP_SIGNEDINT)
f_raw = (float)((short)rawvalue16);
else
f_raw = (float)rawvalue16;
} else if (nobits == 8) {
}
else if (nobits == 8)
{
if (representation == PB_NUMREP_SIGNEDINT)
f_raw = (float)((char)rawvalue8);
else
......@@ -157,7 +170,8 @@ void ConvertAit(pwr_sClass_ChanAit* cop, pwr_tInt16 nobits,
Last = cop->NoOfCoordinates;
while ((Last - First) > 1) {
while ((Last - First) > 1)
{
Middle = (First + Last) / 2;
TransTabValue = cop->InValue[Middle];
if (sigvalue < TransTabValue)
......@@ -174,8 +188,8 @@ void ConvertAit(pwr_sClass_ChanAit* cop, pwr_tInt16 nobits,
/*----------------------------------------------------------------------------*\
Init method for the Pb module Ai
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ai* op;
......@@ -185,23 +199,28 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ai*)cp->op;
local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) {
if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name);
return 1;
}
if (op->Status >= PB_MODULE_STATE_OPERATE) {
for (i = 0; i < IO_MAXCHAN; i++) {
if (op->Status >= PB_MODULE_STATE_OPERATE)
{
for (i = 0; i < IO_MAXCHAN; i++)
{
local->scancount[i] = 0;
}
// Calculate polycoeff
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop)
continue;
io_AiRangeToCoef(chanp);
}
} else
}
else
errh_Info("Error initializing Pb module Ai %s", cp->Name);
return IO__SUCCESS;
......@@ -210,8 +229,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb Ai card
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ai* op;
......@@ -232,8 +251,10 @@ static pwr_tStatus IoCardRead(
op = (pwr_sClass_Pb_Ai*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
for (i = 0; i < cp->ChanListSize; i++) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -244,107 +265,121 @@ static pwr_tStatus IoCardRead(
if (cop->CalculateNewCoef)
io_AiRangeToCoef(chanp);
if (cop->ConversionOn) {
if (local->scancount[i] <= 1) {
if (op->BytesPerChannel == 4) {
if (cop->ConversionOn)
{
if (local->scancount[i] <= 1)
{
if (op->BytesPerChannel == 4)
{
memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32);
data32 = (pwr_tInt32)udata32;
sop->RawValue = 0;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
sop->SigValue
= udata32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
sop->SigValue =
udata32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
else
sop->SigValue
= data32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass) {
sop->SigValue =
data32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass)
{
case pwr_cClass_ChanAi:
ConvertAi(
cop, 32, 0, 0, udata32, &actvalue, op->NumberRepresentation);
ConvertAi(cop, 32, 0, 0, udata32, &actvalue,
op->NumberRepresentation);
break;
case pwr_cClass_ChanAit:
ConvertAit((pwr_sClass_ChanAit*)cop, 32, 0, 0, udata32, &actvalue,
op->NumberRepresentation);
op->NumberRepresentation);
break;
}
} else if (op->BytesPerChannel == 3) {
}
else if (op->BytesPerChannel == 3)
{
udata32 = 0;
memcpy(&udata32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
udata32 = swap32(udata32);
udata32 = udata32 >> 8;
}
data32 = (pwr_tInt32)udata32;
sop->RawValue = 0;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
sop->SigValue
= udata32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
sop->SigValue =
udata32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
else
sop->SigValue
= data32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass) {
sop->SigValue =
data32 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass)
{
case pwr_cClass_ChanAi:
ConvertAi(
cop, 32, 0, 0, udata32, &actvalue, op->NumberRepresentation);
ConvertAi(cop, 32, 0, 0, udata32, &actvalue,
op->NumberRepresentation);
break;
case pwr_cClass_ChanAit:
ConvertAit((pwr_sClass_ChanAit*)cop, 32, 0, 0, udata32, &actvalue,
op->NumberRepresentation);
op->NumberRepresentation);
break;
}
} else if (op->BytesPerChannel == 2) {
}
else if (op->BytesPerChannel == 2)
{
memcpy(&udata16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16);
data16 = (pwr_tInt16)udata16;
sop->RawValue = udata16;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
sop->SigValue
= udata16 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
sop->SigValue =
udata16 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
else
sop->SigValue
= data16 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass) {
sop->SigValue =
data16 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass)
{
case pwr_cClass_ChanAi:
ConvertAi(
cop, 16, 0, udata16, 0, &actvalue, op->NumberRepresentation);
ConvertAi(cop, 16, 0, udata16, 0, &actvalue,
op->NumberRepresentation);
break;
case pwr_cClass_ChanAit:
ConvertAit((pwr_sClass_ChanAit*)cop, 16, 0, udata16, 0, &actvalue,
op->NumberRepresentation);
op->NumberRepresentation);
break;
}
}
else if (op->BytesPerChannel == 1) {
else if (op->BytesPerChannel == 1)
{
memcpy(&udata8, local->input_area + op->OffsetInputs + i, 1);
data8 = (pwr_tInt8)udata8;
sop->RawValue = udata8;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
sop->SigValue
= udata8 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
sop->SigValue =
udata8 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
else
sop->SigValue
= data8 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass) {
sop->SigValue =
data8 * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch (chanp->ChanClass)
{
case pwr_cClass_ChanAi:
ConvertAi(
cop, 8, udata8, 0, 0, &actvalue, op->NumberRepresentation);
ConvertAi(cop, 8, udata8, 0, 0, &actvalue,
op->NumberRepresentation);
break;
case pwr_cClass_ChanAit:
ConvertAit((pwr_sClass_ChanAit*)cop, 8, udata8, 0, 0, &actvalue,
op->NumberRepresentation);
op->NumberRepresentation);
break;
}
}
// Filter
if (sop->FilterType == 1 && sop->FilterAttribute[0] > 0
&& sop->FilterAttribute[0] > ctx->ScanTime) {
actvalue = *(pwr_tFloat32*)chanp->vbp
+ ctx->ScanTime / sop->FilterAttribute[0]
* (actvalue - *(pwr_tFloat32*)chanp->vbp);
if (sop->FilterType == 1 && sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32*)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32*)chanp->vbp);
}
*(pwr_tFloat32*)chanp->vbp = actvalue;
......@@ -353,8 +388,8 @@ static pwr_tStatus IoCardRead(
local->scancount[i]--;
} // if ...ConversionOn
} // for
} // if ...op->Status
} // for
} // if ...op->Status
return IO__SUCCESS;
}
......@@ -362,8 +397,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Close method for the Pb Ai card
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -377,5 +412,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ai) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Ai) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Ao
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ao* op;
......@@ -63,20 +63,24 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ao*)cp->op;
local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) {
if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS;
}
if (op->Status >= PB_MODULE_STATE_OPERATE) {
if (op->Status >= PB_MODULE_STATE_OPERATE)
{
// Calculate polycoeff
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop)
continue;
io_AoRangeToCoef(chanp);
}
} else
}
else
errh_Info("Error initializing Pb module Ao %s", cp->Name);
return IO__SUCCESS;
......@@ -85,8 +89,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Write method for the Pb module Ao
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ao* op;
......@@ -109,10 +113,12 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Ao*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -125,7 +131,8 @@ static pwr_tStatus IoCardWrite(
value = cop->FixedOutValue;
else if (cop->TestOn)
value = cop->TestValue;
else {
else
{
value = *(pwr_tFloat32*)chanp->vbp;
}
......@@ -152,50 +159,66 @@ static pwr_tStatus IoCardWrite(
// Calculate signal value
sop->SigValue = cop->SigValPolyCoef1 * value + cop->SigValPolyCoef0;
if (op->BytesPerChannel == 4) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
if (op->BytesPerChannel == 4)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &udata32, 4);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = (pwr_tInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
}
} else if (op->BytesPerChannel == 3) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 3)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &udata32, 3);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = (pwr_tInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
}
} else if (op->BytesPerChannel == 2) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 2)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata16 = (pwr_tUInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &udata16, 2);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data16 = (pwr_tInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
}
} else if (op->BytesPerChannel == 1) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 1)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata8 = (pwr_tUInt8)rawvalue;
memcpy(local->output_area + op->OffsetOutputs + i, &udata8, 1);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data8 = (pwr_tInt8)rawvalue;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
}
......@@ -209,8 +232,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -224,6 +247,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ao)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Ao) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -54,8 +54,8 @@
/*----------------------------------------------------------------------------*\
Move di data word to valuebase.
\*----------------------------------------------------------------------------*/
void pbio_DiUnpackWord(
io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask, int index)
void pbio_DiUnpackWord(io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask,
int index)
{
io_sChannel* chanp;
......@@ -64,7 +64,8 @@ void pbio_DiUnpackWord(
else
chanp = &cp->chanlist[16];
if (mask == IO_CONVMASK_ALL) {
if (mask == IO_CONVMASK_ALL)
{
/* No conversion test */
if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
......@@ -114,7 +115,9 @@ void pbio_DiUnpackWord(
if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 32768) != 0);
chanp++;
} else {
}
else
{
if (chanp->cop && chanp->sop && mask & 1)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
chanp++;
......@@ -169,8 +172,8 @@ void pbio_DiUnpackWord(
/*----------------------------------------------------------------------------*\
Init method for the Pb module Di
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Di* op;
......@@ -180,8 +183,8 @@ static pwr_tStatus IoCardInit(
// Check configuration
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16
&& op->NumberOfChannels != 32)
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels)
......@@ -196,8 +199,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb module Di
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Di* op;
......@@ -208,22 +211,27 @@ static pwr_tStatus IoCardRead(
pwr_sClass_Di* sig_di;
pwr_tUInt32 mask = 0;
pwr_tUInt16 data[2] = { 0, 0 };
pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Di*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
memcpy(&data, local->input_area + op->OffsetInputs, op->BytesOfInput);
data32 = (pwr_tUInt32*)&data;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]);
data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) {
}
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32);
}
}
......@@ -233,11 +241,13 @@ static pwr_tStatus IoCardRead(
data[1] = data[1] ^ op->InvMask2;
// Packa upp
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
chan_di = (pwr_sClass_ChanDi*)chanp->cop;
sig_di = (pwr_sClass_Di*)chanp->sop;
if (chan_di && sig_di) {
if (chan_di && sig_di)
{
mask = 1 << chan_di->Number;
*(pwr_tUInt16*)(chanp->vbp) = ((*data32 & mask) != 0);
}
......@@ -258,8 +268,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -273,5 +283,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Di) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Di) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Do
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Do* op;
......@@ -61,8 +61,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Do*)cp->op;
local = (io_sCardLocal*)cp->Local;
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16
&& op->NumberOfChannels != 32)
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels)
......@@ -77,8 +77,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Write method for the Pb module Do
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Do* op;
......@@ -90,22 +90,25 @@ static pwr_tStatus IoCardWrite(
pwr_tUInt32 mask = 0;
pwr_tInt32 do_actval;
pwr_tUInt16 data[2] = { 0, 0 };
pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Do*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
data32 = (pwr_tUInt32*)&data;
// Packa ner
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
chan_do = (pwr_sClass_ChanDo*)chanp->cop;
sig_do = (pwr_sClass_Do*)chanp->sop;
if (chan_do && sig_do) {
if (chan_do && sig_do)
{
mask = 1 << chan_do->Number;
do_actval = *(pwr_tInt32*)chanp->vbp;
if (do_actval != 0)
......@@ -118,11 +121,15 @@ static pwr_tStatus IoCardWrite(
io_DoPackWord(cp, &data[0], 0);
if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1);
*/
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]);
data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) {
}
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32);
}
}
......@@ -135,8 +142,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -150,6 +157,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Do)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Do) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -112,7 +112,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
latent_input_count = 0;
latent_output_count = 0;
while (cardp) {
while (cardp)
{
local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card;
local_card->input_area = (void*)&(op->Inputs);
......@@ -124,7 +125,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid)))
;
switch (cid) {
switch (cid)
{
/* Old style configuring with Pb_xx objects. Still here for combatibility
reasons.
New systems (from v4.1.3) should be build with Pb_Module objects or
......@@ -186,16 +188,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
mp = (pwr_sClass_Pb_Module*)cardp->op;
mp->Status = PB__INITFAIL;
cardp->offset = 0;
for (i = 0; i < cardp->ChanListSize; i++) {
for (i = 0; i < cardp->ChanListSize; i++)
{
chanp = &cardp->chanlist[i];
if (is_diag(&chanp->ChanAref)) {
if (is_diag(&chanp->ChanAref))
{
chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) {
switch (chanp->ChanClass)
{
case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi*)chanp->cop)->Number;
chanp->size
= GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation);
chanp->size =
GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation);
break;
default:
errh_Error("Diagnostic channel class, card %s", cardp->Name);
......@@ -203,30 +208,34 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
if (chanp->ChanClass != pwr_cClass_ChanDi)
{
input_counter += latent_input_count;
latent_input_count = 0;
}
if (chanp->ChanClass != pwr_cClass_ChanDo) {
if (chanp->ChanClass != pwr_cClass_ChanDo)
{
output_counter += latent_output_count;
latent_output_count = 0;
}
switch (chanp->ChanClass) {
switch (chanp->ChanClass)
{
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0) {
if (chan_di->Number == 0)
{
input_counter += latent_input_count;
latent_input_count = 0;
}
chanp->offset = input_counter;
chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask);
if (chan_di->Number == 0)
latent_input_count = GetChanSize(chan_di->Representation);
......@@ -269,18 +278,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0) {
if (chan_do->Number == 0)
{
output_counter += latent_output_count;
latent_output_count = 0;
}
chanp->offset = output_counter;
chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_do->Representation == pwr_eDataRepEnum_Bit16 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask);
if (chan_do->Number == 0)
latent_output_count = GetChanSize(chan_do->Representation);
......@@ -342,35 +352,45 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The reading of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
if (sp->DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Status == PB__NORMAL) {
if (sp->DisableSlave != 1 && mp->DisableBus != 1)
{
if (sp->Status == PB__NORMAL)
{
sp->ErrorCount = 0;
} else {
}
else
{
if (local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if (sp->ErrorCount == sp->ErrorSoftLimit) {
if (sp->ErrorCount == sp->ErrorSoftLimit)
{
errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
}
if (sp->ErrorCount == sp->ErrorHardLimit) {
if (sp->ErrorCount == sp->ErrorHardLimit)
{
errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction);
rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
}
if (sp->ErrorCount > sp->ErrorHardLimit
&& sp->StallAction == pwr_ePbStallAction_ResetInputs) {
if (sp->ErrorCount > sp->ErrorHardLimit &&
sp->StallAction == pwr_ePbStallAction_ResetInputs)
{
memset(&sp->Inputs, 0, sp->BytesOfInput);
}
if (sp->ErrorCount > sp->ErrorHardLimit
&& sp->StallAction == pwr_ePbStallAction_EmergencyBreak) {
if (sp->ErrorCount > sp->ErrorHardLimit &&
sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
{
ctx->Node->EmergBreakTrue = 1;
}
} else {
}
else
{
sp->ErrorCount = 0;
sp->Status = PB__DISABLED;
}
......@@ -410,6 +430,7 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = { pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackWrite),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = {
pwr_BindIoMethod(IoRackInit), pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
......@@ -65,8 +65,9 @@
static unsigned char req_res_buffer[512];
static short fdlif_sda_sdn_sdr_req(io_sAgentLocal* local_agent,
pwr_sClass_Pb_FDL_SAP* sap, pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
pwr_sClass_Pb_FDL_SAP* sap,
pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -106,16 +107,20 @@ possible return values:
*/
sdb.comm_ref = 0;
sdb.layer = FDLIF;
switch (op->Type) {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA: {
switch (op->Type)
{
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA:
{
sdb.service = FDLIF_SDA;
break;
}
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN: {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN:
{
sdb.service = FDLIF_SDN;
break;
}
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD: {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD:
{
sdb.service = FDLIF_SRD;
break;
}
......@@ -128,15 +133,17 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res(
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
// result = profi_snd_req_res(
// (T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
result = profi_snd_req_res(&sdb, (void*)req, PB_FALSE);
return ((pwr_tBoolean)(result == E_OK));
}
static short fdlif_reply_update_mult_req(io_sAgentLocal* local_agent,
pwr_sClass_Pb_FDL_SAP* sap, pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
pwr_sClass_Pb_FDL_SAP* sap,
pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -179,8 +186,9 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res(
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
// result = profi_snd_req_res((T_PROFI_DEVICE_HANDLE*)local_agent, &sdb,
// (void*)req, PB_FALSE);
result = profi_snd_req_res(&sdb, (void*)req, PB_FALSE);
return ((pwr_tBoolean)(result == E_OK));
}
......@@ -188,8 +196,8 @@ possible return values:
/*----------------------------------------------------------------------------*\
Init method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sFDLCardLocal* local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
......@@ -206,8 +214,8 @@ static pwr_tStatus IoCardInit(
local->byte_ordering = ((pwr_sClass_Pb_FDL_SAP*)rp->op)->ByteOrdering;
io_bus_card_init(ctx, cp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize, local->byte_ordering,
io_eAlignment_Packed);
&output_area_offset, &output_area_chansize,
local->byte_ordering, io_eAlignment_Packed);
local->input_area_size = input_area_offset + input_area_chansize;
local->output_area_size = output_area_offset + output_area_chansize;
......@@ -227,13 +235,13 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sFDLCardLocal* local = (io_sFDLCardLocal*)cp->Local;
io_bus_card_read(ctx, rp, cp, local->input_area, 0, local->byte_ordering,
local->float_representation);
local->float_representation);
return IO__SUCCESS;
}
......@@ -241,8 +249,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Write method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sAgentLocal* local_agent = (io_sAgentLocal*)ap->Local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
......@@ -251,16 +259,21 @@ static pwr_tStatus IoCardWrite(
op->Status = sap->Status;
if (op->Status == PB__NORMAL) {
if (op->Status == PB__NORMAL)
{
io_bus_card_write(ctx, cp, local->output_area, local->byte_ordering,
local->float_representation);
local->float_representation);
if (op->SendReq) {
if (op->SendReq)
{
pthread_mutex_lock(&local_agent->mutex);
if (sap->Responder) {
if (sap->Responder)
{
fdlif_reply_update_mult_req(local_agent, sap, op, local);
} else {
}
else
{
fdlif_sda_sdn_sdr_req(local_agent, sap, op, local);
}
op->SendReq = 0;
......@@ -274,8 +287,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
Close method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -290,7 +303,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod};
......@@ -85,5 +85,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = { pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = {pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
......@@ -86,7 +86,8 @@ board.
#include "rt_io_pb_locals.h"
typedef struct {
typedef struct
{
/* Board number. */
unsigned short dev_number;
/* Number of occupied bytes in the input area of the dual port ram. */
......@@ -114,7 +115,8 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap);
/* Start segment of the database, shall be 8 for
CIF30-DPM, CIF104-DPM, COM-DPM, COM-PB, CIF104-PB and CIF 50-PB.
Shall be 0 for CIF 30-PB and CIF 60-PB. */
typedef struct {
typedef struct
{
/* Used to terminate the table, se to 1 for every entry but the
last (dummy entry), which should be 0. */
unsigned char entry;
......@@ -129,15 +131,14 @@ typedef struct {
/* Table of known boards, consists of four fields according to the board type.
The last entry must be a null termination (entry == 0).
*/
boards known_boards[]
= { { 1, { 8, 50, 66, { 'C', 'I', 'F' } }, 8, "Hilscher CIF 50-PB" },
{ 0, {}, 0, "" } };
boards known_boards[] = {
{1, {8, 50, 66, {'C', 'I', 'F'}}, 8, "Hilscher CIF 50-PB"}, {0, {}, 0, ""}};
#endif /* FLASH_WRITE_ENABLE */
/* Initializes Profibus DP interface on the CIF board referred to by local.
DRV_NO_ERROR is returned upon success. */
static short dpm_init_master(
io_sAgentLocalHilscher* local, pwr_sClass_Pb_Hilscher* op, io_sAgent* ap)
static short dpm_init_master(io_sAgentLocalHilscher* local,
pwr_sClass_Pb_Hilscher* op, io_sAgent* ap)
{
short rv;
DPM_PLC_PARAMETER prm;
......@@ -166,19 +167,21 @@ static short dpm_init_master(
/* Writes parameters to the board local->dev_number, task 2, size is
* hardcoded to 16 as specified in dpm_pie.pdf, page 9. */
if ((rv = DevPutTaskParameter(local->dev_number, 2, 16, &prm))
!= DRV_NO_ERROR) {
if ((rv = DevPutTaskParameter(local->dev_number, 2, 16, &prm)) !=
DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - "
" DevPutTaskParameter() failed with return code %d",
ap->Name, rv);
ap->Name, rv);
return rv;
}
/* Resets board to put new master parameters into effect. */
if ((rv = DevReset(local->dev_number, WARMSTART, 8000)) != DRV_NO_ERROR) {
if ((rv = DevReset(local->dev_number, WARMSTART, 8000)) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - "
" DevReset() failed with return code %d",
ap->Name, rv);
ap->Name, rv);
return rv;
}
......@@ -191,15 +194,18 @@ static short dpm_init(io_sAgentLocalHilscher* local, io_sAgent* ap)
{
short rv;
if ((rv = DevOpenDriver()) != DRV_NO_ERROR) {
if ((rv = DevOpenDriver()) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - "
" DevOpenDriver() failed with return code %d",
ap->Name, rv);
ap->Name, rv);
return rv;
} else if ((rv = DevInitBoard(local->dev_number)) != DRV_NO_ERROR) {
}
else if ((rv = DevInitBoard(local->dev_number)) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - "
" DevInitBoard() failed with return code %d",
ap->Name, rv);
ap->Name, rv);
return rv;
}
......@@ -213,16 +219,18 @@ static short dpm_exit(io_sAgentLocalHilscher* local, io_sAgent* ap)
short rv;
short rv_ret = DRV_NO_ERROR;
if ((rv = DevExitBoard(local->dev_number)) != DRV_NO_ERROR) {
if ((rv = DevExitBoard(local->dev_number)) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - "
" DevExitBoard() failed with return code %d",
ap->Name, rv);
ap->Name, rv);
rv_ret = rv;
}
if ((rv = DevCloseDriver()) != DRV_NO_ERROR) {
if ((rv = DevCloseDriver()) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - "
" DevCloseDriver() failed with return code %d",
ap->Name, rv);
ap->Name, rv);
rv_ret = rv;
}
......@@ -251,29 +259,35 @@ static short module_cnt_inputs(io_sCard* cp)
for (cid = cp->Class; ODD(gdh_GetSuperClass(cid, &cid, cp->Objid));)
;
if (cid == pwr_cClass_Pb_Module) {
if (cid == pwr_cClass_Pb_Module)
{
/* New style configuring (from v4.1.3) with Pb_Module objects or
subclass. Loop all channels in the module and set channel size and
offset. */
for (i = 0; i < cp->ChanListSize; ++i) {
for (i = 0; i < cp->ChanListSize; ++i)
{
chanp = &cp->chanlist[i];
if (is_diag(&chanp->ChanAref)) {
if (is_diag(&chanp->ChanAref))
{
chanp->udata |= PB_UDATA_DIAG;
if (chanp->ChanClass != pwr_cClass_ChanIi)
errh_Error("Diagnostic channel class, card %s", cp->Name);
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
if (chanp->ChanClass != pwr_cClass_ChanDi)
{
input_counter += latent_input_count;
latent_input_count = 0;
}
switch (chanp->ChanClass) {
switch (chanp->ChanClass)
{
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0) {
if (chan_di->Number == 0)
{
input_counter += latent_input_count;
latent_input_count = 0;
}
......@@ -326,29 +340,35 @@ static short module_cnt_outputs(io_sCard* cp)
for (cid = cp->Class; ODD(gdh_GetSuperClass(cid, &cid, cp->Objid));)
;
if (cid == pwr_cClass_Pb_Module) {
if (cid == pwr_cClass_Pb_Module)
{
/* New style configuring (from v4.1.3) with Pb_Module objects or
subclass. Loop all channels in the module and set channel size and
offset. */
for (i = 0; i < cp->ChanListSize; i++) {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (is_diag(&chanp->ChanAref)) {
if (is_diag(&chanp->ChanAref))
{
chanp->udata |= PB_UDATA_DIAG;
if (chanp->ChanClass != pwr_cClass_ChanIi)
errh_Error("Diagnostic channel class, card %s", cp->Name);
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDo) {
if (chanp->ChanClass != pwr_cClass_ChanDo)
{
output_counter += latent_output_count;
latent_output_count = 0;
}
switch (chanp->ChanClass) {
switch (chanp->ChanClass)
{
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0) {
if (chan_do->Number == 0)
{
output_counter += latent_output_count;
latent_output_count = 0;
}
......@@ -385,7 +405,8 @@ The function will also set up the required fields in op so that Proview
may perform IO operations using the IoAgentRead() and IoAgentWrite() functions
in this module. */
static void dpm_set_add_tab(pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
io_sRack* rp, DPM_SL_PRM_ADD_TAB* add_tab, int add_tab_len)
io_sRack* rp, DPM_SL_PRM_ADD_TAB* add_tab,
int add_tab_len)
{
io_sCard* cardp;
short input_counter;
......@@ -400,10 +421,10 @@ static void dpm_set_add_tab(pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
slaves/modules have occupied so far. */
unsigned short* input_size;
unsigned short* output_size;
input_size
= (unsigned short*)&((io_sAgentLocalHilscher*)ap->Local)->input_size;
output_size
= (unsigned short*)&((io_sAgentLocalHilscher*)ap->Local)->output_size;
input_size =
(unsigned short*)&((io_sAgentLocalHilscher*)ap->Local)->input_size;
output_size =
(unsigned short*)&((io_sAgentLocalHilscher*)ap->Local)->output_size;
/* This lets Proview find the IO-area for this module (in this case it is
actually handled at the agent level, thus in this file). The offsets
......@@ -415,21 +436,24 @@ static void dpm_set_add_tab(pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
op->BytesOfOutput = 0;
/* Finds our rack (slave). */
for (sl = rp; sl != NULL
&& ((pwr_sClass_Pb_DP_Slave*)sl->op)->SlaveAddress != op->SlaveAddress;
for (sl = rp;
sl != NULL &&
((pwr_sClass_Pb_DP_Slave*)sl->op)->SlaveAddress != op->SlaveAddress;
sl = sl->next)
;
if (sl == NULL
|| ((pwr_sClass_Pb_DP_Slave*)sl->op)->SlaveAddress != op->SlaveAddress) {
if (sl == NULL ||
((pwr_sClass_Pb_DP_Slave*)sl->op)->SlaveAddress != op->SlaveAddress)
{
errh_Error("Profibus DP Master %s - "
" Can't find rack for slave %d",
ap->Name, op->SlaveAddress);
ap->Name, op->SlaveAddress);
return;
}
/* Iterates through the cards (modules in Profibus terminology) of
the current rack, counting the length of the input area as we go. */
for (cardp = sl->cardlist; cardp; cardp = cardp->next) {
for (cardp = sl->cardlist; cardp; cardp = cardp->next)
{
/* Gets the size of the input area for this module. */
input_counter = module_cnt_inputs(cardp);
......@@ -438,19 +462,21 @@ static void dpm_set_add_tab(pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
/* Only modules with and input or output area are required to
have an entry in the add tab. */
if (input_counter > 0) {
if (input_counter > 0)
{
assert(add_tab->bInput_Count + 4 < add_tab_len);
/* The MSB tells the Hilscher board whether to treat the address
as a byte (set) or word (unset) offset
(see dpm_pie.pdf, page 45). */
add_tab->ausEA_Offset[add_tab->bInput_Count++]
= *input_size | EA_OFFSET_BYTE;
add_tab->ausEA_Offset[add_tab->bInput_Count++] =
*input_size | EA_OFFSET_BYTE;
*input_size += input_counter;
}
}
/* Now process the output areas. */
for (cardp = sl->cardlist; cardp; cardp = cardp->next) {
for (cardp = sl->cardlist; cardp; cardp = cardp->next)
{
/* Gets the size of the output area for this module. */
output_counter = module_cnt_outputs(cardp);
......@@ -459,14 +485,15 @@ static void dpm_set_add_tab(pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
/* Only modules with and input or output area are required to
have an entry in the add tab. */
if (output_counter > 0) {
if (output_counter > 0)
{
assert(add_tab->bInput_Count + add_tab->bOutput_Count + 4 < add_tab_len);
/* The MSB tells the Hilscher board whether to treat the address
as a byte (set) or word (unset) offset
(see dpm_pie.pdf, page 45). */
/* The input offsets precedes the output offsets. */
add_tab->ausEA_Offset[add_tab->bInput_Count + add_tab->bOutput_Count++]
= *output_size | EA_OFFSET_BYTE;
add_tab->ausEA_Offset[add_tab->bInput_Count + add_tab->bOutput_Count++] =
*output_size | EA_OFFSET_BYTE;
*output_size += output_counter;
}
}
......@@ -474,9 +501,10 @@ static void dpm_set_add_tab(pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
assert(add_tab->bInput_Count + add_tab->bOutput_Count <= MAX_EA_OFFSET_LEN);
/* Updates the length of the add_tab struct. */
add_tab->usAdd_Tab_Len = sizeof(add_tab->usAdd_Tab_Len)
+ sizeof(add_tab->bInput_Count) + sizeof(add_tab->bOutput_Count)
+ 2 * add_tab->bInput_Count + 2 * add_tab->bOutput_Count;
add_tab->usAdd_Tab_Len =
sizeof(add_tab->usAdd_Tab_Len) + sizeof(add_tab->bInput_Count) +
sizeof(add_tab->bOutput_Count) + 2 * add_tab->bInput_Count +
2 * add_tab->bOutput_Count;
}
/* Writes instructions for reflashing the board to the error log. */
......@@ -499,9 +527,11 @@ static void dpm_ddlm_answer_msg_print_error(RCS_MESSAGE* msg, io_sAgent* ap)
if (msg == NULL)
return;
switch (msg->a) {
switch (msg->a)
{
case DDLM_Download:
switch (msg->f) {
switch (msg->f)
{
case 0:
return;
case CON_NO:
......@@ -551,7 +581,8 @@ static void dpm_ddlm_answer_msg_print_error(RCS_MESSAGE* msg, io_sAgent* ap)
break;
case DDLM_Slave_Diag:
switch (msg->f) {
switch (msg->f)
{
case 0:
return;
case CON_NA:
......@@ -567,7 +598,7 @@ static void dpm_ddlm_answer_msg_print_error(RCS_MESSAGE* msg, io_sAgent* ap)
return;
}
errh_Info("Profibus DP Master %s - Station %d - DDLM Slave Diag: %s",
ap->Name, ((RCS_MESSAGETELEGRAM_10*)msg)->device_adr, s);
ap->Name, ((RCS_MESSAGETELEGRAM_10*)msg)->device_adr, s);
break;
default:
......@@ -582,7 +613,8 @@ or 127 to set master bus parameters. The bus parameters are read from
the buffer prmdata and shall be of length prmlen. DRV_NO_ERROR is returned
if successful. */
static short dpm_ddlm_download(io_sAgentLocalHilscher* local,
unsigned char address, unsigned int prmlen, void* prmdata, io_sAgent* ap)
unsigned char address, unsigned int prmlen,
void* prmdata, io_sAgent* ap)
{
short rv;
int got_response = 0;
......@@ -613,32 +645,40 @@ static short dpm_ddlm_download(io_sAgentLocalHilscher* local,
assert(prmlen <= 240);
memcpy(&(msg.d[4]), prmdata, prmlen);
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC*)&msg, 5000))
!= DRV_NO_ERROR) {
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC*)&msg, 5000)) !=
DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - DDLM_Download - DevPutMessage()"
" returned %d",
ap->Name, rv);
ap->Name, rv);
return rv;
}
/* Checks confirmation message. */
while (!got_response) {
if ((rv = DevGetMessage(
local->dev_number, sizeof(rcv_msg), (MSG_STRUC*)&rcv_msg, 5000))
!= DRV_NO_ERROR) {
while (!got_response)
{
if ((rv = DevGetMessage(local->dev_number, sizeof(rcv_msg),
(MSG_STRUC*)&rcv_msg, 5000)) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - DDLM_Download - DevGetMessage()"
" returned %d",
ap->Name, rv);
ap->Name, rv);
return rv;
} else if (rcv_msg.nr != local->cif_msgcnt || rcv_msg.rx != 16
|| rcv_msg.tx != 3 || rcv_msg.a != DDLM_Download) {
}
else if (rcv_msg.nr != local->cif_msgcnt || rcv_msg.rx != 16 ||
rcv_msg.tx != 3 || rcv_msg.a != DDLM_Download)
{
/* Discards all messages prior to our response. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
continue;
} else if (rcv_msg.f != 0) {
}
else if (rcv_msg.f != 0)
{
dpm_ddlm_answer_msg_print_error(&rcv_msg, ap);
return rcv_msg.f;
} else {
}
else
{
got_response = 1;
}
}
......@@ -648,8 +688,8 @@ static short dpm_ddlm_download(io_sAgentLocalHilscher* local,
/* Configures the master bus parameters of the board referred to by
local, the struct containing the parameters should be passed in op. */
static short dpm_download_master_prm(
io_sAgentLocalHilscher* local, pwr_sClass_Pb_Hilscher* op, io_sAgent* ap)
static short dpm_download_master_prm(io_sAgentLocalHilscher* local,
pwr_sClass_Pb_Hilscher* op, io_sAgent* ap)
{
DPM_BUS_DP prm;
......@@ -661,14 +701,17 @@ static short dpm_download_master_prm(
prm.usBus_Para_Len = 32;
/* The master's address is hardcoded to 0. */
prm.bFDL_Add = 0;
prm.bBaudrate = ((op->BaudRate == 500) ? (DP_BAUD_500)
: (op->BaudRate == 1500)
? (DP_BAUD_1500)
: (op->BaudRate == 3000) ? (DP_BAUD_3000)
: (op->BaudRate == 6000)
? (DP_BAUD_6000)
: (op->BaudRate == 12000) ? (DP_BAUD_12000)
: (DP_BAUD_1500));
prm.bBaudrate =
((op->BaudRate == 500)
? (DP_BAUD_500)
: (op->BaudRate == 1500)
? (DP_BAUD_1500)
: (op->BaudRate == 3000)
? (DP_BAUD_3000)
: (op->BaudRate == 6000)
? (DP_BAUD_6000)
: (op->BaudRate == 12000) ? (DP_BAUD_12000)
: (DP_BAUD_1500));
prm.usTSL = op->Tsl;
prm.usMin_TSDR = op->MinTsdr;
prm.usMax_TSDR = op->MaxTsdr;
......@@ -696,7 +739,8 @@ is passed in local. op holds the slave to configure, the corresponding
agent pointer and rack pointer must be passed in ap and rp respectively.
DRV_NO_ERROR will be returned upon success. */
static short dpm_download_slave_prm(io_sAgentLocalHilscher* local,
pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap, io_sRack* rp)
pwr_sClass_Pb_DP_Slave* op, io_sAgent* ap,
io_sRack* rp)
{
unsigned char buf[DPM_MAX_LEN_DATA_UNIT];
unsigned int bufcnt = 0;
......@@ -790,8 +834,8 @@ static short dpm_download_slave_prm(io_sAgentLocalHilscher* local,
board referred to by local. The function will return DRV_NO_ERROR if
the request was sent without error, however, it tells us nothing
about whether any diagnostics data was sent back. */
static short dpm_req_slave_diag(
io_sAgentLocalHilscher* local, unsigned char address, io_sAgent* ap)
static short dpm_req_slave_diag(io_sAgentLocalHilscher* local,
unsigned char address, io_sAgent* ap)
{
short rv;
RCS_MESSAGETELEGRAM_10 msg;
......@@ -819,11 +863,12 @@ static short dpm_req_slave_diag(
msg.function = TASK_TFC_READ;
/* Requests diagnostic data from slave. */
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC*)&msg, 0))
!= DRV_NO_ERROR) {
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC*)&msg, 0)) !=
DRV_NO_ERROR)
{
errh_Info("Profibus DP Master %s - DDLM_Slave_Diag - DevPutMessage()"
" returned %d",
ap->Name, rv);
ap->Name, rv);
return rv;
}
......@@ -834,8 +879,8 @@ static short dpm_req_slave_diag(
to gather diagnostics data asynchronously. The desired agent's local
struct is passed via local and the associated rack list (Profibus slaves) is
passed in slave_list. */
static void dpm_update_slave_diag(
io_sAgentLocalHilscher* local, io_sRack* slave_list, io_sAgent* ap)
static void dpm_update_slave_diag(io_sAgentLocalHilscher* local,
io_sRack* slave_list, io_sAgent* ap)
{
short rv;
RCS_MESSAGETELEGRAM_10 rcv_msg;
......@@ -846,33 +891,40 @@ static void dpm_update_slave_diag(
memset(&rcv_msg, 0, sizeof(rcv_msg));
/* Gets pending diagnostic messages, discards all other messages. */
while ((rv = DevGetMessage(
local->dev_number, sizeof(rcv_msg), (MSG_STRUC*)&rcv_msg, 0))
== DRV_NO_ERROR) {
if (rcv_msg.rx != 16 || rcv_msg.tx != 3 || rcv_msg.a != DDLM_Slave_Diag) {
while ((rv = DevGetMessage(local->dev_number, sizeof(rcv_msg),
(MSG_STRUC*)&rcv_msg, 0)) == DRV_NO_ERROR)
{
if (rcv_msg.rx != 16 || rcv_msg.tx != 3 || rcv_msg.a != DDLM_Slave_Diag)
{
/* Discards received message. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
continue;
} else if (rcv_msg.f != 0) {
}
else if (rcv_msg.f != 0)
{
dpm_ddlm_answer_msg_print_error((RCS_MESSAGE*)&rcv_msg, ap);
/* Discards received message. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
continue;
} else {
}
else
{
/*** Updates Proview's structs with the acquired diagnostics. ***/
/* Finds our slave. */
for (sl = slave_list; sl != NULL; sl = sl->next) {
for (sl = slave_list; sl != NULL; sl = sl->next)
{
sp = (pwr_sClass_Pb_DP_Slave*)sl->op;
if (sp->SlaveAddress == rcv_msg.device_adr)
break;
}
/* The slave from which we were to read diagnostic data could not
be found -- abort. */
if (sp->SlaveAddress != rcv_msg.device_adr) {
if (sp->SlaveAddress != rcv_msg.device_adr)
{
errh_Error("Profibus DP Master %s - Received diagnostic message"
" from unknown slave %d",
ap->Name, rcv_msg.device_adr);
ap->Name, rcv_msg.device_adr);
return;
}
......@@ -888,23 +940,31 @@ static void dpm_update_slave_diag(
/* Updates the slave's status */
if (!(sp->StationStatus1 & ~pwr_mPbStationStatus1Mask_ExternalDiag)
&& !(sp->StationStatus2
& ~(pwr_mPbStationStatus2Mask_Default
| pwr_mPbStationStatus2Mask_ResponseMonitoringOn))) {
if (!(sp->StationStatus1 & ~pwr_mPbStationStatus1Mask_ExternalDiag) &&
!(sp->StationStatus2 &
~(pwr_mPbStationStatus2Mask_Default |
pwr_mPbStationStatus2Mask_ResponseMonitoringOn)))
{
sp->Status = PB__NORMAL;
} else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent) {
}
else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent)
{
sp->Status = PB__NOCONN;
} else if ((sp->StationStatus1
& (pwr_mPbStationStatus1Mask_ConfigFault
| pwr_mPbStationStatus1Mask_ParamFault))
|| (sp->StationStatus2
& pwr_mPbStationStatus2Mask_NewParamsRequested)) {
}
else if ((sp->StationStatus1 & (pwr_mPbStationStatus1Mask_ConfigFault |
pwr_mPbStationStatus1Mask_ParamFault)) ||
(sp->StationStatus2 &
pwr_mPbStationStatus2Mask_NewParamsRequested))
{
sp->Status = PB__CONFIGERR;
} else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_MasterLock) {
}
else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_MasterLock)
{
sp->Status = PB__MASTERLOCK;
} else { /* if (sp->StationStatus1
& pwr_mPbStationStatus1Mask_NotReady) */
}
else
{ /* if (sp->StationStatus1
& pwr_mPbStationStatus1Mask_NotReady) */
sp->Status = PB__NOTREADY;
}
}
......@@ -917,10 +977,14 @@ static void dpm_print_diag(io_sAgent* ap, DPM_DIAGNOSTICS* diag)
{
char* s;
if (diag->tError.bErr_Event == 0) {
if (diag->tError.bErr_Event == 0)
{
return;
} else if (diag->tError.bErr_Rem_Adr == 255) {
switch (diag->tError.bErr_Event) {
}
else if (diag->tError.bErr_Rem_Adr == 255)
{
switch (diag->tError.bErr_Event)
{
case TASK_F_NO_USR_TASK:
s = "usr task not found";
break;
......@@ -993,8 +1057,11 @@ static void dpm_print_diag(io_sAgent* ap, DPM_DIAGNOSTICS* diag)
errh_Info("Profibus DP Master %s - %s", ap->Name, s);
return;
} else {
switch (diag->tError.bErr_Event) {
}
else
{
switch (diag->tError.bErr_Event)
{
case CON_NA:
s = "no reaction of the remote station";
break;
......@@ -1013,7 +1080,7 @@ static void dpm_print_diag(io_sAgent* ap, DPM_DIAGNOSTICS* diag)
#ifdef SLAVE_DIAG_VERBOSE
errh_Info("Profibus DP Master %s - Station %d - %s", ap->Name,
diag->tError.bErr_Rem_Adr, s);
diag->tError.bErr_Rem_Adr, s);
#endif /* SLAVE_DIAG_VERBOSE */
return;
}
......@@ -1026,7 +1093,7 @@ static void dpm_print_diag(io_sAgent* ap, DPM_DIAGNOSTICS* diag)
If the board was found in the database, the function returns DRV_NO_ERROR
and the startsegment will be written to what db_startsegment points to. */
static short dpm_check_board_type(io_sAgentLocalHilscher* local, io_sAgent* ap,
unsigned char* db_startsegment)
unsigned char* db_startsegment)
{
short rv;
DEVINFO info;
......@@ -1035,16 +1102,17 @@ static short dpm_check_board_type(io_sAgentLocalHilscher* local, io_sAgent* ap,
assert(DRV_NO_ERROR == 0);
/* Gets device information from the board. */
if ((rv = DevGetInfo(local->dev_number, GET_DEV_INFO, sizeof(info), &info))
!= DRV_NO_ERROR) {
if ((rv = DevGetInfo(local->dev_number, GET_DEV_INFO, sizeof(info), &info)) !=
DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s - Error %d while checking board type.",
ap->Name, rv);
ap->Name, rv);
return rv;
}
errh_Info("Profibus DP Master %s -"
" Selected board %d has the following device info:",
ap->Name, local->dev_number);
ap->Name, local->dev_number);
errh_Info("Device DPM size: %d", info.bDpmSize);
errh_Info("Device type: %d", info.bDevType);
errh_Info("Device model: %d", info.bDevModel);
......@@ -1055,7 +1123,8 @@ static short dpm_check_board_type(io_sAgentLocalHilscher* local, io_sAgent* ap,
if (memcmp(&known_boards[i].info, &info, sizeof(info)) == 0)
break;
if (known_boards[i].entry == 0) {
if (known_boards[i].entry == 0)
{
/* Board was not found in table. */
errh_Error("Profibus DP Master %s - Unknown board.", ap->Name);
errh_Error("To add support for this board, look up its database start");
......@@ -1067,8 +1136,9 @@ static short dpm_check_board_type(io_sAgentLocalHilscher* local, io_sAgent* ap,
errh_Error("in the above mentioned documentation.");
errh_Error("{ 1, { %d, %d, %d, { '%c', '%c', '%c'} }, "
"<db start segment>, \"<board name>\" },",
info.bDpmSize, info.bDevType, info.bDevModel, info.abDevIdentifier[0],
info.abDevIdentifier[1], info.abDevIdentifier[2]);
info.bDpmSize, info.bDevType, info.bDevModel,
info.abDevIdentifier[0], info.abDevIdentifier[1],
info.abDevIdentifier[2]);
return BOARD_INIT_ERROR;
}
......@@ -1084,8 +1154,8 @@ static short dpm_check_board_type(io_sAgentLocalHilscher* local, io_sAgent* ap,
/* Deletes the "PROFIBUS" protocol settings database from the card referred
to by local, this procedure is described on page 32 -- 33 in dpm_pie.pdf. */
static short dpm_delete_flash_prmdb(
io_sAgentLocalHilscher* local, io_sAgent* ap)
static short dpm_delete_flash_prmdb(io_sAgentLocalHilscher* local,
io_sAgent* ap)
{
unsigned char db_startsegment;
int s = 3;
......@@ -1101,7 +1171,7 @@ static short dpm_delete_flash_prmdb(
memset(&msg, 0, sizeof(msg));
/* Defines message header. */
msg.rx = 0; /* receiver = RCS-Task */
msg.rx = 0; /* receiver = RCS-Task */
msg.tx = 16; /* transmitter = user at HOST */
msg.ln = 2;
msg.nr = ++local->cif_msgcnt;
......@@ -1114,21 +1184,22 @@ static short dpm_delete_flash_prmdb(
msg.d[0] = 4; /* mode = delete data base */
msg.d[1] = db_startsegment;
errh_Info(
"Profibus DP Master %s - Sending delete database request...", ap->Name);
errh_Info("Profibus DP Master %s - Sending delete database request...",
ap->Name);
/* Sends delete database request. */
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC*)&msg, 5000))
!= DRV_NO_ERROR) {
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC*)&msg, 5000)) !=
DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s -"
" DevPutMessage failed with return code %d",
ap->Name, rv);
ap->Name, rv);
return rv;
}
/* Waits for controller to update flash. */
errh_Info("Profibus DP Master %s -"
" Delete db request sent. Waiting %d seconds...",
ap->Name, s);
ap->Name, s);
while ((s = sleep(s)))
;
......@@ -1136,28 +1207,33 @@ static short dpm_delete_flash_prmdb(
memset(&msg, 0, sizeof(msg));
/* Gets response message. */
while (!got_response) {
if ((rv = DevGetMessage(
local->dev_number, sizeof(msg), (MSG_STRUC*)&msg, 10000))
!= DRV_NO_ERROR) {
while (!got_response)
{
if ((rv = DevGetMessage(local->dev_number, sizeof(msg), (MSG_STRUC*)&msg,
10000)) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s -"
" DevGetMessage failed with return code %d\n",
ap->Name, rv);
ap->Name, rv);
return rv;
} else if (msg.nr != local->cif_msgcnt || msg.rx != 16 || msg.tx != 0
|| msg.a != 6) {
}
else if (msg.nr != local->cif_msgcnt || msg.rx != 16 || msg.tx != 0 ||
msg.a != 6)
{
/* Discards all messages prior to our response. */
memset(&msg, 0, sizeof(msg));
continue;
} else {
}
else
{
if (msg.f != 0)
errh_Error("Profibus DP Master %s -"
" Delete db confirmation message f-flag set to %d",
ap->Name, msg.f);
ap->Name, msg.f);
else
errh_Info("Profibus DP Master %s -"
" Delete database confirmation message received.",
ap->Name);
ap->Name);
got_response = 1;
}
}
......@@ -1173,8 +1249,9 @@ static short dpm_delete_flash_prmdb(
/* Wrapper for dpm_init_master(), takes care of checking for (and optionally
removing) the sycon database if present. */
static short dpm_init_master_check_sycon_db(
io_sAgentLocalHilscher* local, pwr_sClass_Pb_Hilscher* op, io_sAgent* ap)
static short dpm_init_master_check_sycon_db(io_sAgentLocalHilscher* local,
pwr_sClass_Pb_Hilscher* op,
io_sAgent* ap)
{
short rv;
DRIVERINFO di;
......@@ -1182,30 +1259,36 @@ static short dpm_init_master_check_sycon_db(
assert(DRV_NO_ERROR == 0);
/* Initializes DP Master. */
if ((rv = dpm_init_master(local, op, ap)) != DRV_NO_ERROR) {
if ((rv = dpm_init_master(local, op, ap)) != DRV_NO_ERROR)
{
return rv;
} else if ((rv = DevGetInfo(
local->dev_number, GET_DRIVER_INFO, sizeof(di), &di))
!= DRV_NO_ERROR) {
}
else if ((rv = DevGetInfo(local->dev_number, GET_DRIVER_INFO, sizeof(di),
&di)) != DRV_NO_ERROR)
{
errh_Error("Profibus DP Master %s -"
" DevGetInfo failed with return code %d",
ap->Name, rv);
ap->Name, rv);
return rv;
} else if ((di.bHostFlags & (READY_FLAG | RUN_FLAG))
== (READY_FLAG | RUN_FLAG)) {
}
else if ((di.bHostFlags & (READY_FLAG | RUN_FLAG)) == (READY_FLAG | RUN_FLAG))
{
/* RUN and RDY bits set */
errh_Info(
"Profibus DP Master %s - Hostflags: 0x%X", ap->Name, di.bHostFlags);
errh_Info("Profibus DP Master %s - Hostflags: 0x%X", ap->Name,
di.bHostFlags);
errh_Info("Device is configured by SyCon.");
#ifdef FLASH_WRITE_ENABLE
errh_Info("Deleting SyCon database from board's flash.");
if ((rv = dpm_delete_flash_prmdb(local, ap)) != DRV_NO_ERROR) {
if ((rv = dpm_delete_flash_prmdb(local, ap)) != DRV_NO_ERROR)
{
return rv;
} else {
}
else
{
/* Reinitializes DP Master. */
rv = dpm_init_master(local, op, ap);
}
#else /* FLASH_WRITE_ENABLE */
#else /* FLASH_WRITE_ENABLE */
errh_Info("Flash writing is not enabled, ");
flashing_disabled_warning(ap);
return BOARD_INIT_ERROR;
......@@ -1231,13 +1314,14 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
pwr_sClass_Pb_DP_Slave* sop;
char name[196];
struct timespec rqtp = { 0, 20000000 }; /* 20 ms */
struct timespec rqtp = {0, 20000000}; /* 20 ms */
int retry;
/* Allocates area for local data structure */
ap->Local = calloc(1, sizeof(io_sAgentLocalHilscher));
if (!ap->Local) {
if (!ap->Local)
{
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name, "calloc");
return IO__ERRINIDEVICE;
}
......@@ -1249,7 +1333,8 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
op->Status = PB__NOTINIT;
/* Initializes interface. */
if (ctx->Node->Restarts > 0) {
if (ctx->Node->Restarts > 0)
{
nanosleep(&rqtp, NULL);
}
......@@ -1263,45 +1348,52 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
local->watchdog = 0;
/* Initializes Profibus driver API. */
if (dpm_init(local, ap) != DRV_NO_ERROR) {
if (dpm_init(local, ap) != DRV_NO_ERROR)
{
/* Cannot open driver */
op->Status = PB__INITFAIL;
errh_Error(
"ERROR config Profibus DP Master %s - %s", ap->Name, "open device");
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"open device");
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* If this is not the Profibus I/O process, return */
if ((op->Process & io_mProcess_Profibus)
&& (ctx->Process != io_mProcess_Profibus)) {
if ((op->Process & io_mProcess_Profibus) &&
(ctx->Process != io_mProcess_Profibus))
{
op->Status = PB__NOTINIT;
errh_Info("Init template I/O agent for Profibus DP Master %s, %d", ap->Name,
ctx->Process);
ctx->Process);
return IO__SUCCESS;
}
if (ctx->Node->Restarts > 0) {
errh_Info(
"Warm restart - Skipping config of Profibus DP Master %s", ap->Name);
if (ctx->Node->Restarts > 0)
{
errh_Info("Warm restart - Skipping config of Profibus DP Master %s",
ap->Name);
op->Status = PB__NORMAL;
return IO__SUCCESS;
}
errh_Info("Config of Profibus DP Master %s", ap->Name);
if (op->DisableBus != 1) {
if (op->DisableBus != 1)
{
ok = FALSE;
if (ctx->Node->Restarts == 0) {
if (ctx->Node->Restarts == 0)
{
retry = 0;
while (!ok) {
while (!ok)
{
op->Status = PB__NOTINIT;
/* Sets DP master parameters and checks for sycon database. */
if (dpm_init_master_check_sycon_db(local, op, ap) != DRV_NO_ERROR) {
if (dpm_init_master_check_sycon_db(local, op, ap) != DRV_NO_ERROR)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"dp init master");
"dp init master");
return IO__ERRINIDEVICE;
}
......@@ -1309,42 +1401,46 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
and initializes them. */
op->NumberSlaves = 0;
status = gdh_GetChild(ap->Objid, &slave_objid);
while (ODD(status)) {
while (ODD(status))
{
status = gdh_GetObjectClass(slave_objid, &slave_class);
status = gdh_ObjidToPointer(slave_objid, (pwr_tAddress*)&sop);
status = gdh_ObjidToName(
slave_objid, (char*)&name, sizeof(name), cdh_mNName);
status = gdh_ObjidToName(slave_objid, (char*)&name, sizeof(name),
cdh_mNName);
errh_Info("Download Profibus DP Slave config - %s", name);
/* Calculates IO offsets and configures the slave. */
if (dpm_download_slave_prm(local, sop, ap, ap->racklist)
!= DRV_NO_ERROR) {
if (dpm_download_slave_prm(local, sop, ap, ap->racklist) !=
DRV_NO_ERROR)
{
errh_Error("ERROR Init Profibus DP slave %s", name);
}
errh_Info("Profibus DP slave %d: in offs %d, input size %d,"
" out offs %d, out size %d",
sop->SlaveAddress, sop->OffsetInputs, sop->BytesOfInput,
sop->OffsetOutputs, sop->BytesOfOutput);
sop->SlaveAddress, sop->OffsetInputs, sop->BytesOfInput,
sop->OffsetOutputs, sop->BytesOfOutput);
op->NumberSlaves++;
status = gdh_GetNextSibling(slave_objid, &slave_objid);
}
/* Downloads the DP bus parameters -- this initiates the
cyclic data exchange. */
if (dpm_download_master_prm(local, op, ap) != DRV_NO_ERROR) {
if (dpm_download_master_prm(local, op, ap) != DRV_NO_ERROR)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"dp download bus");
"dp download bus");
return IO__ERRINIDEVICE;
}
ok = TRUE;
} /* End - While !ok */
} /* End - Initialization only if not restart */
} else
} /* End - Initialization only if not restart */
}
else
op->Status = PB__DISABLED;
return IO__SUCCESS;
......@@ -1376,17 +1472,19 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
however, keeping this code here enables us to confine all the Profibus
board specific code at the agent level. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
slave_list = slave_list->next)
{
sp = (pwr_sClass_Pb_DP_Slave*)slave_list->op;
mp = (pwr_sClass_Pb_Hilscher*)ap->op;
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL
&& sp->DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL &&
sp->DisableSlave != 1 && mp->DisableBus != 1)
{
/* Triggers the board's watchdog. */
DevTriggerWatchDog(local->dev_number, WATCHDOG_START, &local->watchdog);
/* Reads process image from the slave. */
rv = DevExchangeIO(local->dev_number, 0, 0, NULL, sp->OffsetInputs,
sp->BytesOfInput, sp->Inputs, 100);
sp->BytesOfInput, sp->Inputs, 100);
}
}
......@@ -1399,8 +1497,8 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
Make a poll to see if there are diagnostics, the answer also tells us
if there are any hardware faults. */
if ((op->Process & io_mProcess_Profibus)
&& (ctx->Process != io_mProcess_Profibus))
if ((op->Process & io_mProcess_Profibus) &&
(ctx->Process != io_mProcess_Profibus))
return IO__SUCCESS;
if (op->DisableBus == 1)
......@@ -1409,27 +1507,32 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
/* Reads the protocol states and checks for errors. */
DevGetTaskState(local->dev_number, 2, 64, &diag);
/* Checks if master is in state OPERATE. */
switch (diag.bDPM_state) {
switch (diag.bDPM_state)
{
case OPERATE:
if (op->Status != PB__NORMAL) {
if (op->Status != PB__NORMAL)
{
op->Status = PB__NORMAL;
errh_Info("Profibus DP Master %s - Mode changed to OPERATE", ap->Name);
}
break;
case CLEAR:
if (op->Status != PB__CLEARED) {
if (op->Status != PB__CLEARED)
{
op->Status = PB__CLEARED;
errh_Info("Profibus DP Master %s - Mode changed to CLEAR", ap->Name);
}
break;
case STOP:
if (op->Status != PB__STOPPED) {
if (op->Status != PB__STOPPED)
{
op->Status = PB__STOPPED;
errh_Info("Profibus DP Master %s - Mode changed to STOP", ap->Name);
}
break;
case OFFLINE:
if (op->Status != PB__NOTINIT) {
if (op->Status != PB__NOTINIT)
{
errh_Info("Profibus DP Master %s - Mode changed to OFFLINE", ap->Name);
op->Status = PB__NOTINIT;
}
......@@ -1443,10 +1546,12 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
/* Checks if there are any new diagnostics data that we should read from
any of our slaves. */
for (i = 0; i <= 127; ++i) {
for (i = 0; i <= 127; ++i)
{
/* The abSl_diag data structure is described on page 22 in
dpm_pie.pdf. */
if (diag.abSl_diag[i >> 3] & (1 << (i & 7))) {
if (diag.abSl_diag[i >> 3] & (1 << (i & 7)))
{
/* Request diagnostics from slaves with unread diagnostic data. */
dpm_req_slave_diag(local, i, ap);
}
......@@ -1457,12 +1562,12 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
before its watchdog times out the diagnostics would not be updated. The
following code covers that case, it is a bit ugly, but works. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
slave_list = slave_list->next)
{
sp = (pwr_sClass_Pb_DP_Slave*)slave_list->op;
/* The abSl_state has the same layout as the abSl_diag bitmap. */
if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent
&& diag.abSl_state[sp->SlaveAddress >> 3]
& (1 << (sp->SlaveAddress & 7)))
if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent &&
diag.abSl_state[sp->SlaveAddress >> 3] & (1 << (sp->SlaveAddress & 7)))
dpm_req_slave_diag(local, sp->SlaveAddress, ap);
}
/* Collects requested slave diagnostics. */
......@@ -1489,20 +1594,23 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
however, keeping this code here enables us to confine all the Profibus
board specific code at the agent level. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
slave_list = slave_list->next)
{
sp = (pwr_sClass_Pb_DP_Slave*)slave_list->op;
mp = (pwr_sClass_Pb_Hilscher*)ap->op;
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN)
&& mp->Status == PB__NORMAL && (sp->DisableSlave != 1)
&& (mp->DisableBus != 1)) {
if (sp->BytesOfOutput > 0) {
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN) &&
mp->Status == PB__NORMAL && (sp->DisableSlave != 1) &&
(mp->DisableBus != 1))
{
if (sp->BytesOfOutput > 0)
{
/* Trigger the board's watchdog. */
DevTriggerWatchDog(local->dev_number, WATCHDOG_START, &local->watchdog);
/* Writes process image to the slave. */
if (DevExchangeIO(local->dev_number, sp->OffsetOutputs,
sp->BytesOfOutput, sp->Outputs, 0, 0, NULL, 100)
!= DRV_NO_ERROR)
sp->BytesOfOutput, sp->Outputs, 0, 0, NULL,
100) != DRV_NO_ERROR)
sp->ErrorCount++;
}
}
......@@ -1530,6 +1638,7 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Hilscher) = { pwr_BindIoMethod(IoAgentInit),
pwr_BindIoMethod(IoAgentRead), pwr_BindIoMethod(IoAgentWrite),
pwr_BindIoMethod(IoAgentClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Hilscher) = {
pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose),
pwr_NullMethod};
......@@ -51,8 +51,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Ii
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ii* op;
......@@ -60,7 +60,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ii*)cp->op;
local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) {
if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS;
}
......@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb Ii card
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Ii* op;
......@@ -95,8 +96,10 @@ static pwr_tStatus IoCardRead(
op = (pwr_sClass_Pb_Ii*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
for (i = 0; i < cp->ChanListSize; i++) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -104,54 +107,76 @@ static pwr_tStatus IoCardRead(
cop = (pwr_sClass_ChanIi*)chanp->cop;
sop = (pwr_sClass_Ii*)chanp->sop;
if (cop->ConversionOn) {
if (op->BytesPerChannel == 4) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
if (cop->ConversionOn)
{
if (op->BytesPerChannel == 4)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
*(pwr_tInt32*)chanp->vbp = data32;
}
} else if (op->BytesPerChannel == 3) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 3)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = 0;
memcpy(&udata32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
udata32 = swap32(udata32);
udata32 = udata32 >> 8;
}
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = 0;
memcpy(&data32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) {
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
data32 = swap32(data32);
data32 = data32 >> 8;
}
*(pwr_tInt32*)chanp->vbp = data32;
}
} else if (op->BytesPerChannel == 2) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 2)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata16;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data16;
}
} else if (op->BytesPerChannel == 1) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
}
else if (op->BytesPerChannel == 1)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata8, local->input_area + op->OffsetInputs + i, 1);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata8;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data8, local->input_area + op->OffsetInputs + i, 1);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data8;
}
......@@ -166,8 +191,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Close method for the Pb Ii card
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -181,5 +206,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ii) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Ii) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -49,8 +49,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module Io
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Io* op;
......@@ -58,12 +58,14 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Io*)cp->op;
local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) {
if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS;
}
if (op->Status < PB_MODULE_STATE_OPERATE) {
if (op->Status < PB_MODULE_STATE_OPERATE)
{
errh_Info("Error initializing Pb module Io %s", cp->Name);
}
......@@ -73,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Write method for the Pb module Io
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Io* op;
......@@ -91,8 +93,10 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Io*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) {
for (i = 0; i < cp->ChanListSize; i++) {
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop)
continue;
......@@ -105,20 +109,27 @@ static pwr_tStatus IoCardWrite(
data32 = *(pwr_tInt32*)chanp->vbp;
if (op->BytesPerChannel == 4) {
if (op->BytesPerChannel == 4)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
} else if (op->BytesPerChannel == 3) {
}
else if (op->BytesPerChannel == 3)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
} else if (op->BytesPerChannel == 2) {
}
else if (op->BytesPerChannel == 2)
{
data16 = (pwr_tInt16)data32;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
} else if (op->BytesPerChannel == 1) {
}
else if (op->BytesPerChannel == 1)
{
data8 = (pwr_tInt8)data32;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
}
......@@ -130,8 +141,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -145,6 +156,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Io)
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Io) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
......@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Module* op;
......@@ -62,7 +62,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Module*)cp->op;
local = (io_sCardLocal*)cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) {
for (i = 0; i < IO_MAXCHAN; i++)
{
local->scancount[i] = 0;
}
......@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\
Read method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Module* op;
......@@ -92,7 +93,7 @@ static pwr_tStatus IoCardRead(
/* all inputs will be zeroed */
io_bus_card_read(ctx, rp, cp, local->input_area, slave->Diag,
slave->ByteOrdering, slave->FloatRepresentation);
slave->ByteOrdering, slave->FloatRepresentation);
// printf("Method Pb_Module-IoCardRead\n");
return IO__SUCCESS;
......@@ -101,8 +102,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\
Write method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
pwr_sClass_Pb_Module* op;
......@@ -114,9 +115,10 @@ static pwr_tStatus IoCardWrite(
op->Status = slave->Status;
if (op->Status == PB__NORMAL) {
if (op->Status == PB__NORMAL)
{
io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering,
slave->FloatRepresentation);
slave->FloatRepresentation);
}
// printf("Method Pb_Module-IoCardWrite\n");
return IO__SUCCESS;
......@@ -125,8 +127,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\
Close method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
{
io_sCardLocal* local;
local = cp->Local;
......@@ -141,6 +143,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Module) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Module) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod};
......@@ -78,23 +78,23 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event);
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting FMB parameters
\*----------------------------------------------------------------------------*/
static short try_profi_rcv_con_ind(T_PROFI_DEVICE_HANDLE* hDevice,
T_PROFI_SERVICE_DESCR* con_ind_sdb, USIGN8* con_ind_buffer,
USIGN16* con_ind_buffer_len, INT16* result)
static short try_profi_rcv_con_ind(T_PROFI_SERVICE_DESCR* con_ind_sdb,
USIGN8* con_ind_buffer,
USIGN16* con_ind_buffer_len, INT16* result)
{
int retry_counter;
struct timespec rqtp = { 0, 10000000 }; // 10 ms
struct timespec rqtp = {0, 10000000}; // 10 ms
retry_counter = DP_MAX_SERVICE_RETRY;
do {
do
{
nanosleep(&rqtp, NULL);
*result = profi_rcv_con_ind(
hDevice, con_ind_sdb, con_ind_buffer, con_ind_buffer_len);
*result =
profi_rcv_con_ind(con_ind_sdb, con_ind_buffer, con_ind_buffer_len);
} while ((*result == NO_CON_IND_RECEIVED) && (retry_counter-- > 0));
if (*result == E_IF_FATAL_ERROR)
......@@ -105,8 +105,7 @@ static short try_profi_rcv_con_ind(T_PROFI_DEVICE_HANDLE* hDevice,
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting FMB parameters
\*----------------------------------------------------------------------------*/
static short fmb_set_configuration(
T_PROFI_DEVICE_HANDLE* hDevice, io_sAgent* ap)
static short fmb_set_configuration(io_sAgent* ap)
{
T_PROFI_SERVICE_DESCR sdb;
T_FMB_SET_CONFIGURATION_REQ data;
......@@ -126,7 +125,8 @@ static short fmb_set_configuration(
/* Iterate over the slaves. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
slave_list = slave_list->next)
{
cid = slave_list->Class;
while (ODD(gdh_GetSuperClass(cid, &cid, pwr_cNOid)))
......@@ -167,13 +167,14 @@ static short fmb_set_configuration(
data.fdlif.receive_credits = 20;
data.fdlif.max_no_resp_saps = 20;
profi_snd_req_res(hDevice, &sdb, &data, PB_FALSE);
profi_snd_req_res(&sdb, &data, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == FMB_SET_CONFIGURATION)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == FMB_SET_CONFIGURATION) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
......@@ -183,7 +184,7 @@ static short fmb_set_configuration(
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting DP master parameters
\*----------------------------------------------------------------------------*/
static short dp_init_master(T_PROFI_DEVICE_HANDLE* hDevice)
static short dp_init_master()
{
T_PROFI_SERVICE_DESCR sdb;
T_DP_INIT_MASTER_REQ data;
......@@ -203,19 +204,20 @@ static short dp_init_master(T_PROFI_DEVICE_HANDLE* hDevice)
data.master_default_address = 0;
data.master_class2 = PB_FALSE;
data.lowest_slave_address = 2;
data.slave_io_address_mode
= DP_AAM_IO_BLOCKS; // only mode possible with Linux-driver DP_AAM_ARRAY;
data.slave_io_address_mode =
DP_AAM_IO_BLOCKS; // only mode possible with Linux-driver DP_AAM_ARRAY;
data.clear_outputs = PB_TRUE;
data.auto_remote_services = DP_AUTO_REMOTE_SERVICES;
data.cyclic_data_transfer = PB_TRUE;
profi_snd_req_res(hDevice, &sdb, &data, PB_FALSE);
profi_snd_req_res(&sdb, &data, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == DP_INIT_MASTER) && (con_ind_sdb.primitive == CON)
&& (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == DP_INIT_MASTER) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
......@@ -225,11 +227,11 @@ static short dp_init_master(T_PROFI_DEVICE_HANDLE* hDevice)
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting DP bus parameters
\*----------------------------------------------------------------------------*/
static short dp_download_bus(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_Profiboard* op)
static short dp_download_bus(pwr_sClass_Pb_Profiboard* op)
{
T_PROFI_SERVICE_DESCR sdb;
struct {
struct
{
T_DP_DOWNLOAD_REQ drp;
T_DP_BUS_PARA_SET dbp;
} data;
......@@ -255,7 +257,8 @@ static short dp_download_bus(
data.dbp.bus_para_len = swap16(66);
data.dbp.fdl_add = 0;
switch (op->BaudRate) {
switch (op->BaudRate)
{
case 500:
data.dbp.baud_rate = DP_KBAUD_500;
break;
......@@ -298,13 +301,14 @@ static short dp_download_bus(
for (i = 0; i < 32; i++)
data.dbp.master_class2_name[i] = 0;
profi_snd_req_res(hDevice, &sdb, &data, PB_FALSE);
profi_snd_req_res(&sdb, &data, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == DP_DOWNLOAD_LOC) && (con_ind_sdb.primitive == CON)
&& (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == DP_DOWNLOAD_LOC) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
......@@ -313,8 +317,7 @@ static short dp_download_bus(
/*********************** FMB_SET_BUSPARAMETER ******************************/
static short fmb_set_busparameter(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_Profiboard* op)
static short fmb_set_busparameter(pwr_sClass_Pb_Profiboard* op)
/* ------------------------------------------------------------------------ */
/* FUNCTIONAL_DESCRIPTION: */
/* */
......@@ -337,7 +340,8 @@ static short fmb_set_busparameter(
bus_par_req.loc_segm = 255;
bus_par_req.medium_red = 0;
switch (op->BaudRate) {
switch (op->BaudRate)
{
case 500:
bus_par_req.baud_rate = DP_KBAUD_500;
break;
......@@ -381,13 +385,14 @@ static short fmb_set_busparameter(
/* Send Request */
profi_snd_req_res(hDevice, &sdb, &bus_par_req, PB_FALSE);
profi_snd_req_res(&sdb, &bus_par_req, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == FMB_SET_BUSPARAMETER)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == FMB_SET_BUSPARAMETER) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
......@@ -397,8 +402,7 @@ static short fmb_set_busparameter(
/*********************** DP_SET_BUSPARAMETER ******************************/
static short dp_set_busparameter(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_Profiboard* op)
static short dp_set_busparameter(pwr_sClass_Pb_Profiboard* op)
/* ------------------------------------------------------------------------ */
/* FUNCTIONAL_DESCRIPTION: */
/* */
......@@ -432,15 +436,16 @@ static short dp_set_busparameter(
/* Send Request */
profi_snd_req_res(hDevice, &sdb, &bus_par_req, PB_FALSE);
profi_snd_req_res(&sdb, &bus_par_req, PB_FALSE);
con_ind_sdb.service = 0;
while (con_ind_sdb.service != DP_SET_BUSPARAMETER)
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == DP_SET_BUSPARAMETER)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == DP_SET_BUSPARAMETER) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
......@@ -448,8 +453,7 @@ static short dp_set_busparameter(
} /* dp_set_busparameter */
static short fdlif_sap_activate_req(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_FDL_SAP* op)
static short fdlif_sap_activate_req(pwr_sClass_Pb_FDL_SAP* op)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -498,24 +502,24 @@ possible return values:
/* Send Request */
profi_snd_req_res(hDevice, &sdb, &sap, PB_FALSE);
profi_snd_req_res(&sdb, &sap, PB_FALSE);
con_ind_sdb.service = 0;
while (con_ind_sdb.service != FDLIF_SAP_ACTIVATE)
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == FDLIF_SAP_ACTIVATE)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == FDLIF_SAP_ACTIVATE) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
return (PB_FALSE);
}
static short fdlif_rsap_activate_req(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_FDL_SAP* op)
static short fdlif_rsap_activate_req(pwr_sClass_Pb_FDL_SAP* op)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -560,16 +564,17 @@ possible return values:
/* Send Request */
profi_snd_req_res(hDevice, &sdb, &rsap, PB_FALSE);
profi_snd_req_res(&sdb, &rsap, PB_FALSE);
con_ind_sdb.service = 0;
while (con_ind_sdb.service != FDLIF_RSAP_ACTIVATE)
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == FDLIF_RSAP_ACTIVATE)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == FDLIF_RSAP_ACTIVATE) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
return (PB_TRUE);
}
......@@ -579,7 +584,7 @@ possible return values:
/*----------------------------------------------------------------------------*\
Sends request for selecting operation mode to the Profiboard
\*----------------------------------------------------------------------------*/
static short dp_act_param_loc(T_PROFI_DEVICE_HANDLE* hDevice, short arg)
static short dp_act_param_loc(short arg)
{
T_PROFI_SERVICE_DESCR sdb;
T_DP_ACT_PARAM_REQ apr;
......@@ -598,7 +603,7 @@ static short dp_act_param_loc(T_PROFI_DEVICE_HANDLE* hDevice, short arg)
apr.activate = arg;
apr.dummy = 0;
retval = profi_snd_req_res(hDevice, &sdb, &apr, PB_FALSE);
retval = profi_snd_req_res(&sdb, &apr, PB_FALSE);
return retval;
}
......@@ -606,7 +611,7 @@ static short dp_act_param_loc(T_PROFI_DEVICE_HANDLE* hDevice, short arg)
/*----------------------------------------------------------------------------*\
Sends request for getting slave diagnostics
\*----------------------------------------------------------------------------*/
static pwr_tBoolean dp_get_slave_diag(T_PROFI_DEVICE_HANDLE* hDevice)
static pwr_tBoolean dp_get_slave_diag()
{
T_PROFI_SERVICE_DESCR sdb;
pwr_tUInt16 retval;
......@@ -619,7 +624,7 @@ static pwr_tBoolean dp_get_slave_diag(T_PROFI_DEVICE_HANDLE* hDevice)
sdb.invoke_id = 0;
sdb.result = 0;
retval = profi_snd_req_res(hDevice, &sdb, &sdb, PB_FALSE);
retval = profi_snd_req_res(&sdb, &sdb, PB_FALSE);
return ((pwr_tBoolean)(retval == E_OK));
}
......@@ -627,50 +632,62 @@ static pwr_tBoolean dp_get_slave_diag(T_PROFI_DEVICE_HANDLE* hDevice)
/*----------------------------------------------------------------------------*\
Get slave diagnostics
\*----------------------------------------------------------------------------*/
static void dp_get_slave_diag_con(
T_DP_GET_SLAVE_DIAG_CON* get_slave_diag_con_ptr, io_sRack* slave_list,
char log)
static void
dp_get_slave_diag_con(T_DP_GET_SLAVE_DIAG_CON* get_slave_diag_con_ptr,
io_sRack* slave_list, char log)
{
T_DP_DIAG_DATA FAR* diag_data_ptr;
char s[128];
pwr_sClass_Pb_DP_Slave* sp;
if (get_slave_diag_con_ptr->diag_data_len >= DP_MIN_SLAVE_DIAG_LEN) {
if (get_slave_diag_con_ptr->diag_data_len >= DP_MIN_SLAVE_DIAG_LEN)
{
diag_data_ptr = (T_DP_DIAG_DATA FAR*)(get_slave_diag_con_ptr + 1);
while (slave_list != NULL) {
while (slave_list != NULL)
{
sp = (pwr_sClass_Pb_DP_Slave*)slave_list->op;
if (sp->SlaveAddress == get_slave_diag_con_ptr->rem_add) {
if (sp->SlaveAddress == get_slave_diag_con_ptr->rem_add)
{
sp->StationStatus1 = diag_data_ptr->station_status_1;
sp->StationStatus2 = diag_data_ptr->station_status_2;
sp->StationStatus3 = diag_data_ptr->station_status_3;
sp->BytesOfDiag
= get_slave_diag_con_ptr->diag_data_len - DP_MIN_SLAVE_DIAG_LEN;
sp->BytesOfDiag =
get_slave_diag_con_ptr->diag_data_len - DP_MIN_SLAVE_DIAG_LEN;
memcpy(sp->Diag, diag_data_ptr + 1,
memcpy(
sp->Diag, diag_data_ptr + 1,
MIN(get_slave_diag_con_ptr->diag_data_len - DP_MIN_SLAVE_DIAG_LEN,
DP_MAX_EXT_DIAG_DATA_LEN));
/* Update slave status */
if (!(sp->StationStatus1 & ~pwr_mPbStationStatus1Mask_ExternalDiag)
&& !(sp->StationStatus2
& ~(pwr_mPbStationStatus2Mask_Default
| pwr_mPbStationStatus2Mask_ResponseMonitoringOn))) {
if (!(sp->StationStatus1 & ~pwr_mPbStationStatus1Mask_ExternalDiag) &&
!(sp->StationStatus2 &
~(pwr_mPbStationStatus2Mask_Default |
pwr_mPbStationStatus2Mask_ResponseMonitoringOn)))
{
sp->Status = PB__NORMAL;
} else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent) {
}
else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent)
{
sp->Status = PB__NOCONN;
} else if ((sp->StationStatus1
& (pwr_mPbStationStatus1Mask_ConfigFault
| pwr_mPbStationStatus1Mask_ParamFault))
|| (sp->StationStatus2
& pwr_mPbStationStatus2Mask_NewParamsRequested)) {
}
else if ((sp->StationStatus1 &
(pwr_mPbStationStatus1Mask_ConfigFault |
pwr_mPbStationStatus1Mask_ParamFault)) ||
(sp->StationStatus2 &
pwr_mPbStationStatus2Mask_NewParamsRequested))
{
sp->Status = PB__CONFIGERR;
} else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_MasterLock) {
}
else if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_MasterLock)
{
sp->Status = PB__MASTERLOCK;
} else // if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NotReady)
}
else // if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NotReady)
{
sp->Status = PB__NOTREADY;
}
......@@ -681,9 +698,11 @@ static void dp_get_slave_diag_con(
slave_list = slave_list->next;
}
if (log) {
sprintf(s, "Slave [%3hhu] [0x%04hX]: Status = 0x%02hhX 0x%02hhX 0x%02hhX, "
"Master = %3hhu, Ext = %u, Diags = %hu",
if (log)
{
sprintf(
s, "Slave [%3hhu] [0x%04hX]: Status = 0x%02hhX 0x%02hhX 0x%02hhX, "
"Master = %3hhu, Ext = %u, Diags = %hu",
get_slave_diag_con_ptr->rem_add, swap16(diag_data_ptr->ident_number),
diag_data_ptr->station_status_1, diag_data_ptr->station_status_2,
diag_data_ptr->station_status_3, diag_data_ptr->master_add,
......@@ -696,8 +715,9 @@ static void dp_get_slave_diag_con(
} /* diag_data_len */
}
static void fdlif_sda_sdn_srd_ind(
INT8 invoke_id, T_FDLIF_SDN_SDA_SRD_REQ* ind_ptr, io_sRack* slave_list)
static void fdlif_sda_sdn_srd_ind(INT8 invoke_id,
T_FDLIF_SDN_SDA_SRD_REQ* ind_ptr,
io_sRack* slave_list)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -712,26 +732,31 @@ possible return values:
USIGN8* data_ptr;
pwr_sClass_Pb_FDL_SAP* sp;
if (ind_ptr->length > 0) {
if (ind_ptr->length > 0)
{
data_ptr = (USIGN8*)(ind_ptr + 1);
// print_data (data_ptr, cnf_ptr->length);
while (slave_list != NULL) {
if (((io_sRackLocal*)slave_list->Local)->fdl) {
while (slave_list != NULL)
{
if (((io_sRackLocal*)slave_list->Local)->fdl)
{
sp = (pwr_sClass_Pb_FDL_SAP*)slave_list->op;
if (sp->SAP_Nr == ind_ptr->ssap) {
if (sp->SAP_Nr == ind_ptr->ssap)
{
io_sCard* card_list = slave_list->cardlist;
pwr_sClass_Pb_FDL_DataTransfer* cp;
io_sFDLCardLocal* local_card;
if (card_list != NULL) {
if (card_list != NULL)
{
cp = (pwr_sClass_Pb_FDL_DataTransfer*)card_list->op;
local_card = (io_sFDLCardLocal*)card_list->Local;
if (local_card->input_area_size > 0)
memcpy(local_card->input_area, data_ptr,
MIN(local_card->input_area_size, ind_ptr->length));
MIN(local_card->input_area_size, ind_ptr->length));
}
break;
......@@ -745,7 +770,7 @@ possible return values:
}
static void fdlif_srd_con(INT16 result, INT8 invoke_id,
T_FDLIF_SRD_CNF* cnf_ptr, io_sRack* slave_list)
T_FDLIF_SRD_CNF* cnf_ptr, io_sRack* slave_list)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -763,33 +788,41 @@ possible return values:
pwr_sClass_Pb_FDL_SAP* sp;
USIGN8 res;
if (result == POS) {
if (result == POS)
{
res = 0;
} else {
}
else
{
res = cnf_ptr->status;
}
data_ptr = (USIGN8*)(cnf_ptr + 1);
while (slave_list != NULL) {
if (((io_sRackLocal*)slave_list->Local)->fdl) {
while (slave_list != NULL)
{
if (((io_sRackLocal*)slave_list->Local)->fdl)
{
sp = (pwr_sClass_Pb_FDL_SAP*)slave_list->op;
if (!sp->Responder) {
if (!sp->Responder)
{
io_sCard* card_list = slave_list->cardlist;
pwr_sClass_Pb_FDL_DataTransfer* cp;
io_sFDLCardLocal* local_card;
while (card_list != NULL) {
while (card_list != NULL)
{
cp = (pwr_sClass_Pb_FDL_DataTransfer*)card_list->op;
local_card = (io_sFDLCardLocal*)card_list->Local;
if ((local_card->invoke_id == invoke_id)
&& (cp->Type == pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD)) {
if ((local_card->invoke_id == invoke_id) &&
(cp->Type == pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD))
{
cp->Result = res;
if (cnf_ptr->length > 0)
memcpy(local_card->input_area, data_ptr,
MIN(local_card->input_area_size, cnf_ptr->length));
MIN(local_card->input_area_size, cnf_ptr->length));
break;
}
card_list = card_list->next;
......@@ -805,33 +838,41 @@ possible return values:
return;
}
static void fdlif_sda_sdn_con(
INT8 invoke_id, INT16 result, T_FDLIF_ERROR* err_ptr, io_sRack* slave_list)
static void fdlif_sda_sdn_con(INT8 invoke_id, INT16 result,
T_FDLIF_ERROR* err_ptr, io_sRack* slave_list)
{
pwr_sClass_Pb_FDL_SAP* sp;
USIGN8 res;
if (result == POS) {
if (result == POS)
{
res = 0;
} else {
}
else
{
res = err_ptr->result;
}
// print_data (data_ptr, cnf_ptr->length);
while (slave_list != NULL) {
if (((io_sRackLocal*)slave_list->Local)->fdl) {
while (slave_list != NULL)
{
if (((io_sRackLocal*)slave_list->Local)->fdl)
{
sp = (pwr_sClass_Pb_FDL_SAP*)slave_list->op;
if (!sp->Responder) {
if (!sp->Responder)
{
io_sCard* card_list = slave_list->cardlist;
pwr_sClass_Pb_FDL_DataTransfer* cp;
io_sFDLCardLocal* local_card;
while (card_list != NULL) {
while (card_list != NULL)
{
cp = (pwr_sClass_Pb_FDL_DataTransfer*)card_list->op;
local_card = (io_sFDLCardLocal*)card_list->Local;
if (local_card->invoke_id == invoke_id) {
if (local_card->invoke_id == invoke_id)
{
cp->Result = res;
break;
}
......@@ -851,8 +892,7 @@ static void fdlif_sda_sdn_con(
/*----------------------------------------------------------------------------*\
Starts download sequence of prm data to one slave
\*----------------------------------------------------------------------------*/
static pwr_tStatus start_download_seq(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_DP_Slave* op)
static pwr_tStatus start_download_seq(pwr_sClass_Pb_DP_Slave* op)
{
T_PROFI_SERVICE_DESCR sdb;
T_DP_START_SEQ_REQ ssrp;
......@@ -874,13 +914,14 @@ static pwr_tStatus start_download_seq(
ssrp.area_code = op->SlaveAddress;
ssrp.timeout = timeout;
profi_snd_req_res(hDevice, &sdb, &ssrp, PB_FALSE);
profi_snd_req_res(&sdb, &ssrp, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == DP_START_SEQ_LOC)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == DP_START_SEQ_LOC) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
op->Status = PB__NOCONN;
return (PB_TRUE);
}
......@@ -893,8 +934,7 @@ static pwr_tStatus start_download_seq(
/*----------------------------------------------------------------------------*\
Starts download sequence of prm data to one slave
\*----------------------------------------------------------------------------*/
static pwr_tStatus end_download_seq(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_DP_Slave* op)
static pwr_tStatus end_download_seq(pwr_sClass_Pb_DP_Slave* op)
{
T_PROFI_SERVICE_DESCR sdb;
T_DP_END_SEQ_REQ esrp;
......@@ -914,13 +954,14 @@ static pwr_tStatus end_download_seq(
esrp.rem_add = 0;
esrp.dummy = 0;
profi_snd_req_res(hDevice, &sdb, &esrp, PB_FALSE);
profi_snd_req_res(&sdb, &esrp, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == DP_END_SEQ_LOC) && (con_ind_sdb.primitive == CON)
&& (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == DP_END_SEQ_LOC) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
op->Status = PB__NOCONN;
return (PB_TRUE);
}
......@@ -933,12 +974,12 @@ static pwr_tStatus end_download_seq(
/*----------------------------------------------------------------------------*\
Initializes one DP slave in the master card
\*----------------------------------------------------------------------------*/
static pwr_tStatus dp_download_slave(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_DP_Slave* op)
static pwr_tStatus dp_download_slave(pwr_sClass_Pb_DP_Slave* op)
{
int i;
T_PROFI_SERVICE_DESCR sdb;
struct {
struct
{
T_DP_DOWNLOAD_REQ drp;
unsigned char param[512];
} slave_data;
......@@ -960,8 +1001,9 @@ static pwr_tStatus dp_download_slave(
op->Status = PB__NOTINIT;
download_data_size = sizeof(prm_head) + sizeof(prm_data) + op->PrmUserDataLen
+ op->ConfigDataLen + sizeof(aat_data) + sizeof(user_data);
download_data_size = sizeof(prm_head) + sizeof(prm_data) +
op->PrmUserDataLen + op->ConfigDataLen +
sizeof(aat_data) + sizeof(user_data);
data_len = download_data_size;
......@@ -1019,42 +1061,53 @@ static pwr_tStatus dp_download_slave(
send_buf = (char*)slave_data.param;
if (data_len > DP_MAX_DOWNLOAD_DATA_LEN) {
if (!start_download_seq(hDevice, op)) {
if (data_len > DP_MAX_DOWNLOAD_DATA_LEN)
{
if (!start_download_seq(op))
{
op->Status = PB__INITFAIL;
return (PB_FALSE);
}
}
while (download_data_size > 0) {
while (download_data_size > 0)
{
slave_data.drp.data_len = MIN(download_data_size, DP_MAX_DOWNLOAD_DATA_LEN);
profi_snd_req_res(hDevice, &sdb, &slave_data, PB_FALSE);
profi_snd_req_res(&sdb, &slave_data, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if (con_ind_sdb.service == DP_DOWNLOAD_LOC) {
if ((con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
if (con_ind_sdb.service == DP_DOWNLOAD_LOC)
{
if ((con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
op->Status = PB__NOCONN;
} else {
}
else
{
op->Status = PB__INITFAIL;
failure = TRUE;
break;
}
}
if (download_data_size > DP_MAX_DOWNLOAD_DATA_LEN) {
if (download_data_size > DP_MAX_DOWNLOAD_DATA_LEN)
{
download_data_size -= DP_MAX_DOWNLOAD_DATA_LEN;
slave_data.drp.add_offset += DP_MAX_DOWNLOAD_DATA_LEN;
send_buf += DP_MAX_DOWNLOAD_DATA_LEN;
memcpy(slave_data.param, send_buf,
MIN(download_data_size, DP_MAX_DOWNLOAD_DATA_LEN));
} else
MIN(download_data_size, DP_MAX_DOWNLOAD_DATA_LEN));
}
else
download_data_size = 0;
}
if (data_len > DP_MAX_DOWNLOAD_DATA_LEN) {
if (!end_download_seq(hDevice, op)) {
if (data_len > DP_MAX_DOWNLOAD_DATA_LEN)
{
if (!end_download_seq(op))
{
op->Status = PB__INITFAIL;
return (PB_FALSE);
}
......@@ -1069,8 +1122,7 @@ static pwr_tStatus dp_download_slave(
/*----------------------------------------------------------------------------*\
Calculate offsets of inputs and outputs for a slave
\*----------------------------------------------------------------------------*/
static pwr_tStatus dp_io_offsets(
T_PROFI_DEVICE_HANDLE* hDevice, pwr_sClass_Pb_DP_Slave* op)
static pwr_tStatus dp_io_offsets(pwr_sClass_Pb_DP_Slave* op)
{
T_PROFI_SERVICE_DESCR sdb;
T_DP_GET_SLAVE_PARAM_REQ get_slave_param_req;
......@@ -1092,20 +1144,21 @@ static pwr_tStatus dp_io_offsets(
get_slave_param_req.identifier = DP_SLAVE_PARAM_SLAVE_INFO;
get_slave_param_req.rem_add = op->SlaveAddress;
result = profi_snd_req_res(hDevice, &sdb, &get_slave_param_req, PB_FALSE);
result = profi_snd_req_res(&sdb, &get_slave_param_req, PB_FALSE);
if (result != E_OK)
return (result);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
get_slave_param_con_ptr = (T_DP_GET_SLAVE_PARAM_CON FAR*)con_ind_buffer;
if ((con_ind_sdb.service == DP_GET_SLAVE_PARAM)
&& (con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS)) {
slave_info_ptr
= (T_DP_SLAVE_PARAM_SLAVE_INFO FAR*)(get_slave_param_con_ptr + 1);
if ((con_ind_sdb.service == DP_GET_SLAVE_PARAM) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
slave_info_ptr =
(T_DP_SLAVE_PARAM_SLAVE_INFO FAR*)(get_slave_param_con_ptr + 1);
op->BytesOfInput = slave_info_ptr->number_inputs;
op->BytesOfOutput = slave_info_ptr->number_outputs;
......@@ -1126,7 +1179,6 @@ void* handle_events(void* ptr)
io_sAgentLocal* local;
io_sAgent* ap;
short sts;
T_PROFI_DEVICE_HANDLE* hDevice;
pwr_sClass_Pb_Profiboard* op;
char s[128];
......@@ -1134,13 +1186,12 @@ void* handle_events(void* ptr)
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
T_DP_GET_SLAVE_DIAG_CON* get_slave_diag_con_ptr;
struct timespec rqtp = { 0, 10000000 }; // 10 ms
struct timespec rqtp = {0, 10000000}; // 10 ms
args = (agent_args*)ptr;
local = (io_sAgentLocal*)args->local;
ap = args->ap;
hDevice = (T_PROFI_DEVICE_HANDLE*)ap->Local;
op = (pwr_sClass_Pb_Profiboard*)ap->op;
/* If everything is fine we should be in state OPERATE
......@@ -1148,39 +1199,53 @@ void* handle_events(void* ptr)
if there are any hardware faults. In that case, make a reset and a new
init. */
while (1) {
while (1)
{
if (op->DisableBus)
exit(0);
pthread_mutex_lock(&local->mutex);
con_ind_buffer_len = 256;
sts = profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len);
if (sts == CON_IND_RECEIVED) {
switch (con_ind_sdb.layer) {
case DP_USR: {
if (con_ind_sdb.primitive == CON) {
if (con_ind_sdb.result == POS) {
switch (con_ind_sdb.service) {
sts = profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len);
if (sts == CON_IND_RECEIVED)
{
switch (con_ind_sdb.layer)
{
case DP_USR:
{
if (con_ind_sdb.primitive == CON)
{
if (con_ind_sdb.result == POS)
{
switch (con_ind_sdb.service)
{
/*--------------------------------------------------------------*/
case DP_ACT_PARAM_LOC: {
if (op->Status == PB__NOTINIT) {
case DP_ACT_PARAM_LOC:
{
if (op->Status == PB__NOTINIT)
{
op->Status = PB__STOPPED;
errh_Info("Profibus DP Master %s to state STOPPED", ap->Name);
dp_act_param_loc(hDevice, DP_OP_MODE_CLEAR);
} else if (op->Status == PB__STOPPED) {
dp_act_param_loc(DP_OP_MODE_CLEAR);
}
else if (op->Status == PB__STOPPED)
{
op->Status = PB__CLEARED;
errh_Info("Profibus DP Master %s to state CLEARED", ap->Name);
dp_act_param_loc(hDevice, DP_OP_MODE_OPERATE);
} else if (op->Status == PB__CLEARED) {
dp_act_param_loc(DP_OP_MODE_OPERATE);
}
else if (op->Status == PB__CLEARED)
{
errh_Info("Profibus DP Master %s to state OPERATE", ap->Name);
op->Status = PB__NORMAL;
if (!local->slave_diag_requested && local->parallel_service) {
if (dp_get_slave_diag(hDevice)) {
if (!local->slave_diag_requested && local->parallel_service)
{
if (dp_get_slave_diag())
{
local->slave_diag_requested = op->Diag[3] = PB_TRUE;
local->parallel_service = PB_FALSE;
}
......@@ -1192,61 +1257,74 @@ void* handle_events(void* ptr)
/*--------------------------------------------------------------*/
case DP_GET_SLAVE_DIAG: {
get_slave_diag_con_ptr
= (T_DP_GET_SLAVE_DIAG_CON FAR*)con_ind_buffer;
case DP_GET_SLAVE_DIAG:
{
get_slave_diag_con_ptr =
(T_DP_GET_SLAVE_DIAG_CON FAR*)con_ind_buffer;
dp_get_slave_diag_con(
get_slave_diag_con_ptr, ap->racklist, op->Diag[1]);
dp_get_slave_diag_con(get_slave_diag_con_ptr, ap->racklist,
op->Diag[1]);
op->Diag[2]++;
local->slave_diag_requested = op->Diag[3] = PB_FALSE;
if (get_slave_diag_con_ptr->diag_entries < 0) {
if (get_slave_diag_con_ptr->diag_entries < 0)
{
errh_Warning("Profibus - diagnostic circular buffer owerflow.");
}
if (get_slave_diag_con_ptr->diag_entries) {
if (get_slave_diag_con_ptr->diag_entries)
{
local->slave_diag_requested = op->Diag[3] = PB_TRUE;
dp_get_slave_diag(hDevice);
dp_get_slave_diag();
}
break;
} /* case DP_GET_SLAVE_DIAG */
/*--------------------------------------------------------------*/
default: {
default:
{
break;
} /* deafult service */
} /* switch */
} /* if POS */
else {
} /* if POS */
else
{
op->Status = PB__NOTINIT;
errh_Error("Profibus DP Master %s - %x neg con rec", ap->Name,
*((unsigned short*)con_ind_buffer));
*((unsigned short*)con_ind_buffer));
} /* else POS */
} /* if CON */
else if (con_ind_sdb.primitive == IND) {
if (con_ind_sdb.result == POS) {
switch (con_ind_sdb.service) {
} /* if CON */
else if (con_ind_sdb.primitive == IND)
{
if (con_ind_sdb.result == POS)
{
switch (con_ind_sdb.service)
{
/*--------------------------------------------------------------*/
case DP_ACT_PARAM_LOC: {
case DP_ACT_PARAM_LOC:
{
USIGN8 usif_state;
usif_state = ((T_DP_ACT_PARAM_IND FAR*)con_ind_buffer)->activate;
switch (usif_state) {
case DP_OP_MODE_STOP: {
switch (usif_state)
{
case DP_OP_MODE_STOP:
{
op->Status = PB__STOPPED;
sprintf(s, "Mode changed to STOP");
break;
}
case DP_OP_MODE_CLEAR: {
case DP_OP_MODE_CLEAR:
{
op->Status = PB__CLEARED;
sprintf(s, "Mode changed to CLEAR");
break;
}
case DP_OP_MODE_OPERATE: {
case DP_OP_MODE_OPERATE:
{
op->Status = PB__NORMAL;
sprintf(s, "Mode changed to OPERATE");
break;
......@@ -1255,14 +1333,17 @@ void* handle_events(void* ptr)
errh_Info("Profibus DP Master %s - %s", ap->Name, s);
if (usif_state == DP_OP_MODE_STOP) {
if (usif_state == DP_OP_MODE_STOP)
{
usif_state = DP_OP_MODE_CLEAR;
dp_act_param_loc(hDevice, DP_OP_MODE_CLEAR);
} else if (usif_state == DP_OP_MODE_CLEAR) {
dp_act_param_loc(DP_OP_MODE_CLEAR);
}
else if (usif_state == DP_OP_MODE_CLEAR)
{
usif_state = DP_OP_MODE_OPERATE;
dp_act_param_loc(hDevice, DP_OP_MODE_OPERATE);
dp_act_param_loc(DP_OP_MODE_OPERATE);
}
break;
......@@ -1270,28 +1351,37 @@ void* handle_events(void* ptr)
/*--------------------------------------------------------------*/
case DP_GET_SLAVE_DIAG: {
get_slave_diag_con_ptr
= (T_DP_GET_SLAVE_DIAG_CON FAR*)con_ind_buffer;
case DP_GET_SLAVE_DIAG:
{
get_slave_diag_con_ptr =
(T_DP_GET_SLAVE_DIAG_CON FAR*)con_ind_buffer;
dp_get_slave_diag_con(
get_slave_diag_con_ptr, ap->racklist, op->Diag[1]);
dp_get_slave_diag_con(get_slave_diag_con_ptr, ap->racklist,
op->Diag[1]);
op->Diag[0]++;
if (get_slave_diag_con_ptr->diag_entries < 0) {
if (get_slave_diag_con_ptr->diag_entries < 0)
{
errh_Warning("Profibus - diagnostic circular buffer owerflow.");
}
if ((get_slave_diag_con_ptr->diag_entries)
&& (!local->slave_diag_requested)) {
if (op->Status == PB__NORMAL) {
if (dp_get_slave_diag(hDevice)) {
if ((get_slave_diag_con_ptr->diag_entries) &&
(!local->slave_diag_requested))
{
if (op->Status == PB__NORMAL)
{
if (dp_get_slave_diag())
{
local->slave_diag_requested = op->Diag[3] = PB_TRUE;
} else {
}
else
{
errh_Warning("Profibus - Request for diag failed.");
}
} else {
}
else
{
local->parallel_service = PB_TRUE;
}
}
......@@ -1301,31 +1391,38 @@ void* handle_events(void* ptr)
/*--------------------------------------------------------------*/
default: {
default:
{
break;
} /* deafult service */
} /* switch */
} /* if POS */
else {
} /* if POS */
else
{
op->Status = PB__NOTINIT;
errh_Error("Profibus DP Master %s - %x neg ind rec", ap->Name,
*((unsigned short*)con_ind_buffer));
*((unsigned short*)con_ind_buffer));
} /* else POS */
} /* if IND */
} /* if IND */
break;
}
case FMB_USR: {
switch (con_ind_sdb.service) {
case FMB_USR:
{
switch (con_ind_sdb.service)
{
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
case FMB_SET_CONFIGURATION:
case FMB_EXIT:
case FMB_RESET: {
case FMB_RESET:
{
break;
}
case FMB_FM2_EVENT: {
switch (((T_FMB_FM2_EVENT_IND FAR*)con_ind_buffer)->reason) {
case FMB_FM2_EVENT:
{
switch (((T_FMB_FM2_EVENT_IND FAR*)con_ind_buffer)->reason)
{
case FM2_FAULT_ADDRESS:
sprintf(s, "Duplicate address recognized");
break;
......@@ -1355,17 +1452,20 @@ void* handle_events(void* ptr)
break;
} /* case FMB_FM2_EVENT */
default: {
default:
{
printf("\nnot supported FMB service received\n");
printf("service: %d primitive: %d\n", con_ind_sdb.service,
con_ind_sdb.primitive);
con_ind_sdb.primitive);
break;
} /* deafult service */
} /* switch */
break;
}
case FDLIF_USR: {
switch (con_ind_sdb.service) {
case FDLIF_USR:
{
switch (con_ind_sdb.service)
{
case FDLIF_EVENT:
case FDLIF_SET_BUSPARAMETER:
case FDLIF_READ_BUSPARAMETER:
......@@ -1379,39 +1479,51 @@ void* handle_events(void* ptr)
break;
case FDLIF_SDN:
if (con_ind_sdb.primitive == IND) {
if (con_ind_sdb.primitive == IND)
{
fdlif_sda_sdn_srd_ind(con_ind_sdb.invoke_id,
(T_FDLIF_SDN_SDA_SRD_REQ FAR*)con_ind_buffer, ap->racklist);
} else {
(T_FDLIF_SDN_SDA_SRD_REQ FAR*)con_ind_buffer,
ap->racklist);
}
else
{
fdlif_sda_sdn_con(con_ind_sdb.invoke_id, con_ind_sdb.result,
(T_FDLIF_ERROR*)con_ind_buffer, ap->racklist);
(T_FDLIF_ERROR*)con_ind_buffer, ap->racklist);
}
break;
case FDLIF_SDA:
if (con_ind_sdb.primitive == IND) {
if (con_ind_sdb.primitive == IND)
{
fdlif_sda_sdn_srd_ind(con_ind_sdb.invoke_id,
(T_FDLIF_SDN_SDA_SRD_REQ FAR*)con_ind_buffer, ap->racklist);
} else {
(T_FDLIF_SDN_SDA_SRD_REQ FAR*)con_ind_buffer,
ap->racklist);
}
else
{
fdlif_sda_sdn_con(con_ind_sdb.invoke_id, con_ind_sdb.result,
(T_FDLIF_ERROR*)con_ind_buffer, ap->racklist);
(T_FDLIF_ERROR*)con_ind_buffer, ap->racklist);
}
break;
case FDLIF_SRD:
if (con_ind_sdb.primitive == IND) {
if (con_ind_sdb.primitive == IND)
{
fdlif_sda_sdn_srd_ind(con_ind_sdb.invoke_id,
(T_FDLIF_SDN_SDA_SRD_REQ FAR*)con_ind_buffer, ap->racklist);
} else {
(T_FDLIF_SDN_SDA_SRD_REQ FAR*)con_ind_buffer,
ap->racklist);
}
else
{
fdlif_srd_con(con_ind_sdb.result, con_ind_sdb.invoke_id,
(T_FDLIF_SRD_CNF*)con_ind_buffer, ap->racklist);
(T_FDLIF_SRD_CNF*)con_ind_buffer, ap->racklist);
}
break;
default:
printf("\nnot supported FDLIF service received\n");
printf("service: %d primitive: %d\n", con_ind_sdb.service,
con_ind_sdb.primitive);
con_ind_sdb.primitive);
}
break;
}
......@@ -1419,14 +1531,18 @@ void* handle_events(void* ptr)
default:
printf("\nnot supported layer service received\n");
printf("layer: %d service: %d primitive: %d\n", con_ind_sdb.layer,
con_ind_sdb.service, con_ind_sdb.primitive);
con_ind_sdb.service, con_ind_sdb.primitive);
break;
}
} else if (sts != NO_CON_IND_RECEIVED) {
}
else if (sts != NO_CON_IND_RECEIVED)
{
op->Status = PB__NOTINIT;
} else {
if (local->slave_diag_requested) {
}
else
{
if (local->slave_diag_requested)
{
// errh_Info( "Profibus - Diag re-request");
// dp_get_slave_diag(hDevice);
}
......@@ -1444,7 +1560,6 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
pwr_sClass_Pb_Profiboard* op;
pwr_tUInt16 sts;
pwr_tStatus status;
T_PROFI_DEVICE_HANDLE* hDevice;
io_sAgentLocal* local;
pwr_tCid cid;
......@@ -1458,7 +1573,7 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
char name[196];
struct timespec rqtp = { 0, 20000000 }; // 20 ms
struct timespec rqtp = {0, 20000000}; // 20 ms
int retry;
......@@ -1466,13 +1581,12 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
/* Allocate area for local data structure */
ap->Local = calloc(1, sizeof(io_sAgentLocal));
if (!ap->Local) {
if (!ap->Local)
{
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name, "calloc");
return IO__ERRINIDEVICE;
}
hDevice = (T_PROFI_DEVICE_HANDLE*)ap->Local;
local = (io_sAgentLocal*)ap->Local;
op = (pwr_sClass_Pb_Profiboard*)ap->op;
......@@ -1481,58 +1595,67 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
/* Initialize interface */
if (ctx->Node->Restarts > 0) {
if (ctx->Node->Restarts > 0)
{
nanosleep(&rqtp, NULL);
}
errh_Info("Initializing interface for Profibus DP Master %s", ap->Name);
sts = profi_init(hDevice, (unsigned char)op->BusNumber - 1, 0, 0);
sts = profi_init((unsigned char)op->BusNumber - 1, 0, 0);
if (sts != E_OK) {
if (sts != E_OK)
{
/* Can't open driver */
op->Status = PB__INITFAIL;
errh_Error(
"ERROR config Profibus DP Master %s - %s", ap->Name, "open device");
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"open device");
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* If this is not the Profibus I/O process, return */
if ((op->Process & io_mProcess_Profibus)
&& (ctx->Process != io_mProcess_Profibus)) {
if ((op->Process & io_mProcess_Profibus) &&
(ctx->Process != io_mProcess_Profibus))
{
op->Status = PB__NOTINIT;
errh_Info("Init template I/O agent for Profibus DP Master %s, %d", ap->Name,
ctx->Process);
ctx->Process);
return IO__SUCCESS;
}
if (ctx->Node->Restarts > 0) {
errh_Info(
"Warm restart - Skipping config of Profibus DP Master %s", ap->Name);
if (ctx->Node->Restarts > 0)
{
errh_Info("Warm restart - Skipping config of Profibus DP Master %s",
ap->Name);
op->Status = PB__NORMAL;
// return IO__SUCCESS;
}
errh_Info("Config of Profibus DP Master %s", ap->Name);
if (op->DisableBus != 1) {
if (op->DisableBus != 1)
{
ok = FALSE;
if (ctx->Node->Restarts == 0) {
if (ctx->Node->Restarts == 0)
{
retry = 0;
while (!ok) {
while (!ok)
{
op->Status = PB__NOTINIT;
/* Set FMB configuration */
sts = fmb_set_configuration(hDevice, ap);
if (!sts) {
sts = fmb_set_configuration(ap);
if (!sts)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"fmb set configuration");
"fmb set configuration");
retry++;
if (retry < 2) {
if (retry < 2)
{
nanosleep(&rqtp, NULL);
continue;
}
......@@ -1541,48 +1664,60 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
/* Set DP master parameters */
if (local->dp) {
sts = dp_init_master(hDevice);
if (!sts) {
if (local->dp)
{
sts = dp_init_master();
if (!sts)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"dp init master");
"dp init master");
return IO__ERRINIDEVICE;
}
}
/* Download DP bus parameters */
if (local->dp && !local->fdl) {
sts = dp_download_bus(hDevice, op);
if (!sts) {
if (local->dp && !local->fdl)
{
sts = dp_download_bus(op);
if (!sts)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"dp download bus");
"dp download bus");
return IO__ERRINIDEVICE;
}
} else if (!local->dp && local->fdl) {
sts = fmb_set_busparameter(hDevice, op);
if (!sts) {
}
else if (!local->dp && local->fdl)
{
sts = fmb_set_busparameter(op);
if (!sts)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus FDL Master %s - %s", ap->Name,
"fmb set busparam");
"fmb set busparam");
return IO__ERRINIDEVICE;
} else
}
else
op->Status = PB__NORMAL;
} else {
sts = fmb_set_busparameter(hDevice, op);
if (!sts) {
}
else
{
sts = fmb_set_busparameter(op);
if (!sts)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus Master %s - %s", ap->Name,
"fmb set busparam");
"fmb set busparam");
return IO__ERRINIDEVICE;
}
sts = dp_set_busparameter(hDevice, op);
if (!sts) {
sts = dp_set_busparameter(op);
if (!sts)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"dp set busparam");
"dp set busparam");
return IO__ERRINIDEVICE;
}
}
......@@ -1593,7 +1728,8 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
op->NumberSlaves = 0;
status = gdh_GetChild(ap->Objid, &slave_objid);
while (ODD(status)) {
while (ODD(status))
{
status = gdh_GetObjectClass(slave_objid, &slave_class);
cid = slave_class;
......@@ -1602,35 +1738,38 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
;
status = gdh_ObjidToPointer(slave_objid, (pwr_tAddress*)&sop);
status = gdh_ObjidToName(
slave_objid, (char*)&name, sizeof(name), cdh_mNName);
status = gdh_ObjidToName(slave_objid, (char*)&name, sizeof(name),
cdh_mNName);
if (cid == pwr_cClass_Pb_DP_Slave) {
if (cid == pwr_cClass_Pb_DP_Slave)
{
errh_Info("Download Profibus DP Slave config - %s", name);
status = dp_download_slave(hDevice, (pwr_sClass_Pb_DP_Slave*)sop);
status = dp_download_slave((pwr_sClass_Pb_DP_Slave*)sop);
if (!status) {
if (!status)
{
errh_Error("ERROR Init Profibus DP slave %s", name);
}
op->NumberSlaves++;
}
if (cid == pwr_cClass_Pb_FDL_SAP) {
if (cid == pwr_cClass_Pb_FDL_SAP)
{
errh_Info("Download Profibus FDL SAP config - %s", name);
if (!((pwr_sClass_Pb_FDL_SAP*)sop)->Responder)
status = fdlif_sap_activate_req(
hDevice, (pwr_sClass_Pb_FDL_SAP*)sop);
status = fdlif_sap_activate_req((pwr_sClass_Pb_FDL_SAP*)sop);
else
status = fdlif_rsap_activate_req(
hDevice, (pwr_sClass_Pb_FDL_SAP*)sop);
status = fdlif_rsap_activate_req((pwr_sClass_Pb_FDL_SAP*)sop);
if (!status) {
if (!status)
{
((pwr_sClass_Pb_FDL_SAP*)sop)->Status = PB__INITFAIL;
errh_Error("ERROR Init Profibus FDL SAP %s", name);
} else
}
else
((pwr_sClass_Pb_FDL_SAP*)sop)->Status = PB__NORMAL;
}
......@@ -1641,7 +1780,8 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
status = gdh_GetChild(ap->Objid, &slave_objid);
while (ODD(status)) {
while (ODD(status))
{
status = gdh_GetObjectClass(slave_objid, &slave_class);
cid = slave_class;
......@@ -1649,21 +1789,24 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
while (ODD(gdh_GetSuperClass(cid, &cid, pwr_cNOid)))
;
if (cid == pwr_cClass_Pb_DP_Slave) {
if (cid == pwr_cClass_Pb_DP_Slave)
{
status = gdh_ObjidToPointer(slave_objid, (pwr_tAddress*)&sop);
status = dp_io_offsets(hDevice, sop);
status = dp_io_offsets(sop);
}
status = gdh_GetNextSibling(slave_objid, &slave_objid);
}
/* Move to STOP mode, this will fix the DPRAM layout */
if (local->dp) {
sts = dp_act_param_loc(hDevice, DP_OP_MODE_STOP);
if (sts != E_OK) {
if (local->dp)
{
sts = dp_act_param_loc(DP_OP_MODE_STOP);
if (sts != E_OK)
{
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s", ap->Name,
"act param loc to STOPPED");
"act param loc to STOPPED");
return IO__ERRINIDEVICE;
}
}
......@@ -1671,7 +1814,7 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
ok = TRUE;
} /* End - While !ok */
} /* End - Initialization only if not restart */
} /* End - Initialization only if not restart */
/* else {
Move to STOP mode, this will fix the DPRAM layout
......@@ -1683,55 +1826,9 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
return IO__ERRINIDEVICE;
}
} */
} else
op->Status = PB__DISABLED;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Swap method for the Pb_profiboard agent
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event)
{
switch (event) {
case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap: {
pwr_sClass_Pb_Profiboard* op;
char DeviceName[64];
io_sAgentLocal* local;
if (ap->Local == NULL) {
/* Allocate area for local data structure */
ap->Local = calloc(1, sizeof(io_sAgentLocal));
if (!ap->Local) {
errh_Error(
"ERROR swap init Profibus DP Master %s - %s", ap->Name, "calloc");
return IO__ERRINIDEVICE;
}
local = (io_sAgentLocal*)ap->Local;
errh_Info("Swap init interface for Profibus DP Master %s", ap->Name);
op = (pwr_sClass_Pb_Profiboard*)ap->op;
sprintf(DeviceName, "/dev/pbboard%u", op->BusNumber - 1);
local->hDpsBoardDevice = open(DeviceName, O_RDONLY | O_NONBLOCK);
if (local->hDpsBoardDevice == -1) {
errh_Error(
"ERROR swap init Profibus DP Master %s - %s", ap->Name, "open");
return IO__ERRINIDEVICE;
}
}
break;
}
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
IoAgentClose(ctx, ap);
break;
}
else
op->Status = PB__DISABLED;
return IO__SUCCESS;
}
......@@ -1742,7 +1839,6 @@ static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event)
static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
{
io_sAgentLocal* local;
T_PROFI_DEVICE_HANDLE* hDevice;
pwr_sClass_Pb_Profiboard* op;
pwr_tUInt16 sts;
......@@ -1751,18 +1847,19 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
pwr_tUInt16 data_len;
io_sRack* slave_list;
hDevice = (T_PROFI_DEVICE_HANDLE*)ap->Local;
local = (io_sAgentLocal*)ap->Local;
op = (pwr_sClass_Pb_Profiboard*)ap->op;
/* Activate supervision thread, first cycle */
if (!local->args.local) {
if (!local->args.local)
{
pthread_attr_t attr;
pthread_mutexattr_t mutexattr;
local->args.local = local;
local->args.ap = ap;
local->args.ctx = ctx;
pthread_mutexattr_init(&mutexattr);
pthread_mutex_init(&local->mutex, &mutexattr);
......@@ -1776,17 +1873,20 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
/* Iterate over the slaves. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
if (((io_sRackLocal*)slave_list->Local)->dp) {
slave_list = slave_list->next)
{
if (((io_sRackLocal*)slave_list->Local)->dp)
{
sp = (pwr_sClass_Pb_DP_Slave*)slave_list->op;
mp = (pwr_sClass_Pb_Profiboard*)ap->op;
/* Read process data. */
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL
&& sp->DisableSlave != 1 && mp->DisableBus != 1) {
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL &&
sp->DisableSlave != 1 && mp->DisableBus != 1)
{
data_len = sp->BytesOfInput;
sts = profi_get_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetInputs,
&data_len, &sp->Inputs);
sts = profi_get_data(ID_DP_SLAVE_IO_IMAGE, sp->OffsetInputs, &data_len,
&sp->Inputs);
}
}
}
......@@ -1802,33 +1902,35 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
{
io_sAgentLocal* local;
T_PROFI_DEVICE_HANDLE* hDevice;
pwr_tUInt16 sts;
pwr_sClass_Pb_Profiboard* mp;
pwr_sClass_Pb_DP_Slave* sp;
io_sRack* slave_list;
hDevice = (T_PROFI_DEVICE_HANDLE*)ap->Local;
local = (io_sAgentLocal*)ap->Local;
pthread_mutex_lock(&local->mutex);
/* Iterate over the slaves. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
if (((io_sRackLocal*)slave_list->Local)->dp) {
slave_list = slave_list->next)
{
if (((io_sRackLocal*)slave_list->Local)->dp)
{
sp = (pwr_sClass_Pb_DP_Slave*)slave_list->op;
mp = (pwr_sClass_Pb_Profiboard*)ap->op;
// Write the whole I/O output area from local area
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN)
&& mp->Status == PB__NORMAL && (sp->DisableSlave != 1)
&& (mp->DisableBus != 1)) {
if (sp->BytesOfOutput > 0) {
sts = profi_set_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetOutputs,
sp->BytesOfOutput, &sp->Outputs);
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN) &&
mp->Status == PB__NORMAL && (sp->DisableSlave != 1) &&
(mp->DisableBus != 1))
{
if (sp->BytesOfOutput > 0)
{
sts = profi_set_data(ID_DP_SLAVE_IO_IMAGE, sp->OffsetOutputs,
sp->BytesOfOutput, &sp->Outputs);
if (sts != E_OK)
sp->ErrorCount++;
......@@ -1848,7 +1950,6 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
{
io_sAgentLocal* local;
T_PROFI_DEVICE_HANDLE* hDevice;
pwr_tStatus sts = PB_FALSE;
T_PROFI_SERVICE_DESCR sdb;
......@@ -1866,7 +1967,6 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
pthread_mutex_lock(&local->mutex);
hDevice = (T_PROFI_DEVICE_HANDLE*)ap->Local;
sdb.comm_ref = 0;
sdb.layer = DP;
sdb.service = DP_EXIT_MASTER;
......@@ -1874,35 +1974,49 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
sdb.invoke_id = 0;
sdb.result = 0;
profi_snd_req_res(hDevice, &sdb, &sdb, PB_FALSE);
profi_snd_req_res(&sdb, &sdb, PB_FALSE);
try_profi_rcv_con_ind(
hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
try_profi_rcv_con_ind(&con_ind_sdb, con_ind_buffer, &con_ind_buffer_len,
&result);
if ((con_ind_sdb.service == DP_EXIT_MASTER) && (con_ind_sdb.primitive == CON)
&& (con_ind_sdb.result == POS)) {
if ((con_ind_sdb.service == DP_EXIT_MASTER) &&
(con_ind_sdb.primitive == CON) && (con_ind_sdb.result == POS))
{
sts = PB_TRUE;
}
close(local->hServiceReadDevice);
close(local->hServiceWriteDevice);
close(local->hDpDataDevice);
close(local->hDpsInputDataDevice);
close(local->hDpsOutputDataDevice);
close(local->hDpsBoardDevice);
profi_end();
pthread_mutex_unlock(&local->mutex);
free((char*)local);
if (ctx->Node->EmergBreakTrue == 1)
errh_Fatal("Emergency break detected shutting down profibus");
return sts;
}
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event)
{
switch (event) {
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
IoAgentClose(ctx, ap);
break;
default:
break;
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Profiboard)
= { pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose),
pwr_BindIoMethod(IoAgentSwap), pwr_NullMethod };
pwr_dExport pwr_BindIoMethods(Pb_Profiboard) = {
pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose),
pwr_BindIoMethod(IoAgentSwap), pwr_NullMethod};
......@@ -80,8 +80,7 @@ static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap)
/* Allocate area for local data structure */
ap->Local = (io_sAgentLocal*)new io_sAgentLocal;
if (!ap->Local)
{
if (!ap->Local) {
// errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name,
// "calloc");
return IO__ERRINIDEVICE;
......@@ -148,48 +147,39 @@ static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap)
// pthread_mutex_lock(&local->mutex);
for (ii = 1; ii < local->device_data.size(); ii++)
{
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED)
{
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++)
{
for (ii = 1; ii < local->device_data.size(); ii++) {
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
pn_iocr_data = local->device_data[ii]->iocr_data[jj];
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_INPUT)
{
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_INPUT) {
data_length = pn_iocr_data->io_data_length;
sts = pnak_get_iocr_data(0, pn_iocr_data->identifier,
pn_iocr_data->io_data, &data_length, &ioxs,
&status_data);
pn_iocr_data->io_data, &data_length, &ioxs, &status_data);
if (sts == PNAK_OK)
{
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++)
{
if (sts == PNAK_OK) {
for (kk = 0; kk < local->device_data[ii]->module_data.size();
kk++) {
for (ll = 0; ll < local->device_data[ii]
->module_data[kk]
->submodule_data.size();
ll++)
{
submodule =
local->device_data[ii]->module_data[kk]->submodule_data[ll];
if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT) ||
(submodule->type ==
PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))
{
ll++) {
submodule = local->device_data[ii]
->module_data[kk]
->submodule_data[ll];
if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT)
|| (submodule->type
== PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)) {
io_datap = (pn_iocr_data->io_data + submodule->offset_io_in);
clean_io_datap = (pn_iocr_data->clean_io_data +
submodule->offset_clean_io_in);
memcpy(clean_io_datap, io_datap,
submodule->io_in_data_length);
clean_io_datap = (pn_iocr_data->clean_io_data
+ submodule->offset_clean_io_in);
memcpy(
clean_io_datap, io_datap, submodule->io_in_data_length);
}
}
}
}
else
{
} else {
printf("pnak_get_iocr_data failed!\n");
}
}
......@@ -228,45 +218,37 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
// pthread_mutex_lock(&local->mutex);
for (ii = 1; ii < local->device_data.size(); ii++)
{
if (slave_list != NULL)
{
for (ii = 1; ii < local->device_data.size(); ii++) {
if (slave_list != NULL) {
sp = (pwr_sClass_PnDevice*)slave_list->op;
slave_list = slave_list->next;
}
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED)
{
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++)
{
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
pn_iocr_data = local->device_data[ii]->iocr_data[jj];
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_OUTPUT)
{
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_OUTPUT) {
data_length = pn_iocr_data->io_data_length;
/* Set io status to good */
memset(pn_iocr_data->io_data, 0x80,
data_length); // 0x80 is PNAK_IOXS_STATUS_DATA_GOOD
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++)
{
for (ll = 0;
ll <
local->device_data[ii]->module_data[kk]->submodule_data.size();
ll++)
{
submodule =
local->device_data[ii]->module_data[kk]->submodule_data[ll];
if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT) ||
(submodule->type ==
PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))
{
data_length); // 0x80 is PNAK_IOXS_STATUS_DATA_GOOD
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) {
for (ll = 0; ll < local->device_data[ii]
->module_data[kk]
->submodule_data.size();
ll++) {
submodule
= local->device_data[ii]->module_data[kk]->submodule_data[ll];
if ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT)
|| (submodule->type
== PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)) {
io_datap = (pn_iocr_data->io_data + submodule->offset_io_out);
clean_io_datap = (pn_iocr_data->clean_io_data +
submodule->offset_clean_io_out);
clean_io_datap = (pn_iocr_data->clean_io_data
+ submodule->offset_clean_io_out);
memcpy(io_datap, clean_io_datap, submodule->io_out_data_length);
/*status_datap = io_datap + submodule->io_out_data_length;
......@@ -276,60 +258,51 @@ static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap)
}
}
}
char ioxs = CYCLIC_DATA_STATUS_DATA_VALID |
CYCLIC_DATA_STATUS_STATE_PRIMARY |
CYCLIC_DATA_STATUS_STATE_RUN |
CYCLIC_DATA_STATUS_NORMAL_OPERATION;
char ioxs = CYCLIC_DATA_STATUS_DATA_VALID
| CYCLIC_DATA_STATUS_STATE_PRIMARY | CYCLIC_DATA_STATUS_STATE_RUN
| CYCLIC_DATA_STATUS_NORMAL_OPERATION;
sts = pnak_set_iocr_data(0, pn_iocr_data->identifier,
pn_iocr_data->io_data,
pn_iocr_data->io_data_length, ioxs);
if (sts != PNAK_OK)
{
pn_iocr_data->io_data, pn_iocr_data->io_data_length, ioxs);
if (sts != PNAK_OK) {
printf("pnak_set_iocr_data failed!\n");
}
}
}
if (slave_list != NULL)
{
if (slave_list != NULL) {
/* Check if there is a write request pending ?? */
if (sp->WriteReq.SendReq)
{
if ((sp->WriteReq.Length > 0) &&
(sp->WriteReq.Length <= sizeof(sp->WriteReq.Data)))
{
for (jj = 0; jj < local->device_data[ii]->module_data.size(); jj++)
{
if (local->device_data[ii]->module_data[jj]->slot_number ==
sp->WriteReq.SlotNumber)
{
if (sp->WriteReq.SendReq) {
if ((sp->WriteReq.Length > 0)
&& (sp->WriteReq.Length <= sizeof(sp->WriteReq.Data))) {
for (jj = 0; jj < local->device_data[ii]->module_data.size();
jj++) {
if (local->device_data[ii]->module_data[jj]->slot_number
== sp->WriteReq.SlotNumber) {
for (kk = 0; kk < local->device_data[ii]
->module_data[jj]
->submodule_data.size();
kk++)
{
kk++) {
if (local->device_data[ii]
->module_data[jj]
->submodule_data[kk]
->subslot_number == sp->WriteReq.SubslotNumber)
{
->subslot_number
== sp->WriteReq.SubslotNumber) {
if (local->device_data[ii]
->module_data[jj]
->submodule_data[kk]
->api > 0)
{
->api
> 0) {
sp->WriteReq.Api = local->device_data[ii]
->module_data[jj]
->submodule_data[kk]
->api;
}
pack_write_req(&local->service_req_res,
local->device_data[ii]->device_ref,
&sp->WriteReq);
local->device_data[ii]->device_ref, &sp->WriteReq);
sts = pnak_send_service_req_res(0, &local->service_req_res);
errh_Info("Profinet - Asynch write, dev: %d",
local->device_data[ii]->device_ref);
local->device_data[ii]->device_ref);
break;
}
}
......
......@@ -80,8 +80,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
latent_input_count = 0;
latent_output_count = 0;
while (cardp)
{
while (cardp) {
local_card = (io_sPnCardLocal*)calloc(1, sizeof(*local_card));
cardp->Local = local_card;
local_card->input_area = ((io_sPnRackLocal*)(rp->Local))->inputs;
......@@ -93,38 +92,32 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid)))
;
switch (cid)
{
/* New style configuring (from v4.1.3) with Pb_Module objects or subclass.
Loop all channels
in the module and set channel size and offset. */
switch (cid) {
/* New style configuring (from v4.1.3) with Pb_Module objects or subclass.
Loop all channels
in the module and set channel size and offset. */
case pwr_cClass_PnModule:
mp = (pwr_sClass_PnModule*)cardp->op;
mp->Status = PB__INITFAIL;
cardp->offset = 0;
for (i = 0; i < cardp->ChanListSize; i++)
{
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
if (chanp->ChanClass != pwr_cClass_ChanDi)
{
if (chanp->ChanClass != pwr_cClass_ChanDi) {
input_counter += latent_input_count;
latent_input_count = 0;
}
if (chanp->ChanClass != pwr_cClass_ChanDo)
{
if (chanp->ChanClass != pwr_cClass_ChanDo) {
output_counter += latent_output_count;
latent_output_count = 0;
}
switch (chanp->ChanClass)
{
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0)
{
if (chan_di->Number == 0) {
input_counter += latent_input_count;
latent_input_count = 0;
}
......@@ -138,15 +131,15 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
// byte order. Maybe booleans can be
// considered Little Endian...
// More TODO: Check host endianess aswell and take action accordingly
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_di->Representation == pwr_eDataRepEnum_Bit16
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_di->Representation == pwr_eDataRepEnum_Bit32
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask);
if (chan_di->Number == 0)
latent_input_count =
GetChanSize((pwr_eDataRepEnum)chan_di->Representation);
latent_input_count
= GetChanSize((pwr_eDataRepEnum)chan_di->Representation);
// printf("Di channel found in %s, Number %d, Offset %d\n",
// cardp->Name, chan_di->Number, chanp->offset);
break;
......@@ -186,23 +179,22 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0)
{
if (chan_do->Number == 0) {
output_counter += latent_output_count;
latent_output_count = 0;
}
chanp->offset = output_counter;
chan_size = GetChanSize((pwr_eDataRepEnum)chan_do->Representation);
chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_do->Representation == pwr_eDataRepEnum_Bit16
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 &&
op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (chan_do->Representation == pwr_eDataRepEnum_Bit32
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask);
if (chan_do->Number == 0)
latent_output_count =
GetChanSize((pwr_eDataRepEnum)chan_do->Representation);
latent_output_count
= GetChanSize((pwr_eDataRepEnum)chan_do->Representation);
// printf("Do channel found in %s, Number %d, Offset %d\n",
// cardp->Name, chan_do->Number, chanp->offset);
break;
......@@ -256,40 +248,31 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The reading of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
if (sp->Status == PB__NORMAL)
{
if (sp->Status == PB__NORMAL) {
sp->ErrorCount = 0;
}
else
{
} else {
if (local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if (sp->ErrorCount == sp->ErrorHardLimit)
{
if (sp->ErrorCount == sp->ErrorHardLimit) {
errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction);
rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++;
}
else if (sp->ErrorCount == sp->ErrorSoftLimit)
{
} else if (sp->ErrorCount == sp->ErrorSoftLimit) {
errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorHardLimit)
{
if (sp->StallAction == pwr_ePbStallAction_ResetInputs)
{
if (sp->ErrorCount > sp->ErrorHardLimit) {
if (sp->StallAction == pwr_ePbStallAction_ResetInputs) {
if (((io_sPnRackLocal*)(rp->Local))->bytes_of_input > 0)
memset(((io_sPnRackLocal*)(rp->Local))->inputs, 0,
((io_sPnRackLocal*)(rp->Local))->bytes_of_input);
}
else if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
((io_sPnRackLocal*)(rp->Local))->bytes_of_input);
} else if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1;
}
......@@ -307,33 +290,26 @@ static pwr_tStatus IoRackWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The writing of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
if (sp->Status == PB__NORMAL)
{
if (sp->Status == PB__NORMAL) {
sp->ErrorCount = 0;
}
else
{
} else {
if (local->start_cnt >= local->start_time)
sp->ErrorCount++;
}
if (sp->ErrorCount == sp->ErrorHardLimit)
{
if (sp->ErrorCount == sp->ErrorHardLimit) {
errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction);
rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++;
}
else if (sp->ErrorCount == sp->ErrorSoftLimit)
{
} else if (sp->ErrorCount == sp->ErrorSoftLimit) {
errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorHardLimit)
{
if (sp->ErrorCount > sp->ErrorHardLimit) {
if (sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1;
}
......@@ -353,7 +329,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(PnDevice) = {
pwr_BindIoMethod(IoRackInit), pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
pwr_dExport pwr_BindIoMethods(PnDevice) = { pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackWrite),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod };
......@@ -40,8 +40,8 @@
/*----------------------------------------------------------------------------*\
Init method for the Pnmodule
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
static pwr_tStatus IoCardInit(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{
io_sPnCardLocal* local;
pwr_sClass_PnModule* op;
......@@ -57,8 +57,8 @@ static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/*----------------------------------------------------------------------------*\
Read method for the Pn module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
static pwr_tStatus IoCardRead(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{
io_sPnCardLocal* local;
pwr_sClass_PnModule* op;
......@@ -75,7 +75,7 @@ static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/* all inputs will be zeroed */
io_bus_card_read(ctx, rp, cp, local->input_area, 0, slave->ByteOrdering,
slave->FloatRepresentation);
slave->FloatRepresentation);
return IO__SUCCESS;
}
......@@ -83,8 +83,8 @@ static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/*----------------------------------------------------------------------------*\
Write method for the Pn module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
static pwr_tStatus IoCardWrite(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{
io_sPnCardLocal* local;
pwr_sClass_PnModule* op;
......@@ -96,10 +96,9 @@ static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
op->Status = slave->Status;
if (op->Status == PB__NORMAL)
{
if (op->Status == PB__NORMAL) {
io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering,
slave->FloatRepresentation);
slave->FloatRepresentation);
}
// printf("Method Pb_Module-IoCardWrite\n");
return IO__SUCCESS;
......@@ -108,8 +107,8 @@ static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
/*----------------------------------------------------------------------------*\
Close method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_sCard* cp)
static pwr_tStatus IoCardClose(
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp)
{
io_sPnCardLocal* local;
local = (io_sPnCardLocal*)cp->Local;
......@@ -124,7 +123,6 @@ static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(PnModule) = {
pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod};
pwr_dExport pwr_BindIoMethods(PnModule) = { pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod };
......@@ -102,6 +102,7 @@ typedef struct _agent_args
{
void* local;
io_sAgent* ap;
io_tCtx ctx;
} agent_args;
typedef struct
......
......@@ -60,7 +60,8 @@ typedef enum {
GsdmlSlotData* GsdmlDeviceData::paste_slotdata = 0;
GsdmlChannelDiag::GsdmlChannelDiag() : error_type(0)
GsdmlChannelDiag::GsdmlChannelDiag()
: error_type(0)
{
memset(name, 0, sizeof(name));
memset(help, 0, sizeof(help));
......@@ -76,11 +77,13 @@ int GsdmlChannelDiag::print(std::ofstream& fp)
}
GsdmlDataRecord::GsdmlDataRecord(const GsdmlDataRecord& x)
: record_idx(x.record_idx), data(x.data), data_length(x.data_length),
index(x.index), transfer_sequence(x.transfer_sequence)
: record_idx(x.record_idx)
, data(x.data)
, data_length(x.data_length)
, index(x.index)
, transfer_sequence(x.transfer_sequence)
{
if (data)
{
if (data) {
data = (unsigned char*)malloc(data_length);
memcpy(data, x.data, data_length);
}
......@@ -91,14 +94,13 @@ int GsdmlDataRecord::print(std::ofstream& fp, bool reverse_endianess)
char str[1024];
unsigned char* data;
// If we have allocated memory for reversed endianess we come from the pn configurator otherwise we use the data as is.
// The method SetIoDeviceData for instance reads the raw data and then recreates the pn configuration file.
if (data_reversed_endianess)
{
// If we have allocated memory for reversed endianess we come from the pn
// configurator otherwise we use the data as is. The method SetIoDeviceData
// for instance reads the raw data and then recreates the pn configuration
// file.
if (data_reversed_endianess) {
data = (reverse_endianess ? this->data_reversed_endianess : this->data);
}
else
{
} else {
data = this->data;
}
......@@ -121,8 +123,7 @@ int GsdmlSubslotData::print(std::ofstream& fp, bool reverse_endianess)
<< " IOInputLength=\"" << io_input_length << "\"\n"
<< " IOOutputLength=\"" << io_output_length << "\" >\n";
for (unsigned int i = 0; i < data_record.size(); i++)
{
for (unsigned int i = 0; i < data_record.size(); i++) {
data_record[i]->print(fp, reverse_endianess);
}
......@@ -139,8 +140,7 @@ int GsdmlSlotData::print(std::ofstream& fp, bool reverse_endianess)
<< " SlotNumber=\"" << slot_number << "\"\n"
<< " DapFixedInSlot=\"" << dap_fixed_slot << "\" >\n";
for (unsigned int i = 0; i < subslot_data.size(); i++)
{
for (unsigned int i = 0; i < subslot_data.size(); i++) {
subslot_data[i]->print(fp, reverse_endianess);
}
......@@ -193,36 +193,27 @@ int GsdmlDeviceData::print(const char* filename)
// Save in accordance to the chosen endianess
#if (pwr_dHost_byteOrder == pwr_dLittleEndian)
if (byte_order == pwr_eByteOrderingEnum_LittleEndian)
{
if (byte_order == pwr_eByteOrderingEnum_LittleEndian) {
reverse_endianess = false;
}
else
{
} else {
// We use the data saved as the reversed endianess
reverse_endianess = true;
}
#elif (pwr_dHost_byteOrder == pwr_dBigEndian)
if (byte_order == pwr_eByteOrderingEnum_LittleEndian)
{
if (byte_order == pwr_eByteOrderingEnum_LittleEndian) {
reverse_endianess = true;
}
else
{
} else {
reverse_endianess = false;
}
#endif
for (unsigned int i = 0; i < slot_data.size(); i++)
{
for (unsigned int i = 0; i < slot_data.size(); i++) {
slot_data[i]->print(fp, reverse_endianess);
}
for (unsigned int i = 0; i < iocr_data.size(); i++)
{
for (unsigned int i = 0; i < iocr_data.size(); i++) {
iocr_data[i]->print(fp);
}
for (unsigned int i = 0; i < channel_diag.size(); i++)
{
for (unsigned int i = 0; i < channel_diag.size(); i++) {
channel_diag[i]->print(fp);
}
......@@ -271,8 +262,7 @@ int GsdmlDeviceData::cut_slot(unsigned int slot_idx)
delete slot_data[slot_idx];
for (unsigned int i = slot_idx; i < slot_data.size() - 1; i++)
{
for (unsigned int i = slot_idx; i < slot_data.size() - 1; i++) {
tmp_slot_idx = slot_data[i + 1]->slot_idx;
tmp_slot_number = slot_data[i + 1]->slot_number;
......@@ -304,8 +294,7 @@ int GsdmlDeviceData::paste_slot(unsigned int slot_idx)
delete slot_data[slot_data.size() - 1];
for (unsigned int i = slot_data.size() - 1; i > slot_idx; i--)
{
for (unsigned int i = slot_data.size() - 1; i > slot_idx; i--) {
tmp_slot_idx = slot_data[i - 1]->slot_idx;
tmp_slot_number = slot_data[i - 1]->slot_number;
......@@ -329,11 +318,9 @@ int GsdmlDeviceData::modify_value(const char* attr, const char* value)
int ival, num2;
num = dcli_parse(attr, "-", "", (char*)attrvect,
sizeof(attrvect) / sizeof(attrvect[0]), sizeof(attrvect[0]),
0);
sizeof(attrvect) / sizeof(attrvect[0]), sizeof(attrvect[0]), 0);
if (streq(attrvect[0], "NetworkSettings"))
{
if (streq(attrvect[0], "NetworkSettings")) {
if (num < 2)
return 0;
if (streq(attrvect[1], "DeviceName"))
......@@ -344,42 +331,33 @@ int GsdmlDeviceData::modify_value(const char* attr, const char* value)
strncpy(subnet_mask, value, sizeof(subnet_mask));
else if (streq(attrvect[1], "MAC Address"))
strncpy(mac_address, value, sizeof(mac_address));
else if (streq(attrvect[1], "SendClock"))
{
else if (streq(attrvect[1], "SendClock")) {
num2 = sscanf(value, "%d", &ival);
if (num2 != 1)
return 0;
for (unsigned int i = 0; i < iocr_data.size(); i++)
iocr_data[i]->send_clock_factor = ival;
}
else if (streq(attrvect[1], "ReductionRatio"))
{
} else if (streq(attrvect[1], "ReductionRatio")) {
num2 = sscanf(value, "%d", &ival);
if (num2 != 1)
return 0;
for (unsigned int i = 0; i < iocr_data.size(); i++)
iocr_data[i]->reduction_ratio = ival;
}
else if (streq(attrvect[1], "Phase"))
{
} else if (streq(attrvect[1], "Phase")) {
num2 = sscanf(value, "%d", &ival);
if (num2 != 1)
return 0;
for (unsigned int i = 0; i < iocr_data.size(); i++)
iocr_data[i]->phase = ival;
}
else if (streq(attrvect[1], "API"))
{
} else if (streq(attrvect[1], "API")) {
num2 = sscanf(value, "%d", &ival);
if (num2 != 1)
return 0;
for (unsigned int i = 0; i < iocr_data.size(); i++)
iocr_data[i]->api = ival;
}
else
} else
return 0;
}
else
} else
return 0;
return 1;
}
......@@ -390,11 +368,9 @@ int GsdmlDeviceData::get_value(const char* attr, char* buf, int bufsize)
int num;
num = dcli_parse(attr, "-", "", (char*)attrvect,
sizeof(attrvect) / sizeof(attrvect[0]), sizeof(attrvect[0]),
0);
sizeof(attrvect) / sizeof(attrvect[0]), sizeof(attrvect[0]), 0);
if (streq(attrvect[0], "NetworkSettings"))
{
if (streq(attrvect[0], "NetworkSettings")) {
if (num < 2)
return 0;
if (streq(attrvect[1], "DeviceName"))
......@@ -415,8 +391,7 @@ int GsdmlDeviceData::get_value(const char* attr, char* buf, int bufsize)
snprintf(buf, bufsize, "%d", iocr_data[0]->api);
else
return 0;
}
else
} else
return 0;
return 1;
}
......@@ -447,27 +422,22 @@ int GsdmlDataReader::tag(const char* name)
{
if (tag_name_to_id(name, &current_tag))
tag_stack_push(current_tag);
else
{
else {
printf("XML-Parser: Unknown tag: %s\n", name);
return 0;
}
switch (current_tag)
{
case gsdmldata_eTag_Slot:
{
switch (current_tag) {
case gsdmldata_eTag_Slot: {
GsdmlSlotData* sd = new GsdmlSlotData();
data->slot_data.push_back(sd);
object_stack_push(sd, current_tag);
break;
}
case gsdmldata_eTag_Subslot:
{
case gsdmldata_eTag_Subslot: {
GsdmlSlotData* sd = (GsdmlSlotData*)get_object_stack(gsdmldata_eTag_Slot);
if (!sd)
{
if (!sd) {
printf("XML-Parser: Subslot outside slot");
break;
}
......@@ -478,12 +448,10 @@ int GsdmlDataReader::tag(const char* name)
object_stack_push(ssd, current_tag);
break;
}
case gsdmldata_eTag_DataRecord:
{
GsdmlSubslotData* ssd =
(GsdmlSubslotData*)get_object_stack(gsdmldata_eTag_Subslot);
if (!ssd)
{
case gsdmldata_eTag_DataRecord: {
GsdmlSubslotData* ssd
= (GsdmlSubslotData*)get_object_stack(gsdmldata_eTag_Subslot);
if (!ssd) {
printf("XML-Parser: RecordData outside subslot");
break;
}
......@@ -494,16 +462,14 @@ int GsdmlDataReader::tag(const char* name)
object_stack_push(dr, current_tag);
break;
}
case gsdmldata_eTag_IOCR:
{
case gsdmldata_eTag_IOCR: {
GsdmlIOCRData* iod = new GsdmlIOCRData();
data->iocr_data.push_back(iod);
object_stack_push(iod, current_tag);
break;
}
case gsdmldata_eTag_ChannelDiag:
{
case gsdmldata_eTag_ChannelDiag: {
GsdmlChannelDiag* cd = new GsdmlChannelDiag();
data->channel_diag.push_back(cd);
......@@ -515,21 +481,22 @@ int GsdmlDataReader::tag(const char* name)
return 1;
}
int GsdmlDataReader::metatag(const char* name) { return 1; }
int GsdmlDataReader::metatag(const char* name)
{
return 1;
}
int GsdmlDataReader::tag_end(const char* name)
{
unsigned int id;
if (tag_name_to_id(name, &id))
tag_stack_pull(id);
else
{
else {
printf("XML-Parser: Tag/EndTag mismach: %s\n", name);
return 0;
}
switch (id)
{
switch (id) {
case gsdmldata_eTag_Slot:
object_stack_pull(id);
break;
......@@ -546,17 +513,20 @@ int GsdmlDataReader::tag_end(const char* name)
}
return 1;
}
int GsdmlDataReader::metatag_end(const char* name) { return 1; }
int GsdmlDataReader::tag_value(const char* name) { return 1; }
int GsdmlDataReader::metatag_end(const char* name)
{
return 1;
}
int GsdmlDataReader::tag_value(const char* name)
{
return 1;
}
int GsdmlDataReader::tag_attribute(const char* name, const char* value)
{
switch (current_tag)
{
switch (current_tag) {
case gsdmldata_eTag_PnDevice:
if (streq(name, "GsdmlFile"))
{
if (!streq(data->gsdmlfile, ""))
{
if (streq(name, "GsdmlFile")) {
if (!streq(data->gsdmlfile, "")) {
// Check that the GSDML file is not changed
char* gsdmlfile_p;
......@@ -568,11 +538,9 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
if (!streq(value, gsdmlfile_p) && !new_filename)
return PB__GSDMLFILEMISMATCH;
}
else
} else
strncpy(data->gsdmlfile, value, sizeof(data->gsdmlfile));
}
else if (streq(name, "DeviceText"))
} else if (streq(name, "DeviceText"))
strncpy(data->device_text, value, sizeof(data->device_text));
else if (streq(name, "DeviceNumber"))
sscanf(value, "%d", &data->device_num);
......@@ -597,8 +565,7 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
else if (streq(name, "MAC_Address"))
strncpy(data->mac_address, value, sizeof(data->mac_address));
break;
case gsdmldata_eTag_Slot:
{
case gsdmldata_eTag_Slot: {
GsdmlSlotData* sd = (GsdmlSlotData*)get_object_stack(current_tag);
if (streq(name, "ModuleEnumNumber"))
......@@ -615,8 +582,7 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
sscanf(value, "%u", &sd->dap_fixed_slot);
break;
}
case gsdmldata_eTag_Subslot:
{
case gsdmldata_eTag_Subslot: {
GsdmlSubslotData* sd = (GsdmlSubslotData*)get_object_stack(current_tag);
if (streq(name, "SubslotNumber"))
......@@ -633,8 +599,7 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
sscanf(value, "%u", &sd->io_output_length);
break;
}
case gsdmldata_eTag_DataRecord:
{
case gsdmldata_eTag_DataRecord: {
GsdmlDataRecord* dr = (GsdmlDataRecord*)get_object_stack(current_tag);
if (streq(name, "DataLength"))
......@@ -643,15 +608,13 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
sscanf(value, "%hu", &dr->index);
else if (streq(name, "TransferSequence"))
sscanf(value, "%hu", &dr->transfer_sequence);
else if (streq(name, "Data"))
{
else if (streq(name, "Data")) {
int len;
co_xml_parser::ostring_to_data(&dr->data, value, dr->data_length, &len);
}
break;
}
case gsdmldata_eTag_IOCR:
{
case gsdmldata_eTag_IOCR: {
GsdmlIOCRData* iod = (GsdmlIOCRData*)get_object_stack(current_tag);
if (streq(name, "Type"))
......@@ -668,8 +631,7 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
sscanf(value, "%u", &iod->api);
break;
}
case gsdmldata_eTag_ChannelDiag:
{
case gsdmldata_eTag_ChannelDiag: {
GsdmlChannelDiag* cd = (GsdmlChannelDiag*)get_object_stack(current_tag);
if (streq(name, "ErrorType"))
......
......@@ -175,7 +175,8 @@ public:
GsdmlChannelDiag();
unsigned short error_type;
char name[200];
char help[4096]; // We need a large buffer for most of the help text in the diagnostics...
char help[4096]; // We need a large buffer for most of the help text in the
// diagnostics...
int print(std::ofstream& fp);
};
......@@ -213,7 +214,8 @@ public:
static GsdmlSlotData* paste_slotdata;
std::vector<GsdmlChannelDiag*> channel_diag;
~GsdmlDeviceData() {
~GsdmlDeviceData()
{
device_reset();
channel_diag_reset();
}
......
......@@ -23,66 +23,71 @@ Version: 2.22.00
/*****************************************************************************/
#if defined WIN32 || defined _WIN32
#pragma warning (disable : 4103) /* used #pragma pack to change alignment */
#pragma pack (push, 2)
#pragma warning (default : 4103)
#pragma warning(disable : 4103) /* used #pragma pack to change alignment */
#pragma pack(push, 2)
#pragma warning(default : 4103)
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) Struct
#endif
#elif defined __GNUC__
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) __attribute__ ((packed, aligned (2))) Struct
#endif
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) __attribute__((packed, aligned(2))) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) __attribute__ ((packed, aligned (1))) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) __attribute__((packed, aligned(1))) Struct
#endif
#elif defined _OS9000
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) Struct
#endif
#else
#error CAUTION: set word structure alignment
#error CAUTION: set word structure alignment
#endif
/******************************************************************************
ACCESS KIT USER INTERFACE
******************************************************************************/
#define _BITSET256_RESET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] &= ~(1u << ((BitNr) & 7u)))
#define _BITSET256_SET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] |= 1u << ((BitNr) & 7u) )
#define _BITSET256_IS_BIT_SET(pBS,BitNr) ((((pBS)) [(BitNr) >> 3]) & (1u << ((BitNr) & 7u) ))
#define _BITSET256_RESET_BIT(pBS, BitNr) \
(((pBS))[(BitNr) >> 3] &= ~(1u << ((BitNr)&7u)))
#define _BITSET256_SET_BIT(pBS, BitNr) \
(((pBS))[(BitNr) >> 3] |= 1u << ((BitNr)&7u))
#define _BITSET256_IS_BIT_SET(pBS, BitNr) \
((((pBS))[(BitNr) >> 3]) & (1u << ((BitNr)&7u)))
#define _BITSET64_RESET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] &= ~(1u << ((BitNr) & 7u)))
#define _BITSET64_SET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] |= 1u << ((BitNr) & 7u) )
#define _BITSET64_IS_BIT_SET(pBS,BitNr) ((((pBS)) [(BitNr) >> 3]) & (1u << ((BitNr) & 7u) ))
#define _BITSET64_RESET_BIT(pBS, BitNr) \
(((pBS))[(BitNr) >> 3] &= ~(1u << ((BitNr)&7u)))
#define _BITSET64_SET_BIT(pBS, BitNr) \
(((pBS))[(BitNr) >> 3] |= 1u << ((BitNr)&7u))
#define _BITSET64_IS_BIT_SET(pBS, BitNr) \
((((pBS))[(BitNr) >> 3]) & (1u << ((BitNr)&7u)))
/*---------------------------------------------------------------------------*/
#ifndef _MAX
#define _MAX(A,B) ((A) > (B) ? (A) : (B))
#define _MAX(A, B) ((A) > (B) ? (A) : (B))
#endif
#ifndef _MIN
#define _MIN(A,B) ((A) < (B) ? (A) : (B))
#define _MIN(A, B) ((A) < (B) ? (A) : (B))
#endif
/*---------------------------------------------------------------------------*/
typedef enum _T_PNAK_RESULT
{
PNAK_OK = 0,
typedef enum _T_PNAK_RESULT {
PNAK_OK = 0,
/*-------------------------------------------------------------------------*/
......@@ -154,142 +159,139 @@ typedef enum _T_PNAK_RESULT
/*--- errors loading library -------------------------------------------*/
PNAK_ERR_LIBRARY_NOT_LOADED,
} T_PNAK_RESULT;
/*---------------------------------------------------------------------------*/
typedef unsigned char T_BITSET_256 [32];
typedef unsigned char T_BITSET_64 [8];
typedef unsigned char T_BITSET_256[32];
typedef unsigned char T_BITSET_64[8];
/*---------------------------------------------------------------------------*/
typedef unsigned short T_PNAK_EXCEPTION_SOURCE;
typedef unsigned short T_PNAK_EXCEPTION_SOURCE;
#define PNAK_EXCEPTION_SOURCE_IS_STACK 0u
#define PNAK_EXCEPTION_SOURCE_IS_PNAK 1u
#define PNAK_EXCEPTION_SOURCE_IS_APPL 2u
#define PNAK_EXCEPTION_SOURCE_IS_STACK 0u
#define PNAK_EXCEPTION_SOURCE_IS_PNAK 1u
#define PNAK_EXCEPTION_SOURCE_IS_APPL 2u
typedef struct _T_PNAK_EXCEPTION
{
T_PNAK_EXCEPTION_SOURCE Source;
unsigned short ChannelId;
T_PNAK_EXCEPTION_SOURCE Source;
unsigned short ChannelId;
unsigned short ModuleId;
unsigned short FileId;
unsigned short ErrorId;
unsigned short ModuleId;
unsigned short FileId;
unsigned short ErrorId;
PN_U32 UserSpecificParameter;
char UserString [22];
PN_U32 UserSpecificParameter;
char UserString[22];
} PACK_WORD_ALIGNMENT (T_PNAK_EXCEPTION);
} PACK_WORD_ALIGNMENT(T_PNAK_EXCEPTION);
/*---------------------------------------------------------------------------*/
typedef unsigned long T_PNAK_OID;
typedef unsigned long T_PNAK_OID;
/*---------------------------------------------------------------------------*/
typedef unsigned short T_PNAK_MODE_ID;
typedef unsigned short T_PNAK_MODE_ID;
#define PNAK_UNINITIALIZED_MODE 0
#define PNAK_CONTROLLER_MODE 1
#define PNAK_DEVICE_MODE 2
#define PNAK_SUPERVISOR_MODE 3
#define PNAK_UNINITIALIZED_MODE 0
#define PNAK_CONTROLLER_MODE 1
#define PNAK_DEVICE_MODE 2
#define PNAK_SUPERVISOR_MODE 3
/*---------------------------------------------------------------------------*/
#define PNAK_VERSION_STRING_LENGTH 42
#define PNAK_VERSION_STRING_LENGTH 42
typedef struct _T_PNAK_VERSION
{
unsigned short IfId;
unsigned short HostIfId;
unsigned short HostConfigIfId;
unsigned short ExceptionIfId;
unsigned short ServiceIfId;
unsigned short EventIfId;
unsigned short StatisticIfId;
unsigned short DataIfId;
unsigned short IfId;
unsigned short HostIfId;
unsigned short HostConfigIfId;
unsigned short ExceptionIfId;
unsigned short ServiceIfId;
unsigned short EventIfId;
unsigned short StatisticIfId;
unsigned short DataIfId;
char VersionString [PNAK_VERSION_STRING_LENGTH];
char VersionString[PNAK_VERSION_STRING_LENGTH];
} PACK_WORD_ALIGNMENT (T_PNAK_VERSION);
} PACK_WORD_ALIGNMENT(T_PNAK_VERSION);
typedef struct _T_PNAK_VERSIONS
{
T_PNAK_VERSION Firmware;
T_PNAK_VERSION Pnak;
T_PNAK_VERSION Firmware;
T_PNAK_VERSION Pnak;
} PACK_WORD_ALIGNMENT (T_PNAK_VERSIONS);
} PACK_WORD_ALIGNMENT(T_PNAK_VERSIONS);
/*---------------------------------------------------------------------------*/
#define PNAK_INFINITE_TIMEOUT 0xFFFFFFFFuL
#define PNAK_MAX_NUMBER_WAIT_OBJECTS 32uL
typedef PN_U32 T_PNAK_TIMEOUT;
typedef PN_U32 T_PNAK_WAIT_OBJECT;
#define PNAK_WAIT_OBJECT_EXCEPTION ((T_PNAK_WAIT_OBJECT) 0x00000001uL)
#define PNAK_WAIT_OBJECT_STATE_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00000002uL)
#define PNAK_WAIT_OBJECT_ALARM ((T_PNAK_WAIT_OBJECT) 0x00000004uL)
#define PNAK_WAIT_OBJECT_ALARM_ACK ((T_PNAK_WAIT_OBJECT) 0x00000008uL)
#define PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00000010uL)
#define PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00000020uL)
#define PNAK_WAIT_OBJECT_PROVIDER_DATA_UPDATED ((T_PNAK_WAIT_OBJECT) 0x00000040uL)
#define PNAK_WAIT_OBJECT_CONSUMER_DATA_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00000080uL)
#define PNAK_WAIT_OBJECT_SERVICE_IND ((T_PNAK_WAIT_OBJECT) 0x00000100uL)
#define PNAK_WAIT_OBJECT_SERVICE_CON ((T_PNAK_WAIT_OBJECT) 0x00000200uL)
#define PNAK_WAIT_OBJECT_SERVICE_REQ_RES_HANDLED ((T_PNAK_WAIT_OBJECT) 0x00000400uL)
#define PNAK_WAIT_OBJECT_PTCP ((T_PNAK_WAIT_OBJECT) 0x00000800uL)
#define PNAK_WAIT_OBJECT_SOCKET_STATE_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00001000uL)
#define PNAK_WAIT_OBJECT_SOCKET_DATA_RECEIVED ((T_PNAK_WAIT_OBJECT) 0x00002000uL)
#define PNAK_WAIT_OBJECT_MRPD ((T_PNAK_WAIT_OBJECT) 0x00004000uL)
#define PNAK_WAIT_OBJECT_CHANNEL_CLOSED ((T_PNAK_WAIT_OBJECT) 0x00200000uL)
#define PNAK_WAIT_OBJECT_INTERRUPTED ((T_PNAK_WAIT_OBJECT) 0x00400000uL)
#define PNAK_USER_WAIT_OBJECT_1 ((T_PNAK_WAIT_OBJECT) 0x00800000uL)
#define PNAK_USER_WAIT_OBJECT_2 ((T_PNAK_WAIT_OBJECT) 0x01000000uL)
#define PNAK_USER_WAIT_OBJECT_3 ((T_PNAK_WAIT_OBJECT) 0x02000000uL)
#define PNAK_USER_WAIT_OBJECT_4 ((T_PNAK_WAIT_OBJECT) 0x04000000uL)
#define PNAK_USER_WAIT_OBJECT_5 ((T_PNAK_WAIT_OBJECT) 0x08000000uL)
#define PNAK_USER_WAIT_OBJECT_6 ((T_PNAK_WAIT_OBJECT) 0x10000000uL)
#define PNAK_USER_WAIT_OBJECT_7 ((T_PNAK_WAIT_OBJECT) 0x20000000uL)
#define PNAK_USER_WAIT_OBJECT_8 ((T_PNAK_WAIT_OBJECT) 0x40000000uL)
#define PNAK_WAIT_TIMEOUT ((T_PNAK_WAIT_OBJECT) 0x80000000uL)
#define PNAK_WAIT_OBJECTS_SERVICE (PNAK_WAIT_OBJECT_SERVICE_CON | \
PNAK_WAIT_OBJECT_SERVICE_IND | \
PNAK_WAIT_OBJECT_SERVICE_REQ_RES_HANDLED)
#define PNAK_WAIT_OBJECTS_EVENT_IND (PNAK_WAIT_OBJECT_STATE_CHANGED | \
PNAK_WAIT_OBJECT_ALARM | \
PNAK_WAIT_OBJECT_ALARM_ACK | \
PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED | \
PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED | \
PNAK_WAIT_OBJECT_PTCP | \
PNAK_WAIT_OBJECT_MRPD)
#define PNAK_WAIT_OBJECTS_DATA_IND (PNAK_WAIT_OBJECT_PROVIDER_DATA_UPDATED |\
PNAK_WAIT_OBJECT_CONSUMER_DATA_CHANGED)
#define PNAK_WAIT_OBJECTS_SOCKET_IND (PNAK_WAIT_OBJECT_SOCKET_STATE_CHANGED | \
PNAK_WAIT_OBJECT_SOCKET_DATA_RECEIVED)
#define PNAK_WAIT_OBJECTS_OTHER (PNAK_WAIT_OBJECT_EXCEPTION | \
PNAK_WAIT_OBJECT_CHANNEL_CLOSED | \
PNAK_WAIT_OBJECT_INTERRUPTED)
#define PNAK_WAIT_OBJECTS_USER (PNAK_USER_WAIT_OBJECT_1 | \
PNAK_USER_WAIT_OBJECT_2 | \
PNAK_USER_WAIT_OBJECT_3 | \
PNAK_USER_WAIT_OBJECT_4 | \
PNAK_USER_WAIT_OBJECT_5 | \
PNAK_USER_WAIT_OBJECT_6 | \
PNAK_USER_WAIT_OBJECT_7 | \
PNAK_USER_WAIT_OBJECT_8)
#define PNAK_WAIT_OBJECTS_ALL (PNAK_WAIT_OBJECTS_OTHER | \
PNAK_WAIT_OBJECTS_EVENT_IND | \
PNAK_WAIT_OBJECTS_DATA_IND | \
PNAK_WAIT_OBJECTS_SERVICE | \
PNAK_WAIT_OBJECTS_SOCKET_IND | \
PNAK_WAIT_OBJECTS_USER | \
PNAK_WAIT_TIMEOUT)
#define PNAK_INFINITE_TIMEOUT 0xFFFFFFFFuL
#define PNAK_MAX_NUMBER_WAIT_OBJECTS 32uL
typedef PN_U32 T_PNAK_TIMEOUT;
typedef PN_U32 T_PNAK_WAIT_OBJECT;
#define PNAK_WAIT_OBJECT_EXCEPTION ((T_PNAK_WAIT_OBJECT)0x00000001uL)
#define PNAK_WAIT_OBJECT_STATE_CHANGED ((T_PNAK_WAIT_OBJECT)0x00000002uL)
#define PNAK_WAIT_OBJECT_ALARM ((T_PNAK_WAIT_OBJECT)0x00000004uL)
#define PNAK_WAIT_OBJECT_ALARM_ACK ((T_PNAK_WAIT_OBJECT)0x00000008uL)
#define PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED ((T_PNAK_WAIT_OBJECT)0x00000010uL)
#define PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED \
((T_PNAK_WAIT_OBJECT)0x00000020uL)
#define PNAK_WAIT_OBJECT_PROVIDER_DATA_UPDATED \
((T_PNAK_WAIT_OBJECT)0x00000040uL)
#define PNAK_WAIT_OBJECT_CONSUMER_DATA_CHANGED \
((T_PNAK_WAIT_OBJECT)0x00000080uL)
#define PNAK_WAIT_OBJECT_SERVICE_IND ((T_PNAK_WAIT_OBJECT)0x00000100uL)
#define PNAK_WAIT_OBJECT_SERVICE_CON ((T_PNAK_WAIT_OBJECT)0x00000200uL)
#define PNAK_WAIT_OBJECT_SERVICE_REQ_RES_HANDLED \
((T_PNAK_WAIT_OBJECT)0x00000400uL)
#define PNAK_WAIT_OBJECT_PTCP ((T_PNAK_WAIT_OBJECT)0x00000800uL)
#define PNAK_WAIT_OBJECT_SOCKET_STATE_CHANGED ((T_PNAK_WAIT_OBJECT)0x00001000uL)
#define PNAK_WAIT_OBJECT_SOCKET_DATA_RECEIVED ((T_PNAK_WAIT_OBJECT)0x00002000uL)
#define PNAK_WAIT_OBJECT_MRPD ((T_PNAK_WAIT_OBJECT)0x00004000uL)
#define PNAK_WAIT_OBJECT_CHANNEL_CLOSED ((T_PNAK_WAIT_OBJECT)0x00200000uL)
#define PNAK_WAIT_OBJECT_INTERRUPTED ((T_PNAK_WAIT_OBJECT)0x00400000uL)
#define PNAK_USER_WAIT_OBJECT_1 ((T_PNAK_WAIT_OBJECT)0x00800000uL)
#define PNAK_USER_WAIT_OBJECT_2 ((T_PNAK_WAIT_OBJECT)0x01000000uL)
#define PNAK_USER_WAIT_OBJECT_3 ((T_PNAK_WAIT_OBJECT)0x02000000uL)
#define PNAK_USER_WAIT_OBJECT_4 ((T_PNAK_WAIT_OBJECT)0x04000000uL)
#define PNAK_USER_WAIT_OBJECT_5 ((T_PNAK_WAIT_OBJECT)0x08000000uL)
#define PNAK_USER_WAIT_OBJECT_6 ((T_PNAK_WAIT_OBJECT)0x10000000uL)
#define PNAK_USER_WAIT_OBJECT_7 ((T_PNAK_WAIT_OBJECT)0x20000000uL)
#define PNAK_USER_WAIT_OBJECT_8 ((T_PNAK_WAIT_OBJECT)0x40000000uL)
#define PNAK_WAIT_TIMEOUT ((T_PNAK_WAIT_OBJECT)0x80000000uL)
#define PNAK_WAIT_OBJECTS_SERVICE \
(PNAK_WAIT_OBJECT_SERVICE_CON | PNAK_WAIT_OBJECT_SERVICE_IND | \
PNAK_WAIT_OBJECT_SERVICE_REQ_RES_HANDLED)
#define PNAK_WAIT_OBJECTS_EVENT_IND \
(PNAK_WAIT_OBJECT_STATE_CHANGED | PNAK_WAIT_OBJECT_ALARM | \
PNAK_WAIT_OBJECT_ALARM_ACK | PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED | \
PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED | PNAK_WAIT_OBJECT_PTCP | \
PNAK_WAIT_OBJECT_MRPD)
#define PNAK_WAIT_OBJECTS_DATA_IND \
(PNAK_WAIT_OBJECT_PROVIDER_DATA_UPDATED | \
PNAK_WAIT_OBJECT_CONSUMER_DATA_CHANGED)
#define PNAK_WAIT_OBJECTS_SOCKET_IND \
(PNAK_WAIT_OBJECT_SOCKET_STATE_CHANGED | \
PNAK_WAIT_OBJECT_SOCKET_DATA_RECEIVED)
#define PNAK_WAIT_OBJECTS_OTHER \
(PNAK_WAIT_OBJECT_EXCEPTION | PNAK_WAIT_OBJECT_CHANNEL_CLOSED | \
PNAK_WAIT_OBJECT_INTERRUPTED)
#define PNAK_WAIT_OBJECTS_USER \
(PNAK_USER_WAIT_OBJECT_1 | PNAK_USER_WAIT_OBJECT_2 | \
PNAK_USER_WAIT_OBJECT_3 | PNAK_USER_WAIT_OBJECT_4 | \
PNAK_USER_WAIT_OBJECT_5 | PNAK_USER_WAIT_OBJECT_6 | \
PNAK_USER_WAIT_OBJECT_7 | PNAK_USER_WAIT_OBJECT_8)
#define PNAK_WAIT_OBJECTS_ALL \
(PNAK_WAIT_OBJECTS_OTHER | PNAK_WAIT_OBJECTS_EVENT_IND | \
PNAK_WAIT_OBJECTS_DATA_IND | PNAK_WAIT_OBJECTS_SERVICE | \
PNAK_WAIT_OBJECTS_SOCKET_IND | PNAK_WAIT_OBJECTS_USER | PNAK_WAIT_TIMEOUT)
/*---------------------------------------------------------------------------*/
......@@ -299,147 +301,145 @@ typedef PN_U32 T_PNAK_WAIT_OBJECT;
* the max number and add specific statemachines in the
* object data structure
*/
#define MAX_NUMBER_CMDEV_CONNECTIONS 4u
#define MAX_NUMBER_CMDEV_CONNECTIONS 4u
/*=============================================================================
SERVICE INTERFACE
=============================================================================*/
typedef unsigned char T_PNAK_SERVICE_PRIMITIVE;
typedef unsigned char T_PNAK_SERVICE_PRIMITIVE;
#define PNAK_SERVICE_REQ (T_PNAK_SERVICE_PRIMITIVE) 0x01u
#define PNAK_SERVICE_RES (T_PNAK_SERVICE_PRIMITIVE) 0x02u
#define PNAK_SERVICE_CON (T_PNAK_SERVICE_PRIMITIVE) 0x03u
#define PNAK_SERVICE_IND (T_PNAK_SERVICE_PRIMITIVE) 0x04u
#define PNAK_SERVICE_REQ (T_PNAK_SERVICE_PRIMITIVE)0x01u
#define PNAK_SERVICE_RES (T_PNAK_SERVICE_PRIMITIVE)0x02u
#define PNAK_SERVICE_CON (T_PNAK_SERVICE_PRIMITIVE)0x03u
#define PNAK_SERVICE_IND (T_PNAK_SERVICE_PRIMITIVE)0x04u
typedef unsigned char T_PNAK_SERVICE_RESULT;
typedef unsigned char T_PNAK_SERVICE_RESULT;
#define PNAK_RESULT_POS (T_PNAK_SERVICE_RESULT) 0x00u
#define PNAK_RESULT_NEG (T_PNAK_SERVICE_RESULT) 0x01u
#define PNAK_RESULT_POS (T_PNAK_SERVICE_RESULT)0x00u
#define PNAK_RESULT_NEG (T_PNAK_SERVICE_RESULT)0x01u
typedef struct _T_PNAK_SERVICE_DESCRIPTION
{
unsigned short DeviceRef;
unsigned short DeviceRef;
unsigned char Instance;
unsigned char Service;
unsigned char Instance;
unsigned char Service;
T_PNAK_SERVICE_PRIMITIVE Primitive;
T_PNAK_SERVICE_RESULT Result;
T_PNAK_SERVICE_PRIMITIVE Primitive;
T_PNAK_SERVICE_RESULT Result;
unsigned short ClientId;
unsigned short InvokeId;
unsigned short ClientId;
unsigned short InvokeId;
unsigned short DataLength;
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_DESCRIPTION);
unsigned short DataLength;
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_DESCRIPTION);
/*---------------------------------------------------------------------------*/
#define PNAK_MAX_NUMBER_REQ_SERVICES 52u
#define PNAK_MAX_NUMBER_CON_SERVICES 52u
#define PNAK_MAX_NUMBER_IND_SERVICES 52u
#define PNAK_MAX_NUMBER_REQ_SERVICES 52u
#define PNAK_MAX_NUMBER_CON_SERVICES 52u
#define PNAK_MAX_NUMBER_IND_SERVICES 52u
#ifndef PNAK_SERVICE_REQ_CHANNEL_SIZE
#define PNAK_SERVICE_REQ_CHANNEL_SIZE (PN_U16) 8086u
#define PNAK_SERVICE_REQ_CHANNEL_SIZE (PN_U16)8086u
#endif
#ifndef PNAK_SERVICE_CON_CHANNEL_SIZE
#define PNAK_SERVICE_CON_CHANNEL_SIZE (PN_U16) 8086u
#define PNAK_SERVICE_CON_CHANNEL_SIZE (PN_U16)8086u
#endif
#ifndef PNAK_SERVICE_IND_CHANNEL_SIZE
#define PNAK_SERVICE_IND_CHANNEL_SIZE (PN_U16) 8086u
#define PNAK_SERVICE_IND_CHANNEL_SIZE (PN_U16)8086u
#endif
/*=== SERVICE REQUEST/RESPONSE ==============================================*/
typedef struct _T_PNAK_SERVICE_REQ_RES_ENTRY
{
unsigned short ServiceOffset;
unsigned short ServiceOffset;
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_REQ_RES_ENTRY);
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_REQ_RES_ENTRY);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_SERVICE_REQ_RES
{
unsigned short NumberEntries;
unsigned short NumberEntries;
T_PNAK_SERVICE_REQ_RES_ENTRY ServiceEntry [PNAK_MAX_NUMBER_REQ_SERVICES];
unsigned char ServiceChannel [PNAK_SERVICE_REQ_CHANNEL_SIZE];
T_PNAK_SERVICE_REQ_RES_ENTRY ServiceEntry[PNAK_MAX_NUMBER_REQ_SERVICES];
unsigned char ServiceChannel[PNAK_SERVICE_REQ_CHANNEL_SIZE];
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_REQ_RES);
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_REQ_RES);
/*=== SERVICE CONFIRMATION ==================================================*/
typedef struct _T_PNAK_SERVICE_CON_ENTRY
{
unsigned short ServiceOffset;
unsigned short ServiceOffset;
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_CON_ENTRY);
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_CON_ENTRY);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_SERVICE_CON
{
unsigned short NumberEntries;
unsigned short NumberEntries;
T_PNAK_SERVICE_CON_ENTRY ServiceEntry [PNAK_MAX_NUMBER_CON_SERVICES];
unsigned char ServiceChannel [PNAK_SERVICE_CON_CHANNEL_SIZE];
T_PNAK_SERVICE_CON_ENTRY ServiceEntry[PNAK_MAX_NUMBER_CON_SERVICES];
unsigned char ServiceChannel[PNAK_SERVICE_CON_CHANNEL_SIZE];
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_CON);
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_CON);
/*=== SERVICE INDICATION ====================================================*/
typedef struct _T_PNAK_SERVICE_IND_ENTRY
{
unsigned short ServiceOffset;
unsigned short ServiceOffset;
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_IND_ENTRY);
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_IND_ENTRY);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_SERVICE_IND
{
unsigned short NumberEntries;
unsigned short NumberEntries;
T_PNAK_SERVICE_IND_ENTRY ServiceEntry [PNAK_MAX_NUMBER_IND_SERVICES];
unsigned char ServiceChannel [PNAK_SERVICE_IND_CHANNEL_SIZE];
T_PNAK_SERVICE_IND_ENTRY ServiceEntry[PNAK_MAX_NUMBER_IND_SERVICES];
unsigned char ServiceChannel[PNAK_SERVICE_IND_CHANNEL_SIZE];
} PACK_WORD_ALIGNMENT (T_PNAK_SERVICE_IND);
} PACK_WORD_ALIGNMENT(T_PNAK_SERVICE_IND);
/*=============================================================================
EVENT INTERFACE
=============================================================================*/
typedef unsigned short T_PNAK_MODE;
typedef unsigned short T_PNAK_MODE;
#define PNAK_MODE_OFFLINE (T_PNAK_MODE) 0u
#define PNAK_MODE_ONLINE (T_PNAK_MODE) 1u
#define PNAK_MODE_OFFLINE (T_PNAK_MODE)0u
#define PNAK_MODE_ONLINE (T_PNAK_MODE)1u
/*=== EVENT REQUEST ==========================================================*/
typedef struct _T_PNAK_EVENT_SET_MODE
{
T_PNAK_MODE Mode;
T_PNAK_MODE Mode;
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_SET_MODE);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_SET_MODE);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_EVENT_SET_DEVICE_STATE
{
T_BITSET_256 ActivateDeviceReference;
T_BITSET_256 DeactivateDeviceReference;
T_BITSET_256 ActivateDeviceReference;
T_BITSET_256 DeactivateDeviceReference;
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_SET_DEVICE_STATE);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_SET_DEVICE_STATE);
/*=== EVENT INDICATION ======================================================*/
typedef enum _T_PNAK_STATE
{
typedef enum _T_PNAK_STATE {
PNAK_STATE_OK = 0,
PNAK_STATE_NO_PARAMETER,
PNAK_STATE_DOUBLE_ADDRESS_ERROR,
......@@ -457,142 +457,139 @@ typedef enum _T_PNAK_STATE
typedef struct _T_PNAK_EVENT_STATE
{
T_PNAK_MODE Mode;
T_PNAK_STATE State;
T_PNAK_MODE Mode;
T_PNAK_STATE State;
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_STATE);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_STATE);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_EVENT_ALARM
{
T_BITSET_256 DeviceReference;
T_BITSET_256 DeviceReference;
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_ALARM);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_ALARM);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_EVENT_ALARM_ACK
{
T_BITSET_256 DeviceReference;
T_BITSET_256 DeviceReference;
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_ALARM_ACK);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_ALARM_ACK);
/*---------------------------------------------------------------------------*/
#define PNAK_DEVICE_STATE_DEACTIVATED 0x00u
#define PNAK_DEVICE_STATE_FIND_DEVICE 0x01u
#define PNAK_DEVICE_STATE_CONNECTION_ESTABLISHMENT 0x02u
#define PNAK_DEVICE_STATE_CONNECTED 0x04u
#define PNAK_DEVICE_STATE_CONNECT_ERROR 0x10u
#define PNAK_DEVICE_STATE_WRITE_ERROR 0x20u
#define PNAK_DEVICE_STATE_CONTROL_ERROR 0x40u
#define PNAK_DEVICE_STATE_CLOSE_PENDING 0x80u
#define PNAK_DEVICE_STATE_MASK (PNAK_DEVICE_STATE_DEACTIVATED | \
PNAK_DEVICE_STATE_FIND_DEVICE | \
PNAK_DEVICE_STATE_CONNECTION_ESTABLISHMENT | \
PNAK_DEVICE_STATE_CONNECTED)
#define PNAK_DEVICE_STATE_MASK_CONNECTING (PNAK_DEVICE_STATE_FIND_DEVICE | \
PNAK_DEVICE_STATE_CONNECTION_ESTABLISHMENT)
#define PNAK_DEVICE_STATE_ERROR_MASK (PNAK_DEVICE_STATE_CONNECT_ERROR | \
PNAK_DEVICE_STATE_WRITE_ERROR | \
PNAK_DEVICE_STATE_CONTROL_ERROR)
#define PNAK_DEVICE_STATE_DEACTIVATED 0x00u
#define PNAK_DEVICE_STATE_FIND_DEVICE 0x01u
#define PNAK_DEVICE_STATE_CONNECTION_ESTABLISHMENT 0x02u
#define PNAK_DEVICE_STATE_CONNECTED 0x04u
#define PNAK_DEVICE_STATE_CONNECT_ERROR 0x10u
#define PNAK_DEVICE_STATE_WRITE_ERROR 0x20u
#define PNAK_DEVICE_STATE_CONTROL_ERROR 0x40u
#define PNAK_DEVICE_STATE_CLOSE_PENDING 0x80u
#define PNAK_DEVICE_STATE_MASK \
(PNAK_DEVICE_STATE_DEACTIVATED | PNAK_DEVICE_STATE_FIND_DEVICE | \
PNAK_DEVICE_STATE_CONNECTION_ESTABLISHMENT | PNAK_DEVICE_STATE_CONNECTED)
#define PNAK_DEVICE_STATE_MASK_CONNECTING \
(PNAK_DEVICE_STATE_FIND_DEVICE | PNAK_DEVICE_STATE_CONNECTION_ESTABLISHMENT)
#define PNAK_DEVICE_STATE_ERROR_MASK \
(PNAK_DEVICE_STATE_CONNECT_ERROR | PNAK_DEVICE_STATE_WRITE_ERROR | \
PNAK_DEVICE_STATE_CONTROL_ERROR)
typedef struct _T_PNAK_EVENT_DEVICE_STATE
{
unsigned char State [MAX_NUMBER_SUPPORTED_DEVICES];
unsigned char State[MAX_NUMBER_SUPPORTED_DEVICES];
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_DEVICE_STATE);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_DEVICE_STATE);
/*---------------------------------------------------------------------------*/
#define PNAK_PTCP_IN_SNYC 0x00000001uL
#define PNAK_PTCP_NO_SYNC_MESSAGE 0x00000002uL
#define PNAK_PTCP_JITTER_OUT_OF_BOUNDARY 0x00000004uL
#define PNAK_PTCP_IN_SNYC 0x00000001uL
#define PNAK_PTCP_NO_SYNC_MESSAGE 0x00000002uL
#define PNAK_PTCP_JITTER_OUT_OF_BOUNDARY 0x00000004uL
/*---------------------------------------------------------------------------*/
#define PNAK_MRPD_MISSING_APPEARS 0x8000u
#define PNAK_MRPD_MISSING_DISAPPEARS 0x0000u
#define PNAK_MRPD_MISSING_APPEARS 0x8000u
#define PNAK_MRPD_MISSING_DISAPPEARS 0x0000u
typedef struct _T_PNAK_EVENT_MRPD_IOCR
{
PN_U16 FrameId [PN_SERVICE_DOWNLOAD_MAX_NUMBER_IOCRS];
PN_U16 FrameId[PN_SERVICE_DOWNLOAD_MAX_NUMBER_IOCRS];
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_MRPD_IOCR);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_MRPD_IOCR);
typedef struct _T_PNAK_EVENT_MRPD
{
T_PNAK_EVENT_MRPD_IOCR AR [MAX_NUMBER_CMDEV_CONNECTIONS];
T_PNAK_EVENT_MRPD_IOCR AR[MAX_NUMBER_CMDEV_CONNECTIONS];
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_MRPD);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_MRPD);
/*=== EVENT INDICATION MASK =================================================*/
#define PNAK_EVENT_STATE_CHANGED 0x00000001uL
#define PNAK_EVENT_DEVICE_STATE_CHANGED 0x00000002uL
#define PNAK_EVENT_ALARM 0x00000004uL
#define PNAK_EVENT_ALARM_ACK 0x00000008uL
#define PNAK_EVENT_ETHERNET_STATE_CHANGED 0x00000010uL
#define PNAK_EVENT_PTCP 0x00000020uL
#define PNAK_EVENT_MRPD 0x00000040uL
#define PNAK_EVENT_MASK (PNAK_EVENT_STATE_CHANGED | \
PNAK_EVENT_DEVICE_STATE_CHANGED | \
PNAK_EVENT_ALARM | \
PNAK_EVENT_ALARM_ACK | \
PNAK_EVENT_ETHERNET_STATE_CHANGED | \
PNAK_EVENT_PTCP | \
PNAK_EVENT_MRPD)
typedef PN_U32 T_PNAK_EVENT_REG;
#define PNAK_EVENT_STATE_CHANGED 0x00000001uL
#define PNAK_EVENT_DEVICE_STATE_CHANGED 0x00000002uL
#define PNAK_EVENT_ALARM 0x00000004uL
#define PNAK_EVENT_ALARM_ACK 0x00000008uL
#define PNAK_EVENT_ETHERNET_STATE_CHANGED 0x00000010uL
#define PNAK_EVENT_PTCP 0x00000020uL
#define PNAK_EVENT_MRPD 0x00000040uL
#define PNAK_EVENT_MASK \
(PNAK_EVENT_STATE_CHANGED | PNAK_EVENT_DEVICE_STATE_CHANGED | \
PNAK_EVENT_ALARM | PNAK_EVENT_ALARM_ACK | \
PNAK_EVENT_ETHERNET_STATE_CHANGED | PNAK_EVENT_PTCP | PNAK_EVENT_MRPD)
typedef PN_U32 T_PNAK_EVENT_REG;
typedef struct _T_PNAK_EVENT_IND_MASK
{
T_PNAK_EVENT_REG EventMaskReg;
T_PNAK_EVENT_REG EventMaskReg;
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_IND_MASK);
} PACK_WORD_ALIGNMENT(T_PNAK_EVENT_IND_MASK);
/*=============================================================================
STATISTIC INTERFACE
=============================================================================*/
/* Attention: keep in sync with data provided by stack, see controller/device context management */
#define PNAK_CMCTL_VENDOR_ID_MISMATCH 0x00000001uL
#define PNAK_CMCTL_DEVICE_ID_MISMATCH 0x00000002uL
#define PNAK_CMCTL_DUPLICATE_NAME 0x00000004uL
#define PNAK_CMCTL_DUPLICATE_IP_ADDRESS 0x00000008uL
#define PNAK_CMCTL_NO_EMPTY_NAME 0x00000010uL
#define PNAK_CMCTL_RPC_RESPONSE_MISSING 0x00000020uL
#define PNAK_CMCTL_MODULE_MISMATCH 0x00000040uL
/* Attention: keep in sync with data provided by stack, see controller/device
* context management */
#define PNAK_CMCTL_VENDOR_ID_MISMATCH 0x00000001uL
#define PNAK_CMCTL_DEVICE_ID_MISMATCH 0x00000002uL
#define PNAK_CMCTL_DUPLICATE_NAME 0x00000004uL
#define PNAK_CMCTL_DUPLICATE_IP_ADDRESS 0x00000008uL
#define PNAK_CMCTL_NO_EMPTY_NAME 0x00000010uL
#define PNAK_CMCTL_RPC_RESPONSE_MISSING 0x00000020uL
#define PNAK_CMCTL_MODULE_MISMATCH 0x00000040uL
#define PNIO_STATUS_CODING_RPC 0x00000001uL
#define PNIO_STATUS_CODING_NDR 0x00000002uL
#define PNIO_STATUS_CODING_PROFINET 0x00000003uL
#define PNIO_STATUS_CODING_RPC 0x00000001uL
#define PNIO_STATUS_CODING_NDR 0x00000002uL
#define PNIO_STATUS_CODING_PROFINET 0x00000003uL
#define PNIO_STATUS_ENCODING_BIG_ENDIAN 0x00u
#define PNIO_STATUS_ENCODING_LITTLE_ENDIAN 0x10u
#define PNIO_STATUS_ENCODING_MASK 0xF0u
#define PNIO_STATUS_ENCODING_BIG_ENDIAN 0x00u
#define PNIO_STATUS_ENCODING_LITTLE_ENDIAN 0x10u
#define PNIO_STATUS_ENCODING_MASK 0xF0u
typedef struct _T_PNAK_CONNECTION_STATISTIC
{
PN_U32 Coding;
PN_U32 Coding;
PN_U8 Encoding;
PN_U8 Reserved [3];
PN_U8 Encoding;
PN_U8 Reserved[3];
T_PROFINET_STATUS PNIOStatus;
T_PROFINET_STATUS PNIOStatus;
} T_PNAK_CONNECTION_STATISTIC;
typedef struct _T_PNAK_CMCTL_STATISTIC
{
PN_U32 NumberDevicesInStartup;
PN_U32 NumberDevicesConnected;
PN_U32 NumberDevicesInStartup;
PN_U32 NumberDevicesConnected;
T_PN_MAC_ADDRESS MacAddress [MAX_NUMBER_SUPPORTED_DEVICES];
T_PN_MAC_ADDRESS MacAddress[MAX_NUMBER_SUPPORTED_DEVICES];
T_PNAK_CONNECTION_STATISTIC Cmctl [MAX_NUMBER_SUPPORTED_DEVICES];
PN_U32 Status [MAX_NUMBER_SUPPORTED_DEVICES];
T_PNAK_CONNECTION_STATISTIC Cmctl[MAX_NUMBER_SUPPORTED_DEVICES];
PN_U32 Status[MAX_NUMBER_SUPPORTED_DEVICES];
} T_PNAK_CMCTL_STATISTIC;
......@@ -600,7 +597,7 @@ typedef struct _T_PNAK_CMCTL_STATISTIC
typedef struct _T_PNAK_CMDEV_STATISTIC
{
T_PNAK_CONNECTION_STATISTIC Cmdev [MAX_NUMBER_CMDEV_CONNECTIONS];
T_PNAK_CONNECTION_STATISTIC Cmdev[MAX_NUMBER_CMDEV_CONNECTIONS];
} T_PNAK_CMDEV_STATISTIC;
......@@ -612,141 +609,177 @@ DATA INTERFACE
typedef struct _T_PNAK_DATA_CONSUMER_DATA_CHANGED
{
T_BITSET_256 DeviceReference;
T_BITSET_256 DeviceReference;
} PACK_WORD_ALIGNMENT (T_PNAK_DATA_CONSUMER_DATA_CHANGED);
} PACK_WORD_ALIGNMENT(T_PNAK_DATA_CONSUMER_DATA_CHANGED);
/*---------------------------------------------------------------------------*/
typedef struct _T_PNAK_DATA_PROVIDER_DATA_UPDATED
{
T_BITSET_256 DeviceReference;
T_BITSET_256 DeviceReference;
} PACK_WORD_ALIGNMENT (T_PNAK_DATA_PROVIDER_DATA_UPDATED);
} PACK_WORD_ALIGNMENT(T_PNAK_DATA_PROVIDER_DATA_UPDATED);
/*=== DATA INDICATION MASK ==================================================*/
#define PNAK_DATA_EVENT_CYCLIC_TRANSFER_FINISHED 0x00000001uL
#define PNAK_DATA_EVENT_CONSUMER_DATA_CHANGED 0x00000002uL
#define PNAK_DATA_EVENT_PROVIDER_DATA_UPDATED 0x00000004uL
#define PNAK_DATA_EVENT_CYCLIC_TRANSFER_FINISHED 0x00000001uL
#define PNAK_DATA_EVENT_CONSUMER_DATA_CHANGED 0x00000002uL
#define PNAK_DATA_EVENT_PROVIDER_DATA_UPDATED 0x00000004uL
typedef PN_U32 T_PNAK_DATA_EVENT_REG;
typedef PN_U32 T_PNAK_DATA_EVENT_REG;
typedef struct _T_PNAK_DATA_IND_MASK
{
T_PNAK_DATA_EVENT_REG EventMaskReg;
T_PNAK_DATA_EVENT_REG EventMaskReg;
} PACK_WORD_ALIGNMENT (T_PNAK_DATA_IND_MASK);
} PACK_WORD_ALIGNMENT(T_PNAK_DATA_IND_MASK);
/*---------------------------------------------------------------------------*/
#define PNAK_IOXS_STATUS_NO_EXTENTION_FOLLOWS 0x00u
#define PNAK_IOXS_STATUS_DETECTED_BY_SUBSLOT 0x00u
#define PNAK_IOXS_STATUS_DETECTED_BY_SLOT 0x20u
#define PNAK_IOXS_STATUS_DETECTED_BY_DEVICE 0x40u
#define PNAK_IOXS_STATUS_DETECTED_BY_CONTROLLER 0x60u
#define PNAK_IOXS_STATUS_DATA_BAD 0x00u
#define PNAK_IOXS_STATUS_DATA_GOOD 0x80u
#define PNAK_IOXS_STATUS_NO_EXTENTION_FOLLOWS 0x00u
#define PNAK_IOXS_STATUS_DETECTED_BY_SUBSLOT 0x00u
#define PNAK_IOXS_STATUS_DETECTED_BY_SLOT 0x20u
#define PNAK_IOXS_STATUS_DETECTED_BY_DEVICE 0x40u
#define PNAK_IOXS_STATUS_DETECTED_BY_CONTROLLER 0x60u
#define PNAK_IOXS_STATUS_DATA_BAD 0x00u
#define PNAK_IOXS_STATUS_DATA_GOOD 0x80u
/******************************************************************************
FUNCTION DECLARATION
******************************************************************************/
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#ifndef __DOXYGEN__
/*--- initialization/termination functions ----------------------------------*/
extern void pnak_init (void);
extern void pnak_term (void);
extern void pnak_init(void);
extern void pnak_term(void);
#define pnak_start_profistack pnak_start_stack
#define pnak_stop_profistack pnak_stop_stack
#define pnak_start_profistack pnak_start_stack
#define pnak_stop_profistack pnak_stop_stack
extern T_PNAK_RESULT pnak_start_stack (unsigned short, const T_PNAK_MODE_ID);
extern T_PNAK_RESULT pnak_stop_stack (unsigned short);
extern T_PNAK_RESULT pnak_start_stack(unsigned short, const T_PNAK_MODE_ID);
extern T_PNAK_RESULT pnak_stop_stack(unsigned short);
/*--- General interface functions -------------------------------------------*/
extern T_PNAK_RESULT pnak_wait_for_multiple_objects (unsigned short, T_PNAK_WAIT_OBJECT*, T_PNAK_TIMEOUT);
extern T_PNAK_RESULT pnak_set_multiple_objects (unsigned short, const T_PNAK_WAIT_OBJECT);
extern T_PNAK_RESULT pnak_mask_multiple_objects (unsigned short, const T_PNAK_WAIT_OBJECT);
extern T_PNAK_RESULT pnak_wait_for_multiple_objects(unsigned short,
T_PNAK_WAIT_OBJECT*,
T_PNAK_TIMEOUT);
extern T_PNAK_RESULT pnak_set_multiple_objects(unsigned short,
const T_PNAK_WAIT_OBJECT);
extern T_PNAK_RESULT pnak_mask_multiple_objects(unsigned short,
const T_PNAK_WAIT_OBJECT);
extern T_PNAK_RESULT pnak_get_exception (unsigned short, T_PNAK_EXCEPTION*);
extern T_PNAK_RESULT pnak_get_version (unsigned short, T_PNAK_VERSIONS*);
extern T_PNAK_RESULT pnak_get_exception(unsigned short, T_PNAK_EXCEPTION*);
extern T_PNAK_RESULT pnak_get_version(unsigned short, T_PNAK_VERSIONS*);
extern T_PNAK_RESULT pnak_snmp_get_data (unsigned short, T_PNAK_OID*, void*, PN_U32*, PN_U32*, unsigned char, PN_BOOL);
extern T_PNAK_RESULT pnak_snmp_check_data (unsigned short, T_PNAK_OID*, void*, PN_U32, PN_U32, unsigned char);
extern T_PNAK_RESULT pnak_snmp_set_data (unsigned short, T_PNAK_OID*, void*, PN_U32, PN_U32);
extern T_PNAK_RESULT pnak_snmp_get_data(unsigned short, T_PNAK_OID*, void*,
PN_U32*, PN_U32*, unsigned char,
PN_BOOL);
extern T_PNAK_RESULT pnak_snmp_check_data(unsigned short, T_PNAK_OID*, void*,
PN_U32, PN_U32, unsigned char);
extern T_PNAK_RESULT pnak_snmp_set_data(unsigned short, T_PNAK_OID*, void*,
PN_U32, PN_U32);
extern T_PNAK_RESULT pnak_retrigger_watchdog (unsigned short, PN_U32);
extern T_PNAK_RESULT pnak_retrigger_watchdog(unsigned short, PN_U32);
/*--- Service interface functions -------------------------------------------*/
extern T_PNAK_RESULT pnak_limit_number_parallel_services (unsigned short, unsigned short, unsigned short);
extern T_PNAK_RESULT pnak_limit_number_parallel_services(unsigned short,
unsigned short,
unsigned short);
extern T_PNAK_RESULT pnak_send_service_req_res (unsigned short, const T_PNAK_SERVICE_REQ_RES*);
extern T_PNAK_RESULT pnak_get_service_ind (unsigned short, T_PNAK_SERVICE_IND*);
extern T_PNAK_RESULT pnak_get_service_con (unsigned short, T_PNAK_SERVICE_CON*);
extern T_PNAK_RESULT pnak_send_service_req_res(unsigned short,
const T_PNAK_SERVICE_REQ_RES*);
extern T_PNAK_RESULT pnak_get_service_ind(unsigned short, T_PNAK_SERVICE_IND*);
extern T_PNAK_RESULT pnak_get_service_con(unsigned short, T_PNAK_SERVICE_CON*);
/*--- Event interface functions ---------------------------------------------*/
extern T_PNAK_RESULT pnak_set_mode (unsigned short, const T_PNAK_EVENT_SET_MODE*);
extern T_PNAK_RESULT pnak_set_device_state (unsigned short, const T_PNAK_EVENT_SET_DEVICE_STATE*);
extern T_PNAK_RESULT pnak_set_mode(unsigned short,
const T_PNAK_EVENT_SET_MODE*);
extern T_PNAK_RESULT
pnak_set_device_state(unsigned short, const T_PNAK_EVENT_SET_DEVICE_STATE*);
extern T_PNAK_RESULT pnak_get_state (unsigned short, T_PNAK_EVENT_STATE*);
extern T_PNAK_RESULT pnak_get_device_state_ind (unsigned short, T_PNAK_EVENT_DEVICE_STATE*);
extern T_PNAK_RESULT pnak_get_alarm_ind (unsigned short, T_PNAK_EVENT_ALARM*);
extern T_PNAK_RESULT pnak_get_alarm_ack_ind (unsigned short, T_PNAK_EVENT_ALARM_ACK*);
extern T_PNAK_RESULT pnak_get_ptcp_ind (unsigned short, PN_U32*);
extern T_PNAK_RESULT pnak_get_mrpd_ind (unsigned short, T_PNAK_EVENT_MRPD*);
extern T_PNAK_RESULT pnak_get_state(unsigned short, T_PNAK_EVENT_STATE*);
extern T_PNAK_RESULT pnak_get_device_state_ind(unsigned short,
T_PNAK_EVENT_DEVICE_STATE*);
extern T_PNAK_RESULT pnak_get_alarm_ind(unsigned short, T_PNAK_EVENT_ALARM*);
extern T_PNAK_RESULT pnak_get_alarm_ack_ind(unsigned short,
T_PNAK_EVENT_ALARM_ACK*);
extern T_PNAK_RESULT pnak_get_ptcp_ind(unsigned short, PN_U32*);
extern T_PNAK_RESULT pnak_get_mrpd_ind(unsigned short, T_PNAK_EVENT_MRPD*);
/*--- Data interface functions ----------------------------------------------*/
extern T_PNAK_RESULT pnak_set_iocr_data (unsigned short, unsigned short, const unsigned char*, unsigned short, unsigned char);
extern T_PNAK_RESULT pnak_set_iocr_data(unsigned short, unsigned short,
const unsigned char*, unsigned short,
unsigned char);
extern T_PNAK_RESULT pnak_get_iocr_data (unsigned short, unsigned short, unsigned char*, unsigned short*, unsigned char*, unsigned char*);
extern T_PNAK_RESULT pnak_get_consumer_data_changed_ind (unsigned short, T_PNAK_DATA_CONSUMER_DATA_CHANGED*);
extern T_PNAK_RESULT pnak_get_provider_data_updated (unsigned short, T_PNAK_DATA_PROVIDER_DATA_UPDATED*);
extern T_PNAK_RESULT pnak_get_iocr_data(unsigned short, unsigned short,
unsigned char*, unsigned short*,
unsigned char*, unsigned char*);
extern T_PNAK_RESULT
pnak_get_consumer_data_changed_ind(unsigned short,
T_PNAK_DATA_CONSUMER_DATA_CHANGED*);
extern T_PNAK_RESULT
pnak_get_provider_data_updated(unsigned short,
T_PNAK_DATA_PROVIDER_DATA_UPDATED*);
/*=============================================================================
CALLBACK INTERFACE
=============================================================================*/
typedef int (*T_PNAK_WAIT_OBJECT_CALLBACK) (unsigned short, T_PNAK_WAIT_OBJECT);
typedef int (*T_PNAK_HW_START_CALLBACK) (unsigned short, T_PNAK_MODE_ID, void*);
typedef int (*T_PNAK_WAIT_OBJECT_CALLBACK)(unsigned short, T_PNAK_WAIT_OBJECT);
typedef int (*T_PNAK_HW_START_CALLBACK)(unsigned short, T_PNAK_MODE_ID, void*);
typedef void (*T_PROVIDER_CALLBACK) (unsigned short, unsigned short, unsigned char*, unsigned short, unsigned char*);
typedef void (*T_CONSUMER_CALLBACK) (unsigned short, unsigned short, const unsigned char*, unsigned short, unsigned char, unsigned char);
typedef void (*T_PROVIDER_CALLBACK)(unsigned short, unsigned short,
unsigned char*, unsigned short,
unsigned char*);
typedef void (*T_CONSUMER_CALLBACK)(unsigned short, unsigned short,
const unsigned char*, unsigned short,
unsigned char, unsigned char);
extern T_PNAK_RESULT pnak_register_provider_callback (unsigned short, T_PROVIDER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_provider_callback (unsigned short);
extern T_PNAK_RESULT pnak_register_provider_callback(unsigned short,
T_PROVIDER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_provider_callback(unsigned short);
extern T_PNAK_RESULT pnak_register_consumer_callback (unsigned short, T_CONSUMER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_consumer_callback (unsigned short);
extern T_PNAK_RESULT pnak_register_consumer_callback(unsigned short,
T_CONSUMER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_consumer_callback(unsigned short);
extern T_PNAK_RESULT pnak_register_ethernet_provider_hook (unsigned short, T_PROVIDER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_ethernet_provider_hook (unsigned short);
extern T_PNAK_RESULT pnak_register_ethernet_provider_hook(unsigned short,
T_PROVIDER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_ethernet_provider_hook(unsigned short);
/*---------------------------------------------------------------------------*/
typedef void (*T_PNAK_CMCTL_STATISTIC_CALLBACK) (unsigned short, T_PNAK_CMCTL_STATISTIC*);
typedef void (*T_PNAK_CMCTL_STATISTIC_CALLBACK)(unsigned short,
T_PNAK_CMCTL_STATISTIC*);
extern T_PNAK_RESULT pnak_register_cmctl_statistic_callback (unsigned short, T_PNAK_CMCTL_STATISTIC_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_cmctl_statistic_callback (unsigned short);
extern T_PNAK_RESULT
pnak_register_cmctl_statistic_callback(unsigned short,
T_PNAK_CMCTL_STATISTIC_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_cmctl_statistic_callback(unsigned short);
typedef void (*T_PNAK_CMDEV_STATISTIC_CALLBACK) (unsigned short, T_PNAK_CMDEV_STATISTIC*);
typedef void (*T_PNAK_CMDEV_STATISTIC_CALLBACK)(unsigned short,
T_PNAK_CMDEV_STATISTIC*);
extern T_PNAK_RESULT pnak_register_cmdev_statistic_callback (unsigned short, T_PNAK_CMDEV_STATISTIC_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_cmdev_statistic_callback (unsigned short);
extern T_PNAK_RESULT
pnak_register_cmdev_statistic_callback(unsigned short,
T_PNAK_CMDEV_STATISTIC_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_cmdev_statistic_callback(unsigned short);
#endif /* __DOXYGEN__ */
#ifdef __cplusplus
}
}
#endif
/* the scai/sdai socket functions are derived from the basic implementation of
......@@ -754,7 +787,7 @@ extern T_PNAK_RESULT pnak_unregister_cmdev_statistic_callback (unsigned shor
* so we have to disable the original definitions
*/
#if !defined (SCAI_INCLUDE_SOCKET) && !defined(SDAI_INCLUDE_SOCKET)
#if !defined(SCAI_INCLUDE_SOCKET) && !defined(SDAI_INCLUDE_SOCKET)
/******************************************************************************
SOCKET USER INTERFACE
......@@ -764,9 +797,10 @@ SOCKET USER INTERFACE
* @socketmainpage
*
* @section Introduction
* In addition to the realtime ethernet communication via the PROFINET Application Interface (PNAK)
* Softing offers a universal Socket Interface for implementation of any TCP or UDP based protocol. It
* enables the integration of various industrial IT functions into the device:
* In addition to the realtime ethernet communication via the PROFINET
* Application Interface (PNAK) Softing offers a universal Socket Interface for
* implementation of any TCP or UDP based protocol. It enables the integration
* of various industrial IT functions into the device:
*
* - Embedded Webserver for freely designed websites
* - FTP-Server for updating the device firmware or for file downloads
......@@ -774,24 +808,31 @@ SOCKET USER INTERFACE
* - Telnet for virtual terminal connections
* - Implementation of manufacturer specific application protocols
*
* The Socket Interface offers a comfortable application interface which disburdens the user from a lot of
* tasks and provides a lot of automatisms. The special characteristics of each TCP/IP stack will be hidden
* from the user. Establishment and management of TCP connections are handled completely by the socket interface.
* The user can focus on the implementation of the desired IT functionality. This allows an easy implementation
* of the socket application. The resources needed by the socket interface (see also \ref SocketResources) can be
* easily adpated to the available memory provided by the used the hardware platform.
* The Socket Interface offers a comfortable application interface which
* disburdens the user from a lot of tasks and provides a lot of automatisms.
* The special characteristics of each TCP/IP stack will be hidden from the
* user. Establishment and management of TCP connections are handled completely
* by the socket interface. The user can focus on the implementation of the
* desired IT functionality. This allows an easy implementation of the socket
* application. The resources needed by the socket interface (see also \ref
* SocketResources) can be easily adpated to the available memory provided by
* the used the hardware platform.
*
* The communication via the Socket Interface can be used in parallel and without influencing the realtime
* communication via the used realtime ethernet protocol. Therefore the realtime ethernet communication
* will be processed with a higher priority than the communication via the Socket Interface. The network interface
* is shared between the Socket Interface and the realtime ethernet protocol. Thus a high communication load
* to be processed by the realtime ethernet protocol limits the available bandwith and the performance of the
* Socket Interface communication.
* The communication via the Socket Interface can be used in parallel and
* without influencing the realtime communication via the used realtime ethernet
* protocol. Therefore the realtime ethernet communication will be processed
* with a higher priority than the communication via the Socket Interface. The
* network interface is shared between the Socket Interface and the realtime
* ethernet protocol. Thus a high communication load to be processed by the
* realtime ethernet protocol limits the available bandwith and the performance
* of the Socket Interface communication.
*
* @section Application Interface Description
* The following figure shows the structure of Softings Socket Interface implementation.
* The following figure shows the structure of Softings Socket Interface
* implementation.
* @image html Socket_Structure.png
* A detailed description of the Socket Application Interface can be found in the following chapters:
* A detailed description of the Socket Application Interface can be found in
* the following chapters:
* - \ref sock_defines
* - \ref sock_structures
* - \ref sock_functions
......@@ -816,7 +857,7 @@ SOCKET USER INTERFACE
* @{
*/
#define MAX_NUMBER_SUPPORTED_SOCKETS (PN_U16) 64u
#define MAX_NUMBER_SUPPORTED_SOCKETS (PN_U16)64u
/*--- Socket options --------------------------------------------------------*/
......@@ -825,12 +866,22 @@ SOCKET USER INTERFACE
* @{
*/
#define SOCK_FLAG_TYPE_UDP 0x00000000uL /**< Socket type TCP */
#define SOCK_FLAG_TYPE_TCP 0x00008000uL /**< Socket type UDP */
#define SOCK_FLAG_ENABLE_KEEPALIVE (SOCK_FLAG_TYPE_TCP | 0x00000001uL) /**< Enables keep-alive packets to supervise a TCP connection */
#define SOCK_FLAG_ENABLE_BROADCAST (SOCK_FLAG_TYPE_UDP | 0x00000002uL) /**< Enables the transmission of broadcast messages over a UDP socket */
#define SOCK_FLAG_ENABLE_MULTICAST (SOCK_FLAG_TYPE_UDP | 0x00000004uL) /**< Enables the transmission of multicast messages over a UDP socket */
#define SOCK_FLAG_USER_MASK 0x0000FFFFuL /**< Specifies the bits wich are valid for the socket application */
#define SOCK_FLAG_TYPE_UDP 0x00000000uL /**< Socket type TCP */
#define SOCK_FLAG_TYPE_TCP 0x00008000uL /**< Socket type UDP */
#define SOCK_FLAG_ENABLE_KEEPALIVE \
(SOCK_FLAG_TYPE_TCP | 0x00000001uL) /**< Enables keep-alive packets to \
supervise a TCP connection */
#define SOCK_FLAG_ENABLE_BROADCAST \
(SOCK_FLAG_TYPE_UDP | \
0x00000002uL) /**< Enables the transmission of broadcast messages over \
a UDP socket */
#define SOCK_FLAG_ENABLE_MULTICAST \
(SOCK_FLAG_TYPE_UDP | \
0x00000004uL) /**< Enables the transmission of multicast messages over \
a UDP socket */
#define SOCK_FLAG_USER_MASK \
0x0000FFFFuL /**< Specifies the bits wich are valid for the socket \
application */
/** @} */
......@@ -841,39 +892,68 @@ SOCKET USER INTERFACE
* @{
*/
typedef enum _T_SOCKET_RESULT
{
SOCK_SUCCESS = 0u, /**< General success return value */
SOCK_ERR_INVALID_ARGUMENT, /**< Passed argument is invalid */
SOCK_ERR_API_ALREADY_INITIALIZED, /**< Socket Interface already initialized */
SOCK_ERR_API_NOT_INITIALIZED, /**< Socket Interface not initialized */
SOCK_ERR_INVALID_SOCKET_ID, /**< The passed socket ID is invalid */
SOCK_ERR_OUT_OF_SOCKETS, /**< No free socket available */
SOCK_ERR_SOCKET_NOT_CREATED, /**< The specified socket has not been created. */
SOCK_ERR_SOCKET_OFFLINE, /**< The local port associated with the socket is not open. Sending/Receiving of messages is not possible. */
SOCK_ERR_SOCKET_BUSY, /**< A send request is rejected because a previous send request on the specified socket is not completed */
SOCK_ERR_SOCKET_NOT_CONNECTED, /**< The request is rejected because the specified TCP connection or no TCP connection has been established for the specified socket. */
SOCK_ERR_SOCKET_CONNECTED, /**< The request is rejected because the specified TCP connection has established a connection before the filter was activated. */
SOCK_ERR_ADDR_IN_USE, /**< The passed local address is already in use by another socket. */
SOCK_ERR_INVALID_LOCAL_ADDR, /**< The passed local IP address is invalid. It is not possible to bind the socket to this address. Which IP addresses are allowed depends
on the socket configuration (e.g. socket type UDP or TCP) and the network settings adjusted by calling the function sock_init(). */
SOCK_ERR_INVALID_REMOTE_ADDR, /**< The passed remote IP address is invalid. It is not possible to send or connect to this address. Which IP addresses are allowed depends
on the socket configuration (e.g. socket type UDP or TCP) and the network settings adjusted by calling the function sock_init(). */
SOCK_ERR_NO_DATA_RECEIVED, /**< No data has been received on the specfied socket or TCP connection. */
SOCK_ERR_NOT_SUPPORTED, /**< The requested action is not supported on the specified socket. */
SOCK_ERR_TEMPORARY_NOT_EXECUTABLE, /**< The requested action is temporary not executable on the specified socket due a concurrent pending request. */
SOCK_ERR_FATAL_ERROR, /**< A fatal error is reported during execution of function. */
SOCK_ERR_LIBRARY_NOT_LOADED /**< Can not load socket library */
typedef enum _T_SOCKET_RESULT {
SOCK_SUCCESS = 0u, /**< General success return value */
SOCK_ERR_INVALID_ARGUMENT, /**< Passed argument is invalid */
SOCK_ERR_API_ALREADY_INITIALIZED, /**< Socket Interface already initialized */
SOCK_ERR_API_NOT_INITIALIZED, /**< Socket Interface not initialized */
SOCK_ERR_INVALID_SOCKET_ID, /**< The passed socket ID is invalid */
SOCK_ERR_OUT_OF_SOCKETS, /**< No free socket available */
SOCK_ERR_SOCKET_NOT_CREATED, /**< The specified socket has not been created.
*/
SOCK_ERR_SOCKET_OFFLINE, /**< The local port associated with the socket is not
open. Sending/Receiving of messages is not
possible. */
SOCK_ERR_SOCKET_BUSY, /**< A send request is rejected because a previous send
request on the specified socket is not completed */
SOCK_ERR_SOCKET_NOT_CONNECTED, /**< The request is rejected because the
specified TCP connection or no TCP
connection has been established for the
specified socket. */
SOCK_ERR_SOCKET_CONNECTED, /**< The request is rejected because the specified
TCP connection has established a connection
before the filter was activated. */
SOCK_ERR_ADDR_IN_USE, /**< The passed local address is already in use by
another socket. */
SOCK_ERR_INVALID_LOCAL_ADDR, /**< The passed local IP address is invalid. It
is not possible to bind the socket to this
address. Which IP addresses are allowed
depends on the socket configuration (e.g.
socket type UDP or TCP) and the network
settings adjusted by calling the function
sock_init(). */
SOCK_ERR_INVALID_REMOTE_ADDR, /**< The passed remote IP address is invalid. It
is not possible to send or connect to this
address. Which IP addresses are allowed
depends on the socket configuration (e.g.
socket type UDP or TCP) and the network
settings adjusted by calling the function
sock_init(). */
SOCK_ERR_NO_DATA_RECEIVED, /**< No data has been received on the specfied
socket or TCP connection. */
SOCK_ERR_NOT_SUPPORTED, /**< The requested action is not supported on the
specified socket. */
SOCK_ERR_TEMPORARY_NOT_EXECUTABLE, /**< The requested action is temporary not
executable on the specified socket due a
concurrent pending request. */
SOCK_ERR_FATAL_ERROR, /**< A fatal error is reported during execution of
function. */
SOCK_ERR_LIBRARY_NOT_LOADED /**< Can not load socket library */
} T_SOCKET_RESULT;
/** @} */
/*---------------------------------------------------------------------------*/
#define SOCK_IP_ADDR_ANY 0x00000000uL /**< Can be used as local IP address when creating a socket to bind the socket to all the IP addresses (If the system has
multiple IP addresses) or if the local IP address is unknown. */
#define SOCK_PORT_ANY 0u /**< Can be used as local port when creating a TCP Client socket to let the TCP/IP stack select a unique local port from the
dynamic client port range. */
#define SOCK_IP_ADDR_ANY \
0x00000000uL /**< Can be used as local IP address when creating a socket to \
bind the socket to all the IP addresses (If the system has \
multiple IP addresses) or if the local IP address is \
unknown. */
#define SOCK_PORT_ANY \
0u /**< Can be used as local port when creating a TCP Client socket to let \
the TCP/IP stack select a unique local port from the dynamic client \
port range. */
/** @} */
/*===========================================================================*/
......@@ -881,18 +961,19 @@ typedef enum _T_SOCKET_RESULT
/** \addtogroup sock_structures Data Structures
* @{
* \brief Specifies a transport IP address and port.
* All of the structure data must be specified in network-byte-order (big-endian).
* All of the structure data must be specified in network-byte-order
* (big-endian).
*/
typedef struct _T_PNAK_SOCK_ADDR
{
PN_U32 IpAddress; /**< IP address */
PN_U32 IpAddress; /**< IP address */
unsigned short Port; /**< port number */
unsigned short Port; /**< port number */
unsigned char Alignment [2];
unsigned char Alignment[2];
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_ADDR);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_ADDR);
/** @} */
......@@ -904,12 +985,19 @@ typedef struct _T_PNAK_SOCK_ADDR
*/
typedef struct _T_PNAK_SOCK_CONFIG_OPTIONS
{
PN_U32 Timeout; /**< Keep-Alive Timeout in milliseconds. The Keep-Alive Timeout will be used for the supervision of TCP connections. The connection will be aborted if the
remote connection partner did not show activity within this timeout. The supervision of TCP connections can be enabled/disabled socket-specific when
creating the socket by calling sock_create(). For UDP sockets the application needs to perform a supervision if necessary. If the timeout value is set to 0
and #SOCK_FLAG_ENABLE_KEEPALIVE is set when creating a socket, a default value for the Keep-Alive Timeout will be used. */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_CONFIG_OPTIONS);
PN_U32
Timeout; /**< Keep-Alive Timeout in milliseconds. The Keep-Alive Timeout
will be used for the supervision of TCP connections. The
connection will be aborted if the remote connection partner
did not show activity within this timeout. The supervision of
TCP connections can be enabled/disabled socket-specific when
creating the socket by calling sock_create(). For UDP
sockets the application needs to perform a supervision if
necessary. If the timeout value is set to 0 and
#SOCK_FLAG_ENABLE_KEEPALIVE is set when creating a socket, a
default value for the Keep-Alive Timeout will be used. */
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_CONFIG_OPTIONS);
/** @} */
......@@ -918,18 +1006,20 @@ typedef struct _T_PNAK_SOCK_CONFIG_OPTIONS
/** \addtogroup sock_structures Data Structures
* @{
* \brief Network specific parameter
* All of the structure data must be specified in network-byte-order (big-endian).
* All of the structure data must be specified in network-byte-order
* (big-endian).
*/
typedef struct _T_PNAK_SOCK_NETWORK_SETTINGS
{
PN_U32 IpAddress; /**< The IP-Address of the Device. For future use only. */
PN_U32 SubnetMask; /**< The Netmask of the Device. For future use only. */
PN_U32 GatewayAddress; /**< The Gateway of the Device. For future use only. */
PN_U32 IpAddress; /**< The IP-Address of the Device. For future use only. */
PN_U32 SubnetMask; /**< The Netmask of the Device. For future use only. */
PN_U32 GatewayAddress; /**< The Gateway of the Device. For future use only. */
unsigned char MacAddress [6]; /**< The MAC address of the device. For future use only. */
unsigned char Alignment [2];
unsigned char
MacAddress[6]; /**< The MAC address of the device. For future use only. */
unsigned char Alignment[2];
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_NETWORK_SETTINGS);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_NETWORK_SETTINGS);
/** @} */
......@@ -941,10 +1031,12 @@ typedef struct _T_PNAK_SOCK_NETWORK_SETTINGS
*/
typedef struct _T_PNAK_SOCK_INIT
{
T_PNAK_SOCK_NETWORK_SETTINGS NetworkSettings; /**< Network specific parameter */
T_PNAK_SOCK_CONFIG_OPTIONS ConfigOptions; /**< Configurable Options for the socket interface */
T_PNAK_SOCK_NETWORK_SETTINGS
NetworkSettings; /**< Network specific parameter */
T_PNAK_SOCK_CONFIG_OPTIONS
ConfigOptions; /**< Configurable Options for the socket interface */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_INIT);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_INIT);
/** @} */
/*---------------------------------------------------------------------------*/
......@@ -955,25 +1047,44 @@ typedef struct _T_PNAK_SOCK_INIT
* Status of a TCP connection
* @{
*/
#define SOCK_TCP_CONNECTION_STATUS_UNCONNECTED 0x00000001uL /**< TCP connection not established */
#define SOCK_TCP_CONNECTION_STATUS_CONNECTING 0x00000002uL /**< A TCP connection establishment is in progress. This status is only possible for a TCP client socket. */
#define SOCK_TCP_CONNECTION_STATUS_CONNECTED 0x00000003uL /**< TCP connection established */
#define SOCK_TCP_CONNECTION_STATUS_UNCONNECTED \
0x00000001uL /**< TCP connection not established */
#define SOCK_TCP_CONNECTION_STATUS_CONNECTING \
0x00000002uL /**< A TCP connection establishment is in progress. This status \
is only possible for a TCP client socket. */
#define SOCK_TCP_CONNECTION_STATUS_CONNECTED \
0x00000003uL /**< TCP connection established */
/** @} */
/** \anchor ConnectionStatusCode @name TCP Connection Status Codes
* Error Codes of a TCP connection
* @{
*/
#define SOCK_TCP_CONNECTION_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_TCP_CONNECTION_STATUS_CODE_INTERNAL_ERROR 0x00000001uL /**< An internal error occurred in the socket interface causing the connection to abort. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_CLOSED_REMOTELY 0x00000002uL /**< The connection has been orderly closed by the remote connection partner (TCP FIN received). */
#define SOCK_TCP_CONNECTION_STATUS_CODE_ABORTED_REMOTELY 0x00000003uL /**< The connection has been aborted by the remote connection partner (TCP RST received), e.g. because
the remote partner has detected an error or temporarily crashed. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_TIMEOUT 0x00000004uL /**< The connection has been aborted because of a network failure or because the remote connection partner failed
to respond within the configured supervision timeout (see also T_PNAK_SOCK_CONFIG_OPTIONS). */
#define SOCK_TCP_CONNECTION_STATUS_CODE_CONNECT_REJECTED 0x00000005uL /**< It was not possible to establish a connection because the destination host rejected the connect request,
e.g. because the remote port is closed. This error only occurs for a TCP client socket. To retry connection
establishment the application has to close the socket and re-create the socket again. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_NO_ERROR \
0x00000000uL /**< No error detected */
#define SOCK_TCP_CONNECTION_STATUS_CODE_INTERNAL_ERROR \
0x00000001uL /**< An internal error occurred in the socket interface causing \
the connection to abort. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_CLOSED_REMOTELY \
0x00000002uL /**< The connection has been orderly closed by the remote \
connection partner (TCP FIN received). */
#define SOCK_TCP_CONNECTION_STATUS_CODE_ABORTED_REMOTELY \
0x00000003uL /**< The connection has been aborted by the remote connection \
partner (TCP RST received), e.g. because \
the remote partner has detected an error or temporarily \
crashed. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_TIMEOUT \
0x00000004uL /**< The connection has been aborted because of a network \
failure or because the remote connection partner failed to \
respond within the configured supervision timeout (see also \
T_PNAK_SOCK_CONFIG_OPTIONS). */
#define SOCK_TCP_CONNECTION_STATUS_CODE_CONNECT_REJECTED \
0x00000005uL /**< It was not possible to establish a connection because the \
destination host rejected the connect request, e.g. because \
the remote port is closed. This error only occurs for a TCP \
client socket. To retry connection establishment the \
application has to close the socket and re-create the socket \
again. */
/** @} */
/** @} */
......@@ -983,26 +1094,31 @@ typedef struct _T_PNAK_SOCK_INIT
*/
typedef struct _T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS
{
PN_U32 Status; /**< Local status of the TCP connection. Valid values: \ref ConnectionStatus */
PN_U32 StatusCode; /**< Indicates the last error of the TCP connection. Valid values: \ref ConnectionStatusCode */
PN_U32 Status; /**< Local status of the TCP connection. Valid values: \ref
ConnectionStatus */
PN_U32 StatusCode; /**< Indicates the last error of the TCP connection. Valid
values: \ref ConnectionStatusCode */
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
T_PNAK_SOCK_ADDR
RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS);
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds status informations about all TCP connections of a socket
* \brief This structure holds status informations about all TCP connections of
* a socket
*/
typedef struct _T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA
{
PN_U32 NumberConnections; /**< Number of TCP connection for which status info is provided */
PN_U32 NumberConnections; /**< Number of TCP connection for which status info
is provided */
/*T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS Connection [NumberConnections];*/ /**< TCP connection status information */
/*T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS Connection [NumberConnections];*/ /**< TCP connection status information */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA);
/** @} */
......@@ -1012,18 +1128,28 @@ typedef struct _T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA
* Status of a socket
* @{
*/
#define SOCK_LOCAL_STATUS_CLOSED 0x00000001uL /**< The local socket is closed */
#define SOCK_LOCAL_STATUS_OFFLINE 0x00000002uL /**< The local port associated with the socket is not open. Sending/Receiving of messages is not possible. */
#define SOCK_LOCAL_STATUS_ONLINE 0x00000003uL /**< The local port associated with the socket is open. Sending/Receiving of messages is possible. */
#define SOCK_LOCAL_STATUS_CLOSED \
0x00000001uL /**< The local socket is closed \
*/
#define SOCK_LOCAL_STATUS_OFFLINE \
0x00000002uL /**< The local port associated with the socket is not open. \
Sending/Receiving of messages is not possible. */
#define SOCK_LOCAL_STATUS_ONLINE \
0x00000003uL /**< The local port associated with the socket is open. \
Sending/Receiving of messages is possible. */
/** @} */
/** \anchor SocketStatusCode @name Socket Status Codes
* Error Codes of a socket
* @{
*/
#define SOCK_LOCAL_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_LOCAL_STATUS_CODE_ADDR_IN_USE 0x00000001uL /**< The local address passed with sock_create() is already in use by another socket. */
#define SOCK_LOCAL_STATUS_CODE_INTERNAL_ERROR 0x00000002uL /**< An internal error occurred in the socket interface causing the socket to close. */
#define SOCK_LOCAL_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_LOCAL_STATUS_CODE_ADDR_IN_USE \
0x00000001uL /**< The local address passed with sock_create() is already in \
use by another socket. */
#define SOCK_LOCAL_STATUS_CODE_INTERNAL_ERROR \
0x00000002uL /**< An internal error occurred in the socket interface causing \
the socket to close. */
/** @} */
/** @} */
......@@ -1033,17 +1159,19 @@ typedef struct _T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA
*/
typedef struct _T_PNAK_SOCK_IOC_GET_LOCAL_STATUS
{
PN_U32 Status; /**< Common socket status information. Valid values: \ref SocketStatus */
PN_U32 StatusCode; /**< Common socket error code. Valid values: \ref SocketStatusCode */
union
{
T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA Tcp; /**< TCP specific socket status information */
PN_U32 Status; /**< Common socket status information. Valid values: \ref
SocketStatus */
PN_U32 StatusCode; /**< Common socket error code. Valid values: \ref
SocketStatusCode */
union {
T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA
Tcp; /**< TCP specific socket status information */
/* UDP specific socket status information not existing */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_GET_LOCAL_STATUS);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IOC_GET_LOCAL_STATUS);
/** @} */
......@@ -1055,20 +1183,30 @@ typedef struct _T_PNAK_SOCK_IOC_GET_LOCAL_STATUS
* Send Status of a socket
* @{
*/
#define SOCK_SEND_STATUS_NOT_BUSY 0x00000001uL /**< No send request produced by the application */
#define SOCK_SEND_STATUS_BUSY 0x00000002uL /**< The send request is in progress. */
#define SOCK_SEND_STATUS_NOT_BUSY \
0x00000001uL /**< No send request produced by the application */
#define SOCK_SEND_STATUS_BUSY \
0x00000002uL /**< The send request is in progress. */
/** @} */
/** \anchor SendStatusCode @name Send Status Codes
* Send Error Codes
* @{
*/
#define SOCK_SEND_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_SEND_STATUS_CODE_NO_BUFFERS 0x00000001uL /**< The TCP/IP stack was unable to allocate an internal buffer or the output queue is full. */
#define SOCK_SEND_STATUS_CODE_HOST_UNREACHABLE 0x00000002uL /**< The destination host is unreachable, e.g. the destination host is down */
#define SOCK_SEND_STATUS_CODE_REJECTED 0x00000003uL /**< The destination host rejected the message, e.g. remote port is closed.
This error can only be returned by TCP sockets. */
#define SOCK_SEND_STATUS_CODE_SEND_ERROR 0x00000004uL /**< The TCP/IP stack reported a general problem sending the message. */
#define SOCK_SEND_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_SEND_STATUS_CODE_NO_BUFFERS \
0x00000001uL /**< The TCP/IP stack was unable to allocate an internal buffer \
or the output queue is full. */
#define SOCK_SEND_STATUS_CODE_HOST_UNREACHABLE \
0x00000002uL /**< The destination host is unreachable, e.g. the destination \
host is down */
#define SOCK_SEND_STATUS_CODE_REJECTED \
0x00000003uL /**< The destination host rejected the message, e.g. remote \
port is closed. This error can only be returned by TCP \
sockets. */
#define SOCK_SEND_STATUS_CODE_SEND_ERROR \
0x00000004uL /**< The TCP/IP stack reported a general problem sending the \
message. */
/** @} */
/** @} */
......@@ -1078,9 +1216,10 @@ typedef struct _T_PNAK_SOCK_IOC_GET_LOCAL_STATUS
*/
typedef struct _T_PNAK_SOCK_TCP_SEND_STATUS_DATA
{
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
T_PNAK_SOCK_ADDR
RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_SEND_STATUS_DATA);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_TCP_SEND_STATUS_DATA);
/** @} */
......@@ -1090,17 +1229,19 @@ typedef struct _T_PNAK_SOCK_TCP_SEND_STATUS_DATA
*/
typedef struct _T_PNAK_SOCK_IOC_GET_SEND_STATUS
{
PN_U32 Status; /**< Common send status information. Valid values: \ref SendStatus */
PN_U32 StatusCode; /**< Common send error code. Valid values: \ref SendStatusCode */
union
{
T_PNAK_SOCK_TCP_SEND_STATUS_DATA Tcp; /**< TCP specific send status information */
PN_U32 Status; /**< Common send status information. Valid values: \ref
SendStatus */
PN_U32 StatusCode; /**< Common send error code. Valid values: \ref
SendStatusCode */
union {
T_PNAK_SOCK_TCP_SEND_STATUS_DATA
Tcp; /**< TCP specific send status information */
/* UDP specific send status information not existing */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_GET_SEND_STATUS);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IOC_GET_SEND_STATUS);
/** @} */
......@@ -1112,15 +1253,21 @@ typedef struct _T_PNAK_SOCK_IOC_GET_SEND_STATUS
* Receive Status of a socket
* @{
*/
#define SOCK_RECEIVE_STATUS_NO_DATA_RECEIVED 0x00000000uL /**< No data on the specfied socket or TCP connection has been received. */
#define SOCK_RECEIVE_STATUS_DATA_RECEIVED 0x00000001uL /**< New data has been received on the specfied socket or TCP connection. */
#define SOCK_RECEIVE_STATUS_NO_DATA_RECEIVED \
0x00000000uL /**< No data on the specfied socket or TCP connection has been \
received. */
#define SOCK_RECEIVE_STATUS_DATA_RECEIVED \
0x00000001uL /**< New data has been received on the specfied socket or TCP \
connection. */
/** @} */
/** \anchor ReceiveStatusCode @name Receive Status Codes
* Receive Error Codes
* @{
*/
#define SOCK_RECEIVE_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_RECEIVE_STATUS_CODE_NO_ERROR \
0x00000000uL /**< No error detected \
*/
/** @} */
/** @} */
......@@ -1130,9 +1277,10 @@ typedef struct _T_PNAK_SOCK_IOC_GET_SEND_STATUS
*/
typedef struct _T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA
{
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
T_PNAK_SOCK_ADDR
RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA);
/** @} */
......@@ -1142,17 +1290,19 @@ typedef struct _T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA
*/
typedef struct _T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS
{
PN_U32 Status; /**< Common receive status information. Valid values: \ref ReceiveStatus */
PN_U32 StatusCode; /**< Common receive error code. Valid values: \ref ReceiveStatusCode */
union
{
T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA Tcp; /**< TCP specific receive status information */
PN_U32 Status; /**< Common receive status information. Valid values: \ref
ReceiveStatus */
PN_U32 StatusCode; /**< Common receive error code. Valid values: \ref
ReceiveStatusCode */
union {
T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA
Tcp; /**< TCP specific receive status information */
/* UDP specific send status information not existing */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS);
/** @} */
......@@ -1164,28 +1314,30 @@ typedef struct _T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS
*/
typedef struct _T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION
{
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
T_PNAK_SOCK_ADDR
RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION);
/** @} */
/*---------------------------------------------------------------------------*/
#define SOCK_MAX_NUMBER_FILTER_ENTRIES 4u
#define SOCK_MAX_NUMBER_FILTER_ENTRIES 4u
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure specifies the IP addresses from which a connection establishment shall be accepted
* \brief This structure specifies the IP addresses from which a connection
* establishment shall be accepted
*/
typedef struct _T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER
{
PN_U16 NumberEntries; /**< number of filter entries */
PN_U16 Alignment;
PN_U16 NumberEntries; /**< number of filter entries */
PN_U16 Alignment;
PN_U32 Filter [SOCK_MAX_NUMBER_FILTER_ENTRIES]; /**< IP address */
PN_U32 Filter[SOCK_MAX_NUMBER_FILTER_ENTRIES]; /**< IP address */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER);
/** @} */
......@@ -1193,13 +1345,14 @@ typedef struct _T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure specifies the IP addresses of the multicast group the application wants to join or leave
* \brief This structure specifies the IP addresses of the multicast group the
* application wants to join or leave
*/
typedef struct _T_PNAK_SOCK_IOC_MULTICAST
{
PN_U32 IpAddress;
PN_U32 IpAddress;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_MULTICAST);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IOC_MULTICAST);
/*---------------------------------------------------------------------------*/
......@@ -1209,13 +1362,20 @@ typedef struct _T_PNAK_SOCK_IOC_MULTICAST
* IO Control Commands for a socket
* @{
*/
#define SOCK_IOC_GET_LOCAL_STATUS 0x00000001uL /**< Get the local socket status */
#define SOCK_IOC_GET_SEND_STATUS 0x00000002uL /**< Get the status of a send request */
#define SOCK_IOC_GET_RECEIVE_STATUS 0x00000003uL /**< Checks if new data has been received */
#define SOCK_IOC_CLOSE_TCP_CONNECTION 0x00000004uL /**< Closes a TCP connection */
#define SOCK_IOC_TCP_ACCEPT_FILTER 0x00000005uL /**< Defines which IP Addresses are accepted by the socket */
#define SOCK_IOC_UDP_ADD_MULTICAST 0x00000006uL /**< Join a multicast group */
#define SOCK_IOC_UDP_DEL_MULTICAST 0x00000007uL /**< Leave a multicast group */
#define SOCK_IOC_GET_LOCAL_STATUS \
0x00000001uL /**< Get the local socket status */
#define SOCK_IOC_GET_SEND_STATUS \
0x00000002uL /**< Get the status of a send request */
#define SOCK_IOC_GET_RECEIVE_STATUS \
0x00000003uL /**< Checks if new data has been received */
#define SOCK_IOC_CLOSE_TCP_CONNECTION \
0x00000004uL /**< Closes a TCP connection */
#define SOCK_IOC_TCP_ACCEPT_FILTER \
0x00000005uL /**< Defines which IP Addresses are accepted by the socket */
#define SOCK_IOC_UDP_ADD_MULTICAST 0x00000006uL /**< Join a multicast group */
#define SOCK_IOC_UDP_DEL_MULTICAST \
0x00000007uL /**< Leave a multicast group \
*/
/** @} */
/** @} */
......@@ -1225,21 +1385,27 @@ typedef struct _T_PNAK_SOCK_IOC_MULTICAST
*/
typedef struct _T_PNAK_SOCK_IO_CONTROL
{
PN_U32 Command; /**< Specifies the IO Control Command. Valid values: \ref IoctlCommand */
union
{
T_PNAK_SOCK_IOC_GET_LOCAL_STATUS GetLocalStatus; /**< Local Socket Status informations */
T_PNAK_SOCK_IOC_GET_SEND_STATUS GetSendStatus; /**< Send Status informations */
T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS GetReceiveStatus; /**< Receive Status informations */
T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION CloseTcpConnection; /**< TCP connection which shall be closed */
T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER TcpAcceptFilter; /**< IP Address which shall be able to connect to the server */
T_PNAK_SOCK_IOC_MULTICAST AddMulticast; /**< Multicast group to join */
T_PNAK_SOCK_IOC_MULTICAST DelMulticast; /**< Multicast group to leave */
PN_U32 Command; /**< Specifies the IO Control Command. Valid values: \ref
IoctlCommand */
union {
T_PNAK_SOCK_IOC_GET_LOCAL_STATUS
GetLocalStatus; /**< Local Socket Status informations */
T_PNAK_SOCK_IOC_GET_SEND_STATUS
GetSendStatus; /**< Send Status informations */
T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS
GetReceiveStatus; /**< Receive Status informations */
T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION
CloseTcpConnection; /**< TCP connection which shall be closed */
T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER
TcpAcceptFilter; /**< IP Address which shall be able to connect to the
server */
T_PNAK_SOCK_IOC_MULTICAST AddMulticast; /**< Multicast group to join */
T_PNAK_SOCK_IOC_MULTICAST DelMulticast; /**< Multicast group to leave */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IO_CONTROL);
} PACK_WORD_ALIGNMENT(T_PNAK_SOCK_IO_CONTROL);
/** @} */
......@@ -1248,32 +1414,40 @@ FUNCTION DECLARATION
******************************************************************************/
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#ifndef __DOXYGEN__
/*--- initialization/termination functions ----------------------------------*/
extern T_SOCKET_RESULT pnak_sock_init (unsigned short, T_PNAK_SOCK_INIT*);
extern T_SOCKET_RESULT pnak_sock_term (unsigned short);
extern T_SOCKET_RESULT pnak_sock_init(unsigned short, T_PNAK_SOCK_INIT*);
extern T_SOCKET_RESULT pnak_sock_term(unsigned short);
/*--- socket interface functions --------------------------------------------*/
extern T_SOCKET_RESULT pnak_sock_create (unsigned short, PN_U32, T_PNAK_SOCK_ADDR*, T_PNAK_SOCK_ADDR*, unsigned short*);
extern T_SOCKET_RESULT pnak_sock_close (unsigned short, unsigned short);
extern T_SOCKET_RESULT pnak_sock_send (unsigned short, unsigned short, T_PNAK_SOCK_ADDR*, PN_U16, const unsigned char*);
extern T_SOCKET_RESULT pnak_sock_receive (unsigned short, unsigned short, T_PNAK_SOCK_ADDR*, PN_U16*, unsigned char*);
extern T_SOCKET_RESULT pnak_sock_ioctl (unsigned short, unsigned short, T_PNAK_SOCK_IO_CONTROL*);
extern T_SOCKET_RESULT pnak_sock_create(unsigned short, PN_U32,
T_PNAK_SOCK_ADDR*, T_PNAK_SOCK_ADDR*,
unsigned short*);
extern T_SOCKET_RESULT pnak_sock_close(unsigned short, unsigned short);
extern T_SOCKET_RESULT pnak_sock_send(unsigned short, unsigned short,
T_PNAK_SOCK_ADDR*, PN_U16,
const unsigned char*);
extern T_SOCKET_RESULT pnak_sock_receive(unsigned short, unsigned short,
T_PNAK_SOCK_ADDR*, PN_U16*,
unsigned char*);
extern T_SOCKET_RESULT pnak_sock_ioctl(unsigned short, unsigned short,
T_PNAK_SOCK_IO_CONTROL*);
/*--- socket interface helper functions -------------------------------------*/
extern T_SOCKET_RESULT pnak_sock_get_receive_status (unsigned short, T_BITSET_64*);
extern T_SOCKET_RESULT pnak_sock_get_receive_status(unsigned short,
T_BITSET_64*);
#endif /* __DOXYGEN__ */
#ifdef __cplusplus
}
}
#endif
#endif /* SCAI_INCLUDE_SOCKET || SDAI_INCLUDE_SOCKET */
......@@ -1281,18 +1455,18 @@ extern T_SOCKET_RESULT pnak_sock_get_receive_status (unsigned shor
/*****************************************************************************/
#if defined WIN32 || defined _WIN32
#pragma warning (disable : 4103) /* used #pragma pack to reset alignment */
#pragma pack(pop)
#pragma warning (default : 4103)
#pragma warning(disable : 4103) /* used #pragma pack to reset alignment */
#pragma pack(pop)
#pragma warning(default : 4103)
#elif defined __GNUC__
/* nothing to do */
/* nothing to do */
#elif defined _OS9000
/* nothing to do */
/* nothing to do */
#else
#error CAUTION: set default structure alignment
#error CAUTION: set default structure alignment
#endif
/*****************************************************************************/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
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