亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲精品日日夜夜| 裸体一区二区三区| 亚洲成av人片一区二区| 久色婷婷小香蕉久久| 97超碰欧美中文字幕| 56国语精品自产拍在线观看| 中文av一区二区| 日韩av高清在线观看| jlzzjlzz欧美大全| 精品免费一区二区三区| 亚洲一区二区三区四区在线观看 | 色婷婷激情综合| 精品久久人人做人人爽| 亚洲一区在线观看免费| 岛国一区二区在线观看| 日韩欧美国产综合| 视频一区中文字幕| 91久久精品午夜一区二区| 国产亚洲欧美日韩在线一区| 日韩精品一级中文字幕精品视频免费观看 | 亚洲一区二区三区四区不卡 | 99视频在线精品| 精品国产一二三区| 日韩电影在线一区二区| 在线精品观看国产| 亚洲品质自拍视频网站| 波多野洁衣一区| 国产欧美日韩中文久久| 国产乱码字幕精品高清av| 日韩欧美国产综合在线一区二区三区 | 九九**精品视频免费播放| 欧美精品v日韩精品v韩国精品v| 亚洲欧洲日本在线| 99精品视频一区二区三区| 欧美经典三级视频一区二区三区| 美日韩一区二区| 91精品国产欧美一区二区18 | 亚洲成av人片在线| 欧美日韩国产精选| 夜夜爽夜夜爽精品视频| 色综合 综合色| 有码一区二区三区| 欧美色手机在线观看| 亚洲国产日韩精品| 欧美性大战久久久久久久蜜臀| 亚洲女同一区二区| 欧美系列亚洲系列| 五月激情综合婷婷| 欧美精品乱码久久久久久| 亚洲成人激情综合网| 69堂亚洲精品首页| 久久国内精品视频| 国产三级一区二区| aa级大片欧美| 亚洲一级二级在线| 91精品国产综合久久久久久久| 美女视频黄频大全不卡视频在线播放| 欧美草草影院在线视频| 国产一区 二区 三区一级| 日本一区二区三区四区| 91麻豆精东视频| 午夜久久久久久久久久一区二区| 欧美一区二区三区四区久久| 国产另类ts人妖一区二区| 国产精品另类一区| 精品视频123区在线观看| 国模大尺度一区二区三区| 国产精品国产三级国产普通话三级| 色综合久久综合网| 麻豆国产精品一区二区三区 | 欧美色图12p| 国产一区二区精品久久99| 国产精品女人毛片| 欧美日韩国产高清一区二区三区 | 国产精品亚洲一区二区三区在线| 国产精品久久久久久久久搜平片| 色av一区二区| 美女免费视频一区二区| 自拍偷拍国产亚洲| 日韩欧美激情在线| 色综合久久综合| 久久成人免费电影| 亚洲另类春色校园小说| 精品欧美一区二区久久| 色综合久久久久| 麻豆精品一区二区三区| 亚洲乱码国产乱码精品精的特点| 欧美老肥妇做.爰bbww| 国产精品1区2区| 亚洲一区在线观看网站| 国产欧美精品在线观看| 51精品秘密在线观看| 国产精品一区二区久久精品爱涩| 亚洲一二三四区| 国产亚洲美州欧州综合国| 正在播放一区二区| 欧美在线观看视频在线| 不卡一区二区三区四区| 另类调教123区| 亚洲高清三级视频| 中文字幕一区二区三区视频| 欧美mv日韩mv国产网站app| 精品视频色一区| 91农村精品一区二区在线| 国内精品在线播放| 免费在线观看日韩欧美| 一区二区三区不卡在线观看 | 日韩三级精品电影久久久| 91国模大尺度私拍在线视频| 成人精品免费视频| 国产曰批免费观看久久久| 日日夜夜精品视频免费| 一级女性全黄久久生活片免费| 国产精品成人免费| 国产欧美日韩一区二区三区在线观看| 精品日韩在线一区| 91精品国产一区二区三区香蕉| 欧洲激情一区二区| 色婷婷av一区二区三区大白胸| 成人午夜视频网站| 成人午夜视频免费看| 国产白丝精品91爽爽久久| 精品影视av免费| 麻豆91在线看| 久久精品国产免费看久久精品| 天天色综合成人网| 免费高清在线视频一区·| 日韩电影在线观看电影| 日本中文一区二区三区| 日韩在线卡一卡二| 日产国产欧美视频一区精品 | 91精品婷婷国产综合久久性色| 在线观看亚洲一区| 欧美视频中文字幕| 欧美精品一卡二卡| 日韩午夜精品视频| 精品欧美一区二区三区精品久久| 日韩欧美久久一区| 国产日产欧美一区二区视频| 国产亲近乱来精品视频 | 国产高清精品在线| 国产精品一品视频| 成人美女视频在线看| 成人午夜电影网站| 一本到三区不卡视频| 欧美亚洲动漫精品| 欧美一区二区不卡视频| 精品久久人人做人人爱| 久久精品亚洲精品国产欧美| 国产午夜精品一区二区三区嫩草| 国产精品污www在线观看| 亚洲天天做日日做天天谢日日欢| 亚洲综合在线观看视频| 三级精品在线观看| 国产精品99久久久久| 99re热视频精品| 欧美美女一区二区三区| 精品久久久久久久久久久院品网| 国产欧美一区二区三区沐欲| 亚洲免费在线视频一区 二区| 亚洲成人精品在线观看| 国产麻豆91精品| 欧美午夜片在线观看| 欧美成人国产一区二区| 欧美国产欧美综合| 亚洲国产精品久久人人爱| 精品午夜久久福利影院| 97精品国产97久久久久久久久久久久| 欧美日韩视频第一区| 久久久午夜精品| 亚洲国产成人91porn| 狠狠色狠狠色综合| 91国模大尺度私拍在线视频| 精品久久人人做人人爽| 一区二区三区在线观看网站| 国内外成人在线| 欧美亚洲禁片免费| 国产亚洲欧美日韩日本| 婷婷夜色潮精品综合在线| 北条麻妃国产九九精品视频| 91精品欧美福利在线观看| 国产精品三级电影| 久久97超碰色| 欧美日韩精品久久久| 视频一区在线视频| 成人午夜视频福利| 欧美大白屁股肥臀xxxxxx| 亚洲欧洲制服丝袜| 国产成人超碰人人澡人人澡| 91精品欧美一区二区三区综合在| 国产精品久久久久久久久免费桃花| 日本不卡在线视频| 色欧美日韩亚洲| 国产日韩欧美电影| 日本午夜一本久久久综合| 欧美伊人久久大香线蕉综合69 | 欧美日韩高清一区| 亚洲人成网站精品片在线观看 | 粉嫩av一区二区三区| 欧美成人a∨高清免费观看|