Skip to content
Snippets Groups Projects

awgtpman: client interface will now detect and use older RPC interfaces

Merged Erik von Reis requested to merge erik.vonreis/advligorts:awg_backwards_compat into master
3 files
+ 222
2
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 148
2
@@ -10,6 +10,7 @@
#include "dtt/gdserr.h"
#include "dtt/gdserrmsg.h"
#include "tconv.h"
#include "testpoint_interface_v3.h"
#if defined (_CONFIG_DYNAMIC)
#include "confinfo.h"
@@ -43,6 +44,7 @@ static int tp_init = 0;
static tpNode_t tpNode[TP_MAX_NODE];
static int tpNum = 0;
/*----------------------------------------------------------------------*/
/* */
/* Internal Procedure Name: tpSetHostAddress */
@@ -597,8 +599,11 @@ int tpQuery (int node, int tpinterface, testpoint_t tp[], int tplen,
return -2;
}
int max_interface = (testAwgTpInterfaceVersion(node) > 3)
? TP_MAX_INTERFACE : TP_MAX_INTERFACE_V3;
/* check interface */
if ((tpinterface < 0) || (tpinterface >= TP_MAX_INTERFACE)) {
if ((tpinterface < 0) || (tpinterface >= max_interface)) {
return -2;
}
@@ -678,7 +683,77 @@ static char* cmdreply (const char* m)
/* Procedure Returns: void */
/* */
/*----------------------------------------------------------------------*/
static void queryCmd (char* buf, int node)
static void queryCmd_v3 (char* buf, int node)
{
int i;
char* p;
testpoint_t tp[TP_MAX_INDEX]; /* test points */
int num; /* number of test points */
sprintf (buf, "Test points for node %i\n", node);
/* query lsc exc */
num = tpQuery (node, TP_LSC_EX_INTERFACE, tp,
TP_MAX_INDEX, 0, 0);
p = strend (buf);
sprintf (p, "LSC EX:");
p = strend (p);
if (num < 0) {
sprintf (p, " invalid\n");
return;
}
for (i = 0; i < num; i++) {
sprintf (p, " %i", tp[i]);
p = strend (p);
}
sprintf (p++, "\n");
/* query lsc tp */
num = tpQuery (node, TP_LSC_TP_INTERFACE, tp,
TP_MAX_INDEX, 0, 0);
p = strend (buf);
sprintf (p, "LSC TP:");
p = strend (p);
if (num < 0) {
sprintf (p, " invalid\n");
return;
}
for (i = 0; i < num; i++) {
sprintf (p, " %i", tp[i]);
p = strend (p);
}
sprintf (p++, "\n");
/* query asc exc */
num = tpQuery (node, TP_ASC_EX_INTERFACE, tp,
TP_MAX_INDEX, 0, 0);
p = strend (buf);
sprintf (p, "ASC EX:");
p = strend (p);
if (num < 0) {
sprintf (p, " invalid\n");
return;
}
for (i = 0; i < num; i++) {
sprintf (p, " %i", tp[i]);
p = strend (p);
}
sprintf (p++, "\n");
/* query asc tp */
num = tpQuery (node, TP_ASC_TP_INTERFACE, tp,
TP_MAX_INDEX, 0, 0);
p = strend (buf);
sprintf (p, "ASC TP:");
p = strend (p);
if (num < 0) {
sprintf (p, " invalid\n");
return;
}
for (i = 0; i < num; i++) {
sprintf (p, " %i", tp[i]);
p = strend (p);
}
sprintf (p++, "\n");
}
static void queryCmd_v4 (char* buf, int node)
{
int i;
char* p;
@@ -718,6 +793,23 @@ static void queryCmd (char* buf, int node)
sprintf (p++, "\n");
}
static void queryCmd (char* buf, int node)
{
int interface_version = testAwgTpInterfaceVersion(node);
switch (interface_version)
{
case 3:
queryCmd_v3(buf, node);
break;
case 4:
queryCmd_v4(buf, node);
break;
default:
printf("unrecognized awgtp interface version %d\n", interface_version);
break;
}
}
/*----------------------------------------------------------------------*/
/* */
@@ -963,3 +1055,57 @@ int keepAlive (int node)
clnt_destroy (clnt);
return ret;
}
/// Find RPC interface version used by awgtpman
/// version 4 was introduced about RCG version 4.1.0
/// all previous interface versions, including for RCG 4.0.1,
/// are considered version 3.
/// Version 4 has only two testpoint interfaces: one for excitations and one for
/// other test points.
/// Version 3 has 4 testpoint interfaces: the two interfaces of version 4 are
/// divided between LSC and ASC test points.
///
/// \param node the node number to identify
/// \return the version number, 0 on error
int testAwgTpInterfaceVersion(int node)
{
// memoize
static int node_version[ TP_MAX_NODE ];
if ( node_version[ node ] )
{
return node_version[ node ];
}
testpoint_t tp[ 128 ];
resultQueryTP_r result;
memset (&result, 0, sizeof (resultQueryTP_r));
int chk = testpoint_client( );
if (chk < 0) {
printf("testAwgTpInterfaceVersion: testpoint_client() failed with return code %d\n", chk);
return 0;
}
CLIENT * clnt = tpMakeHandle (node);
if(clnt == NULL)
{
return 0;
}
if ((querytp_1 (tpNode[node].id, node, TP_ASC_TP_INTERFACE, 128, 0,
0, &result, clnt) == RPC_SUCCESS) && (result.status >= 0)) {
printf("found version 3 or older test point interface\n");
node_version[node] = 3;
}
else
{
printf("found version 4 or newer test point interface\n");
node_version[node] = 4;
}
clnt_destroy (clnt);
return node_version[node];
}
\ No newline at end of file
Loading