Click here to Skip to main content
15,912,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralEdit Version Info Properties Tab Pin
pjobson12-Aug-04 5:20
pjobson12-Aug-04 5:20 
GeneralRe: Edit Version Info Properties Tab Pin
David Crow12-Aug-04 5:58
David Crow12-Aug-04 5:58 
GeneralRe: Edit Version Info Properties Tab Pin
pjobson12-Aug-04 8:43
pjobson12-Aug-04 8:43 
GeneralRe: Edit Version Info Properties Tab Pin
David Crow12-Aug-04 8:51
David Crow12-Aug-04 8:51 
GeneralRe: Edit Version Info Properties Tab Pin
pjobson12-Aug-04 10:20
pjobson12-Aug-04 10:20 
GeneralRe: Edit Version Info Properties Tab Pin
tlerner12-Aug-04 10:36
tlerner12-Aug-04 10:36 
Generalerfc in c++ Pin
chepah12-Aug-04 5:18
chepah12-Aug-04 5:18 
GeneralCInternetSession Debug assertation error Pin
biggsy1412-Aug-04 3:06
biggsy1412-Aug-04 3:06 
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++

<br />
#include <stdio.h><br />
#include <afxinet.h><br />
//#include "StdAfx.h"<br />
#include "Serial.h"<br />
<br />
#define EVER ;;<br />
<br />
//my thread functions<br />
static DWORD listenThread_id;<br />
static DWORD WINAPI listenThread(LPVOID ref);<br />
<br />
<br />
char * command = "AT+CMGR=3\n";<br />
char * delcommand = "AT+CMGD=1\n";<br />
<br />
int count = 0;<br />
<br />
bool appRunning;<br />
bool sendComm, delComm, sendToDB = false;<br />
<br />
CString st;<br />
CInternetSession InternetSession;<br />
<br />
void main()<br />
{<br />
	appRunning = true;<br />
	<br />
	printf("Application Started. Press q to Quit. \n\n");<br />
<br />
	printf("Please enter a command. \n\n");<br />
<br />
	printf("Press r to read\n\n");<br />
<br />
	if (CreateThread(NULL, 0, listenThread, NULL, 0, &listenThread_id) == NULL)<br />
	{<br />
		exit(-1);<br />
	}<br />
<br />
	while (appRunning)<br />
	{<br />
		char inChar = getchar();<br />
<br />
		if (inChar == 'q')<br />
			appRunning = false;<br />
		if (inChar == 'r')<br />
			sendComm = true;<br />
		if (inChar == 's')<br />
			sendToDB = true;<br />
		if (inChar == 'd')<br />
			delComm = true;<br />
	}<br />
}<br />
<br />
static DWORD WINAPI listenThread(LPVOID ref)<br />
{<br />
	CSerial Serial;<br />
	int port=1, baud=115200;<br />
	char lpBuffer[100];<br />
<br />
	if (Serial.Open(port, baud))<br />
	{<br />
		for (EVER)<br />
		{<br />
			if (sendComm)<br />
			{<br />
				int commLength = strlen(command);<br />
				Serial.SendData(command, commLength);<br />
				sendComm=false;<br />
			}<br />
<br />
			if (delComm)<br />
			{<br />
				int commLength = strlen(delcommand);<br />
				Serial.SendData(delcommand, commLength);<br />
				delComm=false;<br />
			}<br />
<br />
			while (Serial.ReadDataWaiting() > 0)<br />
			{<br />
				int nBytesRead = Serial.ReadData(lpBuffer, 100);<br />
				for (int i=0; i<nBytesRead; i++)<br />
				{<br />
					printf("%c", lpBuffer[i]);<br />
					st += lpBuffer[i];<br />
<br />
					int newMsg = st.Find("+CMTI: \"SM\",");<br />
<br />
					if (newMsg != -1)	// Message rec'd <br />
					{<br />
						count++;<br />
						if (count == 2 && lpBuffer[i] != '1') // then the index has been added to the string st<br />
						{<br />
							switch(lpBuffer[i])<br />
							{<br />
							case '2': command = "AT+CMGR=2\n"; delcommand = "AT+CMGD=2\n";<br />
								break;<br />
							case '3': command = "AT+CMGR=3\n"; delcommand = "AT+CMGD=3\n";<br />
								break;<br />
							case '4': command = "AT+CMGR=4\n"; delcommand = "AT+CMGD=4\n";<br />
								break;<br />
							case '5': command = "AT+CMGR=5\n"; delcommand = "AT+CMGD=5\n";<br />
								break;<br />
							case '6': command = "AT+CMGR=6\n"; delcommand = "AT+CMGD=6\n";<br />
								break;<br />
							case '7': command = "AT+CMGR=7\n"; delcommand = "AT+CMGD=7\n";<br />
								break;<br />
							case '8': command = "AT+CMGR=8\n"; delcommand = "AT+CMGD=8\n";<br />
								break;<br />
							case '9': command = "AT+CMGR=9\n"; delcommand = "AT+CMGD=9\n";<br />
								break;<br />
							default: command = "";<br />
								break;<br />
							}<br />
							sendComm = true;							// Send comm to read msg<br />
							st.Empty();<br />
						}<br />
						if (count == 3 && lpBuffer[i-1] == '1' && lpBuffer[i] == '0') // index is 10<br />
						{<br />
							command = "AT+CMGR=10\n"; delcommand = "AT+CMGD=10\n";<br />
							sendComm = true;							// Send comm to read msg<br />
							st.Empty();<br />
						}<br />
						if (count == 3 && lpBuffer[i-1] == '1' && lpBuffer[i] != '0') // index is 1<br />
						{<br />
							command = "AT+CMGR=1\n"; delcommand = "AT+CMGD=1\n";<br />
							sendComm = true;							// Send comm to read msg<br />
							st.Empty();<br />
						}<br />
					}<br />
<br />
					if (st.Find("RING") != -1)<br />
					{<br />
						st.Empty();<br />
					}<br />
<br />
					if (lpBuffer[i-1] == 'O' && lpBuffer[i] == 'K' && st.GetLength() > 20)		// Flag to send string to php script for processing<br />
					{<br />
						sendToDB = true;<br />
					}<br />
				}<br />
			}<br />
<br />
			if (sendToDB)<br />
			{<br />
				CString s_url = "http://localhost/motm/logvote.php?";<br />
				CString s_var = "mess=";<br />
<br />
				CString s_urlMessage = s_url + s_var + st;<br />
		<br />
				char * urlMessage = s_urlMessage.GetBuffer(s_urlMessage.GetLength());<br />
				<br />
				if(InternetSession.OpenURL(urlMessage))<br />
				{<br />
					printf("\nSent\n");<br />
					st.Empty();								// reset the message string<br />
					delComm = true;							// Flag to delete message as it has now been sent<br />
					count = 0;<br />
				}<br />
				sendToDB = false;<br />
<br />
				delete urlMessage;<br />
			}<br />
		}<br />
	}<br />
	else<br />
<br />
		appRunning = false;<br />
<br />
	return 0;<br />
}<br />
<br />

