⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 async.doc

📁 source code for visa card
💻 DOC
字号:
This is a set of rather simple serial communication routines written in assembly, and to be called from C.  If it is not stated elsewhere, this codeis public domain!  Do with it as you wish, put it in your programs, etc, etc.This is the second 'release' of the ASYNC functions.  Since the first releaseseveral people have contributed modifications to the routines, to which Iwant to give them thanks and some credit where credit is due.Roy M. Silvernail --  roy%cybrspc@cs.umn.edu - OR-  cybrspc!roy@cs.umn.edu	For clarifying the documentation of AsyncHand() and AsyncSet().  He	added a few #define's to further clarify AsyncSet().  He also is 	responsible for adding some error checking to AsyncInit()-- it now	returns a non-zero on error (when the COM port isnt there).Steve Miller  -  uunet!pictel!miller	For finding a rather obscure bug.  If a character was recieved and	sent at exactly the same time, then it would stop receiving or	sending characters.  Thanks again.In addition, the buffer size has been increased from 1024 to 8196 characters.Here is a list of all the files included in this package:	async.doc	- 	What you are reading.	async.h		-	The C prototypes/header file	async.asm	-	The assembly source	term.c		-	The source for a simple terminal program	asyncs.obj	-	The .obj async.asm file for the SMALL model	asyncc.obj	-	The .obj for the COMPACT model	asyncm.obj	-	The .obj for the MEDIUM model	asyncl.obj	-	The .obj for the LARGE model	term.exe	-	The executable for the terminal programI have used these with Turbo C, and Turbo ASM without any problems.  Itshould work with Microsoft C and ASM, but a bit of re-writing will be neededto make the assmebler part work.  I have also used it with Turbo C++ and Turbo Assembler 2.0 without any problem, but you will have to treat the Async functions as standard C, rather than C++.Here is a short tutorial of the Async functions:AsyncInit( int Port)AsyncStop( void)These functions start and stop the interrupt handlers.  No characters can berecieved if it isn't started, and the computer will crash if they are not stopped before the program is exited.  The paramater 'port' is the COM portto use, there are #defines in the header file that defines the values to beused.  It would be 'more bug proof' if AsyncStop was called via the atexit()function (check your compiler manual).AsyncInit() will return a non-zero value upon an error (when the COM port isnot there).AsyncClear( void)Clears the internal buffers.AsyncOut( int c)Sends out a character.AsyncIn( void)Returns the next character in the buffer or a NULL upon an empty buffer.  UseAsyncInStat() to check for the number of characters in the buffer.AsyncHand( int handshake)Sets the status of the handshaking lines.  The values are defined in the header file and can be or'd together.  A typical call would look like this:	AsyncHand( DTR | RTS);Roy M. Silvernail found confusion in this rather simple explanation of AsyncHand().  I thought of editing the above description, but his descriptionis better than mine, so here it is:"The AsyncHand routine wants the whole set of flags upon invocation. Atfirst, I had tried AsyncHand(~DTR) to drop DTR, but soon found it didn'twork. With the 2 main control bits being DTR and RTS, AsyncHand(RTS)drops DTR just fine, and (of course) AsyncHand(DTR | RTS) raises it onceagain."AsyncSet( int Baud, int Control)This sets the baud rate, paraty, etc, of the serial line.  The paramater 'Baud'is the baud rate (ie 1200, 2400, 9600, etc), and 'control' is a number thatrepresents parity, length and stop bits.  There are defines for this in ASYNC.H, but here are a few commonly used examples:	AsyncSet( 2400, BITS_8 | STOP_1 | NO_PARITY )   for 2400 baud 8N1.	AsyncSet( 9600, BITS_7 | STOP_1 | EVEN_PARITY)  for 9600 baud 7E1.AsyncInStat( void)This frunction returns the number of characters in the input buffer.AsyncOutStat( void)Returns the number of characters in the output buffer.AsyncStat( void)Returns the status of the handshaking lines.  Use the & and | oporaters with the values defined in the header file to extract any useful informaton out ofthis value.The values used include the normal DCD, RI, and CTS, but also include D_DCD for'Delta-DCD' or CHANGE IN DCD.  This is useful in detecting changes in the handshaking lines since the last time the status was read.These routines do have their limitations, however.  They cannot deal with morethan one serial port, and cannot take advantage of the 16550 UART.  There is also no routines for input and output of strings-- there is so many ways of doing it that I left it up to whoever used these routines.  Enjoy, and if you have any questions, dont hesitate to ask.David Kessner - david@kessner.denver.co.us            | do {1135 Fairfax, Denver CO  80220  (303) 377-1801 (p.m.) |    . . .If you cant flame MS-DOS, who can you flame?          |    } while( jones);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -