@@ -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 }
0 commit comments