GeneralRe: CInternetSession Debug assertation error Pin
David Crow12-Aug-04 3:14
David Crow12-Aug-04 3:14 
GeneralRe: CInternetSession Debug assertation error Pin
biggsy1412-Aug-04 3:46
biggsy1412-Aug-04 3:46 
GeneralRe: CInternetSession Debug assertation error Pin
David Crow12-Aug-04 5:57
David Crow12-Aug-04 5:57 
GeneralRe: CInternetSession Debug assertation error Pin
mahade112-Aug-04 18:43
mahade112-Aug-04 18:43 
GeneralRe: CInternetSession Debug assertation error Pin
biggsy1413-Aug-04 1:26
biggsy1413-Aug-04 1:26 
GeneralPlaySound()..on PocketPC Pin
LozEvans12-Aug-04 2:48
LozEvans12-Aug-04 2:48 
GeneralHelp Regarding MFC Pin
balajeedurai12-Aug-04 1:58
balajeedurai12-Aug-04 1:58 
GeneralRe: Help Regarding MFC Pin
David Crow12-Aug-04 3:12
David Crow12-Aug-04 3:12 
GeneralList of USB devices through C++ Pin
Fatboyslim12-Aug-04 1:42
Fatboyslim12-Aug-04 1:42 
GeneralRe: List of USB devices through C++ Pin
Henry miller12-Aug-04 3:53
Henry miller12-Aug-04 3:53 
GeneralRe: List of USB devices through C++ Pin
David Crow12-Aug-04 10:26
David Crow12-Aug-04 10:26 
QuestionHow to add Automation in already built application Pin
Anonymous12-Aug-04 0:37
Anonymous12-Aug-04 0:37 
GeneralDDV AfxMessageBox in another client Pin
NtwoO11-Aug-04 22:50
NtwoO11-Aug-04 22:50 
GeneralRe: DDV AfxMessageBox in another client Pin
Member 83481212-Aug-04 5:07
Member 83481212-Aug-04 5:07 
GeneralReal time graph / Visual C++ Pin
Anonymous11-Aug-04 22:47
Anonymous11-Aug-04 22:47 
GeneralRe: Real time graph / Visual C++ Pin
Antony M Kancidrowski12-Aug-04 1:12
Antony M Kancidrowski12-Aug-04 1:12 
GeneralRe: Real time graph / Visual C++ Pin
V.12-Aug-04 2:59
professionalV.12-Aug-04 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.