Click here to Skip to main content
15,917,862 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: need sql query? Pin
David Crow17-Feb-04 7:16
David Crow17-Feb-04 7:16 
GeneralRe: need sql query? Pin
Prakash Nadar17-Feb-04 14:38
Prakash Nadar17-Feb-04 14:38 
AnswerRe: need sql query? Pin
Doug Mitchell17-Feb-04 7:15
Doug Mitchell17-Feb-04 7:15 
GeneralParallel port in C++ Pin
abc87617-Feb-04 3:02
abc87617-Feb-04 3:02 
GeneralRe: Parallel port in C++ Pin
Roger Wright17-Feb-04 5:20
professionalRoger Wright17-Feb-04 5:20 
GeneralRe: Parallel port in C++ Pin
John M. Drescher17-Feb-04 7:17
John M. Drescher17-Feb-04 7:17 
GeneralRe: Parallel port in C++ Pin
Roger Wright17-Feb-04 8:46
professionalRoger Wright17-Feb-04 8:46 
GeneralRe: Parallel port in C++ Pin
jhorstkamp17-Feb-04 6:35
jhorstkamp17-Feb-04 6:35 
Mostly like reading and writing a file: (EXAMPLE - your mileage may vary...)


void CSerialPort::initPort(int comNumber, int baudRate)
{
closePort();

m_ComNumber = comNumber;
m_BaudRate = baudRate;

CString comStr;
comStr.Format(_T("%s%d"), _T("COM"), comNumber);
m_ComHandle = CreateFile(comStr,
GENERIC_READ | GENERIC_WRITE,
0, 0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);

DCB dcb;
GetCommState(m_ComHandle, &dcb);
dcb.BaudRate = m_BaudRate;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(m_ComHandle, &dcb);

COMMTIMEOUTS timeouts;
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(m_ComHandle, &timeouts);

EscapeCommFunction(m_ComHandle, SETRTS);
EscapeCommFunction(m_ComHandle, SETDTR);
}

bool CSerialPort::readByteFromChannel(char* inByte)
{
DWORD numRead;
BOOL ret = true;

ret = ReadFile(m_ComHandle, inByte, 1, &numRead, 0);
return ( (ret) && (numRead == 1) );
}

void CSerialPort::sendPacket(char* pktBuffer, int len)
{
DWORD numWritten;
WriteFile(m_ComHandle, pktBuffer, len, &numWritten, 0);
if (numWritten != (DWORD)len)
// do comm error handling here

}

GeneralRe: Parallel port in C++ Pin
John M. Drescher17-Feb-04 7:08
John M. Drescher17-Feb-04 7:08 
GeneralRe: Parallel port in C++ Pin
jhorstkamp17-Feb-04 7:58
jhorstkamp17-Feb-04 7:58 
Generalreading without mfc Pin
ns17-Feb-04 2:58
ns17-Feb-04 2:58 
GeneralRe: reading without mfc Pin
RChin17-Feb-04 3:10
RChin17-Feb-04 3:10 
GeneralRe: reading without mfc Pin
Henrik Stuart17-Feb-04 3:20
Henrik Stuart17-Feb-04 3:20 
GeneralRe: reading without mfc Pin
John M. Drescher17-Feb-04 8:10
John M. Drescher17-Feb-04 8:10 
GeneralRe: reading without mfc Pin
Anonymous17-Feb-04 3:23
Anonymous17-Feb-04 3:23 
Generalthank you everyone! Pin
ns17-Feb-04 3:29
ns17-Feb-04 3:29 
GeneralRe: thank you everyone! Pin
Ravi Bhavnani17-Feb-04 17:17
professionalRavi Bhavnani17-Feb-04 17:17 
GeneralRe: thank you everyone! Pin
ns18-Feb-04 7:18
ns18-Feb-04 7:18 
GeneralRe: thank you everyone! Pin
Ravi Bhavnani18-Feb-04 7:26
professionalRavi Bhavnani18-Feb-04 7:26 
QuestionHow much memory? Pin
mcgahanfl17-Feb-04 2:57
mcgahanfl17-Feb-04 2:57 
AnswerRe: How much memory? Pin
Hesham Amin17-Feb-04 3:28
Hesham Amin17-Feb-04 3:28 
AnswerRe: How much memory? Pin
David Crow17-Feb-04 3:43
David Crow17-Feb-04 3:43 
GeneralRe: How much memory? Pin
mcgahanfl19-Feb-04 10:15
mcgahanfl19-Feb-04 10:15 
GeneralCWnd::OnVScroll() Pin
фил17-Feb-04 1:51
фил17-Feb-04 1:51 
GeneralRe: CWnd::OnVScroll() Pin
basementman17-Feb-04 6:04
basementman17-Feb-04 6:04 

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.