Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CInternetSession Debug assertation error

CInternetSession Debug assertation error

Scheduled Pinned Locked Moved C / C++ / MFC
databasec++debugginghelp
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    biggsy14
    wrote on last edited by
    #1

    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";

    D M 2 Replies Last reply
    0
    • B biggsy14

      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";

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • D David Crow

        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

        B Offline
        B Offline
        biggsy14
        wrote on last edited by
        #3

        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?

        D 1 Reply Last reply
        0
        • B biggsy14

          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?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • B biggsy14

            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";

            M Offline
            M Offline
            mahade1
            wrote on last edited by
            #5

            Hi, Just initialize the CInternetSession Variable with a name. For example, CInternetSession x("MY APPLICATION"); That should solve your problem. Regards, Mahadevan.

            B 1 Reply Last reply
            0
            • M mahade1

              Hi, Just initialize the CInternetSession Variable with a name. For example, CInternetSession x("MY APPLICATION"); That should solve your problem. Regards, Mahadevan.

              B Offline
              B Offline
              biggsy14
              wrote on last edited by
              #6

              Thanks Mahadevan, that seemed to sort it. Much appreciated!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups