Skip to content

Commit fdfc415

Browse files
author
Scott Vincent
committed
Major release (64-bit)
1 parent e28dcf6 commit fdfc415

File tree

4 files changed

+48
-12
lines changed

4 files changed

+48
-12
lines changed

instrument-data-link/instrument-data-link.cpp

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,11 +973,26 @@ void processSwitchBox(int joyNum)
973973
case 17: simVars.sbMode = 1; break; // Autopilot
974974
case 18: simVars.sbMode = 2; break; // Radio
975975
case 19: simVars.sbMode = 3; break; // Instruments
976+
case 20: simVars.sbMode = 4; break; // Navigation
976977
}
977978
}
978979

979-
void processRequest()
980+
void processRequest(int bytes)
980981
{
982+
//// For testing only - Leave commented out
983+
//if (request.requestedSize == writeDataSize) {
984+
// if (request.writeData.eventId == KEY_SKYTRACK_STATE) {
985+
// printf("Received %d bytes from %s - Write Request eventId: SKYTRACK_STATE\n", bytes, inet_ntoa(senderAddr.sin_addr));
986+
// }
987+
// else {
988+
// printf("Received %d bytes from %s - Write Request eventId: %d\n", bytes, inet_ntoa(senderAddr.sin_addr), request.writeData.eventId);
989+
// }
990+
//}
991+
//else {
992+
// // To test you can send from client with this command: echo - e '\x1\x0\x0\x0' | ncat -u 192.168.1.143 52020
993+
// printf("Received %d bytes from %s - Requesting %d bytes\n", bytes, inet_ntoa(senderAddr.sin_addr), request.requestedSize);
994+
//}
995+
981996
if (request.requestedSize == writeDataSize) {
982997
// This is a write
983998
if (request.writeData.eventId == KEY_ENG_CRANK) {
@@ -1003,7 +1018,7 @@ void processRequest()
10031018

10041019
//// For testing only - Leave commented out
10051020
//if (request.writeData.eventId == KEY_CABIN_SEATBELTS_ALERT_SWITCH_TOGGLE) {
1006-
// request.writeData.eventId = KEY_COM2_VOLUME_SET;
1021+
// request.writeData.eventId = EVENT_RESET_DRONE_FOV;
10071022
// request.writeData.value = 0;
10081023
// printf("Intercepted event - Changed to: %d = %f\n", request.writeData.eventId, request.writeData.value);
10091024
//}
@@ -1114,6 +1129,10 @@ void processRequest()
11141129
}
11151130
return;
11161131
}
1132+
else if (request.writeData.eventId == EVENT_RESET_DRONE_FOV) {
1133+
writeJetbridgeVar(DRONE_CAMERA_FOV, 50);
1134+
return;
1135+
}
11171136

11181137
if (request.writeData.eventId == KEY_TOGGLE_RAMPTRUCK) {
11191138
printf("Ramp truck requested\n");
@@ -1193,7 +1212,7 @@ void processRequest()
11931212
}
11941213
else {
11951214
// Data size mismatch
1196-
bytes = sendto(sockfd, (char*)&instrumentsDataSize, sizeof(long), 0, (SOCKADDR*)&senderAddr, addrSize);
1215+
bytes = sendto(sockfd, (char*)&instrumentsDataSize, 4, 0, (SOCKADDR*)&senderAddr, addrSize);
11971216
#ifdef SHOW_NETWORK_USAGE
11981217
networkOut += bytes;
11991218
#endif
@@ -1251,13 +1270,26 @@ void server()
12511270
int sel = select(FD_SETSIZE, &fds, 0, 0, &timeout);
12521271
if (sel > 0) {
12531272
bytes = recvfrom(sockfd, (char*)&request, sizeof(request), 0, (SOCKADDR*)&senderAddr, &addrSize);
1273+
12541274
#ifdef SHOW_NETWORK_USAGE
12551275
networkIn += bytes;
12561276
#endif
1257-
if (bytes > 0) {
1258-
processRequest();
1277+
if (bytes > 3) {
1278+
processRequest(bytes);
12591279
}
12601280
else {
1281+
if (bytes == -1) {
1282+
int error = WSAGetLastError();
1283+
if (error == 10040) {
1284+
printf("Received more than %ld bytes from %s (WSAError = %d)\n", sizeof(request), inet_ntoa(senderAddr.sin_addr), error);
1285+
}
1286+
else {
1287+
printf("Received from %s but WSAError = %d\n", inet_ntoa(senderAddr.sin_addr), error);
1288+
}
1289+
}
1290+
else {
1291+
printf("Received %d bytes from %s - Not a valid request\n", bytes, inet_ntoa(senderAddr.sin_addr));
1292+
}
12611293
bytes = SOCKET_ERROR;
12621294
}
12631295
}

instrument-data-link/jetbridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "jetbridge\client.h"
1919

20+
const char DRONE_CAMERA_FOV[] = "A:DRONE CAMERA FOV, percent";
21+
2022
void jetbridgeInit(HANDLE hSimConnect);
2123

2224
void readJetbridgeVar(const char* var);

instrument-data-link/simvarDefs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdio.h>
22
#include "simvarDefs.h"
33

4-
const char* versionString = "v1.7.8";
4+
const char* versionString = "v2.0.0";
55

66
const char* SimVarDefs[][2] = {
77
// Vars for Jetbridge (must come first)
@@ -370,6 +370,7 @@ WriteEvent WriteEvents[] = {
370370
{ EVENT_GO_AROUND, "EVENT_GO_AROUND" },
371371
{ EVENT_IS_CESSNA_152, "EVENT_IS_CESSNA_152" },
372372
{ EVENT_NOT_CESSNA_152, "EVENT_NOT_CESSNA_152" },
373+
{ EVENT_RESET_DRONE_FOV, "EVENT_RESET_DRONE_FOV" },
373374
{ SWITCHBOX_JOY, "SWITCHBOX_JOY" },
374375
{ VJOY_BUTTONS, "VJOY_BUTTONS" },
375376
{ VJOY_BUTTON_1, "VJOY_BUTTON_1" },

instrument-data-link/simvarDefs.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ enum EVENT_ID {
228228
KEY_TOGGLE_FLIGHT_DIRECTOR,
229229
KEY_AP_SPD_VAR_SET,
230230
KEY_AP_MACH_VAR_SET,
231-
KEY_HEADING_BUG_SET,
231+
KEY_HEADING_BUG_SET, // 50
232232
KEY_AP_ALT_VAR_SET_ENGLISH,
233233
KEY_AP_VS_VAR_SET_ENGLISH,
234234
KEY_AP_AIRSPEED_ON,
@@ -276,7 +276,7 @@ enum EVENT_ID {
276276
KEY_TANK_SELECT_1,
277277
KEY_TANK_SELECT_2,
278278
KEY_ENG_CRANK,
279-
KEY_SKYTRACK_STATE,
279+
KEY_SKYTRACK_STATE, // 98
280280
KEY_G1000_PFD_SOFTKEY_1,
281281
KEY_G1000_PFD_SOFTKEY_2,
282282
KEY_G1000_PFD_SOFTKEY_3,
@@ -365,6 +365,7 @@ enum EVENT_ID {
365365
EVENT_GO_AROUND,
366366
EVENT_IS_CESSNA_152,
367367
EVENT_NOT_CESSNA_152,
368+
EVENT_RESET_DRONE_FOV,
368369
SWITCHBOX_JOY,
369370
VJOY_BUTTONS,
370371
// Buttons must start from 1 and must be sequential until VJOY_BUTTONS_END
@@ -404,18 +405,18 @@ struct PosData {
404405
};
405406

406407
struct Request {
407-
long requestedSize;
408-
long wantFullData;
408+
int requestedSize;
409+
int wantFullData;
409410
WriteData writeData;
410411
};
411412

412413
struct DeltaDouble {
413-
long offset;
414+
int offset;
414415
double data;
415416
};
416417

417418
struct DeltaString {
418-
long offset;
419+
int offset;
419420
char data[32];
420421
};
421422

0 commit comments

Comments
 (0)