亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? serdpcin.c

?? 一個C語言寫的讀入位置跟蹤器數據的源程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/****************************************************************************
*****************************************************************************
    serdpcin.c      - Serial Routines - DOS PC Interrupt Mode

    written for:    Ascension Technology Corporation
		    PO Box 527
		    Burlington, Vermont  05402

		    802-655-7879


    written by:     Jeff Finkelstein

    Modification History:

    10/18/90        jf  - created
    11/12/90        jf  - add getdosticks() to allow Polled mode operation
			  at 19200 even on a pretty slow machine
    4/16/91         jf  - renamed module
    6/18/91         jf  - added FOB baudrate selections
    8/19/91         jf  - removed asserting of RTS
    12/23/92        jf  - added baudratebit definitions to allow
			  for compatibility with UNIX
    1/31/93         jf  - send_serial_cmd modified to be able to send out
			  rs232 to fbb commands to addr 30
    10/20/93        jf  - included pcpic.h
			- added protected mode vector settings


	   <<<< Copyright 1990 Ascension Technology Corporation >>>>
*****************************************************************************
****************************************************************************/
#include <stdio.h>          /* general I/O */
#include <time.h>           /* clock functions */
#include <dos.h>            /* needed for SETVECT/GETVECT */
#include "compiler.h"
#include "asctech.h"
#include "menu.h"
#include "pcpic.h"
#include "pctimer.h"
#include "serial.h"

#ifdef DOS    /* DOS Systems Only */

/*
    Global Variables for the COM port
*/
	short com_base = COM1BASE;           /* holds the base address of the 8250 */
	short comport = COM1;                /* holds the comport # */

    char * sys_com_port[2] ={"com1","com2"};

/*
    The FOB Bird uses a different set of Baud Rates as compared
    to the standard Bird
*/
    long baud = 9600L;                     /* holds the default baud rate */
    long baudratetable[] = {115200L,
			    57600L,
			    38400L,
			    19200L,
			    9600L,
			    4800L,          /* holds the baud rate selections */
			    2400L};         /* for the FOB Bird               */
    /*
       Used for compatibility with UNIX versions
    */
    short baudspeedbits = 7;            /* holds the current bit definition */
    short baudspeedbittable[] = {11,
				 10,
				 9,
				 8,
				 7,
				 6,
				 5};    /* holds the bitspeed definition */


	short serialconfigsaved = FALSE;            /* flag indicates serial port saved */

/*
    UART variable Storage
*/
    unsigned char olddivisorlow;            /* holds the old divisor low value */
    unsigned char olddivisorhigh;           /* holds the old divisor high value */
    unsigned char oldlinecont;              /* holds the old line control value */
    unsigned char oldinterenable;           /* holds the old interrupt enable value */
    unsigned char oldmodemcont;             /* holds the old modem control value */
    unsigned char oldirqmsk;                /* holds the old interrupt cont msk value */

/*
    Storage for the old serial interrupt vector
*/
#ifdef DPMC /* DOS Protected Mode Compiler */
    RINTTYPE oldserialintvect;    /* REAL old serial interrupt vector */
    INTTYPE  (* oldserialpintvect)(); /* PROT old serial interrupt vector */
#ifdef HIGHC
    extern _INTERRPT void hc_serialisr(void);
    void serialisr(void);
#else
    INTTYPE serialisr(void);
#endif /* HIGHC */

#else
#ifdef MSC
    void (interrupt far * oldserialintvect)();  /* old serial interrupt vector */
#else
    INTTYPE (* oldserialintvect)(); /* old serial interrupt vector */
#endif /* MSC */
    INTTYPE serialisr(void);
#endif /* DPMC */



/*
    Error Counters
*/

	short phaseerror_count = 0;      /* holds the phase errors */
	short rxerrorvalue = 0;          /* holds the rx error value */
	short rxbufoverruns = FALSE;     /* rx buffer overrun flag */
	short rxerrors = FALSE;          /* rx line errors flag */
	short txbufempty = TRUE;         /* tx buffer empty flag */

/*
    RX buffer
*/
    unsigned char rxbuf[RXBUFSIZE];         /* rx buffer */
    unsigned char * rxbufinptr = rxbuf;     /* rx buffer input pointer */
    unsigned char * rxbufoutptr = rxbuf;    /* rx buffer output pointer */

