Commit bccc769f authored by Robert Karlsson's avatar Robert Karlsson

Fixed problem with profibus diagnostic messages handling

parent 07453054
...@@ -84,7 +84,8 @@ typedef struct { ...@@ -84,7 +84,8 @@ typedef struct {
int hDpsInputDataDevice; // Handle for DP-Slave Input-Data device int hDpsInputDataDevice; // Handle for DP-Slave Input-Data device
int hDpsOutputDataDevice; // Handle for DP-Slave Output-Data device int hDpsOutputDataDevice; // Handle for DP-Slave Output-Data device
unsigned char CurrentBoardNumber; unsigned char CurrentBoardNumber;
int slave_diag_requested; int slave_diag_requested; // Slave diag requested
int parallel_service; // parallel activity
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
pthread_t events; pthread_t events;
pthread_mutex_t mutex; pthread_mutex_t mutex;
...@@ -791,6 +792,14 @@ void *handle_events(void *ptr) { ...@@ -791,6 +792,14 @@ void *handle_events(void *ptr) {
else if (op->Status == PB__CLEARED) { else if (op->Status == PB__CLEARED) {
errh_Info( "Profibus DP Master %s to state OPERATE", ap->Name); errh_Info( "Profibus DP Master %s to state OPERATE", ap->Name);
op->Status = PB__NORMAL; op->Status = PB__NORMAL;
if (!local->slave_diag_requested && local->parallel_service) {
if (dp_get_slave_diag(hDevice)) {
local->slave_diag_requested = op->Diag[3] = PB_TRUE;
local->parallel_service = PB_FALSE;
}
}
} }
break; break;
...@@ -905,11 +914,15 @@ void *handle_events(void *ptr) { ...@@ -905,11 +914,15 @@ void *handle_events(void *ptr) {
if ( (get_slave_diag_con_ptr->diag_entries) && if ( (get_slave_diag_con_ptr->diag_entries) &&
(! local->slave_diag_requested ) ) { (! local->slave_diag_requested ) ) {
if (op->Status == PB__NORMAL) {
if (dp_get_slave_diag(hDevice)) { if (dp_get_slave_diag(hDevice)) {
local->slave_diag_requested = op->Diag[3] = PB_TRUE; local->slave_diag_requested = op->Diag[3] = PB_TRUE;
} else { } else {
errh_Warning( "Profibus - Request for diag failed."); errh_Warning( "Profibus - Request for diag failed.");
} }
} else {
local->parallel_service = PB_TRUE;
}
} }
break; break;
...@@ -1121,21 +1134,6 @@ static pwr_tStatus IoAgentInit ( ...@@ -1121,21 +1134,6 @@ static pwr_tStatus IoAgentInit (
return IO__ERRINIDEVICE; return IO__ERRINIDEVICE;
} }
} */ } */
/* Active supervision thread */
pthread_attr_t attr;
pthread_mutexattr_t mutexattr;
local->args.local = local;
local->args.ap = ap;
pthread_mutexattr_init(&mutexattr);
pthread_mutex_init(&local->mutex, &mutexattr);
pthread_mutexattr_destroy(&mutexattr);
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
pthread_create(&local->events, &attr, handle_events, &local->args);
} }
else else
op->Status = PB__DISABLED; op->Status = PB__DISABLED;
...@@ -1217,6 +1215,24 @@ static pwr_tStatus IoAgentRead ( ...@@ -1217,6 +1215,24 @@ static pwr_tStatus IoAgentRead (
local = (io_sAgentLocal *) ap->Local; local = (io_sAgentLocal *) ap->Local;
op = (pwr_sClass_Pb_Profiboard *) ap->op; op = (pwr_sClass_Pb_Profiboard *) ap->op;
/* Activate supervision thread, first cycle */
if (!local->args.local) {
pthread_attr_t attr;
pthread_mutexattr_t mutexattr;
local->args.local = local;
local->args.ap = ap;
pthread_mutexattr_init(&mutexattr);
pthread_mutex_init(&local->mutex, &mutexattr);
pthread_mutexattr_destroy(&mutexattr);
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
pthread_create(&local->events, &attr, handle_events, &local->args);
}
pthread_mutex_lock(&local->mutex); pthread_mutex_lock(&local->mutex);
/* Iterate over the slaves. */ /* Iterate over the slaves. */
......
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