Mohammad Sufyan Palwala Posted July 10, 2018 Report Share Posted July 10, 2018 (edited) I am getting some problems in my Main.cpp file, I have attached my whole fime, if someone could help me out, it would be really appreciated. Here's mu main.cpp file : #include "mainwindow.h" #include <QApplication> #include <QDebug> #include <windows.h> #include <conio.h> #include <stdio.h> #include <string.h> #include <math.h> // Universal data #include "universal.h" // FS interface #include "FSinterface.h" #include "FSUIPC_User.h" // for setting the timer #include "timer.h" // for Serial RS232 #include "tserial.h" #include"universal.h" #include "types.h" const char *pszErrors[] = { "Okay", "Attempt to Open when already Open", "Cannot link to FSUIPC or WideClient", "Failed to Register common message with Windows", "Failed to create Atom for mapping filename", "Failed to create a file mapping object", "Failed to open a view to the file map", "Incorrect version of FSUIPC, or not FSUIPC", "Sim is not version requested", "Call cannot execute, link not Open", "Call cannot execute: no requests accumulated", "IPC timed out all retries", "IPC sendmessage failed all retries", "IPC request contains bad data", "Maybe running on WideClient, but FS not running on Server, or wrong FSUIPC", "Read or Write request cannot be added, memory for Process is full", }; char buffer_fsupc[25000]; char buffer_reception[12]; char bufftx[40]; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; double Attitude[NROT]; FSAttitudeType FSAtt; DWORD dwResult;// a pointer to receive an error number if the operation fails. Tserial *com; // Serial declaration int SampleTime; // Sample Time in ms Timer timer; int capsam=0; int pousseeL, pousseeR; int pousseeOldL = 0, pousseeOldR = 0; char car; int vret,index=0; int oktrame=0; int pousseeTmp; char x[]=" \\\\.\\com3"; if(FSUIPC_Open(SIM_ANY,&dwResult)){ // Declaration des variables locales const char *pFS[] = { "FS98", "FS2000", "CFS2", "CFS1", "Fly!", "FS2002", "FS2004" }; // Change made 060603 // Okay, we're linked, and already the FSUIPC_Open has had an initial // exchange with FSUIPC to get its version number and to differentiate // between FS's. printf ("CapSim: Link established to FSUIPC\n") ; // printf ("Sim is %s,FSUIPC Version = %c.%c%c%c%c\r%s\n",(FSUIPC_FS_Version && (FSUIPC_FS_Version <= 7)) ? pFS[FSUIPC_FS_Version - 1] : "Unknown FS",'0' + (0x0f & (FSUIPC_Version >> 28)),'0' + (0x0f & (FSUIPC_Version >> 24)),'0' + (0x0f & (FSUIPC_Version >> 20)),'0' + (0x0f & (FSUIPC_Version >> 16)),(FSUIPC_Version & 0xffff) ? 'a' + (FSUIPC_Version & 0xff) - 1 : ' '); /* ///////////////////////////// une autre maniere de faire ///////////////////////////// */ // Timer //printf("\nEnter the Sample Time in miliseconde\n"); //scanf("%d",&SampleTime); SampleTime=100; // RS232 com=new Tserial(); if( com!=0 ) com->connect (x,9600,spNONE); // com Initialisation else printf("Error Setting COM"); }else{ //Openninig FSUIPC failed printf ("CapSim: Failed to open link to FSUIPC:%s\n", pszErrors[dwResult]) ; FSUIPC_Close(); // Closing when it wasn't open is okay, so this is safe here // com->disconnect(); // Closing the port return 0; } while(true) { Sleep(40); //if(timer.elasped((clock_t)SampleTime)) if(1){ /* -------------------------------------- Sending Data -------------------------------------- */ // Read from FS data structure FSUIPC_Read(0x000,25000,buffer_fsupc,&dwResult); FSUIPC_Process(&dwResult); // Process all the request(s) // sprintf(bufftx,"%4u %3u %6u %3u",*((unsigned int*)(buffer_fsupc+0x2BC))/128,(unsigned int)(*((double*)(buffer_fsupc+0x2CC))), // (unsigned int)floor((double)(((unsigned int)*((__int64 *)(buffer_fsupc+0x570))*(double)3.2808)/((double)65536.)+0.5)),0); /*(unsigned int)floor(((unsigned int)*((unsigned short int*)(buffer_fsupc+0xcc))*360.)/65536.+0.5),(unsigned int)*((unsigned short int*)(buffer_fsupc+0xe2)), (unsigned int)floor((double)(((unsigned int)*((unsigned int*)(buffer_fsupc+0xd4))*3.2808)/65536.+0.5)));*/ /* sprintf(bufftx,"%6u %01u %01u\n", *((unsigned short*)(buffer_fsupc+0x5682))&0xffff, *((unsigned char*)(buffer_fsupc+ 0x568A))&0xff, *((unsigned char*)(buffer_fsupc+ 0x568E))&0xff); printf("%s\n",bufftx);*/ if(_kbhit()){ car=_getch(); switch(car) { case ui->Alt : printf("To change Altitude turn the Dial"); capsam= (capsam*(65536./3.2808)); *((unsigned int*)buffer_fsupc)= capsam; FSUIPC_Write(0x7D4,4,buffer_fsupc,&dwResult); FSUIPC_Process(&dwResult); break; case ui-> Spd: printf("To change Speed turn the Dial:"); scanf("%u",&capsam); capsam = (capsam*16384)/100; *((unsigned int*)buffer_fsupc)= (unsigned short int) capsam; FSUIPC_Write(0x88C,2,buffer_fsupc,&dwResult); FSUIPC_Process(&dwResult); break; case ui-> Hdg : printf("To Change Heading , turn the Dial"); scanf("%u",&capsam); capsam= (capsam*65536)/36; capsam += ((capsam%10)>=5 ? 10 : 0); capsam= capsam/10; *((unsigned short int*)buffer_fsupc)= (unsigned short int )capsam; FSUIPC_Write(0x7CC,2,buffer_fsupc,&dwResult); FSUIPC_Process(&dwResult); // Process all th break; }} w.show(); return a.exec(); } } } The errors I am getting are these: Tserial: undeclared variable. line 59 com : undeclared variable. line 91,93, syntax error; identifier ' Tserial'. Ui undeclared variable., Alt undeclared variable. mainwindow.cpp main.cpp fsinterface.cpp Edited July 10, 2018 by Mohammad Sufyan Palwala attach more attachments Link to comment Share on other sites More sharing options...
Thomas Richter Posted July 10, 2018 Report Share Posted July 10, 2018 Hi, why do you think there is a problem with FSUIPC? The errors you get are not linked to FSUIPC but the COM you try to open. Quote Tserial: undeclared variable. line 59 com : undeclared variable. line 91,93, syntax error; identifier ' Tserial'. Ui undeclared variable., Alt undeclared variable. Also it seems you used an very old SDK example, I would strongly recommend to use the latest SDK examples useful-additional-programs In addition you want to read a big amount of data into a structure per Process? I would only read what is needed. Quote // Read from FS data structure FSUIPC_Read(0x000,25000,buffer_fsupc,&dwResult); FSUIPC_Process(&dwResult); // Process all the request(s) Thomas Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now