Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

serial communication using turbo c from system to system

Status
Not open for further replies.

annapoorani

Junior Member level 3
Joined
Nov 20, 2010
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
chennai
Activity points
1,496
here is my code...............
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#define PORT1 0X3F8
void main()
{
unsigned char c;
unsigned char ch;
int i,k,buff=0;
int buffer[100]={0};
unsigned char A1[9]={0x7e,0xa0,0x07,0x03,0x41,0x93,0x5a,0x64,0x7e};
// unsigned char S1[65]={0x7e,0xa0,0x3f,0x03,0x41,0x10,0xe3,0x7b,0xe6,0xe6,0x00,0x60,0x31,0xa1,0x09,0x06,0x07,0x60,0x85,0x74,0x05,0x08,0x01,0x01,0x8a,0x02,0x07,0x80,0x8b,0x07,0x60,0x85,0x74,0x05,0x08,0x02,0x01,0xac,0x05,0x80,0x03,0x31,0x32,0x33,0xbe,0x10,0x04,0x0e,0x01,0x00,0x00,0x00,0x06,0x5f,0x1f,0x04,0x00,0x00,0x18,0x1d,0xff,0xff,0xd1,0x80,0x7e};

clrscr();
outportb(PORT1 + 1, 0x00);
outportb(PORT1 + 3, 0x80);
outportb(PORT1 + 0, 0X0C);
outportb(PORT1 + 1, 0x00);
outportb(PORT1 + 3, 0x03);
outportb(PORT1 + 2, 0xc7);
outportb(PORT1 + 4, 0X0F);

printf("\n Sample comm's program. Press ESC to quit\n");
for(k=0;k<9;k++)
{
outportb(PORT1, A1[k]);
}
printf("hai");
for(k=0;k<=10;k++);
do
{
c=inportb(PORT1+5);
if(c&1)
{
for(i=0;i<=buff;i++)
{
buffer[buff]=inportb(PORT1);
printf("%02x",buffer[buff]);
buff++;
}
}
}while(c&1);
/* for(i=0;i<buff;i++)
{
printf("%02x",buffer);
}
/* switch(buffer[5])
{
case 73:
printf("hello");
for(k=0;k<65;k++)
{
outportb(PORT1, S1[k]);
}
break;
/* case 03:
outport(PORT1, 7e a0 19 03 41 32 3a bd e6 e6 00 c0 01 81 00 07 00 00 63 62 00 ff 02 00 91 79 7e);
break;*/
// }


// goto label;
exit();


/* do
{
c=inportb(PORT1+5);
if(c&1)
{
buffer[buff]=inportb(PORT1);
buff++;
}
}while(inportb(PORT1+5));
printf("hai");
for(i=0;i<=buff;i++)
{
printf("%02x",buffer);
}
if(buffer[1]==0xa0)
{
printf("ok");
}
else
{
printf("not ok");
} */
}


my aim is i send request..... then another person send response..... i want to collect that response in buffer and print that......

but i send. but can't able to receive whole response and print correctly.... pl anyone explain me.....:-:)-:)-:)-(
 

hi pooorani,
i have attached a c code that can be compiled on turbo c. you can use that code to create serial communication between systems. On top of it, you can try whatever you want. Instead of trying it on dos, if you try it on windows , it will be easier for you.


regards,
vinoth.
 

Attachments

  • Nterm.txt
    8.2 KB · Views: 69
  • Like
Reactions: blooz

    blooz

    Points: 2
    Helpful Answer Positive Rating
hi pooorani,
i have attached a c code that can be compiled on turbo c. you can use that code to create serial communication between systems. On top of it, you can try whatever you want. Instead of trying it on dos, if you try it on windows , it will be easier for you.


regards,
vinoth.
thank you..........
using dos, only i have to work thats my boss order. now my program runs well with some changes made after:):)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top