
#include "sio.h"
#include <stdio.h>
#include <conio.h>
#include <alloc.h>

void main(void)
{
    char inch, outch;

    com[2] = malloc(sizeof(struct port_des));
    memset(com[2],0,sizeof(struct port_des));

    com[2]->com = 2;
    com[2]->baudrate = 19200;
    
    sio_init_port(com[2]);

    do
    {
        if(!sio_rx_bytes(com[2]))
        {
            if(kbhit())
            {
                inch = getch();
                sio_tx(com[2],1,&inch);
            };
        }
        else
        {
            sio_rx(com[2],1,&outch);
            putch(outch);
        };
    } while(inch!=8);

    printf("\nerror    = %d",com[2]->error);
    printf("\ntx_write = %d",com[2]->tx_write);
    printf("\ntx_read  = %d",com[2]->tx_read);
    printf("\nrx_write = %d",com[2]->rx_write);
    printf("\nrx_read  = %d\n",com[2]->rx_read);
    printf("\ntx_sum   = %ld",com[2]->tx_sum);
    printf("\nrx_sum   = %ld\n",com[2]->rx_sum);

    sio_close_port(com[2]);

    free(com[2]);
};

