Commit 93679d5b authored by Claes Sjofors's avatar Claes Sjofors

Event arg added to swap IO method, new event for emergency break

parent ed0522fc
...@@ -107,7 +107,8 @@ static pwr_tStatus IoAgentClose ( ...@@ -107,7 +107,8 @@ static pwr_tStatus IoAgentClose (
); );
static pwr_tStatus IoAgentSwap ( static pwr_tStatus IoAgentSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap io_sAgent *ap,
io_eEvent event
); );
...@@ -784,36 +785,49 @@ static pwr_tStatus IoAgentInit ( ...@@ -784,36 +785,49 @@ static pwr_tStatus IoAgentInit (
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoAgentSwap ( static pwr_tStatus IoAgentSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap io_sAgent *ap,
io_eEvent event
) )
{ {
pwr_sClass_Pb_Profiboard *op;
char DeviceName[64]; switch ( event) {
io_sAgentLocal *local; case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap: {
pwr_sClass_Pb_Profiboard *op;
char DeviceName[64];
io_sAgentLocal *local;
if (ap->Local == NULL) { if (ap->Local == NULL) {
/* Allocate area for local data structure */ /* Allocate area for local data structure */
ap->Local = calloc(1, sizeof(io_sAgentLocal)); ap->Local = calloc(1, sizeof(io_sAgentLocal));
if (!ap->Local) { if (!ap->Local) {
errh_Error( "ERROR swap init Profibus DP Master %s - %s", ap->Name, "calloc"); errh_Error( "ERROR swap init Profibus DP Master %s - %s", ap->Name, "calloc");
return IO__ERRINIDEVICE; return IO__ERRINIDEVICE;
} }
local = (io_sAgentLocal *) ap->Local; local = (io_sAgentLocal *) ap->Local;
errh_Info( "Swap init interface for Profibus DP Master %s", ap->Name); errh_Info( "Swap init interface for Profibus DP Master %s", ap->Name);
op = (pwr_sClass_Pb_Profiboard *) ap->op; op = (pwr_sClass_Pb_Profiboard *) ap->op;
sprintf(DeviceName, "/dev/pbboard%u", op->BusNumber - 1); sprintf(DeviceName, "/dev/pbboard%u", op->BusNumber - 1);
local->hDpsBoardDevice = open(DeviceName, O_RDONLY | O_NONBLOCK); local->hDpsBoardDevice = open(DeviceName, O_RDONLY | O_NONBLOCK);
if (local->hDpsBoardDevice == -1) { if (local->hDpsBoardDevice == -1) {
errh_Error( "ERROR swap init Profibus DP Master %s - %s", ap->Name, "open"); errh_Error( "ERROR swap init Profibus DP Master %s - %s", ap->Name, "open");
return IO__ERRINIDEVICE; return IO__ERRINIDEVICE;
}
} }
break;
} }
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
IoAgentClose( ctx, ap);
break;
}
return IO__SUCCESS; return IO__SUCCESS;
} }
......
...@@ -405,6 +405,7 @@ struct sLocal { ...@@ -405,6 +405,7 @@ struct sLocal {
sNodeInfo nodeDb[cNodes]; sNodeInfo nodeDb[cNodes];
pwr_tBoolean outunitServer; pwr_tBoolean outunitServer;
pwr_sClass_IOHandler *iohp; pwr_sClass_IOHandler *iohp;
pwr_sNode *nodep;
}; };
/* Global variables */ /* Global variables */
...@@ -1253,6 +1254,7 @@ cSup_exec ( ...@@ -1253,6 +1254,7 @@ cSup_exec (
o->DelayNoted = TRUE; o->DelayNoted = TRUE;
if (o->DelayAction == 2) { if (o->DelayAction == 2) {
l.iohp->IOReadWriteFlag = FALSE; l.iohp->IOReadWriteFlag = FALSE;
l.nodep->EmergBreakTrue = TRUE;
errh_SetStatus( MH__IOSTALLED); errh_SetStatus( MH__IOSTALLED);
} }
} }
...@@ -1996,6 +1998,7 @@ getHandlerObject () ...@@ -1996,6 +1998,7 @@ getHandlerObject ()
pwr_sAttrRef aref; pwr_sAttrRef aref;
pwr_tDlid dlid; pwr_tDlid dlid;
pwr_tBoolean created = FALSE; pwr_tBoolean created = FALSE;
pwr_tOid node_oid;
sts = gdh_GetClassList(pwr_eClass_Node, &nodeOid); sts = gdh_GetClassList(pwr_eClass_Node, &nodeOid);
if (EVEN(sts)) { if (EVEN(sts)) {
...@@ -2099,7 +2102,14 @@ getHandlerObject () ...@@ -2099,7 +2102,14 @@ getHandlerObject ()
l.iohp = NULL; l.iohp = NULL;
gdh_ObjidToPointer(oid, (void *) &l.iohp); gdh_ObjidToPointer(oid, (void *) &l.iohp);
sts = gdh_GetNodeObject( 0, &node_oid);
if (ODD(sts))
sts = gdh_ObjidToPointer( node_oid, (void **)&l.nodep);
if (EVEN(sts)) {
errh_Fatal("No node object found\n%m", sts);
exit(sts);
}
} }
static mh_eAgent static mh_eAgent
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
EVENT io_comm_terminate; EVENT io_comm_terminate;
#endif #endif
static pwr_sClass_IOHandler* init(qcom_sQid*, lst_sEntry**); static pwr_sClass_IOHandler* init(qcom_sQid*, lst_sEntry**, pwr_sNode**);
static void usage() static void usage()
{ {
...@@ -100,6 +100,8 @@ int main (int argc, char **argv) ...@@ -100,6 +100,8 @@ int main (int argc, char **argv)
pwr_tDeltaTime cycle; pwr_tDeltaTime cycle;
lst_sEntry *csup_lh; lst_sEntry *csup_lh;
int delay_action = 0; int delay_action = 0;
pwr_sNode *nodep;
pwr_tBoolean old_emergency_break = 0;
if ( argc > 1) { if ( argc > 1) {
if ( strcmp( argv[1], "-m") == 0) { if ( strcmp( argv[1], "-m") == 0) {
...@@ -112,7 +114,7 @@ int main (int argc, char **argv) ...@@ -112,7 +114,7 @@ int main (int argc, char **argv)
} }
} }
ihp = init(&qid, &csup_lh); ihp = init(&qid, &csup_lh, &nodep);
plc_UtlWaitForPlc(); plc_UtlWaitForPlc();
...@@ -146,13 +148,28 @@ int main (int argc, char **argv) ...@@ -146,13 +148,28 @@ int main (int argc, char **argv)
get.data = mp; get.data = mp;
qcom_Get(&sts,&qid, &get, tmo); qcom_Get(&sts,&qid, &get, tmo);
if (sts == QCOM__TMO || sts == QCOM__QEMPTY) { if (sts == QCOM__TMO || sts == QCOM__QEMPTY) {
if ( nodep->EmergBreakTrue && !old_emergency_break)
sts = io_swap(io_ctx_swap, io_eEvent_IoCommEmergencyBreak);
sts = io_read(io_ctx); sts = io_read(io_ctx);
if (EVEN(sts)) {
ihp->IOReadWriteFlag = FALSE;
errh_Error("IO read, %m", sts);
}
sts = io_write(io_ctx); sts = io_write(io_ctx);
if (EVEN(sts)) {
ihp->IOReadWriteFlag = FALSE;
errh_Error("IO write, %m", sts);
}
if ( nodep->EmergBreakTrue && !old_emergency_break)
sts = io_swap(io_ctx, io_eEvent_EmergencyBreak);
old_emergency_break = nodep->EmergBreakTrue;
if (swap_io) if (swap_io)
{ {
sts = io_swap(io_ctx_swap); sts = io_swap(io_ctx_swap, io_eEvent_IoCommSwap);
} }
io_ScanSupLst( io_ctx->SupCtx); io_ScanSupLst( io_ctx->SupCtx);
...@@ -193,13 +210,14 @@ int main (int argc, char **argv) ...@@ -193,13 +210,14 @@ int main (int argc, char **argv)
} }
static pwr_sClass_IOHandler * static pwr_sClass_IOHandler *
init (qcom_sQid *qid, lst_sEntry **csup_lh) init (qcom_sQid *qid, lst_sEntry **csup_lh, pwr_sNode **nodep)
{ {
pwr_tStatus sts = 1; pwr_tStatus sts = 1;
pwr_sClass_IOHandler *ihp; pwr_sClass_IOHandler *ihp;
qcom_sQattr qAttr; qcom_sQattr qAttr;
qcom_sQid qini; qcom_sQid qini;
pwr_tObjid oid; pwr_tOid oid;
pwr_tOid node_oid;
errh_Init("pwr_io", errh_eAnix_io); errh_Init("pwr_io", errh_eAnix_io);
...@@ -238,6 +256,18 @@ init (qcom_sQid *qid, lst_sEntry **csup_lh) ...@@ -238,6 +256,18 @@ init (qcom_sQid *qid, lst_sEntry **csup_lh)
exit(sts); exit(sts);
} }
sts = gdh_GetNodeObject( 0, &node_oid);
if (EVEN(sts)) {
errh_Fatal("rt_io_comm aborted, no node object found\n%m", sts);
exit(sts);
}
sts = gdh_ObjidToPointer( node_oid, (void **)nodep);
if (EVEN(sts)) {
errh_Fatal("rt_io_comm aborted, no node object found\n%m", sts);
exit(sts);
}
aproc_RegisterObject( oid); aproc_RegisterObject( oid);
*csup_lh = csup_Init(&sts, oid, ihp->CycleTimeBus); *csup_lh = csup_Init(&sts, oid, ihp->CycleTimeBus);
......
...@@ -2143,7 +2143,7 @@ static pwr_tStatus io_init_agent( ...@@ -2143,7 +2143,7 @@ static pwr_tStatus io_init_agent(
io_tCtx ctx, io_tCtx ctx,
void *dummy, void *dummy,
int agent_type, int agent_type,
int swap) int iocomm_swap)
{ {
pwr_tStatus sts; pwr_tStatus sts;
pwr_tClassId class; pwr_tClassId class;
...@@ -2181,7 +2181,7 @@ static pwr_tStatus io_init_agent( ...@@ -2181,7 +2181,7 @@ static pwr_tStatus io_init_agent(
strcat( attrname, ".Process"); strcat( attrname, ".Process");
sts = gdh_GetObjectInfo( attrname, &process, sizeof(process)); sts = gdh_GetObjectInfo( attrname, &process, sizeof(process));
if (( EVEN(sts) || if (( EVEN(sts) ||
(ODD(sts) && ctx->Process & process)) && !swap) { (ODD(sts) && ctx->Process & process)) && !iocomm_swap) {
if ( EVEN(sts)) if ( EVEN(sts))
process = io_mProcess_All; process = io_mProcess_All;
if ( ctx->Process == io_mProcess_Profibus) if ( ctx->Process == io_mProcess_Profibus)
...@@ -2199,7 +2199,7 @@ static pwr_tStatus io_init_agent( ...@@ -2199,7 +2199,7 @@ static pwr_tStatus io_init_agent(
else else
ok = 1; ok = 1;
} }
else if (ODD(sts) && swap && AgentSwap != NULL) { else if (ODD(sts) && iocomm_swap && AgentSwap != NULL) {
/* IoComm-process should always handle the Swap-method */ /* IoComm-process should always handle the Swap-method */
ok = 1; ok = 1;
} }
...@@ -2213,11 +2213,13 @@ static pwr_tStatus io_init_agent( ...@@ -2213,11 +2213,13 @@ static pwr_tStatus io_init_agent(
ap->Objid = objid; ap->Objid = objid;
strcpy( ap->Name, aname); strcpy( ap->Name, aname);
ap->Process = process; ap->Process = process;
if (!swap) { if (!iocomm_swap) {
if ( AgentRead != NULL) if ( AgentRead != NULL)
ap->Action |= io_mAction_Read; ap->Action |= io_mAction_Read;
if ( AgentWrite != NULL) if ( AgentWrite != NULL)
ap->Action |= io_mAction_Write; ap->Action |= io_mAction_Write;
if ( AgentSwap != NULL)
ap->Action |= io_mAction_Swap;
ap->Init = AgentInit; ap->Init = AgentInit;
ap->Close = AgentClose; ap->Close = AgentClose;
ap->Read = AgentRead; ap->Read = AgentRead;
...@@ -2252,7 +2254,7 @@ static pwr_tStatus io_init_agent( ...@@ -2252,7 +2254,7 @@ static pwr_tStatus io_init_agent(
alp->next = ap; alp->next = ap;
} }
sts = io_trv_child( objid, 0, io_init_rack, ctx, ap, agent_type, swap); sts = io_trv_child( objid, 0, io_init_rack, ctx, ap, agent_type, iocomm_swap);
} }
} }
} }
...@@ -2646,7 +2648,7 @@ pwr_tStatus io_init_swap ( ...@@ -2646,7 +2648,7 @@ pwr_tStatus io_init_swap (
{ {
if (ap->Action & io_mAction_Swap) if (ap->Action & io_mAction_Swap)
{ {
sts = (ap->Swap) ( *ctx, ap); sts = (ap->Swap) ( *ctx, ap, io_eEvent_IoCommSwapInit);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
} }
...@@ -2798,59 +2800,42 @@ pwr_tStatus io_write( ...@@ -2798,59 +2800,42 @@ pwr_tStatus io_write(
Swap io racks and cards. Swap io racks and cards.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_tStatus io_swap( pwr_tStatus io_swap(
io_tCtx ctx) io_tCtx ctx,
io_eEvent event)
{ {
pwr_tStatus sts; pwr_tStatus sts;
io_sAgent *ap; io_sAgent *ap;
io_sRack *rp; io_sRack *rp;
io_sCard *cp; io_sCard *cp;
if ( ctx->Node->EmergBreakTrue || !ctx->IOHandler->IOReadWriteFlag) switch ( event) {
return IO__IS_STOPPED; case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
break;
default:
if ( ctx->Node->EmergBreakTrue || !ctx->IOHandler->IOReadWriteFlag)
return IO__IS_STOPPED;
}
/* Call the read methods for agents, racks and cards */ /* Call the read methods for agents, racks and cards */
for ( ap = ctx->agentlist; ap != NULL; ap = ap->next) for ( ap = ctx->agentlist; ap != NULL; ap = ap->next) {
{ if (ap->Action & io_mAction_Swap) {
if (ap->Action & io_mAction_Swap) sts = (ap->Swap) ( ctx, ap, event);
{ if ( EVEN(sts)) return sts;
if ( ap->scan_interval_cnt <= 1)
{
sts = (ap->Swap) ( ctx, ap);
if ( EVEN(sts)) return sts;
ap->scan_interval_cnt = ap->scan_interval;
}
else
ap->scan_interval_cnt--;
} }
for ( rp = ap->racklist; rp != NULL; rp = rp->next) for ( rp = ap->racklist; rp != NULL; rp = rp->next) {
{
if (rp->Action & io_mAction_Swap && if (rp->Action & io_mAction_Swap &&
!rp->MethodDisabled) !rp->MethodDisabled) {
{ sts = (rp->Swap) ( ctx, ap, rp, event);
if ( rp->scan_interval_cnt <= 1) if ( EVEN(sts)) return sts;
{
sts = (rp->Swap) ( ctx, ap, rp);
if ( EVEN(sts)) return sts;
rp->scan_interval_cnt = rp->scan_interval;
}
else
rp->scan_interval_cnt--;
} }
for ( cp = rp->cardlist; cp != NULL; cp = cp->next) for ( cp = rp->cardlist; cp != NULL; cp = cp->next) {
{
if (cp->Action & io_mAction_Swap && if (cp->Action & io_mAction_Swap &&
!cp->MethodDisabled) !cp->MethodDisabled) {
{ sts = (cp->Swap) ( ctx, ap, rp, cp, event);
if ( cp->scan_interval_cnt <= 1) if ( EVEN(sts)) return sts;
{
sts = (cp->Swap) ( ctx, ap, rp, cp);
if ( EVEN(sts)) return sts;
cp->scan_interval_cnt = cp->scan_interval;
}
else
cp->scan_interval_cnt--;
} }
} }
} }
......
...@@ -105,6 +105,13 @@ typedef enum { ...@@ -105,6 +105,13 @@ typedef enum {
io_mProcess_All = ~0 io_mProcess_All = ~0
} io_mProcess; } io_mProcess;
typedef enum {
io_eEvent_EmergencyBreak,
io_eEvent_IoCommEmergencyBreak,
io_eEvent_IoCommSwapInit,
io_eEvent_IoCommSwap
} io_eEvent;
typedef struct { typedef struct {
void *cop; /* Pointer to channel object */ void *cop; /* Pointer to channel object */
pwr_tDlid ChanDlid; /* Dlid for pointer to channel */ pwr_tDlid ChanDlid; /* Dlid for pointer to channel */
...@@ -245,7 +252,8 @@ pwr_tStatus io_write( ...@@ -245,7 +252,8 @@ pwr_tStatus io_write(
); );
pwr_tStatus io_swap( pwr_tStatus io_swap(
io_tCtx ctx io_tCtx ctx,
io_eEvent event
); );
pwr_tStatus io_close( pwr_tStatus io_close(
......
...@@ -172,6 +172,7 @@ struct plc_sThread { ...@@ -172,6 +172,7 @@ struct plc_sThread {
io_tCtx plc_io_ctx; io_tCtx plc_io_ctx;
pwr_tBoolean first_scan; pwr_tBoolean first_scan;
int skip_count; int skip_count;
pwr_tBoolean emergency_break_old;
}; };
struct plc_sProcess { struct plc_sProcess {
......
...@@ -250,6 +250,9 @@ scan ( ...@@ -250,6 +250,9 @@ scan (
errh_SetStatus( PLC__IOREAD); errh_SetStatus( PLC__IOREAD);
} }
} }
if ( pp->Node->EmergBreakTrue && !tp->emergency_break_old)
io_swap(tp->plc_io_ctx, io_eEvent_EmergencyBreak);
tp->emergency_break_old = pp->Node->EmergBreakTrue;
thread_MutexLock(&pp->io_copy_mutex); thread_MutexLock(&pp->io_copy_mutex);
...@@ -307,6 +310,7 @@ scan ( ...@@ -307,6 +310,7 @@ scan (
delay_action = csup_Exec(&sts, tp->csup_lh, (pwr_tDeltaTime *) &tp->sync_time, (pwr_tDeltaTime *) &tp->after_scan, &now); delay_action = csup_Exec(&sts, tp->csup_lh, (pwr_tDeltaTime *) &tp->sync_time, (pwr_tDeltaTime *) &tp->after_scan, &now);
if (delay_action == 2) { if (delay_action == 2) {
pp->IOHandler->IOReadWriteFlag = FALSE; pp->IOHandler->IOReadWriteFlag = FALSE;
pp->Node->EmergBreakTrue = TRUE;
errh_SetStatus( PLC__IOSTALLED); errh_SetStatus( PLC__IOSTALLED);
} }
} }
......
...@@ -84,25 +84,33 @@ static pwr_tStatus IoRackInit ( ...@@ -84,25 +84,33 @@ static pwr_tStatus IoRackInit (
static pwr_tStatus IoRackSwap ( static pwr_tStatus IoRackSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap, io_sAgent *ap,
io_sRack *rp io_sRack *rp,
io_eEvent event
) )
{ {
io_sRackLocal *local; io_sRackLocal *local;
if (!rp->Local) { switch ( event) {
/* Open Qbus driver */ case io_eEvent_IoCommSwapInit:
local = calloc( 1, sizeof(*local)); case io_eEvent_IoCommSwap:
rp->Local = local; if (!rp->Local) {
/* Open Qbus driver */
local->Qbus_fp = open("/dev/qbus", O_RDWR); local = calloc( 1, sizeof(*local));
if ( local->Qbus_fp == -1) rp->Local = local;
{
errh_Error( "Qbus swap initialization error, IO rack %s", rp->Name); local->Qbus_fp = open("/dev/qbus", O_RDWR);
return IO__ERRDEVICE; if ( local->Qbus_fp == -1)
{
errh_Error( "Qbus swap initialization error, IO rack %s", rp->Name);
return IO__ERRDEVICE;
}
errh_Info( "Swap init of IO rack %s", rp->Name);
} }
default: ;
errh_Info( "Swap init of IO rack %s", rp->Name);
} }
return 1; return 1;
} }
......
...@@ -278,7 +278,8 @@ static pwr_tStatus IoCardSwap ( ...@@ -278,7 +278,8 @@ static pwr_tStatus IoCardSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap, io_sAgent *ap,
io_sRack *rp, io_sRack *rp,
io_sCard *cp io_sCard *cp,
io_eEvent event
) )
{ {
io_sLocal *local; io_sLocal *local;
...@@ -289,32 +290,37 @@ static pwr_tStatus IoCardSwap ( ...@@ -289,32 +290,37 @@ static pwr_tStatus IoCardSwap (
qbus_io_read rb; qbus_io_read rb;
int sts; int sts;
op = (pwr_sClass_Ssab_BaseDoCard *) cp->op; switch ( event) {
case io_eEvent_IoCommSwapInit:
if (!cp->Local) { case io_eEvent_IoCommSwap:
local = calloc( 1, sizeof(*local)); op = (pwr_sClass_Ssab_BaseDoCard *) cp->op;
cp->Local = local;
local->Address[0] = op->RegAddress; if (!cp->Local) {
local->Address[1] = op->RegAddress + 2; local = calloc( 1, sizeof(*local));
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp; cp->Local = local;
}
for ( i = 0; i < 2; i++) local->Address[0] = op->RegAddress;
{ local->Address[1] = op->RegAddress + 2;
if (r_local->Qbus_fp != 0 && r_local->s == 0) { local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Write to local Q-bus */
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i], &sts);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1;
} }
for ( i = 0; i < 2; i++) {
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i], &sts);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1;
}
}
break;
default: ;
} }
return 1; return 1;
} }
......
...@@ -209,7 +209,9 @@ static pwr_tStatus IoRackInit ( ...@@ -209,7 +209,9 @@ static pwr_tStatus IoRackInit (
static pwr_tStatus IoRackSwap ( static pwr_tStatus IoRackSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap, io_sAgent *ap,
io_sRack *rp io_sRack *rp,
io_eEvent event
) )
{ {
io_sRackLocal *local; io_sRackLocal *local;
...@@ -220,44 +222,51 @@ static pwr_tStatus IoRackSwap ( ...@@ -220,44 +222,51 @@ static pwr_tStatus IoRackSwap (
struct bfb_buf rbuf; struct bfb_buf rbuf;
int size; int size;
if (!rp->Local) { switch ( event) {
case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap:
sts = IoRackInitSwap(ctx, ap, rp); if (!rp->Local) {
if (sts != IO__SUCCESS)
return IO__ERRINIDEVICE;
}
local = (io_sRackLocal *) rp->Local;
op = (pwr_sClass_Ssab_RemoteRack *) rp->op;
// Calc length and send read request
local->read_req.service = BFB_SERVICE_READ;
local->read_req.length = local->next_read_req_item*4 + 4;
sts = send(local->s, &local->read_req, local->read_req.length, 0);
op->TX_packets++;
local->next_read_req_item = 0;
bzero(&local->read_area, sizeof(local->read_area));
sts = 1; sts = IoRackInitSwap(ctx, ap, rp);
while (sts > 0) { if (sts != IO__SUCCESS)
FD_ZERO(&fds); return IO__ERRINIDEVICE;
FD_SET(local->s, &fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
sts = select(32, &fds, NULL, NULL, &tv);
if (sts > 0) {
size = recv(local->s, &rbuf, sizeof(rbuf), 0);
if (rbuf.service == BFB_SERVICE_READ) {
bzero(&local->read_area, sizeof(local->read_area));
memcpy(&local->read_area, &rbuf, size);
}
else if (rbuf.service == BFB_SERVICE_WRITE) {
bzero(&local->write_area, sizeof(local->write_area));
memcpy(&local->write_area, &rbuf, size);
}
op->RX_packets++;
} }
}
local = (io_sRackLocal *) rp->Local;
op = (pwr_sClass_Ssab_RemoteRack *) rp->op;
// Calc length and send read request
local->read_req.service = BFB_SERVICE_READ;
local->read_req.length = local->next_read_req_item*4 + 4;
sts = send(local->s, &local->read_req, local->read_req.length, 0);
op->TX_packets++;
local->next_read_req_item = 0;
bzero(&local->read_area, sizeof(local->read_area));
sts = 1;
while (sts > 0) {
FD_ZERO(&fds);
FD_SET(local->s, &fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
sts = select(32, &fds, NULL, NULL, &tv);
if (sts > 0) {
size = recv(local->s, &rbuf, sizeof(rbuf), 0);
if (rbuf.service == BFB_SERVICE_READ) {
bzero(&local->read_area, sizeof(local->read_area));
memcpy(&local->read_area, &rbuf, size);
}
else if (rbuf.service == BFB_SERVICE_WRITE) {
bzero(&local->write_area, sizeof(local->write_area));
memcpy(&local->write_area, &rbuf, size);
}
op->RX_packets++;
}
}
break;
default: ;
}
return IO__SUCCESS; return IO__SUCCESS;
......
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