Commit 425873de authored by claes's avatar claes

Added io-method IoAgentSwap

parent 87b55537
/*
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.10 2007-05-07 12:19:44 claes Exp $
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.11 2007-05-18 12:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -75,6 +75,10 @@ static pwr_tStatus IoAgentClose (
io_tCtx ctx,
io_sAgent *ap
);
static pwr_tStatus IoAgentSwap (
io_tCtx ctx,
io_sAgent *ap
);
......@@ -742,6 +746,44 @@ static pwr_tStatus IoAgentInit (
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Swap method for the Pb_profiboard agent
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoAgentSwap (
io_tCtx ctx,
io_sAgent *ap
)
{
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;
}
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
......@@ -1007,6 +1049,7 @@ static pwr_tStatus IoAgentClose (
close(local->hDpDataDevice);
close(local->hDpsInputDataDevice);
close(local->hDpsOutputDataDevice);
close(local->hDpsBoardDevice);
free( (char *)local);
......@@ -1023,5 +1066,6 @@ pwr_dExport pwr_BindIoMethods(Pb_Profiboard) = {
pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite),
pwr_BindIoMethod(IoAgentClose),
pwr_BindIoMethod(IoAgentSwap),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_pb_locals.h,v 1.4 2007-01-12 13:28:32 claes Exp $
* Proview $Id: rt_io_pb_locals.h,v 1.5 2007-05-18 12:00:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -59,6 +59,7 @@ typedef struct {
int hDpsOutputDataDevice; // Handle for DP-Slave Output-Data device
unsigned char CurrentBoardNumber;
int slave_diag_requested;
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
} io_sAgentLocal;
typedef struct {
......
Volume Profibus $ClassVolume 0.0.250.7
Body SysBody 05-SEP-2005 17:51:40.00
Attr NextOix = "_X108"
Attr NextOix = "_X109"
Attr NextCix = "_X14"
Attr NextTix[0] = "_X7"
EndBody
......@@ -1797,6 +1797,11 @@ Volume Profibus $ClassVolume 0.0.250.7
Attr MethodName = "Pb_Profiboard-IoAgentWrite"
EndBody
EndObject
Object IoAgentSwap $Method 109 18-MAY-2007 10:32:38.97
Body SysBody 18-MAY-2007 10:32:42.61
Attr MethodName = "Pb_Profiboard-IoAgentSwap"
EndBody
EndObject
EndObject
EndObject
EndObject
......
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