/*
    TX buffer
*/
    unsigned char txbuf[TXBUFSIZE];         /* tx buffer */
    unsigned char * txbufinptr = txbuf;     /* tx buffer input pointer */
    unsigned char * txbufoutptr = txbuf;    /* tx buffer output pointer */

/*
    Define RS232 to FBB Global Address
*/
    short rs232tofbbaddr = 0;

/*
    configserialport    -   Configure the Serial Port connected to the BIRD

    Prototype in:       serial.h

    Parameters Passed:  void

    Return Value:       TRUE if successfull, else FALSE

    Remarks:            Routine assumes that the current comports parameters
			have been saved prior to the call.
					    ** NOTE **
			Unfortunately, the PC ROM BIOS does NOT support baud
			rates upto 19200. Therefore, this routine must talk
			directly to the hardware to configure the serial port
			...this is not a problem in a PC environment since the
			I/O map is fixed for COM1 and COM2.
*/
int configserialport(void)
{
    unsigned divisor;
    unsigned comirq;

    /*
	Verify the comport and set the Base Address
    */
    switch (comport)
    {
	case COM1:
	    com_base = COM1BASE;                /* set the new I/O addr */
	    comirq = IRQ4;
	    break;
	case COM2:
	    com_base = COM2BASE;                /* set the new I/O addr */
	    comirq = IRQ3;
	    break;
	default:
	    printf("\n** ERROR ** invalid COM port\n");
	    return(FALSE);
    }

    /*
	Disable the interrupts
    */
    OUTPORTB(com_base + INTERENABLE, 0);

    /*
	Setup Vectors
    */
#ifdef DPMC
#ifdef HIGHC
    SETRPVECT(COM1INTERRUPT-comport,hc_serialisr);
#else
    SETPVECT(COM1INTERRUPT-comport,serialisr);
#endif /* HIGHC */
#else
    SETVECT(COM1INTERRUPT-comport,serialisr);
#endif /* DPMC */

    /*
	assume that there are NO CHARACTERS CURRENTLY in the Tx Buffer
	and change the baud rate
    */
    OUTPORTB(com_base + LINECONT, DLAB);

    /*
	Set the least significant byte and then the most significant
	byte of the baud rate divisor
    */
    divisor = 115200L/baud;
    OUTPORTB(com_base, (divisor & 0xff));
    OUTPORTB(com_base + 1, ((divisor & 0xff00) >> 8));

    /*
	Set the Stop Bits = 1, Word Length = 8 and Parity = None
    */
    OUTPORTB(com_base + LINECONT, STOP_WORDLEN_PARITY);

    /*
	Clear the Rx Buffer and Rx Errors
    */
    clear_rx();

    /*
	Assert DTR...just in case the cable uses the DTR signal
	Deassert RTS...else the system will reset
	Assert OUT2...needed to allow interrupts to occur on PC compatible
	    serial I/O cards
    */
    OUTPORTB(com_base + MODEMCONT, DTRON | OUT2);

    /*
	Setup the 8250 Interrupt Enable register, RXDATA and RXLINESTATUS
	are turned on...but NOT TXHOLDINTENABLE since it will be turned on
	when we send the first character
    */
    OUTPORTB(com_base + INTERENABLE, RXLINESTATUSINTENABLE | RXDATAAVAILINTENABLE);
    OUTPORTB(com_base + INTERENABLE, RXLINESTATUSINTENABLE | RXDATAAVAILINTENABLE);


    /*
	Enable the 8259 Mask register for serial interrupts
	...IRQ4 ~(0x10) for COM1, IRQ3 ~(0x08) for COM2

	Note: Disable other serial ports (ie. Mouse) to ensure that
	      we do not miss any characters at a high baud rate
    */
    PCPIC_MASK(DISABLESERIALMSK);     /* disable all serial ports */
    PCPIC_UNMASK(comirq);             /* enable the desired serial port */

    return(TRUE);
}

