🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

HELP with error

Started by
0 comments, last by deathkrush 17 years, 9 months ago
Hi All: I have created the NEHE Crate from lesson 6. I am adding functionality with a different part. It is communicating to the PC through my SCI class. I am having the following error, and I am not sure why. Below is my files, please help! Error: c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(144): error C2065: 'COINIT_MULTITHREADED' : undeclared identifier

#include "stdafx.h"

static HANDLE hPortHandle;         // Handle to COM port

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

bool SCIopen()
{
	CString szPortName;
	szPortName = "COM1";
	hPortHandle=CreateFile(szPortName, GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	
	if(hPortHandle == INVALID_HANDLE_VALUE)
		return false;
	DCB dcb;

	if(!GetCommState(hPortHandle, &dcb))
		return false;

	dcb.BaudRate = 38400;
	dcb.ByteSize = 8;
	dcb.Parity = NOPARITY;
	dcb.StopBits = ONESTOPBIT;

	if(!SetCommState(hPortHandle, &dcb))
		return false;

	COMMTIMEOUTS timeout;

	if(!GetCommTimeouts(hPortHandle, &timeout))
		return false;

	timeout.ReadIntervalTimeout = 50;
	timeout.ReadTotalTimeoutMultiplier = 1;
	timeout.ReadTotalTimeoutConstant = 50;
	timeout.WriteTotalTimeoutMultiplier = 0;
	timeout.WriteTotalTimeoutConstant = 0;
	
	if(!SetCommTimeouts(hPortHandle, &timeout))
		return false;

	return true;
  }

void SCIclose()
{
if (hPortHandle!=NULL) {CloseHandle(hPortHandle); hPortHandle=NULL;}
}

bool SCIread(unsigned char &pChar, DWORD dwToRead)
{
DWORD dwRead;
bool bOK= 0!=ReadFile(hPortHandle,&pChar,dwToRead,&dwRead,NULL);
if (dwRead!=dwToRead) bOK=false;
return bOK;
}

bool SCIwrite(char *pBuf, DWORD dwSend)
{
DWORD dwSent;
bool  bOK= 0!=WriteFile(hPortHandle,pBuf,dwSend,&dwSent,NULL);
if (dwSent!=dwSend) bOK=false;
return bOK;
}

bool SCIgetXYZ(unsigned char &uX, unsigned char &uY, unsigned char &uZ)
{
unsigned char SCIcomm[10];
SCIwrite("V",1);
bool bOK=SCIread(SCIcomm[0],6);
if ((bOK)&&(SCIcomm[0]=='x')&&(SCIcomm[2]=='y')&&(SCIcomm[4]=='z')) 
  {uX=SCIcomm[1]; uY=SCIcomm[3]; uZ=SCIcomm[5];}
else bOK=false;
return bOK;
}

bool SCIgetCal(unsigned char &uX0, unsigned char &uX1,
			   unsigned char &uY0, unsigned char &uY1,
			   unsigned char &uZ0, unsigned char &uZ1)
{
unsigned char SCIcomm[10];
SCIwrite("K",1);
bool bOK=SCIread(SCIcomm[0],9);
if ((bOK)&&(SCIcomm[0]=='X')&&(SCIcomm[3]=='Y')&&(SCIcomm[6]=='Z')) 
  {uX0=SCIcomm[1]; uX1=SCIcomm[2]; uY0=SCIcomm[4]; uY1=SCIcomm[5]; uZ0=SCIcomm[7]; uZ1=SCIcomm[8];}
else bOK=false;
return bOK;
}

bool SCIHandShake()
{
CString s;
int nAttempt=1;
SCIwrite("R",1);
unsigned char ua=' ';
SCIread(ua,1);
int nChoice=IDOK;
while ((ua!='M') && (ua!='N') && (nAttempt<6)) {
	SCIwrite("R",1);
	SCIread(ua,1);
	nAttempt++;
	}
if ((ua!='M')&& (ua!='N')) return false; else return true;
}


#include "stdafx.h"

static HANDLE hPortHandle;         // Handle to COM port

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

bool SCIopen()
{
	CString szPortName;
	szPortName = "COM1";
	hPortHandle=CreateFile(szPortName, GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
	
	if(hPortHandle == INVALID_HANDLE_VALUE)
		return false;
	DCB dcb;

	if(!GetCommState(hPortHandle, &dcb))
		return false;

	dcb.BaudRate = 38400;
	dcb.ByteSize = 8;
	dcb.Parity = NOPARITY;
	dcb.StopBits = ONESTOPBIT;

	if(!SetCommState(hPortHandle, &dcb))
		return false;

	COMMTIMEOUTS timeout;

	if(!GetCommTimeouts(hPortHandle, &timeout))
		return false;

	timeout.ReadIntervalTimeout = 50;
	timeout.ReadTotalTimeoutMultiplier = 1;
	timeout.ReadTotalTimeoutConstant = 50;
	timeout.WriteTotalTimeoutMultiplier = 0;
	timeout.WriteTotalTimeoutConstant = 0;
	
	if(!SetCommTimeouts(hPortHandle, &timeout))
		return false;

	return true;
  }

void SCIclose()
{
if (hPortHandle!=NULL) {CloseHandle(hPortHandle); hPortHandle=NULL;}
}

bool SCIread(unsigned char &pChar, DWORD dwToRead)
{
DWORD dwRead;
bool bOK= 0!=ReadFile(hPortHandle,&pChar,dwToRead,&dwRead,NULL);
if (dwRead!=dwToRead) bOK=false;
return bOK;
}

bool SCIwrite(char *pBuf, DWORD dwSend)
{
DWORD dwSent;
bool  bOK= 0!=WriteFile(hPortHandle,pBuf,dwSend,&dwSent,NULL);
if (dwSent!=dwSend) bOK=false;
return bOK;
}

bool SCIgetXYZ(unsigned char &uX, unsigned char &uY, unsigned char &uZ)
{
unsigned char SCIcomm[10];
SCIwrite("V",1);
bool bOK=SCIread(SCIcomm[0],6);
if ((bOK)&&(SCIcomm[0]=='x')&&(SCIcomm[2]=='y')&&(SCIcomm[4]=='z')) 
  {uX=SCIcomm[1]; uY=SCIcomm[3]; uZ=SCIcomm[5];}
else bOK=false;
return bOK;
}

bool SCIgetCal(unsigned char &uX0, unsigned char &uX1,
			   unsigned char &uY0, unsigned char &uY1,
			   unsigned char &uZ0, unsigned char &uZ1)
{
unsigned char SCIcomm[10];
SCIwrite("K",1);
bool bOK=SCIread(SCIcomm[0],9);
if ((bOK)&&(SCIcomm[0]=='X')&&(SCIcomm[3]=='Y')&&(SCIcomm[6]=='Z')) 
  {uX0=SCIcomm[1]; uX1=SCIcomm[2]; uY0=SCIcomm[4]; uY1=SCIcomm[5]; uZ0=SCIcomm[7]; uZ1=SCIcomm[8];}
else bOK=false;
return bOK;
}

bool SCIHandShake()
{
CString s;
int nAttempt=1;
SCIwrite("R",1);
unsigned char ua=' ';
SCIread(ua,1);
int nChoice=IDOK;
while ((ua!='M') && (ua!='N') && (nAttempt<6)) {
	SCIwrite("R",1);
	SCIread(ua,1);
	nAttempt++;
	}
if ((ua!='M')&& (ua!='N')) return false; else return true;
}

Advertisement
Quick Googling pointed me to a thread with exactly the same problem and a solution.

[google]
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)

This topic is closed to new replies.

Advertisement