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. Mobile Development
  3. Mobile
  4. Connecting to COM port

Connecting to COM port

Scheduled Pinned Locked Moved Mobile
c++comdebuggingquestion
2 Posts 2 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.
  • U Offline
    U Offline
    User 16796
    wrote on last edited by
    #1

    Hi all, I want to write the data to COM Port using embeddedVC++ 4.0 .But nothing comes on COM port, code is as follows. If i debug the application it shows COM port is opened successfully,number of Bytes written is also correct Do i need to do some settings in emulator to make it connect to com port?? same code works fine in VC++6.0. //// wchar_t rightString[80]; wcscpy(rightString,_T("Hello")); DCB m_DCB; m_DCB.DCBlength = sizeof(m_DCB); m_DCB.BaudRate = 9600; m_DCB.ByteSize = 8; m_DCB.fBinary = TRUE; m_DCB.Parity = NOPARITY; m_DCB.StopBits = ONESTOPBIT; m_DCB.fParity = TRUE; m_DCB.fNull = FALSE; m_DCB.XonChar = 0x11; m_DCB.XoffChar = 0x13; m_DCB.XonLim = 80; m_DCB.XoffLim = 200; m_DCB.fAbortOnError = TRUE; m_DCB.fOutX = false; m_DCB.fInX = false; HANDLE m_hPort = CreateFile(_T("COM1:"), GENERIC_READ | GENERIC_WRITE, 0,NULL, OPEN_EXISTING, 0, NULL); SetCommState(m_hPort,&m_DCB); if(m_hPort == NULL) AfxMessageBox(_T("Can not open port")); else if(WriteFile(m_hPort, rightString, 10, &BytesWritten, NULL)) AfxMessageBox(_T("Successfully written")); CloseHandle(m_hPort); /// Thanks in Advance Tushar Mahajan

    G 1 Reply Last reply
    0
    • U User 16796

      Hi all, I want to write the data to COM Port using embeddedVC++ 4.0 .But nothing comes on COM port, code is as follows. If i debug the application it shows COM port is opened successfully,number of Bytes written is also correct Do i need to do some settings in emulator to make it connect to com port?? same code works fine in VC++6.0. //// wchar_t rightString[80]; wcscpy(rightString,_T("Hello")); DCB m_DCB; m_DCB.DCBlength = sizeof(m_DCB); m_DCB.BaudRate = 9600; m_DCB.ByteSize = 8; m_DCB.fBinary = TRUE; m_DCB.Parity = NOPARITY; m_DCB.StopBits = ONESTOPBIT; m_DCB.fParity = TRUE; m_DCB.fNull = FALSE; m_DCB.XonChar = 0x11; m_DCB.XoffChar = 0x13; m_DCB.XonLim = 80; m_DCB.XoffLim = 200; m_DCB.fAbortOnError = TRUE; m_DCB.fOutX = false; m_DCB.fInX = false; HANDLE m_hPort = CreateFile(_T("COM1:"), GENERIC_READ | GENERIC_WRITE, 0,NULL, OPEN_EXISTING, 0, NULL); SetCommState(m_hPort,&m_DCB); if(m_hPort == NULL) AfxMessageBox(_T("Can not open port")); else if(WriteFile(m_hPort, rightString, 10, &BytesWritten, NULL)) AfxMessageBox(_T("Successfully written")); CloseHandle(m_hPort); /// Thanks in Advance Tushar Mahajan

      G Offline
      G Offline
      glweid
      wrote on last edited by
      #2

      HI My experience is that the emulators do not connect to the COM ports, you must test on a real device. Make sure you get a device that supports RS232 serial connections !! I found out the hard way that some do not ! Dell Axim X5 does and the HP IPAQ 4000 series and above should also. G. Weideman

      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