Practical 3 (DOC) by joyakhan

VIEWS: 3 PAGES: 3

									                BASIC COMMUNICATION SYSTEM




PRACTICAL-3




08 CE 15 (15)                                1
                                                     BASIC COMMUNICATION SYSTEM




                                    PRACTICAL – 3

AIM:            Write a programme to connect two PCs using parallel port,
                both should work as transceiver.

DISCRIPTION OF AIM:
    We want that both PCs should work as transceiver and both are connected using parallel
     port.
    When one is transmitter the other should be selected in receiver mode.
    Transmitter transmits the character given by the user and receiver receives any character
     available on the port line on users command only.
    If transmitter is going to transmit '$', the receiver should stop to receive.


PROGRAMME:
#include <stdio.h>
#include <conio.h>
#define ecr 0x378 + 0x402                       //giving name to registers: ecr and cr
#define cr     0x378 + 0x02
#define data 0x378                              //giving name to port address

void main()
{
        char tc='0',rc,x,y;                      //taking required variables.
        int i;
        clrscr();                                //make the output screen clear.
        outportb(ecr,0x20);                      //Setting port in the Byte Mode.
        start:
printf ("Specify the job to be performed :\nt = Transmiter\nr = Receiver\ne = exit\n");
                                        //asking for operation of interest.

       x = getch();
       fflush (stdin);                          //clear the standard input.

       check:                                   //check for decision
       clrscr();
       if (x == 't')
                goto transmit;
       else if (x == 'r')
                goto receive;
       else if (x == 'e')
                goto stop;


08 CE 15 (15)                                                                                    2
                                                       BASIC COMMUNICATION SYSTEM




      else                                       // give masege if invalid key is pressed.
                {      printf ("\nInvalid Key Press !\n\n\n");
                       goto start;               // go again for making decision
                }

      transmit:
              outportb(cr,0x1f);                  //Setting control register for transmission
              printf ("Enter the characters to be transmited:\n");
              for (tc='0';tc!='$';)               //checking for character to be
              {                                   //transmitted.
                       tc = getch();              //taking character.
                       fflush (stdin);            //clear the standard input.
                       printf("/n%c",tc);         //print the character to be transmitted
                       outportb (data,tc);       //putting the character in the parallel port
                                                  // (to transmit).
              }
      bye:                                        //asking again if you want to do another
                                                  // or same job.
      printf("\n\nTo change the job press t or r or e :");
      x = getch();                                //take the decision.
      fflush (stdin);
      goto check;                                 //go to check the decision

      receive:
             outportb (cr,0xff);                   //Setting the control reg. for reception.
             printf("RECEIVING:");
             for (rc='0';rc!='$';)                 //make a loop and check what we are
             {                                     //receiving
                     getch();                      //to receiving each and every character
                                                   //press a key
                       fflush (stdin);             //clear the standard input.
                       rc = inportb(data);         //take data available on the parallel port.
                       switch(rc)                  //cheak the character.
                       {
                               case '$':break;     //if '$' then break the loop of receiving.
                               default: printf("/n%c",rc);       //print if other.
                                        break;
                       }
                }
                goto bye;                      //ask for any other job if you want
      stop:                                    //stop if nothing to do.
}



08 CE 15 (15)                                                                                    3

								
To top