-
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
- #include <math.h>
-
- union REGS regs;
- char caract;
- char tab[5];
- int i=0,j,o,p,w;
- int port=0;
-
- void init_rs()
- {
- regs.h.ah = 0;
- regs.x.dx = port;
- regs.h.al = 0x1e;
- int86(0x14, ®s,®s);
- }
- void emission()
- {
- do {
- regs.h.ah = 3;
- int86(0x14, ®s,®s);
- }while ( (regs.h.ah && 0x20)== 0);
-
- regs.h.ah = 1;
- regs.x.dx = port;
- regs.h.al = caract;
- int86(0x14, ®s,®s);
- }
- void reception(void)
- {
- regs.h.ah = 2;
- regs.x.dx = port;
- int86(0x14, ®s,®s);
- }
-
- void main(void)
- {
- char c='a';
- int u=0;
- clrscr();
- printf("Sur quel port voulez vous communiquer\n\r");
- while (c!=\r')
- {
- c=getch();
- if (c>='0' & c<='9')
- {
- tab[i]=c;
- printf("%c",c);
- i++;
- }
- }
- tab[i]=0x00;
- port=atoi(tab);
- clrscr();
- init_rs();
- c='0';
- i=0;
- j=0;
- while (u!=1)
- {
- clrscr();
- for(o=0;o<i;o++)
- {
- printf("Info emise: %c",tab_emis[o]);
- }
- printf("\n\r\n\r");
- if (u==3)
- {
- for(p=0;p<j;p++)
- {
- printf("Info recu: %c",tab_recept[p]);
- }
- }
- delay(50); // sert à ralentir le programme
- if (kbhit() & u!=2)
- {
- c=getch();
- printf("\r\n");
- if (c==0x1b) u=0;
- tab_emis[i]=c
- i++;
- if (c=='\r')
- {
- u=2;
- w=i;
- i=0;
- }
- if (c=0x1B) u=1; // caratere echap
- }
- if (u==2)
- {
- caract=tab_emis[i];
- emission();
- if (i==w)
- {
- u=0;
- i=0;
- w=0;
- }
- i++;
- }
- regs.h.ah = 3;
- regs.x.dx = port;
- int86(0x14, ®s,®s);
- if(regs.h.ah & 0x01 == 0x01)
- {
- reception();
- c=regs.h.al;
- tab_recept[j]=c;
- j++;
- if (c=='\r')
- {
- j=0;
- u=3;
- }
- }
-
- }
- }
-
-
-
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
union REGS regs;
char caract;
char tab[5];
int i=0,j,o,p,w;
int port=0;
void init_rs()
{
regs.h.ah = 0;
regs.x.dx = port;
regs.h.al = 0x1e;
int86(0x14, ®s,®s);
}
void emission()
{
do {
regs.h.ah = 3;
int86(0x14, ®s,®s);
}while ( (regs.h.ah && 0x20)== 0);
regs.h.ah = 1;
regs.x.dx = port;
regs.h.al = caract;
int86(0x14, ®s,®s);
}
void reception(void)
{
regs.h.ah = 2;
regs.x.dx = port;
int86(0x14, ®s,®s);
}
void main(void)
{
char c='a';
int u=0;
clrscr();
printf("Sur quel port voulez vous communiquer\n\r");
while (c!=\r')
{
c=getch();
if (c>='0' & c<='9')
{
tab[i]=c;
printf("%c",c);
i++;
}
}
tab[i]=0x00;
port=atoi(tab);
clrscr();
init_rs();
c='0';
i=0;
j=0;
while (u!=1)
{
clrscr();
for(o=0;o<i;o++)
{
printf("Info emise: %c",tab_emis[o]);
}
printf("\n\r\n\r");
if (u==3)
{
for(p=0;p<j;p++)
{
printf("Info recu: %c",tab_recept[p]);
}
}
delay(50); // sert à ralentir le programme
if (kbhit() & u!=2)
{
c=getch();
printf("\r\n");
if (c==0x1b) u=0;
tab_emis[i]=c
i++;
if (c=='\r')
{
u=2;
w=i;
i=0;
}
if (c=0x1B) u=1; // caratere echap
}
if (u==2)
{
caract=tab_emis[i];
emission();
if (i==w)
{
u=0;
i=0;
w=0;
}
i++;
}
regs.h.ah = 3;
regs.x.dx = port;
int86(0x14, ®s,®s);
if(regs.h.ah & 0x01 == 0x01)
{
reception();
c=regs.h.al;
tab_recept[j]=c;
j++;
if (c=='\r')
{
j=0;
u=3;
}
}
}
}