locked
handle RRS feed

  • Question

  • hello,


    I'm trying to use the naughter class to use the serial communication. I have a bug in my application.

    I created the serial communication object and opened the communication in one thread, and I'm trying to access it from another thread.
    I sent to this other thread the handle of the communication. I double checked, it's the same handle.
    But the next read I try to use from that second thread returns a getLastError = 6, which apparently is because the handle is incorrect.
    But it's the handle that was retrieved using HANDLE() so I don't understand what's wrong.

    Please help me.

    Thanks


    Tuesday, May 31, 2011 9:49 AM

Answers

  • I fixed this HANDLE(m_port) error using detach (which also returns the handle) followed by attach again. It just happens that HANDLE() and detach don't return the same value. I don't really care why though, because it works now. I'll just refrain myself from using HANDLE().
    • Marked as answer by BobbyQ Tuesday, May 31, 2011 4:57 PM
    Tuesday, May 31, 2011 4:57 PM

All replies

  • Does your "next read" comment mean you are trying to read from more than one thread?  Do you have two serial objects, one for reading and one for writing?
    Tuesday, May 31, 2011 12:24 PM
  • try to use DuplicateHandle Function. If you have source code, please post the code.

     


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    Tuesday, May 31, 2011 12:24 PM
  • I fixed this HANDLE(m_port) error using detach (which also returns the handle) followed by attach again. It just happens that HANDLE() and detach don't return the same value. I don't really care why though, because it works now. I'll just refrain myself from using HANDLE().
    • Marked as answer by BobbyQ Tuesday, May 31, 2011 4:57 PM
    Tuesday, May 31, 2011 4:57 PM