need help with a C code(RS 232 COM)

Discussion in 'Programmer's Corner' started by indianhits, Mar 13, 2010.

  1. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    Hello guys i need help in understand this code which i found in the web

    Code ( (Unknown Language)):
    1.  
    2. [FONT=Courier New][COLOR=#a020f0]#include [/COLOR][COLOR=#ff00ff]<bios.h>[/COLOR]
    3.         [COLOR=#a020f0]#include [/COLOR][COLOR=#ff00ff]<conio.h>[/COLOR]
    4.         [COLOR=#a020f0]#define COM1               [/COLOR][COLOR=#ff00ff]0[/COLOR]
    5.         [COLOR=#a020f0]#define DATA_READY [/COLOR][COLOR=#ff00ff]         0x100
    6. [/COLOR]         [COLOR=#a020f0]#define SETTINGS ( [/COLOR][COLOR=#ff00ff]         0x80[/COLOR][COLOR=#a020f0] | [/COLOR][COLOR=#ff00ff]0x02[/COLOR][COLOR=#a020f0]          | [/COLOR][COLOR=#ff00ff]0x00[/COLOR][COLOR=#a020f0] |         [/COLOR][COLOR=#ff00ff]0x00[/COLOR][COLOR=#a020f0])[/COLOR]
    7.         [COLOR=#2e8b57][B]int[/B][/COLOR] main([COLOR=#2e8b57][B]void[/B][/COLOR])
    8.         {
    9.    [COLOR=#2e8b57][B]int[/B][/COLOR] in, out, status;
    10.    bioscom([COLOR=#ff00ff]0[/COLOR], SETTINGS, COM1);         [COLOR=#0000ff]/*initialize the port*/[/COLOR]
    11.    cprintf([COLOR=#ff00ff]"Data sent to you:  "[/COLOR]);
    12.    [COLOR=#804040][B]while[/B][/COLOR] ([COLOR=#ff00ff]1[/COLOR])
    13.    {
    14.       status = bioscom([COLOR=#ff00ff]3[/COLOR],         [COLOR=#ff00ff]0[/COLOR], COM1); [COLOR=#0000ff]/*wait           until get a data*/[/COLOR]
    15.       [COLOR=#804040][B]if[/B][/COLOR] (status &           DATA_READY)
    16.            if ((out = bioscom([COLOR=#ff00ff]2[/COLOR],         [COLOR=#ff00ff]0[/COLOR], COM1) & [COLOR=#ff00ff]0x7F[/COLOR])           != [COLOR=#ff00ff]0[/COLOR])  [COLOR=#0000ff]/*input  a          data*/[/COLOR]
    17.                        putch(out);
    18.            if (kbhit())
    19.            {
    20.                       [COLOR=#804040][B]if[/B][/COLOR] ((in =  getch()) ==         [COLOR=#ff00ff]27[/COLOR])   [COLOR=#0000ff]/*          ASCII of Esc*/[/COLOR]
    21.                          [COLOR=#804040][B]break[/B][/COLOR];
    22.                        bioscom([COLOR=#ff00ff]1[/COLOR], in,  COM1);           [COLOR=#0000ff]/*output a data*/[/COLOR]
    23.            }
    24.    }
    25.    [COLOR=#804040][B]return[/B][/COLOR] [COLOR=#ff00ff]0[/COLOR];
    26.         }
    27. [/FONT]
    i need help in this
    Code ( (Unknown Language)):
    1.  
    2. [FONT=Courier New]status = bioscom([COLOR=#ff00ff]3[/COLOR],          [COLOR=#ff00ff]0[/COLOR], COM1); [COLOR=#0000ff]/*wait            until get a data*/[/COLOR]
    3.       [COLOR=#804040][B]if[/B][/COLOR] (status &           DATA_READY)
    4.            if ((out = bioscom([COLOR=#ff00ff]2[/COLOR],         [COLOR=#ff00ff]0[/COLOR], COM1) & [COLOR=#ff00ff]0x7F[/COLOR])           != [COLOR=#ff00ff]0[/COLOR])  [COLOR=#0000ff]/*input   a          data*/[/COLOR]
    5.                        putch(out);
    6. [/FONT]
    what does these mean like what is the use of data ready 0X100
    and 0X7F

    please help me.Thanks!
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,145
    1,791
    It is a bit in a register that tells the software when there is a byte of data that is READY.
     
Loading...