CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Posts
    12

    Serial Communications

    I am attempting to write to and read from the serial port using the CreateFile function. This works fine when I am writing to the port, but when I should be seeing data coming back in, I don't get anything. I set the timeouts and the function returns, but the number of bytes read is always zero. I don't understand why this isn't working. I am able to write to the port successfully, which indicates that the baud rate and all of the transmit settings are configured properly. Is there some setting that is only for receiving data that I should look at? Is there some way to see what the error is that is causing my function to not receive data?


    ReadFile(
    FileIO, // handle of file to read
    lpBuffer, // address of buffer that receives data
    nNumberOfBytesToRead, // number of bytes to read
    &lpNumberOfBytesRead, // address of number of bytes read
    NULL // address of structure for data
    );


  2. #2
    Join Date
    Apr 1999
    Location
    CA
    Posts
    20

    Re: Serial Communications

    I couldn't get that to work either. I bought a third party library that works well from a company called MarshallSoft. But I noticed there is a class CSerialPort on this site that you can use for free.


  3. #3
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Serial Communications

    There is a sample on this site called CommSpy in the Network (?) category.
    It might be helpful.



  4. #4
    Guest

    Re: Serial Communications

    If you are using Visual C++ 5.0, you can find the answer in the example code COMM. I used it succesfully in an industrial project application. You just cut and paste the code, then setup the communication paramaters and that's all!. You should understand the code, to adapt it to your own needings. It's very simple.


  5. #5
    Join Date
    May 2004
    Posts
    94

    serial port

    can you please tell me where exactly is that example COMM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured