Hello,

I'm trying to compile a program related with serial communication via RS232. I've found this program at microsoft page http://support.microsoft.com/?scid=kb%3Ben-us%3B39501&x=9&y=11#top. When I try to compile this same program in Dev C++ editor the following message appears:
bios.h: No such file or directory. Please, help me about what can I do in order to advance or give me an alternative solution. Thanks in advance.

/* Compile options needed: none
 - The following program is a simple example which sends and receives
   one character to/from COM1:
*/ 

#include <stdio.h>
#include <bios.h>

void main(void)
{
    unsigned com1_status;
    unsigned com1_send;
    unsigned com1_rec;
    unsigned com1_init;
    int result, mask;

    /* open serial port at 1200 baud, 8 data bits,
    ** No parity, 1 stop bit */ 
    com1_init = _bios_serialcom(_COM_INIT, 0,
        _COM_CHR8 | _COM_NOPARITY | _COM_STOP1 | _COM_1200);
    printf("Init status: 0x%4.4X\n", com1_init);

    /* send an '*' to com1 */ 
    com1_send = _bios_serialcom(_COM_SEND, 0, '*');
    printf("Send status: 0x%4.4X\n", com1_send);

    mask = 0x6100;
    /* value used to mask:
    *    bits 0-7 are related to modems,
    *    bits 8-15 are for port status,
    *      check to see that the following bits are set:
    *         8 (data ready)
    *        13 (Transmission-hold  register empty)
    *        14 (Transmission-shift register empty)
    */ 

    /* check the status */ 
    com1_status = _bios_serialcom(_COM_STATUS, 0, 0);
    printf("COM1 status: 0x%4.4X\n", com1_status);

    /* wait until a character is ready */ 
    do {
        /* check the status */ 
        com1_status = _bios_serialcom(_COM_STATUS, 0, 0);

        /* mask off the low order byte of com1_status */ 
        com1_status = com1_status & 0xFF00;
    } while( (mask & com1_status) == 0);

    /* get a character */ 
    com1_rec =  _bios_serialcom(_COM_RECEIVE, 0, 0);
    printf("Read status: 0x%4.4X\n", com1_rec);

    /* print the character we just received */ 
    result = com1_rec & 0x00FF;
    printf("Character: 0x%2.2X  =  %c\n", result, (char)result);
}

Modern 32-bit compilers to not support that header file because it was intended for 16-bit MS-DOS 6.X and earlier operating systems. The alternative is to use win32 api functions OpenFile() to open a comm port, ReadFile() and WriteFile() to read/write to it. MSDN has a large article about serial communications.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.