I/o

This is a discussion on I/o within the C Programming forums, part of the General Programming Boards category; hello... anybody here know how to control the I/O, comm port etc. I have a gps receiver and i want ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    I/o

    hello...
    anybody here know how to control the I/O, comm port etc. I have a gps receiver and i want to control it (extract data) by comm port.

    anyone can help?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    UK
    Posts
    169
    You could experiment with the following code to get you started. Check the error return codes on these calls.
    Code:
    DCB dcb;
    char Buffer[BUFFER_SIZE];
    int iNoOfBytesRead;
    
    hComPortHandle = CreateFile("COM1", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
    ErrorCheck = GetCommState(hComPortHandle, &dcb);
    
    dcb.BaudRate = 1200; // change to your requirments
    dcb.ByteSize = 8;         //  ..
    dcb.Parity   = 0;           //  ..
    dcb.StopBits = 0;         //  ..
    
    SetCommState(hComPortHandle, &dcb);
    
    for(;;)
    {
    	ReadFile(hComPortHandle, &Buffer, BUFFER_SIZE, (unsigned long*)&iNoOfBytesRead, NULL); 
    }

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Try a board search too, this has been asked a few times before.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. asynchronized I/O == multiplexing I/O?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-24-2006, 10:06 AM
  2. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  3. Nonblocking I/O
    By fnoyan in forum Linux Programming
    Replies: 4
    Last Post: 11-29-2005, 03:37 PM
  4. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 04:14 PM
  5. WSAAsyncSelect I/O Mode :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 1
    Last Post: 05-12-2002, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21