Commit 828fbbeb authored by Claes Sjofors's avatar Claes Sjofors

remote_pvd_pwrcli updated to 4.4.4 version

parent 9402d6a0
......@@ -121,10 +121,14 @@ void remote_pvd_pwrcli::objectOid( co_procom *pcom, pwr_tOix oix)
sts = udp_Request( (char *)&msg, sizeof(msg), (char **)&rmsg);
if ( pvd_cLog) logg( "Reply", sts, "");
if ( EVEN(sts) || sts == REM__TIMEOUT) {
if ( EVEN(sts)) {
pcom->provideStatus( sts);
return;
}
if ( sts == REM__TIMEOUT) {
pcom->provideStatus( REM__UDPNOCON);
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......@@ -175,10 +179,14 @@ void remote_pvd_pwrcli::objectName( co_procom *pcom, char *name, pwr_tOix poix)
if ( pvd_cLog) logg( "ObjName", poix, name);
sts = udp_Request( (char *)&msg, sizeof(msg), (char **)&rmsg);
if ( EVEN(sts) || sts == REM__TIMEOUT) {
if ( EVEN(sts)) {
pcom->provideStatus( sts);
return;
}
if ( sts == REM__TIMEOUT) {
pcom->provideStatus( REM__UDPNOCON);
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......@@ -271,10 +279,15 @@ void remote_pvd_pwrcli::writeAttribute( co_procom *pcom, pwr_tOix oix,
if ( pvd_cLog) logg( "Write", aref.Objid.oix, aname);
sts = udp_Request( (char *)&msg, sizeof(msg), (char **)&rmsg);
if ( EVEN(sts) || sts == REM__TIMEOUT) {
if ( EVEN(sts)) {
pcom->provideStatus( sts);
return;
}
if ( sts == REM__TIMEOUT) {
pcom->provideStatus( REM__UDPNOCON);
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......@@ -329,10 +342,14 @@ void remote_pvd_pwrcli::readAttribute( co_procom *pcom, pwr_tOix oix,
sts = udp_Request( (char *)&msg, sizeof(msg), (char **)&rmsg);
if ( pvd_cLog) logg( "Reply", sts, "");
if ( EVEN(sts) || sts == REM__TIMEOUT) {
if ( EVEN(sts)) {
pcom->provideStatus( sts);
return;
}
if ( sts == REM__TIMEOUT) {
pcom->provideStatus( REM__UDPNOCON);
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......@@ -496,10 +513,14 @@ void remote_pvd_pwrcli::subAssociateBuffer( co_procom *pcom, void **buff, int oi
if ( pvd_cLog) logg( "AssoBuff", msg.Oid.oix, aname);
sts = udp_Request( (char *)&msg, sizeof(msg), (char **)&rmsg);
if ( EVEN(sts) || sts == REM__TIMEOUT) {
if ( EVEN(sts)) {
pcom->provideStatus( sts);
return;
}
if ( sts == REM__TIMEOUT) {
pcom->provideStatus( REM__UDPNOCON);
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......@@ -546,10 +567,14 @@ void remote_pvd_pwrcli::subDisassociateBuffer( co_procom *pcom, pwr_tSubid subid
if ( pvd_cLog) logg( "DisoBuff", subid.rix, "(rix)");
sts = udp_Request( (char *)&msg, sizeof(msg), (char **)&rmsg);
if ( EVEN(sts) || sts == REM__TIMEOUT) {
if ( EVEN(sts)) {
pcom->provideStatus( sts);
return;
}
if ( sts == REM__TIMEOUT) {
pcom->provideStatus( REM__UDPNOCON);
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......@@ -579,12 +604,19 @@ void remote_pvd_pwrcli::subRequest( co_procom *pcom)
msg.Type = rpvd_eMsg_SubRequest;
msg.Id = rpvd_id++;
for (;;) {
sts = udp_CheckLink();
if ( EVEN(sts)) return;
sts = udp_Send( (char *)&msg, sizeof(msg));
if ( EVEN(sts)) return;
sts = udp_Receive( (char **)&rmsg, 5000);
if ( EVEN(sts) || sts == REM__TIMEOUT)
sts = udp_Receive( (char **)&rmsg, 1000);
if ( EVEN(sts))
return;
if ( sts == REM__TIMEOUT) {
udp_LinkFailure();
return;
}
while ( rmsg->Id != msg.Id) {
dispatch( pcom, (rpvd_sMsg *)rmsg);
......
......@@ -29,6 +29,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include "co_time.h"
#include "rs_remote_msg.h"
#include "remote_pvd_udp.h"
......@@ -167,25 +168,56 @@ static int CreateSocket( udp_tCtx ctx)
return 1;
}
static pwr_tTime last_try = {0,0};
pwr_tStatus udp_CheckLink()
{
if ( !udp_ctx->LinkUp && last_try.tv_sec != 0) {
/* Don't try again within 20 seconds */
pwr_tTime current;
pwr_tDeltaTime diff;
time_GetTime( &current);
time_Adiff( &diff, &current, &last_try);
if ( time_DToFloat( 0, &diff) < 30) {
// printf( "Reqest Dismissed\n");
return REM__UDPNOCON;
}
}
return REM__SUCCESS;
}
void udp_LinkFailure()
{
time_GetTime( &last_try);
// printf( "Request timeout !!!!!!!!!!\n");
}
pwr_tStatus udp_Request( char *sendbuf, int sendbuf_size,
char **rcvbuf)
{
int i;
pwr_tStatus sts;
int tmo = 400;
int tmo = 200;
if (udp_ctx->Disable) return REM__DISABLED;
if ( udp_ctx->Disable) return REM__DISABLED;
sts = udp_CheckLink();
if ( EVEN(sts)) return sts;
for ( i = 0; i < 5; i++) {
for ( i = 0; i < 4; i++) {
sts = udp_Send( sendbuf, sendbuf_size);
if ( EVEN(sts)) return sts;
sts = udp_Receive( rcvbuf, tmo);
if ( sts != REM__TIMEOUT)
if ( sts != REM__TIMEOUT) {
udp_ctx->LinkUp = 1;
return sts;
}
tmo = tmo * 2;
}
udp_LinkFailure();
if ( udp_ctx->LinkUp) {
printf( "UDP link Down to node %s\n", udp_ctx->RemoteHostName);
udp_ctx->LinkUp = 0;
......@@ -202,7 +234,7 @@ pwr_tStatus udp_Send( char *buf, int buf_size)
char data[UDP_MAX_SIZE];
} message;
if (ctx->Disable) return REM__DISABLED;
if ( ctx->Disable) return REM__DISABLED;
message.header.protocol_id[0] = STX;
......
......@@ -98,7 +98,7 @@ typedef struct {
pwr_tOName Attribute;
int Size;
pwr_tTypeId Tid;
char Value[1000];
char Value[1200];
} rpvd_sMsgAttribute;
typedef struct {
......@@ -109,7 +109,7 @@ typedef struct {
pwr_tOName Attribute;
int Size;
pwr_tTypeId Tid;
char Value[1000];
char Value[1200];
} rpvd_sMsgWriteAttribute;
typedef struct {
......@@ -164,6 +164,8 @@ pwr_tStatus udp_Request( char *sendbuf, int sendbuf_size,
pwr_tStatus udp_Init( char *remote_address, char *remote_host_name, int port);
void udp_LinkFailure();
pwr_tStatus udp_CheckLink();
#if defined __cplusplus
}
......
......@@ -64,3 +64,4 @@ udpunknown <UDP message from unknown ip-address '%s' received> /info
udpweirdheader <UDP message with illegal header received> /info
disorder <Message disorder> /error
disabled <Transport disabled> /error
udpnocon <No UDP connection> /error
\ No newline at end of file
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