/*
    saveserialconfig    -   save serial port configuration

    Prototype in:       serial.h

    Parameters Passed:  com_base    -   base address of 8250 type comport

    Return Value:       void

    Remarks:            saves the current configuration of the serial port

*/
int saveserialconfig()
{

    /*
	Save the Serial interrupt Vector
    */
    oldserialintvect = GETVECT(COM1INTERRUPT - comport);
#ifdef DPMC
    oldserialpintvect = GETPVECT(COM1INTERRUPT - comport);
#endif

    /*
	Save the current 8259 Interrupt request register
    */
    oldirqmsk = PCPIC_SAVEMASK;

    /*
	Save the Current Com Port Configuration Regs including:
	    Divisor, Interrupt Enable, Line Control, Modem Control
    */
    oldlinecont = INPORTB(com_base + LINECONT);         /* save the old line control value */
    OUTPORTB(com_base + LINECONT, DLAB);                /* set DLAB to get the divisor */
    olddivisorlow = INPORTB(com_base + DIVISORLOW);     /* save the divisor low */
    olddivisorhigh = INPORTB(com_base + DIVISORHIGH);   /* save the divisor high */
    OUTPORTB(com_base + LINECONT,oldlinecont & 0x7f);   /* reset DLAB to get the divisor */
    oldinterenable = INPORTB(com_base + INTERENABLE);   /* save the interrupt enable reg */
    oldmodemcont = INPORTB(com_base + MODEMCONT);       /* save the modem control reg */

    serialconfigsaved = TRUE;

    return(TRUE);
}

/*
    restoreserialconfig -   Restore the original serial port configuration

    Prototype in:       serial.h

    Parameters Passed:  com_base    -   base address of 8250 serial port

    Return Value:       void

    Remarks:            restores the configuration of the serial port
*/
void restoreserialconfig()
{
    /*
	Do not Restore if not previously stored
    */
    if (!serialconfigsaved)
	return;

    /*
	Disable Serial Interrupts on 8259 while initializing port
	and switching interrupt vectors
    */
    PCPIC_MASK(oldirqmsk | DISABLESERIALMSK);

    /*
	Restore the Com Port Configuration Regs including:
	    Divisor, Interrupt Enable, Line Control, Modem Control
    */
    OUTPORTB(com_base + LINECONT, DLAB);                /* set DLAB to get the divisor */
    OUTPORTB(com_base,olddivisorlow);                   /* restore the divisor low */
    OUTPORTB(com_base + 1,olddivisorhigh);              /* restore the divisor high */
    OUTPORTB(com_base + LINECONT,oldlinecont);          /* reset DLAB to get the divisor */
    OUTPORTB(com_base + INTERENABLE,oldinterenable);    /* restore the interrupt enable reg */
    OUTPORTB(com_base + MODEMCONT,oldmodemcont);        /* restore the interrupt enable reg */

    /*
	Restore the Serial Vector
	..disable interrupts during restoration
    */
    DISABLE();
#ifdef DPMC
    SETPVECT(COM1INTERRUPT - comport,oldserialpintvect);
#endif
    SETVECT(COM1INTERRUPT - comport,oldserialintvect);

    /*
	Restore the 8259 Interrupt Mask register
    */
    PCPIC_RESTOREMASK(oldirqmsk);

    ENABLE();
}


/*
    clearrx             -   Read the characters out of the Rx buffer if available

    Prototype in:       serial.h

    Parameters Passed:  void

    Return Value:       void

    Remarks:            clears the rx buffer and rx errors if any

*/
void clear_rx()
{
    phaseerror_count = 0;                       /* clear phase error cntr */
    rxerrorvalue = 0;                           /* clear error byte */
    rxerrors = FALSE;                           /* clear Rx error flag */
    rxbufoverruns = FALSE;                      /* clear Buf Overrun flag */
    rxbufinptr = rxbufoutptr = rxbuf;           /* re initialize buffer ptrs */

    /*
	Clear out pending errors and chars
    */
    INPORTB(com_base + INTERIDENT);
    INPORTB(com_base + INTERIDENT);
    INPORTB(com_base + LINESTATUS);
    INPORTB(com_base + LINESTATUS);
    INPORTB(com_base + RXBUF);
    INPORTB(com_base + RXBUF);

}

