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. Accessing the DCB object

Accessing the DCB object

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelp
1 Posts 1 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.
  • R Offline
    R Offline
    Rsh
    wrote on last edited by
    #1

    i have a public DCB variable(DCB m_dcb) in a class called Comm which is in Comm.h file. In Comm.cpp am accessing the m_dcb through a member function. this member function i am calling from the App file. Its compliling & linking. But whrn u go in debug mode or run the appliaction,the member function not able to recognize the DCB variable and throws the error "(MSVCRTD.DLL)0xC0000005:Access violation" at the "FillMemory(&dcb, sizeof(dcb),0);" line. My code is as follows. ///////////////Comm.h/////////////////////////////////// class Comm { private: BOOL OpenComm(CString strPort); BOOL SetComTimeOuts(); BOOL SetComState(); public: Comm(CString port = "COM1"); virtual ~Comm(); BOOL Connect(CString sPort); BOOL Disconnect(); BOOL ChangeBaudRate(DWORD dwBaudrate); private: CString m_strPort; BYTE* m_pMsgBuf; public: static HANDLE m_hComEvent; static HANDLE m_hCommHandle; DCB dcb; OVERLAPPED osReader; OVERLAPPED osWrite; BOOL fWaitingOnRead; BOOL fWaitingOnWrite; }; //////////////Comm.cpp//////////////////////// #include "stdafx.h" #include "CEU Simulator.h" #include "Comm.h" BOOL Comm::Connect(CString strPort) { if(OpenComm(strPort)) if(PurgeComm(m_hCommHandle, PURGE_RXCLEAR | PURGE_TXCLEAR)) return TRUE; return FALSE; } //opencomm BOOL Comm::OpenComm(CString strPort) { m_hCommHandle = ::CreateFile( strPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL ); if (m_hCommHandle == INVALID_HANDLE_VALUE) { return FALSE; } /*if(INVALID_HANDLE_VALUE == m_Handle && ERROR_ALREADY_EXISTS != GetLastError()) return FALSE;*/ if( !SetComTimeOuts() ) { CloseHandle(m_hCommHandle); m_hCommHandle = INVALID_HANDLE_VALUE; return FALSE; } if( !SetComState() ) { CloseHandle(m_hCommHandle); m_hCommHandle = INVALID_HANDLE_VALUE; return FALSE; } return TRUE; } // setcommtimeouts BOOL Comm::SetComTimeOuts() { COMMTIMEOUTS commTimeOut; commTimeOut.ReadIntervalTimeout = MAXDWORD; // | Read operation should return immediately commTimeOut.ReadTotalTimeoutMultiplier = 0; // |=> with chars that have been revceived, even commTimeOut.ReadTotalTimeoutConstant = 0; // | even no chars have been received commTimeOut.WriteTotalTimeoutMultiplier = 2; commTimeOut.WriteTotalTimeoutConstant = 0; if( !SetCommT

    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