@@ -58,8 +58,6 @@ int sendUDP(XPCSocket sock, char buffer[], int len);
|
|||||||
int readUDP(XPCSocket sock, char buffer[], int len);
|
int readUDP(XPCSocket sock, char buffer[], int len);
|
||||||
int sendDREFRequest(XPCSocket sock, const char* drefs[], unsigned char count);
|
int sendDREFRequest(XPCSocket sock, const char* drefs[], unsigned char count);
|
||||||
int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int sizes[]);
|
int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int sizes[]);
|
||||||
int sendTERRRequest(XPCSocket sock, double posi[3], char ac);
|
|
||||||
int getTERRResponse(XPCSocket sock, double values[11], char ac);
|
|
||||||
|
|
||||||
void printError(char *functionName, char *format, ...)
|
void printError(char *functionName, char *format, ...)
|
||||||
{
|
{
|
||||||
@@ -609,8 +607,8 @@ int sendPOSI(XPCSocket sock, double values[], int size, char ac)
|
|||||||
char buffer[46] = "POSI";
|
char buffer[46] = "POSI";
|
||||||
buffer[4] = 0xff; //Placeholder for message length
|
buffer[4] = 0xff; //Placeholder for message length
|
||||||
buffer[5] = ac;
|
buffer[5] = ac;
|
||||||
|
|
||||||
int i; // iterator
|
int i; // iterator
|
||||||
|
|
||||||
for (i = 0; i < 7; i++) // double for lat/lon/h
|
for (i = 0; i < 7; i++) // double for lat/lon/h
|
||||||
{
|
{
|
||||||
double val = -998;
|
double val = -998;
|
||||||
@@ -642,83 +640,6 @@ int sendPOSI(XPCSocket sock, double values[], int size, char ac)
|
|||||||
/**** End POSI functions ****/
|
/**** End POSI functions ****/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**** TERR functions ****/
|
|
||||||
/*****************************************************************************/
|
|
||||||
int sendTERRRequest(XPCSocket sock, double posi[3], char ac)
|
|
||||||
{
|
|
||||||
// Setup send command
|
|
||||||
char buffer[30] = "GETT";
|
|
||||||
buffer[5] = ac;
|
|
||||||
memcpy(&buffer[6], posi, 3 * sizeof(double));
|
|
||||||
|
|
||||||
// Send command
|
|
||||||
if (sendUDP(sock, buffer, 30) < 0)
|
|
||||||
{
|
|
||||||
printError("getTERR", "Failed to send command.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getTERRResponse(XPCSocket sock, double values[11], char ac)
|
|
||||||
{
|
|
||||||
// Get response
|
|
||||||
char readBuffer[62];
|
|
||||||
int readResult = readUDP(sock, readBuffer, 62);
|
|
||||||
if (readResult < 0)
|
|
||||||
{
|
|
||||||
printError("getTERR", "Failed to read response.");
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (readResult != 62)
|
|
||||||
{
|
|
||||||
printError("getTERR", "Unexpected response length.");
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy response into outputs
|
|
||||||
float f[8];
|
|
||||||
ac = readBuffer[5];
|
|
||||||
memcpy(values, readBuffer + 6, 3 * sizeof(double));
|
|
||||||
memcpy(f, readBuffer + 30, 8 * sizeof(float));
|
|
||||||
values[ 3] = (double)f[0];
|
|
||||||
values[ 4] = (double)f[1];
|
|
||||||
values[ 5] = (double)f[2];
|
|
||||||
values[ 6] = (double)f[3];
|
|
||||||
values[ 7] = (double)f[4];
|
|
||||||
values[ 8] = (double)f[5];
|
|
||||||
values[ 9] = (double)f[6];
|
|
||||||
values[10] = (double)f[7];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getTERR(XPCSocket sock, double posi[3], double values[11], char ac)
|
|
||||||
{
|
|
||||||
// Send Command
|
|
||||||
int result = sendTERRRequest(sock, posi, ac);
|
|
||||||
if (result < 0)
|
|
||||||
{
|
|
||||||
// An error ocurred while sending.
|
|
||||||
// sendTERRRequest will print an error message, so just return.
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read Response
|
|
||||||
result = getTERRResponse(sock, values, ac);
|
|
||||||
if (result < 0)
|
|
||||||
{
|
|
||||||
// An error ocurred while reading the response.
|
|
||||||
// getTERRResponse will print an error message, so just return.
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**** End TERR functions ****/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**** CTRL functions ****/
|
/**** CTRL functions ****/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user