/*
    get_serial_record   - Get a record from the serial port

    Prototype in:       serial.h

    Parameters Passed:  rxbuf       -   pointer to a buffer to store the
					received characters
			recsize     -   number of characters to receive
			outputmode  -   POINT, CONTINUOUS or STREAM

    Return Value:       If successful, returns recsize
			else, RXERRORS if Rx errors were detected while
			receiving data, or RXPHASEERRORS if in POINT or
			CONTINUOUS mode and a phase error is detected.

    Remarks:            A record of data has the MSB of the first
			character set to a 1.  The routine verifies that
			the first character received is in PHASE.  If
			in STREAM mode, the routine resynches and tries
			to capture the data into the rxbuf.  If in POINT
			or CONTINUOUS mode, then the routine returns
			indicating a RXPHASEERROR.

*/
int get_serial_record(rxbuffer, recsize, outputmode)
unsigned char * rxbuffer;
short recsize;
short outputmode;
{
	short rxcount = 0;
	short rxchar;
	short resynch;
    char * rxbufptr = (char *)rxbuffer;

    resynch = TRUE;

    do
    {
	if  (resynch)
	{
	    rxcount = 0;                 /* initialize char counter */
	    rxbufptr = (char *)rxbuffer; /* setup buffer pointer */
	    resynch = FALSE;
	}

	/*
	    Get first character and if error and NOT in STREAM mode..return
	*/
	if (rxcount == 0)
	{   
	    if ((rxchar = waitforchar()) < 0)
	    {
		if ((outputmode != STREAM) || (rxchar == RXTIMEOUT))
		{
		    return(RXERRORS);
		}
	    }

	    /*
		Check to make sure the the phase bit is a '1'
		If not, then if STREAM mode, resynch
		else, return with error
	    */
	    if (!(rxchar & 0x80))
	    {
		if (outputmode == STREAM)
		{
		    /*
		       Resynch
		       ...and keep track of the phase error
		    */
		    phaseerror_count++;
		    resynch = TRUE;
		    continue;
		}
		else
		{
		     return(RXPHASEERROR);
		}
	    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃91丨九色丨蝌蚪91桃色| 99精品视频免费在线观看| 国产精品一区2区| 在线亚洲一区二区| 日韩欧美一级二级三级| 最新不卡av在线| 激情综合网天天干| 欧美色电影在线| 国产精品国产三级国产aⅴ入口| 日本vs亚洲vs韩国一区三区二区| 99麻豆久久久国产精品免费优播| 精品久久人人做人人爽| 丝袜脚交一区二区| 日本道免费精品一区二区三区| 国产欧美日韩视频在线观看| 蜜桃一区二区三区四区| 欧美日韩国产精品自在自线| 综合欧美一区二区三区| 国产盗摄一区二区三区| 欧美v亚洲v综合ⅴ国产v| 日本aⅴ亚洲精品中文乱码| 欧美午夜免费电影| 一区二区高清免费观看影视大全| 成人一区二区三区中文字幕| 久久精品免费在线观看| 狠狠色丁香久久婷婷综合丁香| 日韩一区二区三区三四区视频在线观看 | 亚洲精品一区二区三区香蕉| 午夜国产精品影院在线观看| 欧美三级在线视频| 亚洲一区二区三区美女| 欧美三级三级三级爽爽爽| 亚洲精品福利视频网站| 91玉足脚交白嫩脚丫在线播放| 欧美激情一区在线观看| 成人黄色网址在线观看| 亚洲国产精品成人久久综合一区| 国产黄人亚洲片| 国产精品入口麻豆九色| 成人黄色片在线观看| 综合久久久久久久| 欧美午夜宅男影院| 日韩一区精品视频| 欧美大片在线观看| 丰满少妇久久久久久久| 中文字幕一区三区| 色妹子一区二区| 一级日本不卡的影视| 欧美亚洲高清一区二区三区不卡| 亚洲图片欧美综合| 欧美一级高清大全免费观看| 久久国产精品72免费观看| 久久久久久久久久久久久女国产乱| 国产成人免费9x9x人网站视频| 亚洲视频精选在线| 在线不卡免费欧美| 国产精品一区二区久久不卡| 亚洲国产成人午夜在线一区| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 日韩一级视频免费观看在线| 国产麻豆精品theporn| 国产精品久久久久久久午夜片| 色综合天天狠狠| 日本不卡一区二区三区| 国产欧美一区二区精品仙草咪| 99久久精品国产一区二区三区| 视频一区二区欧美| 国产午夜亚洲精品不卡| 日本二三区不卡| 国产一区二区导航在线播放| 亚洲美女偷拍久久| 精品粉嫩超白一线天av| 91麻豆swag| 激情综合色播激情啊| 一区二区免费在线播放| 久久综合九色综合欧美就去吻| 91免费国产在线观看| 国产一区二区美女诱惑| 亚洲图片欧美视频| 国产精品人人做人人爽人人添| 欧美喷水一区二区| 成人免费va视频| 免费成人你懂的| 一区二区三区免费观看| 久久久精品黄色| 91精品国产色综合久久ai换脸| 成人av免费在线| 国内精品在线播放| 亚洲成av人影院在线观看网| 国产精品国产三级国产aⅴ无密码| 欧美一级理论片| 欧美日韩在线不卡| 一本大道久久a久久精二百| 国产经典欧美精品| 另类人妖一区二区av| 午夜国产精品一区| 亚洲国产一区二区a毛片| 欧美国产视频在线| 久久综合色综合88| 欧美一区二视频| 欧美在线短视频| 一本色道a无线码一区v| 成人一区在线看| 大白屁股一区二区视频| 久久99国产精品久久99| 日本免费新一区视频| 肉丝袜脚交视频一区二区| 一区二区视频免费在线观看| 亚洲视频在线观看三级| 国产精品区一区二区三区| 2019国产精品| 国产亚洲精品福利| 欧美极品美女视频| 国产喷白浆一区二区三区| 久久免费精品国产久精品久久久久| 欧美成va人片在线观看| 精品国产成人系列| 久久青草欧美一区二区三区| 久久久精品欧美丰满| 国产色91在线| 中文字幕在线观看一区二区| 国产精品久久久久aaaa| 亚洲日本免费电影| 亚洲高清一区二区三区| 日韩**一区毛片| 激情文学综合网| 成人在线一区二区三区| 91小视频免费看| 欧美亚洲动漫精品| 欧美一级在线免费| 国产亚洲精品资源在线26u| 亚洲日本在线视频观看| 一区二区三区四区视频精品免费 | 欧美午夜精品久久久| 欧美在线免费观看亚洲| 91精品国产品国语在线不卡| 欧美电影免费提供在线观看| 国产三级欧美三级日产三级99| 国产精品国产三级国产普通话99 | 亚洲国产精品传媒在线观看| 国产精品第四页| 亚洲午夜电影网| 国产高清不卡二三区| 日本精品裸体写真集在线观看| 欧美一级艳片视频免费观看| 国产女同互慰高潮91漫画| 亚洲欧洲日韩女同| 亚洲va在线va天堂| 国产不卡视频一区二区三区| 欧美色视频在线| 久久久久久久久久久久久夜| 亚洲精品成a人| 另类的小说在线视频另类成人小视频在线 | 日本va欧美va精品| 91在线观看地址| 日韩精品一区在线观看| 最新不卡av在线| 99国产精品久| 日韩欧美视频一区| 亚洲欧美另类在线| 久久av老司机精品网站导航| 91影院在线观看| 精品卡一卡二卡三卡四在线| 亚洲一区二区三区四区在线免费观看 | 国产亚洲短视频| 亚洲国产成人91porn| 高清shemale亚洲人妖| 4438成人网| 亚洲男女毛片无遮挡| 国产一二精品视频| 日韩一级视频免费观看在线| 亚洲乱码中文字幕综合| 国产九色sp调教91| 欧美一级二级三级蜜桃| 亚洲影院理伦片| 色综合一个色综合| 国产欧美一区二区精品久导航| 日本伊人精品一区二区三区观看方式| av爱爱亚洲一区| 中文字幕欧美日韩一区| 麻豆国产欧美日韩综合精品二区 | 在线观看日韩毛片| 欧美激情一区在线观看| 寂寞少妇一区二区三区| 91精品综合久久久久久| 亚洲午夜av在线| 欧美丝袜第三区| 一区二区三区高清| 91亚洲永久精品| 中文字幕一区二区视频| 国产高清无密码一区二区三区| 日韩精品一区二区三区中文精品| 亚洲一级二级三级在线免费观看| 97久久超碰精品国产| 国产精品久久夜| 99国产精品久久久久久久久久| 国产精品不卡视频| 91色婷婷久久久久合中文| 综合婷婷亚洲小说| 日本韩国欧美在线|