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. opening more than one serial port

opening more than one serial port

Scheduled Pinned Locked Moved Mobile
4 Posts 2 Posters 11 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.
  • F Offline
    F Offline
    Frank S
    wrote on last edited by
    #1

    Hi, i have a function, which should open a serial Port. Now i wan't to open more than one port with that function: HANDLE port1, port2; PortInitialize(portname1, port1); PortInitialize(portname2, port2); with that function: BOOL CPort::PortInitialize(LPTSTR lpszPortName, HANDLE hCommPort) { DWORD dwError; DCB PortDCB; COMMTIMEOUTS CommTimeouts; // Open the serial port. hCommPort = CreateFile (lpszPortName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); ....... } But unfortunately, the second port2 can't be opened. I think there is a conflict with the handles, because there should be a pointer on the address of the handle, but that's even not working. Greetings, Frank _____ easySMS for pocket PC _____ www.Siedler-Net.de/WinCE/easySMS/

    J 2 Replies Last reply
    0
    • F Frank S

      Hi, i have a function, which should open a serial Port. Now i wan't to open more than one port with that function: HANDLE port1, port2; PortInitialize(portname1, port1); PortInitialize(portname2, port2); with that function: BOOL CPort::PortInitialize(LPTSTR lpszPortName, HANDLE hCommPort) { DWORD dwError; DCB PortDCB; COMMTIMEOUTS CommTimeouts; // Open the serial port. hCommPort = CreateFile (lpszPortName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); ....... } But unfortunately, the second port2 can't be opened. I think there is a conflict with the handles, because there should be a pointer on the address of the handle, but that's even not working. Greetings, Frank _____ easySMS for pocket PC _____ www.Siedler-Net.de/WinCE/easySMS/

      J Offline
      J Offline
      Joao Paulo Figueira
      wrote on last edited by
      #2

      After CreateFile check this:

      if(ERROR_FILE_NOT_FOUND == hCommPort)
      {
      // The COMM port does not exist.
      }

      F 1 Reply Last reply
      0
      • J Joao Paulo Figueira

        After CreateFile check this:

        if(ERROR_FILE_NOT_FOUND == hCommPort)
        {
        // The COMM port does not exist.
        }

        F Offline
        F Offline
        Frank S
        wrote on last edited by
        #3

        Yes, but that port does exist! _____ easySMS for pocket PC _____ www.Siedler-Net.de/WinCE/easySMS/

        1 Reply Last reply
        0
        • F Frank S

          Hi, i have a function, which should open a serial Port. Now i wan't to open more than one port with that function: HANDLE port1, port2; PortInitialize(portname1, port1); PortInitialize(portname2, port2); with that function: BOOL CPort::PortInitialize(LPTSTR lpszPortName, HANDLE hCommPort) { DWORD dwError; DCB PortDCB; COMMTIMEOUTS CommTimeouts; // Open the serial port. hCommPort = CreateFile (lpszPortName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); ....... } But unfortunately, the second port2 can't be opened. I think there is a conflict with the handles, because there should be a pointer on the address of the handle, but that's even not working. Greetings, Frank _____ easySMS for pocket PC _____ www.Siedler-Net.de/WinCE/easySMS/

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #4

          Two questions: Frank S. wrote: HANDLE hCommPort Shouldn't this be HANDLE& hCommPort ? Are you correctly spelling the COM ports like COM1: and COM2:? You are using the same code for CreateFile as I did. The only difference is that I opened only one port... Other than these, I have no immediate clues. :(

          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