Added support for the TEXT command to the C client.
This commit is contained in:
@@ -419,6 +419,20 @@ short sendpCTRL(struct xpcSocket recfd, short numArgs, float valueArray[], char
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short sendTEXT(struct xpcSocket sendfd, char* msg, int x, int y)
|
||||||
|
{
|
||||||
|
char buf[269] = { 0 };
|
||||||
|
size_t msgLen = strnlen(msg, 255);
|
||||||
|
size_t len = 14 + msgLen;
|
||||||
|
strcpy(buf, "TEXT");
|
||||||
|
memcpy(buf + 5, &x, sizeof(int));
|
||||||
|
memcpy(buf + 9, &y, sizeof(int));
|
||||||
|
buf[13] = msgLen;
|
||||||
|
strncpy(buf + 14, msg, msgLen);
|
||||||
|
|
||||||
|
sendUDP(sendfd, buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
//READ
|
//READ
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
short readUDP(struct xpcSocket recfd, char *dataRef, struct sockaddr *recvaddr)
|
short readUDP(struct xpcSocket recfd, char *dataRef, struct sockaddr *recvaddr)
|
||||||
|
|||||||
@@ -81,7 +81,11 @@
|
|||||||
short requestDREF(struct xpcSocket sendfd, struct xpcSocket recfd, char DREFArray[][100], short DREFSizes[], short listLength, float *resultArray[], short arraySizes[]);
|
short requestDREF(struct xpcSocket sendfd, struct xpcSocket recfd, char DREFArray[][100], short DREFSizes[], short listLength, float *resultArray[], short arraySizes[]);
|
||||||
int parseGETD(const char my_message[], char *DREFArray[], int DREFSizes[]);
|
int parseGETD(const char my_message[], char *DREFArray[], int DREFSizes[]);
|
||||||
short parseRequest(const char my_message[], float *resultArray[], short arraySizes[]);
|
short parseRequest(const char my_message[], float *resultArray[], short arraySizes[]);
|
||||||
short readRequest(struct xpcSocket recfd, float *dataRef[], short arraySizes[], struct sockaddr *recvaddr);
|
short readRequest(struct xpcSocket recfd, float *dataRef[], short arraySizes[], struct sockaddr *recvaddr);
|
||||||
|
|
||||||
|
// Screen Text
|
||||||
|
short sendTEXT(struct xpcSocket sendfd, int x, int y, char* msg);
|
||||||
|
|
||||||
|
|
||||||
#endif //ifdef _h
|
#endif //ifdef _h
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,25 @@ short sendReadTest() // send/read Test
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short sendTEXTTest()
|
||||||
|
{
|
||||||
|
printf("sendTEXT - ");
|
||||||
|
|
||||||
|
// Setup
|
||||||
|
struct xpcSocket sendPort = openUDP(49064, "127.0.0.1", 49009);
|
||||||
|
int x = 100;
|
||||||
|
int y = 700;
|
||||||
|
char* msg = "XPlaneConnect test message. Now with 100% fewer new lines!";
|
||||||
|
|
||||||
|
// Test
|
||||||
|
sendTEXT(sendPort, msg, x, y);
|
||||||
|
// NOTE: Manually verify that msg appears on the screen in X-Plane!
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
closeUDP(sendPort);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
short requestDREFTest() // Request DREF Test (Required for next tests)
|
short requestDREFTest() // Request DREF Test (Required for next tests)
|
||||||
{
|
{
|
||||||
printf("requestDREF - ");
|
printf("requestDREF - ");
|
||||||
@@ -542,15 +561,16 @@ int main(int argc, const char * argv[])
|
|||||||
|
|
||||||
runTest(openTest);
|
runTest(openTest);
|
||||||
runTest(closeTest);
|
runTest(closeTest);
|
||||||
runTest(sendReadTest);
|
runTest(sendReadTest);
|
||||||
|
runTest(sendTEXTTest);
|
||||||
runTest(requestDREFTest);
|
runTest(requestDREFTest);
|
||||||
runTest(sendDREFTest);
|
runTest(sendDREFTest);
|
||||||
runTest(sendDATATest);
|
runTest(sendDATATest);
|
||||||
runTest(sendCTRLTest);
|
runTest(sendCTRLTest);
|
||||||
runTest(sendpCTRLTest);
|
runTest(sendpCTRLTest);
|
||||||
runTest(sendPOSITest);
|
runTest(sendPOSITest);
|
||||||
runTest(pauseTest);
|
runTest(pauseTest);
|
||||||
runTest(connTest);
|
runTest(connTest);
|
||||||
|
|
||||||
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );
|
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user