C Language Development Kit/Functions/ResetReceive

From OptiWiki

Jump to: navigation, search
Description This function resets the serial receiver electronics and associated

software of the communications port last opened with comopen(). It also clears the receive buffers.

Syntax
void resetreceive(void);
Arguments None
Returns None
Remarks Like resetkey(), this routine can be used to

delete old data. In this case data still placed in the receive buffer is cleared.

Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    comopen( COM0 );    //direct cable, 9600,N,8,1
 
    while( 1 )
    {
        while( 1 )
        {
            resetkey();
            resetreceive();
            printf("\fReceiving..\n");
            if( xmodemreceive("test.dat") != XMR_OK)
            {
                printf("\fERROR:\nfile not received\npress any key");
                while( !kbhit())
                    idle();
                continue;
            }
 
            printf("file Received OK\n\rPress key\n\r");
            while( !kbhit())
                idle();
            break;
        }
 
        while( 1 )
        {
            resetkey();
            resetreceive();
            printf("\fSending..\n");
            if( xmodemtransmit("test.dat") != XMT_OK)
            {
                printf("\fERROR:\nfile not send\npress any key");
                while( !kbhit())
                    idle();
                continue;
            }
 
            printf("file send OK\n\rPress key\n\r");
            while( !kbhit())
                idle();
            break;
        }
    }
}


Views
Personal tools