Commit 18c06731 authored by claes's avatar claes

*** empty log message ***

parent 003ca386
/*
* Proview $Id: rt_io_m_pb_ai.c,v 1.2 2006-01-16 13:56:52 claes Exp $
* Proview $Id: rt_io_m_pb_ai.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -271,7 +271,7 @@ static pwr_tStatus IoCardRead (
if (op->BytesPerChannel == 4) {
memcpy(&udata32, local->input_area + op->OffsetInputs + 4*i, 4);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata32 = swap32(udata32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata32 = swap32(udata32);
data32 = (pwr_tInt32) udata32;
sop->RawValue = 0;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
......@@ -290,7 +290,10 @@ static pwr_tStatus IoCardRead (
else if (op->BytesPerChannel == 3) {
udata32 = 0;
memcpy(&udata32, local->input_area + op->OffsetInputs + 3*i, 3);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata32 = swap32(udata32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
udata32 = swap32(udata32);
udata32 = udata32 >> 8;
}
data32 = (pwr_tInt32) udata32;
sop->RawValue = 0;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
......@@ -308,7 +311,7 @@ static pwr_tStatus IoCardRead (
}
else if (op->BytesPerChannel == 2) {
memcpy(&udata16, local->input_area + op->OffsetInputs + 2*i, 2);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata16 = swap16(udata16);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata16 = swap16(udata16);
data16 = (pwr_tInt16) udata16;
sop->RawValue = udata16;
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
......
/*
* Proview $Id: rt_io_m_pb_ao.c,v 1.2 2006-01-16 13:56:52 claes Exp $
* Proview $Id: rt_io_m_pb_ao.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -160,12 +160,12 @@ static pwr_tStatus IoCardWrite (
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
udata32 = (pwr_tUInt32) rawvalue;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata32 = swap32(udata32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 4*i, &udata32, 4);
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
data32 = (pwr_tInt32) rawvalue;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data32 = swap32(data32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4*i, &data32, 4);
}
......@@ -174,12 +174,12 @@ static pwr_tStatus IoCardWrite (
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
udata32 = (pwr_tUInt32) rawvalue;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata32 = swap32(udata32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 3*i, &udata32, 3);
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
data32 = (pwr_tInt32) rawvalue;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data32 = swap32(data32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3*i, &data32, 3);
}
......@@ -188,12 +188,12 @@ static pwr_tStatus IoCardWrite (
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
udata16 = (pwr_tUInt16) rawvalue;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata16 = swap16(udata16);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata16 = swap16(udata16);
memcpy(local->output_area + op->OffsetOutputs + 2*i, &udata16, 2);
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
data16 = (pwr_tInt16) rawvalue;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data16 = swap16(data16);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2*i, &data16, 2);
}
......
/*
* Proview $Id: rt_io_m_pb_di.c,v 1.2 2006-01-16 13:56:52 claes Exp $
* Proview $Id: rt_io_m_pb_di.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -98,7 +98,7 @@ static pwr_tStatus IoCardRead (
memcpy(&data, local->input_area + op->OffsetInputs, op->BytesOfInput);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) {
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) {
data[0] = swap16(data[0]);
data[1] = swap16(data[1]);
......
/*
* Proview $Id: rt_io_m_pb_do.c,v 1.2 2006-01-16 13:56:52 claes Exp $
* Proview $Id: rt_io_m_pb_do.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -97,7 +97,7 @@ static pwr_tStatus IoCardWrite (
io_DoPackWord(cp, &data[0], 0);
if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) {
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
if (op->Orientation == PB_ORIENTATION_WORD) {
data[0] = swap16(data[0]);
data[1] = swap16(data[1]);
......
/*
* Proview $Id: rt_io_m_pb_dp_slave.c,v 1.3 2006-04-12 12:16:59 claes Exp $
* Proview $Id: rt_io_m_pb_dp_slave.c,v 1.4 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -59,6 +59,10 @@ pwr_tInt32 GetChanSize(pwr_eDataRepEnum rep)
case pwr_eDataRepEnum_Float32:
return 4;
break;
case pwr_eDataRepEnum_Int24:
case pwr_eDataRepEnum_UInt24:
return 3;
break;
case pwr_eDataRepEnum_Bit16:
case pwr_eDataRepEnum_Int16:
case pwr_eDataRepEnum_UInt16:
......@@ -107,7 +111,7 @@ static pwr_tStatus IoRackInit (
pwr_sClass_ChanIo *chan_io;
sts = gdh_ObjidToName(rp->Objid, (char *) &name, sizeof(name), cdh_mNName);
errh_Info( "Init of Profibus DP Slave and modules %s", name);
errh_Info( "Init of Profibus DP Slave and Modules %s", name);
op = (pwr_sClass_Pb_DP_Slave *) rp->op;
......@@ -118,17 +122,25 @@ static pwr_tStatus IoRackInit (
output_counter = 0;
op->NumberModules = 0;
latent_input_count = 0;
latent_output_count = 0;
while(cardp) {
local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card;
local_card->input_area = (void *) &(op->Inputs);
local_card->output_area = (void *) &(op->Outputs);
/* From v4.1.3 we can have subclasses, find the super class */
cid = cardp->Class;
while ( ODD( gdh_GetSuperClass( cid, &cid, cardp->Objid))) ;
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 subclasses */
case pwr_cClass_Pb_Di:
dip = (pwr_sClass_Pb_Di *) cardp->op;
dip->OffsetInputs = input_counter;
......@@ -177,13 +189,13 @@ static pwr_tStatus IoRackInit (
iop->Status = PB_MODULE_STATE_OPERATE;
break;
/* 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_Pb_Module:
mp = (pwr_sClass_Pb_Module *) cardp->op;
mp->Status = PB__NOTINIT;
mp->Status = PB__INITFAIL;
cardp->offset = 0;
latent_input_count = 0;
latent_output_count = 0;
for (i=0; i<cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
......@@ -207,6 +219,10 @@ static pwr_tStatus IoRackInit (
}
chanp->offset = input_counter;
chanp->mask = 1<<chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 && op->ByteOrdering == pwr_eByteOrdering_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 && op->ByteOrdering == pwr_eByteOrdering_BigEndian)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_di->Number == 0) latent_input_count = GetChanSize(chan_di->Representation);
printf("Di channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_di->Number, chanp->offset);
break;
......@@ -239,6 +255,7 @@ static pwr_tStatus IoRackInit (
chanp->size = chan_size;
chanp->mask = 0;
input_counter += chan_size;
printf("Ii channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ii->Number, chanp->offset);
break;
case pwr_cClass_ChanDo:
......@@ -250,6 +267,10 @@ static pwr_tStatus IoRackInit (
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_eByteOrdering_BigEndian)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 && op->ByteOrdering == pwr_eByteOrdering_BigEndian)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_do->Number == 0) latent_output_count = GetChanSize(chan_do->Representation);
printf("Do channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_do->Number, chanp->offset);
break;
......@@ -272,6 +293,7 @@ static pwr_tStatus IoRackInit (
chanp->size = chan_size;
chanp->mask = 0;
output_counter += chan_size;
printf("Io channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_io->Number, chanp->offset);
break;
}
}
......@@ -315,12 +337,10 @@ static pwr_tStatus IoRackRead (
if ((sts != PB_OK) || (diag & 1)) {
sp->Status = PB__NOCONN;
sp->ErrorCount++;
if (sp->ErrorCount > sp->ErrorSoftLimit && sp->StallAction >= PB_STALLACTION_RESET) {
memset(&sp->Inputs, 0, sp->BytesOfInput);
}
}
else {
sp->Status = PB__NORMAL;
sp->ErrorCount = 0;
}
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN) && sp->BytesOfInput > 0) {
......@@ -333,11 +353,17 @@ static pwr_tStatus IoRackRead (
if (sts != PB_OK)
sp->ErrorCount++;
else
sp->ErrorCount = 0;
// else
// sp->ErrorCount = 0;
}
// Stall handling
if (sp->ErrorCount > sp->ErrorSoftLimit && sp->StallAction >= pwr_ePbStallAction_ResetInputs) {
memset(&sp->Inputs, 0, sp->BytesOfInput);
}
if (sp->ErrorCount > sp->ErrorHardLimit && sp->StallAction >= PB_STALLACTION_BREAK)
if (sp->ErrorCount > sp->ErrorHardLimit && sp->StallAction >= pwr_ePbStallAction_EmergencyBreak)
ctx->Node->EmergBreakTrue = 1;
}
......
/*
* Proview $Id: rt_io_m_pb_ii.c,v 1.2 2006-01-16 13:56:52 claes Exp $
* Proview $Id: rt_io_m_pb_ii.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -113,12 +113,12 @@ static pwr_tStatus IoCardRead (
if (op->BytesPerChannel == 4) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
memcpy(&udata32, local->input_area + op->OffsetInputs + 4*i, 4);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata32 = swap32(udata32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata32 = swap32(udata32);
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) udata32;
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
memcpy(&data32, local->input_area + op->OffsetInputs + 4*i, 4);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data32 = swap32(data32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
*(pwr_tInt32 *) chanp->vbp = data32;
}
}
......@@ -126,25 +126,31 @@ static pwr_tStatus IoCardRead (
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
udata32 = 0;
memcpy(&udata32, local->input_area + op->OffsetInputs + 3*i, 3);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata32 = swap32(udata32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
udata32 = swap32(udata32);
udata32 = udata32 >> 8;
}
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) udata32;
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
data32 = 0;
memcpy(&data32, local->input_area + op->OffsetInputs + 3*i, 3);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data32 = swap32(data32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
data32 = swap32(data32);
data32 = data32 >> 8;
}
*(pwr_tInt32 *) chanp->vbp = data32;
}
}
else if (op->BytesPerChannel == 2) {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) {
memcpy(&udata16, local->input_area + op->OffsetInputs + 2*i, 2);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) udata16 = swap16(udata16);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata16 = swap16(udata16);
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) udata16;
}
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) {
memcpy(&data16, local->input_area + op->OffsetInputs + 2*i, 2);
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data16 = swap16(data16);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data16 = swap16(data16);
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) data16;
}
}
......
/*
* Proview $Id: rt_io_m_pb_io.c,v 1.2 2006-01-16 13:56:52 claes Exp $
* Proview $Id: rt_io_m_pb_io.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -110,16 +110,16 @@ static pwr_tStatus IoCardWrite (
data32 = *(pwr_tInt32 *) chanp->vbp;
if (op->BytesPerChannel == 4) {
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data32 = swap32(data32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4*i, &data32, 4);
}
else if (op->BytesPerChannel == 3) {
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data32 = swap32(data32);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3*i, &data32, 3);
}
else if (op->BytesPerChannel == 2) {
data16 = (pwr_tInt16) data32;
if (slave->ByteOrdering == PB_BYTEORDERING_BE) data16 = swap16(data16);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2*i, &data16, 2);
}
else if (op->BytesPerChannel == 1) {
......
/*
* Proview $Id: rt_io_m_pb_module.c,v 1.3 2006-04-12 12:16:59 claes Exp $
* Proview $Id: rt_io_m_pb_module.c,v 1.4 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -155,6 +155,9 @@ static pwr_tStatus IoCardRead (
pwr_tInt8 data8 = 0;
pwr_tInt16 data16 = 0;
pwr_tInt32 data32 = 0;
pwr_tUInt8 *udata8p;
pwr_tUInt16 *udata16p;
pwr_tUInt32 *udata32p;
pwr_tFloat32 f_raw = 0.0;
int i;
......@@ -175,32 +178,27 @@ static pwr_tStatus IoCardRead (
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi *) chanp->cop;
sig_di = (pwr_sClass_Di *) chanp->sop;
if (chan_di && sig_di && chan_di->ConversionOn) {
if (chan_di && sig_di) {
switch (chan_di->Representation) {
case pwr_eDataRepEnum_Bit8:
memcpy(&udata8, local->input_area + cp->offset + chanp->offset, 1);
* (pwr_tUInt16 *) (chanp->vbp) = ((udata8 & chanp->mask) != 0);
udata8p = local->input_area + cp->offset + chanp->offset;
* (pwr_tUInt16 *) (chanp->vbp) = ((*udata8p & chanp->mask) != 0);
break;
case pwr_eDataRepEnum_Bit16:
memcpy(&udata16, local->input_area + cp->offset + chanp->offset, 2);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata16 = swap16(udata16);
* (pwr_tUInt16 *) (chanp->vbp) = ((udata16 & chanp->mask) != 0);
udata16p = local->input_area + cp->offset + chanp->offset;
* (pwr_tUInt16 *) (chanp->vbp) = ((*udata16p & chanp->mask) != 0);
break;
case pwr_eDataRepEnum_Bit32:
memcpy(&udata32, local->input_area + cp->offset + chanp->offset, 4);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata32 = swap32(udata32);
* (pwr_tUInt16 *) (chanp->vbp) = ((udata32 & chanp->mask) != 0);
udata32p = local->input_area + cp->offset + chanp->offset;
* (pwr_tUInt16 *) (chanp->vbp) = ((*udata32p & chanp->mask) != 0);
break;
}
// Invert ?
if (chan_di->InvertOn) * (pwr_tUInt16 *) (chanp->vbp) ^= 1;
}
break;
......@@ -209,7 +207,7 @@ static pwr_tStatus IoCardRead (
case pwr_cClass_ChanAi:
chan_ai = (pwr_sClass_ChanAi *) chanp->cop;
sig_ai = (pwr_sClass_Ai *) chanp->sop;
if (chan_ai && sig_ai && chan_ai->ConversionOn) {
if (chan_ai && sig_ai) {
if (chan_ai->CalculateNewCoef) io_AiRangeToCoef(chanp);
......@@ -274,7 +272,7 @@ static pwr_tStatus IoCardRead (
case pwr_cClass_ChanIi:
chan_ii = (pwr_sClass_ChanIi *) chanp->cop;
sig_ii = (pwr_sClass_Ii *) chanp->sop;
if (chan_ii && sig_ii /* && chan_ii->ConversionOn */) {
if (chan_ii && sig_ii) {
switch (chan_ii->Representation) {
case pwr_eDataRepEnum_Int8:
......@@ -299,6 +297,26 @@ static pwr_tStatus IoCardRead (
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) udata16;
break;
case pwr_eDataRepEnum_Int24:
data32 = 0;
memcpy(&data32, local->input_area + cp->offset + chanp->offset, 3);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
data32 = swap32(data32);
data32 = data32 >> 8;
}
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) data32;
break;
case pwr_eDataRepEnum_UInt24:
udata32 = 0;
memcpy(&udata32, local->input_area + cp->offset + chanp->offset, 3);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) {
udata32 = swap32(udata32);
udata32 = udata32 >> 8;
}
*(pwr_tInt32 *) chanp->vbp = (pwr_tInt32) udata32;
break;
case pwr_eDataRepEnum_Int32:
memcpy(&data32, local->input_area + cp->offset + chanp->offset, 4);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
......@@ -345,13 +363,16 @@ static pwr_tStatus IoCardWrite (
pwr_sClass_Io *sig_io;
pwr_sClass_Pb_DP_Slave *slave;
pwr_tUInt8 udata8 = 0;
pwr_tUInt8 *udata8p;
pwr_tUInt16 *udata16p;
pwr_tUInt32 *udata32p;
pwr_tUInt8 udata8 = 0;
pwr_tUInt16 udata16 = 0;
pwr_tUInt32 udata32 = 0;
pwr_tInt8 data8 = 0;
pwr_tInt16 data16 = 0;
pwr_tInt32 data32 = 0;
pwr_tInt32 do_actval;;
pwr_tFloat32 value, rawvalue;
int fixout;
int i;
......@@ -375,30 +396,39 @@ static pwr_tStatus IoCardWrite (
sig_do = (pwr_sClass_Do *) chanp->sop;
if (chan_do && sig_do) {
if (fixout) {}
if (fixout)
do_actval = chan_do->FixedOutValue;
else if (chan_do->TestOn != 0)
do_actval = chan_do->TestValue;
else
do_actval = *(pwr_tInt32 *) chanp->vbp;
switch (chan_do->Representation) {
case pwr_eDataRepEnum_Bit8:
udata8p = local->output_area + cp->offset + chanp->offset;
if (*(pwr_tInt32 *) chanp->vbp != 0)
if (do_actval != 0)
*udata8p |= chanp->mask;
else
*udata8p &= ~chanp->mask;
break;
/*
case pwr_eDataRepEnum_Bit16:
memcpy(&udata16, local->input_area + cp->offset + chanp->offset, 2);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata16 = swap16(udata16);
* (pwr_tUInt16 *) (chanp->vbp) = ((udata16 & chanp->mask) != 0);
udata16p = local->output_area + cp->offset + chanp->offset;
if (do_actval != 0)
*udata16p |= chanp->mask;
else
*udata16p &= ~chanp->mask;
break;
case pwr_eDataRepEnum_Bit32:
memcpy(&udata32, local->input_area + cp->offset + chanp->offset, 4);
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) udata32 = swap32(udata32);
* (pwr_tUInt16 *) (chanp->vbp) = ((udata32 & chanp->mask) != 0);
udata32p = local->output_area + cp->offset + chanp->offset;
if (do_actval != 0)
*udata32p |= chanp->mask;
else
*udata32p &= ~chanp->mask;
break;
*/
}
}
......@@ -522,6 +552,16 @@ static pwr_tStatus IoCardWrite (
memcpy(local->output_area + cp->offset + chanp->offset, &udata16, 2);
break;
case pwr_eDataRepEnum_Int24:
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32) << 8;
memcpy(local->output_area + cp->offset + chanp->offset, &data32, 3);
break;
case pwr_eDataRepEnum_UInt24:
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32) << 8;
memcpy(local->output_area + cp->offset + chanp->offset, &udata32, 3);
break;
case pwr_eDataRepEnum_Int32:
if (slave->ByteOrdering == pwr_eByteOrdering_BigEndian) data32 = swap32(data32);
memcpy(local->output_area + cp->offset + chanp->offset, &data32, 4);
......
/*
* Proview $Id: rt_io_pb_locals.h,v 1.2 2006-04-12 12:16:59 claes Exp $
* Proview $Id: rt_io_pb_locals.h,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -19,7 +19,7 @@
#define IO_MAXCHAN 96
// These status constants are obsolete from V4.1, except for the old style
// These constants are obsolete from V4.1, except for the old style
// (Pb_Di, Pb_Do etc)
#define PB_MODULE_STATE_NOTINIT 0
......@@ -34,9 +34,9 @@
//#define PB_MASTER_STATE_CLEARED 2
//#define PB_MASTER_STATE_OPERATE 3
#define PB_STALLACTION_NONE 0
#define PB_STALLACTION_RESET 1
#define PB_STALLACTION_BREAK 2
//#define PB_STALLACTION_NONE 0
//#define PB_STALLACTION_RESET 1
//#define PB_STALLACTION_BREAK 2
#define PB_NUMREP_UNSIGNEDINT 0
#define PB_NUMREP_SIGNEDINT 1
......@@ -44,8 +44,8 @@
#define PB_NUMREP_FLOATVAX 3
#define PB_NUMREP_FLOATINTEL 4
#define PB_BYTEORDERING_LE 0
#define PB_BYTEORDERING_BE 1
//#define PB_BYTEORDERING_LE 0
//#define PB_BYTEORDERING_BE 1
#define PB_ORIENTATION_BYTE 8
#define PB_ORIENTATION_WORD 16
......
/*
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.3 2006-06-02 07:57:23 claes Exp $
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.4 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -130,7 +130,7 @@ static pwr_tStatus IoCardInit (
local->bfb_item = r_local->in_items;
r_local->in_items += op->MaxNoOfChannels;
/* Set card address in racks local in- and out-area, used by remote rack only
* Set card address in racks local in- and out-area, used by remote rack only
for (i=0; i<op->MaxNoOfChannels; i++) {
r_local->in.item[local->bfb_item+i].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF);
r_local->in.item[local->bfb_item+i].data = 0;
......
/*
* Proview $Id: rt_io_m_ssab_di.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_ssab_di.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -42,6 +42,7 @@
#include "rt_io_card_read.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\
......@@ -133,6 +134,7 @@ static pwr_tStatus IoCardRead (
)
{
io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tUInt16 data = 0;
pwr_sClass_Ssab_BaseDiCard *op;
pwr_tUInt16 invmask;
......@@ -161,9 +163,20 @@ static pwr_tStatus IoCardRead (
break;
}
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Read from local Q-bus */
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1;
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) local->Address[i]);
}
if ( sts == -1)
{
/* Increase error count and check error limits */
......
/*
* Proview $Id: rt_io_m_ssab_do.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_ssab_do.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -42,8 +42,10 @@
#include "rt_io_card_write.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
......@@ -135,6 +137,7 @@ static pwr_tStatus IoCardWrite (
)
{
io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tUInt16 data = 0;
pwr_sClass_Ssab_BaseDoCard *op;
pwr_tUInt16 invmask;
......@@ -193,9 +196,19 @@ static pwr_tStatus IoCardWrite (
data = (data & ~ testmask) | (testmask & testvalue);
}
wb.Data = data;
wb.Address = local->Address[i];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
wb.Data = data;
wb.Address = local->Address[i];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
}
else {
/* Ethernet I/O, Request a write to current address */
bfbeth_set_write_req(r_local, (pwr_tUInt16) local->Address[i], data);
sts = 1;
}
if ( sts == -1)
{
#if 0
......
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