CInternetSession Debug assertation error
-
Hey people, I'm developing an application that gets SMS's from a GSM modem and uploads them to a DB. To do this i'm using a CInternetSession object. The app compiles OK but I get a Debug Assertation Error!. I think it has something to do with the internet session object because if I comment out anything to to with the CInternetSession then i don't get the debug error. Infact, simply the 'CInternetSession InternetSession;' declaration at the beginning causes the error alone. Here's the code. sorry about the spaghetti style code - i'm a bit of a newbie to C++
#include <stdio.h> #include <afxinet.h> //#include "StdAfx.h" #include "Serial.h" #define EVER ;; //my thread functions static DWORD listenThread_id; static DWORD WINAPI listenThread(LPVOID ref); char * command = "AT+CMGR=3\n"; char * delcommand = "AT+CMGD=1\n"; int count = 0; bool appRunning; bool sendComm, delComm, sendToDB = false; CString st; CInternetSession InternetSession; void main() { appRunning = true; printf("Application Started. Press q to Quit. \n\n"); printf("Please enter a command. \n\n"); printf("Press r to read\n\n"); if (CreateThread(NULL, 0, listenThread, NULL, 0, &listenThread_id) == NULL) { exit(-1); } while (appRunning) { char inChar = getchar(); if (inChar == 'q') appRunning = false; if (inChar == 'r') sendComm = true; if (inChar == 's') sendToDB = true; if (inChar == 'd') delComm = true; } } static DWORD WINAPI listenThread(LPVOID ref) { CSerial Serial; int port=1, baud=115200; char lpBuffer[100]; if (Serial.Open(port, baud)) { for (EVER) { if (sendComm) { int commLength = strlen(command); Serial.SendData(command, commLength); sendComm=false; } if (delComm) { int commLength = strlen(delcommand); Serial.SendData(delcommand, commLength); delComm=false; } while (Serial.ReadDataWaiting() > 0) { int nBytesRead = Serial.ReadData(lpBuffer, 100); for (int i=0; i<nBytesRead; i++) { printf("%c", lpBuffer[i]); st += lpBuffer[i]; int newMsg = st.Find("+CMTI: \"SM\","); if (newMsg != -1) // Message rec'd { count++; if (count == 2 && lpBuffer[i] != '1') // then the index has been added to the string st { switch(lpBuffer[i]) { case '2': command = "AT+CMGR=2\n"; delcommand = "AT+CMGD=2\n"; break; case '3': command = "AT+CMGR=3\n";
-
Hey people, I'm developing an application that gets SMS's from a GSM modem and uploads them to a DB. To do this i'm using a CInternetSession object. The app compiles OK but I get a Debug Assertation Error!. I think it has something to do with the internet session object because if I comment out anything to to with the CInternetSession then i don't get the debug error. Infact, simply the 'CInternetSession InternetSession;' declaration at the beginning causes the error alone. Here's the code. sorry about the spaghetti style code - i'm a bit of a newbie to C++
#include <stdio.h> #include <afxinet.h> //#include "StdAfx.h" #include "Serial.h" #define EVER ;; //my thread functions static DWORD listenThread_id; static DWORD WINAPI listenThread(LPVOID ref); char * command = "AT+CMGR=3\n"; char * delcommand = "AT+CMGD=1\n"; int count = 0; bool appRunning; bool sendComm, delComm, sendToDB = false; CString st; CInternetSession InternetSession; void main() { appRunning = true; printf("Application Started. Press q to Quit. \n\n"); printf("Please enter a command. \n\n"); printf("Press r to read\n\n"); if (CreateThread(NULL, 0, listenThread, NULL, 0, &listenThread_id) == NULL) { exit(-1); } while (appRunning) { char inChar = getchar(); if (inChar == 'q') appRunning = false; if (inChar == 'r') sendComm = true; if (inChar == 's') sendToDB = true; if (inChar == 'd') delComm = true; } } static DWORD WINAPI listenThread(LPVOID ref) { CSerial Serial; int port=1, baud=115200; char lpBuffer[100]; if (Serial.Open(port, baud)) { for (EVER) { if (sendComm) { int commLength = strlen(command); Serial.SendData(command, commLength); sendComm=false; } if (delComm) { int commLength = strlen(delcommand); Serial.SendData(delcommand, commLength); delComm=false; } while (Serial.ReadDataWaiting() > 0) { int nBytesRead = Serial.ReadData(lpBuffer, 100); for (int i=0; i<nBytesRead; i++) { printf("%c", lpBuffer[i]); st += lpBuffer[i]; int newMsg = st.Find("+CMTI: \"SM\","); if (newMsg != -1) // Message rec'd { count++; if (count == 2 && lpBuffer[i] != '1') // then the index has been added to the string st { switch(lpBuffer[i]) { case '2': command = "AT+CMGR=2\n"; delcommand = "AT+CMGD=2\n"; break; case '3': command = "AT+CMGR=3\n";
biggsy14 wrote: ...I get a Debug Assertation Error!. When the assertion fires, it tells you the line number and file of the offending statement. That should give you a big hint.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
biggsy14 wrote: ...I get a Debug Assertation Error!. When the assertion fires, it tells you the line number and file of the offending statement. That should give you a big hint.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
Thanks David, I looked at that and it refers to line 31 of some MFC file. When i press retry on the debug assertation window it refers to getAfxAppName() at line 31 of that file with a yellow arrow in the call stack window. Also in the call stack window is a green arrow referring to line 22 of the code that i posted which is the 'CInternetSession InternetSession;' declaration, and refers to a $E4() method. There is also a window that comes up showing an 'Unhandled Exception' which i'm guessing is what the $E4() is. Any ideas on what to do with this exception?
-
Thanks David, I looked at that and it refers to line 31 of some MFC file. When i press retry on the debug assertation window it refers to getAfxAppName() at line 31 of that file with a yellow arrow in the call stack window. Also in the call stack window is a green arrow referring to line 22 of the code that i posted which is the 'CInternetSession InternetSession;' declaration, and refers to a $E4() method. There is also a window that comes up showing an 'Unhandled Exception' which i'm guessing is what the $E4() is. Any ideas on what to do with this exception?
biggsy14 wrote: I looked at that and it refers to line 31 of some MFC file. It would help to also know the name of the file. Are you using Visual Studio v6 or .Net?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
Hey people, I'm developing an application that gets SMS's from a GSM modem and uploads them to a DB. To do this i'm using a CInternetSession object. The app compiles OK but I get a Debug Assertation Error!. I think it has something to do with the internet session object because if I comment out anything to to with the CInternetSession then i don't get the debug error. Infact, simply the 'CInternetSession InternetSession;' declaration at the beginning causes the error alone. Here's the code. sorry about the spaghetti style code - i'm a bit of a newbie to C++
#include <stdio.h> #include <afxinet.h> //#include "StdAfx.h" #include "Serial.h" #define EVER ;; //my thread functions static DWORD listenThread_id; static DWORD WINAPI listenThread(LPVOID ref); char * command = "AT+CMGR=3\n"; char * delcommand = "AT+CMGD=1\n"; int count = 0; bool appRunning; bool sendComm, delComm, sendToDB = false; CString st; CInternetSession InternetSession; void main() { appRunning = true; printf("Application Started. Press q to Quit. \n\n"); printf("Please enter a command. \n\n"); printf("Press r to read\n\n"); if (CreateThread(NULL, 0, listenThread, NULL, 0, &listenThread_id) == NULL) { exit(-1); } while (appRunning) { char inChar = getchar(); if (inChar == 'q') appRunning = false; if (inChar == 'r') sendComm = true; if (inChar == 's') sendToDB = true; if (inChar == 'd') delComm = true; } } static DWORD WINAPI listenThread(LPVOID ref) { CSerial Serial; int port=1, baud=115200; char lpBuffer[100]; if (Serial.Open(port, baud)) { for (EVER) { if (sendComm) { int commLength = strlen(command); Serial.SendData(command, commLength); sendComm=false; } if (delComm) { int commLength = strlen(delcommand); Serial.SendData(delcommand, commLength); delComm=false; } while (Serial.ReadDataWaiting() > 0) { int nBytesRead = Serial.ReadData(lpBuffer, 100); for (int i=0; i<nBytesRead; i++) { printf("%c", lpBuffer[i]); st += lpBuffer[i]; int newMsg = st.Find("+CMTI: \"SM\","); if (newMsg != -1) // Message rec'd { count++; if (count == 2 && lpBuffer[i] != '1') // then the index has been added to the string st { switch(lpBuffer[i]) { case '2': command = "AT+CMGR=2\n"; delcommand = "AT+CMGD=2\n"; break; case '3': command = "AT+CMGR=3\n";
-
Hi, Just initialize the CInternetSession Variable with a name. For example, CInternetSession x("MY APPLICATION"); That should solve your problem. Regards, Mahadevan.