Ir ao conteúdo
  • Cadastre-se

Renato Parisotto

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

posts postados por Renato Parisotto

  1. Bom dia, o problema é o seguinte: o programa compilado funciona perfeitamente rodando no windows xp porém quando roda em MSDos 6.22 não funciona, foi compilado no turboc 3.0,

    Gostaria de saber se o dos ou o turboc não tem suporte a essa placa, processador athlon xp 3000+, e qual seria a solução. 

     

    segue o programa fonte:

     

    #include<stdio.h>
    #include<conio.h>
    #include<bios.h>
    #define SETTINGS (_COM_9600 | _COM_CHR8 | _COM_EVENPARITY | _COM_STOP1) /* baud rate = 9600, 8 data bits, even parity bit, 1 stop bit */
    /////////////////////////////////// protótipos///////////////////////////////////
    void display(char *, int);
    /////////////////////////////////// inicio do programa ///////////////////////////////////
    void main(void)
    {
         unsigned in, out, status, count_in=0, count_out=0;
        int port, i;
         char msg_in[75], msg_out[75];
         textbackground(BLACK);
         clrscr();
         gotoxy(3, 1);
         textcolor(GREEN);
         cprintf("Full-Duplex PC para PC Communicação via RS-232 Serial Port usando 'C':Chatting");
         gotoxy(7, 3);
         textcolor(LIGHTCYAN);
         gotoxy(15, 5);
         textcolor(LIGHTGRAY);
         cprintf("Selecione a Porta (Digite '0' para COM1 ou '1' para COM2) : ");
         scanf("%d",&port);
         textcolor(LIGHTGRAY + BLINK);
         cprintf("\n Pressione ESC para sair, Pressione Enter para enviar a mensagem de saída");
         gotoxy(10, 9);
         textcolor(MAGENTA + BLINK);
        putch(1);
         cprintf("-Mensagem de saída");
         gotoxy(53, 9);
         textcolor(BLUE + BLINK);
         putch(1);
         cprintf("-Mensagem recebida");
         window(10, 11, 70, 23);
         textbackground(YELLOW);
         clrscr();
     /* Exibição da Comunicação */
         window(1, 25, 80, 25);
         textbackground(BLUE);
         textcolor(YELLOW);
         clrscr();
     /* Entrada de texto */
         window(1, 1, 80, 25);
         gotoxy(2, 25);
         putch(2);
         _bios_serialcom(_COM_INIT, port, SETTINGS);
         window(4, 25, 80, 25);
    ///////////////////////////////////inicio do programa principal ///////////////////////////////////
       for(;;)
       {
         status=_bios_serialcom(_COM_STATUS, port, 0);
         if (status & 512)
          printf("\n\t\a Overrun Error");
         if (status & 1024)
          printf("\n\t\a Parity Error");
         if (status & 2048)
          printf("\n\t\a Framing Error");
         if(status & (512|1024|2048)) /* if any error */
         break;
     
        if(status & 256) /* if data ready */
         {
          if((out=_bios_serialcom(_COM_RECEIVE, port, 0) & 255)!=0)
            msg_in[count_in++] = out;
          if(out=='\r')
            {
            display(msg_in, BLUE);
            count_in=0;
            gotoxy(count_out+1, 1);
            }
         }
          
         if(kbhit()) /* if a keystroke is currently available */
         {
           gotoxy(count_out+1, 1);
           in=getche(); /* get a character by echoing onto the screen */
           if(in==27) /* if ESC */
            break;
           if(in=='\b' && count_out>0)
            {
            count_out=count_out-2;
            cprintf(" \b");
            }
            else
            msg_out[count_out]=in;
           if(count_out==74)
            {
             in='\r';
             msg_out[74]='\r';
            }
            count_out++;
            
           if(in=='\r')
            {
             display(msg_out, MAGENTA);
             for(i=0; i<count_out; i++)
             _bios_serialcom(_COM_SEND, port, msg_out);
             count_out=0;
             clrscr();
            }
         }
       }
    }
    /////////////////////////////////// funções////////////////////////////////////////////
    void display(char arr[75], int COLOR)
    {
     static int line=1;
     int j;
     window(10, 11, 70, 23);
     gotoxy(1, line);
     textcolor(COLOR);
     textbackground(YELLOW);
     cprintf("\n");
     putch(1);
     for(j=0; arr[j]!='\r'; j++)
     putch(arr[j]);
     line=wherey();
     window(4, 25, 80, 25);
     textcolor(YELLOW);
     textbackground(BLUE);
    }
    ///////////////////////////////////

     

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...