Commit b589d90a authored by claes's avatar claes

Handling of remote rack cards added

parent 3ddf8306
/*
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.4 2006-07-03 06:20:03 claes Exp $
* Proview $Id: rt_io_m_ai_ai32up.c,v 1.5 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -44,7 +44,7 @@
#include "rt_io_card_read.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\
......@@ -126,16 +126,6 @@ static pwr_tStatus IoCardInit (
local->Qbus_fp = r_local->Qbus_fp;
/* Get item offset from rack's local and increment it, used by remote rack only
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
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;
}
*/
errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */
......@@ -184,6 +174,7 @@ static pwr_tStatus IoCardRead (
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tInt16 data = 0;
pwr_sClass_Ai_AI32uP *op;
pwr_sClass_Ssab_RemoteRack *rrp;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
......@@ -191,6 +182,7 @@ static pwr_tStatus IoCardRead (
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
int bfb_error = 0;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
......@@ -223,9 +215,40 @@ static pwr_tStatus IoCardRead (
data = (unsigned short) rb.Data;
}
else {
/* Read from remote Q-bus, I/O-area stored in rack's local
data = r_local->in.item[local->bfb_item+i].data;*/
sts = 1;
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 2*i), &sts);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 2*i));
if (sts == -1) {
/* Error handling for ethernet Qbus-I/O */
rrp = (pwr_sClass_Ssab_RemoteRack *) rp->op;
if (bfb_error == 0) {
op->ErrorCount++;
bfb_error = 1;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount == op->ErrorHardLimit)
errh_Error( "IO Error hard limit reached on card '%s', stall action %d", cp->Name, rrp->StallAction);
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_ResetInputs )
{
data = 0;
sts = 1;
}
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_EmergencyBreak )
{
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
}
if (sts == -1) {
chanp++;
continue;
}
}
else {
op->ErrorCount = 0;
}
}
if ( sts == -1)
......
/*
* Proview $Id: rt_io_m_ao_hvao4.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_ao_hvao4.c,v 1.3 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -44,6 +44,7 @@
#include "rt_io_card_write.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\
......@@ -180,6 +181,7 @@ static pwr_tStatus IoCardWrite (
)
{
io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_sClass_Ao_HVAO4 *op;
int i;
io_sChannel *chanp;
......@@ -241,9 +243,17 @@ static pwr_tStatus IoCardWrite (
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
wb.Data = data;
wb.Address = local->Address + 2*i;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
wb.Data = data;
wb.Address = local->Address + 2*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 + 2*i), data);
sts = 1;
}
if ( sts == -1)
{
/* Exceptionhandler was called */
......
/*
* Proview $Id: rt_io_m_co_pi24bo.c,v 1.4 2006-06-02 07:57:23 claes Exp $
* Proview $Id: rt_io_m_co_pi24bo.c,v 1.5 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -41,6 +41,7 @@
#include "rt_io_card_read.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
#define IO_MAXCHAN 4
#define MIN16 -32767
......@@ -58,8 +59,7 @@
typedef struct {
unsigned int Address;
int Qbus_fp;
unsigned int bfb_read_item;
unsigned int bfb_write_item;
unsigned int bfb_item;
pwr_tInt32 OldValue[IO_MAXCHAN];
int FirstScan[IO_MAXCHAN];
} io_sLocal;
......@@ -92,21 +92,6 @@ static pwr_tStatus IoCardInit (
errh_Info( "Init of co card '%s'", cp->Name);
/* Get item offset from rack's local and increment it
/* This is a CO-card which means that we have both read and write possibilities
local->bfb_read_item = r_local->in_items;
r_local->in_items += op->MaxNoOfCounters*2;
local->bfb_write_item = r_local->out_items;
r_local->out_items += op->MaxNoOfCounters*2;
/* Set card address in racks local in- and out-area
for (i=0; i<op->MaxNoOfCounters; i++) {
r_local->in.item[local->bfb_read_item+i*2].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF);
r_local->in.item[local->bfb_read_item+i*2+1].address = (pwr_tUInt16) ((op->RegAddress+i*2+2) & 0xFFFF);
r_local->out.item[local->bfb_write_item+i*2].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF); // We dont normally write
r_local->out.item[local->bfb_write_item+i*2+1].address = (pwr_tUInt16) ((op->RegAddress+i*2+2) & 0xFFFF); // We dont normally write
}
*/
/* Configure card */
for ( i = 0; i < op->MaxNoOfCounters; i++)
{
......@@ -144,8 +129,10 @@ static pwr_tStatus IoCardInit (
}
}
else {
/* Write to remote Q-bus, I/O-area stored in rack's local */
sts = 1;
/* Ethernet I/O, Request a write to current address */
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 4*i), wr_data[0]);
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 4*i + 2), wr_data[1]);
sts = 1;
}
if ( sts == -1)
......@@ -265,8 +252,10 @@ static pwr_tStatus IoCardRead (
}
}
else {
/* Write to remote Q-bus, I/O-area stored in rack's local */
sts = 1;
/* Ethernet I/O, Request a write to current address */
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 4*i), wr_data[0]);
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 4*i + 2), wr_data[1]);
sts = 1;
}
if ( sts == -1)
......@@ -290,9 +279,10 @@ static pwr_tStatus IoCardRead (
re_data[0] = (unsigned short) rb.Data;
}
else {
/* Read from remote Q-bus, I/O-area stored in rack's local
re_data[0] = r_local->in.item[local->bfb_read_item+2*i].data; */
sts1 = 1;
/* Ethernet I/O, Get data from current address */
re_data[0] = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 4*i), &sts1);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 4*i));
}
if ( numofword == 2)
......@@ -304,9 +294,10 @@ static pwr_tStatus IoCardRead (
re_data[1] = (unsigned short) rb.Data;
}
else {
/* Read from remote Q-bus, I/O-area stored in rack's local
re_data[1] = r_local->in.item[local->bfb_read_item+2*i+1].data; */
sts2 = 1;
/* Ethernet I/O, Get data from current address */
re_data[1] = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 4*i + 2), &sts2);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 4*i + 2));
}
}
else
......
/*
* Proview $Id: rt_io_m_di_dix2.c,v 1.4 2006-06-02 07:57:23 claes Exp $
* Proview $Id: rt_io_m_di_dix2.c,v 1.5 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -82,19 +82,7 @@ static pwr_tStatus IoCardInit (
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = r_local->Qbus_fp;
/* Get item offset from rack's local and increment it
local->bfb_item = r_local->in_items;
r_local->in_items += 2;
Set card address in racks local in- and out-area
r_local->in.item[local->bfb_item].address = (pwr_tUInt16) (op->RegAddress & 0xFFFF);
r_local->in.item[local->bfb_item+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->in.item[local->bfb_item].data = 0;
r_local->in.item[local->bfb_item+1].data = 0;
*/
/* Init filter */
for ( i = 0; i < 2; i++)
{
......@@ -152,11 +140,13 @@ static pwr_tStatus IoCardRead (
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tUInt16 data = 0;
pwr_sClass_Di_DIX2 *op;
pwr_sClass_Ssab_RemoteRack *rrp;
pwr_tUInt16 invmask;
pwr_tUInt16 convmask;
int i;
int sts;
qbus_io_read rb;
int bfb_error = 0;
op = (pwr_sClass_Di_DIX2 *) cp->op;
......@@ -185,10 +175,36 @@ static pwr_tStatus IoCardRead (
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1;
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]);
if (sts == -1) {
/* Error handling for ethernet Qbus-I/O */
rrp = (pwr_sClass_Ssab_RemoteRack *) rp->op;
if (bfb_error == 0) {
op->ErrorCount++;
bfb_error = 1;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount == op->ErrorHardLimit)
errh_Error( "IO Error hard limit reached on card '%s', stall action %d", cp->Name, rrp->StallAction);
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_ResetInputs )
{
data = 0;
sts = 1;
}
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_EmergencyBreak )
{
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
}
if (sts == -1) continue;
}
else {
op->ErrorCount = 0;
}
}
if ( sts <= 0)
......
/*
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.4 2006-06-02 07:57:23 claes Exp $
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.5 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -81,17 +81,6 @@ static pwr_tStatus IoCardInit (
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = r_local->Qbus_fp;
/* Get item offset from rack's local and increment it
local->bfb_item = r_local->out_items;
r_local->out_items += 2;
Set card address in racks local out-area and initialize data
r_local->out.item[local->bfb_item].address = (pwr_tUInt16) (op->RegAddress & 0xFFFF);
r_local->out.item[local->bfb_item+1].address = (pwr_tUInt16) ((op->RegAddress+2) & 0xFFFF);
r_local->out.item[local->bfb_item].data = 0;
r_local->out.item[local->bfb_item+1].data = 0;
*/
/* Init filter for Po signals */
for ( i = 0; i < 2; i++)
{
......
/*
* Proview $Id: rt_io_m_ssab_aiup.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_ssab_aiup.c,v 1.3 2006-09-05 12:03:01 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"
/*----------------------------------------------------------------------------*\
......@@ -165,8 +166,10 @@ static pwr_tStatus IoCardRead (
)
{
io_sLocal *local;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tInt16 data = 0;
pwr_sClass_Ssab_BaseACard *op;
pwr_sClass_Ssab_RemoteRack *rrp;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
......@@ -174,6 +177,7 @@ static pwr_tStatus IoCardRead (
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
int bfb_error = 0;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseACard *) cp->op;
......@@ -200,10 +204,50 @@ static pwr_tStatus IoCardRead (
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
rb.Address = local->Address + 2*i;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
rb.Address = local->Address + 2*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 + 2*i), &sts);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 2*i));
if (sts == -1) {
/* Error handling for ethernet Qbus-I/O */
rrp = (pwr_sClass_Ssab_RemoteRack *) rp->op;
if (bfb_error == 0) {
op->ErrorCount++;
bfb_error = 1;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount == op->ErrorHardLimit)
errh_Error( "IO Error hard limit reached on card '%s', stall action %d", cp->Name, rrp->StallAction);
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_ResetInputs )
{
data = 0;
sts = 1;
}
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_EmergencyBreak )
{
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
}
if (sts == -1) {
chanp++;
continue;
}
}
else {
op->ErrorCount = 0;
}
}
if ( sts == -1)
/* Error handling for local Qbus-I/O */
{
#if 0
/* Exceptionhandler was called */
......@@ -229,7 +273,8 @@ static pwr_tStatus IoCardRead (
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
sop->SigValue = data * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch ( chanp->ChanClass)
......@@ -244,16 +289,17 @@ static pwr_tStatus IoCardRead (
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
......
/*
* Proview $Id: rt_io_m_ssab_aoup.c,v 1.3 2006-06-02 07:57:23 claes Exp $
* Proview $Id: rt_io_m_ssab_aoup.c,v 1.4 2006-09-05 12:03:01 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_write.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\
......@@ -131,16 +132,6 @@ static pwr_tStatus IoCardInit (
errh_Info( "Init of ao card '%s'", cp->Name);
/* Get item offset from rack's local and increment it, used by remote rack only
local->bfb_item = r_local->out_items;
r_local->out_items += op->MaxNoOfChannels;
/* Set card address in racks local in- and out-area, used by remote rack only
for (i=0; i<op->MaxNoOfChannels; i++) {
r_local->out.item[local->bfb_item+i].address = (pwr_tUInt16) ((op->RegAddress+i*2) & 0xFFFF);
r_local->out.item[local->bfb_item+i].data = 0;
}
*/
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local;
......@@ -259,9 +250,9 @@ static pwr_tStatus IoCardWrite (
sts = write( local->Qbus_fp, &wb, sizeof(wb));
}
else {
/* Write to remote Q-bus, I/O-area stored in rack's local
r_local->out.item[local->bfb_item+i].data = data; */
sts = 1;
/* Ethernet I/O, Request a write to current address */
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 2*i), data);
sts = 1;
}
if ( sts == -1)
......
/*
* Proview $Id: rt_io_m_ssab_co.c,v 1.2 2006-04-12 10:14:49 claes Exp $
* Proview $Id: rt_io_m_ssab_co.c,v 1.3 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -39,6 +39,7 @@
#include "rt_io_card_read.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
#define IO_MAXCHAN 4
#define MIN16 -32767
......@@ -74,6 +75,7 @@ static pwr_tStatus IoCardInit (
pwr_tUInt16 wr_data[2];
pwr_tUInt32 *wr_data_p;
qbus_io_write wb;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
op = (pwr_sClass_Ssab_CO4uP *) cp->op;
......@@ -112,15 +114,24 @@ static pwr_tStatus IoCardInit (
if ( op->LoadWrReg[i] == 1)
wr_data[1] |= (1 << 15);
wb.Address = local->Address + 4*i;
wb.Data = wr_data[0];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts != -1)
{
wb.Address += 2;
wb.Data = wr_data[1];
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
wb.Address = local->Address + 4*i;
wb.Data = wr_data[0];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts != -1) {
wb.Address += 2;
wb.Data = wr_data[1];
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 + 4*i), wr_data[0]);
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 4*i + 2), wr_data[1]);
sts = 1;
}
if ( sts == -1)
{
errh_Error( "IO init, Fatal write error, card '%s', IO i stopped", cp->Name);
......@@ -188,6 +199,7 @@ static pwr_tStatus IoCardRead (
int sts, sts1, sts2;
qbus_io_read rb;
qbus_io_write wb;
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_CO4uP *) cp->op;
......@@ -224,14 +236,23 @@ static pwr_tStatus IoCardRead (
if ( op->LoadWrReg[i] == 1)
wr_data[1] |= (1 << 15);
wb.Address = local->Address + 4*i;
wb.Data = wr_data[0];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts != -1)
{
wb.Address += 2;
wb.Data = wr_data[1];
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */
wb.Address = local->Address + 4*i;
wb.Data = wr_data[0];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts != -1)
{
wb.Address += 2;
wb.Data = wr_data[1];
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 + 4*i), wr_data[0]);
bfbeth_set_write_req(r_local, (pwr_tUInt16) (local->Address + 4*i + 2), wr_data[1]);
sts = 1;
}
if ( sts == -1)
......@@ -247,20 +268,38 @@ static pwr_tStatus IoCardRead (
numofword = 1; /* 16 bitscounter */
re_data_p = (pwr_tUInt32 *) &re_data;
#if defined(OS_ELN)
vaxc$establish(machfailread_co);
#endif
rb.Address = local->Address + 4*i;
sts1 = read( local->Qbus_fp, &rb, sizeof(rb));
re_data[0] = (unsigned short) rb.Data;
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Read from local Q-bus */
rb.Address = local->Address + 4*i;
sts1 = read( local->Qbus_fp, &rb, sizeof(rb));
re_data[0] = (unsigned short) rb.Data;
}
else {
/* Ethernet I/O, Get data from current address */
re_data[0] = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 4*i), &sts1);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 4*i));
}
if ( numofword == 2)
{
rb.Address += 2;
sts2 = read( local->Qbus_fp, &rb, sizeof(rb));
re_data[1] = (unsigned short) rb.Data;
if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Read from local Q-bus */
rb.Address += 2;
sts2 = read( local->Qbus_fp, &rb, sizeof(rb));
re_data[1] = (unsigned short) rb.Data;
}
else {
/* Ethernet I/O, Get data from current address */
re_data[1] = bfbeth_get_data(r_local, (pwr_tUInt16) (local->Address + 4*i + 2), &sts2);
/* Yes, we want to read this address the next time aswell */
bfbeth_set_read_req(r_local, (pwr_tUInt16) (local->Address + 4*i + 2));
}
}
else
sts2 = 0;
if ( sts1 == -1 || sts2 == -1)
{
#if 0
......
/*
* Proview $Id: rt_io_m_ssab_di.c,v 1.3 2006-07-03 06:20:03 claes Exp $
* Proview $Id: rt_io_m_ssab_di.c,v 1.4 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -137,11 +137,13 @@ static pwr_tStatus IoCardRead (
io_sRackLocal *r_local = (io_sRackLocal *)(rp->Local);
pwr_tUInt16 data = 0;
pwr_sClass_Ssab_BaseDiCard *op;
pwr_sClass_Ssab_RemoteRack *rrp;
pwr_tUInt16 invmask;
pwr_tUInt16 convmask;
int i;
int sts;
qbus_io_read rb;
int bfb_error = 0;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseDiCard *) cp->op;
......@@ -171,13 +173,40 @@ static pwr_tStatus IoCardRead (
}
else {
/* Ethernet I/O, Get data from current address */
data = bfbeth_get_data(r_local, (pwr_tUInt16) local->Address[i]);
sts = 1;
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]);
if (sts == -1) {
/* Error handling for ethernet Qbus-I/O */
rrp = (pwr_sClass_Ssab_RemoteRack *) rp->op;
if (bfb_error == 0) {
op->ErrorCount++;
bfb_error = 1;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount == op->ErrorHardLimit)
errh_Error( "IO Error hard limit reached on card '%s', stall action %d", cp->Name, rrp->StallAction);
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_ResetInputs )
{
data = 0;
sts = 1;
}
if ( op->ErrorCount >= op->ErrorHardLimit && rrp->StallAction == pwr_eSsabStallAction_EmergencyBreak )
{
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
}
if (sts == -1) continue;
}
else {
op->ErrorCount = 0;
}
}
if ( sts == -1)
/* Error handling for local Qbus-I/O */
{
/* Increase error count and check error limits */
op->ErrorCount++;
......
/*
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.4 2006-06-02 07:14:29 claes Exp $
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.5 2006-09-05 12:03:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -99,6 +99,33 @@ static pwr_tStatus IoRackInit (
op->RX_packets = 0;
op->TX_packets = 0;
/*
cardp = rp->cardlist;
while(cardp) {
cid = cardp->Class;
while ( ODD( gdh_GetSuperClass( cid, &cid, cardp->Objid))) ;
switch (cid) {
case pwr_cClass_Ssab_BaseAiCard:
base_ai_card = (pwr_sClass_Ssab_BaseAiCard *) cardp->op;
break;
cardp = cardp->next;
}
local->next_read_req_item = 0;
local->next_write_req_item = 0;
*/
// 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));
/* Log initialization */
errh_Info( "Init of IO remote rack %s/%s:%d",
......@@ -131,9 +158,14 @@ static pwr_tStatus IoRackRead (
struct bfb_buf rbuf;
int size;
bzero(&local->read_area, sizeof(local->read_area));
// Calc length and send write request
local->write_req.service = BFB_SERVICE_WRITE;
local->write_req.length = local->next_write_req_item*4 + 4;
sts = send(local->s, &local->write_req, local->write_req.length, 0);
op->TX_packets++;
local->next_write_req_item = 0;
bzero(&local->write_area, sizeof(local->write_area));
sts = 1;
while (sts > 0) {
FD_ZERO(&fds);
......@@ -168,20 +200,13 @@ static pwr_tStatus IoRackWrite (
io_sRackLocal *local = (io_sRackLocal *) rp->Local;
pwr_sClass_Ssab_RemoteRack *op = (pwr_sClass_Ssab_RemoteRack *) rp->op;
// Calc length and send write request
local->write_req.service = BFB_SERVICE_WRITE;
local->write_req.length = local->next_write_req_item*4 + 4;
sts = send(local->s, &local->write_req, local->write_req.length, 0);
op->TX_packets++;
// 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;
local->next_write_req_item = 0;
bzero(&local->read_area, sizeof(local->read_area));
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