Reading serial port in c language | CTechnotips

#include<stdio.h>
#include<conio.h>
#include<dos.h>

void main()
  {
    char data;
    int choice;

    clrscr();

  printf("Enter the choice to send or receive from COM1::");
  scanf("%d",&choice);


  if(choice==1)
    {
      printf("Enter data to send::");
      flushall();
      scanf("%c",&data);
      outportb(0x03f8,data);
    }


  else
    {
    data=inport(0x3f8);
    printf("reding from  COM1::%d",data);
    }

    getch();
}

0 comments:

Post a Comment