. . . . ########################################## . . . . . . . . . ## ## . . . . . . . . ## Async Tools for the Async Minded ## . . . . . . . . . ## ================================ ## . . . . . . . . ## Scott A. Deming ## . . . . . . . . . ## sad@umcc.umich.edu ## . . . . . . . . ## No version yet, and no real name. ## . . . . . . . . . ## ## . . . . . . . . ########################################## . . . . . ============================================================================ ---------------------------------------------------------------------------- SETUART.C ========= void set_UART_port(int comport, int value); void set_UART_int(int comport, int value); void set_UART_onmask(int comport, int value); void set_UART_offmask(int comport, int value); Change defaults. Probably not very useful, but maybe. No return values, because there really isn't anything significant here. These routines probably wont stick around too long as they seem like they will probably just clutter the code up. int set_parity(int comport, int parity); Change parity of currently open port. Returns 1 if successful, 0 if not. int set_stopbits(int comport, int stopbits); Change stop bits of currently open port. Returns 1 if successful, 0 if not. int set_wordlength(int comport, int wordlength); Change word length of currently open port. Returns 1 if successful, 0 if not. int set_baudrate(int comport, long baudrate); Change baudrate of currently open port. Returns 1 if successful, 0 if not. void set_handshaking(int comport, int status); Enable/Disable handshaking -- NOT YET IMPLEMENTED -- I NEED SOME INFO ON THIS. PLEASE EMAIL ME. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- DETECT.C -- These routines were taken DIRECTLY from Chris Blums SERIAL port ======== Summary. int async_detect_uart(int comport); Detect what type of UART is on a particular comport. Returns UART_xxxx which are MACRO's that can be found in ASYNC.H int async_detect_irq(int comport); Detect what IRQ line is used by a particular comport. Returns the IRQ or -1 if it fails for some reason. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ISR.C ===== void init_ISR(int comport); Initialize the Interrupt Service Routine for a specified comport. void deinit_ISR(int comport); Remove the ISR from comport. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- FIFO.C ====== int init_fifo(int comport, int enable); Enable or Disable FIFO on the UART. Returns 1 if successful, or 0 if not. It does make sure you have a 16550A before continuing. This routine will only work on a port opened with open_port(async.c). THIS CODE ISN'T COMPLETE YET EITHER. I JUST HAVEN'T GOTTEN AROUND TO IT YET ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ASYNC.C ======= int open_port(int comport, long baudrate, int parity, int stopbits, int wordlength); Pretty much self explanitory. If the port is already open, it returns a 0, otherwise it returns 1 for a successful open. int close_port(int comport, int rts, int dtr); Closes the com port. If rts != 0 it leaves the rts line the same. If dtr != 0 it leaves the dtr line the same. This is useful for programs that exit but don't want to hang up the modem. Returns a 0 if the port wasn't open to begin with, or a 1 if it closes down successfuly. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- LINE.C ====== int async_LCR(int comport); Returns the value of the LCR line on comport. int async_MCR(int comport); Returns the value of the MCR line on comport. int async_LSR(int comport); Returns the value of the LSR line on comport. int async_MSR(int comport); Returns the value of the MSR line on comport. int async_DTR_status(int comport); Returns the status of DTR on comport. int async_RTS_status(int comport); Returns the status of RTS on comport. void async_set_DTR(int comport, int status); Sets the status of DTR on comport. void async_set_RTS(int comport, int status); Sets the status of RTS on comport. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ASYIO.C ======= int async_putch_timeout(int comport, char c, long timeout); Put a character (c) to comport, failing after timeout milliseconds Returns 1 on success, and 0 on timeout. void async_putch(int comport, char c); Put a character (c) to comport. void async_puts(int comport, char *s); Put a string (s) to comport. int async_putblock_timeout(int comport, const char *block, int size, long timeout); Put a block (block) of size to comport, failing after timeout milliseconds Returns 1 on success, and 0 on timeout. void async_putblock(int comport, const char *block, int size); Put a block (block) of size to comport. int async_ready(int comport); Returns 1 if there is a character waiting in the RX buffer of comport, and 0 if no character is waiting. char async_getch(int comport); Returns the next character in the RX buffer of comport, removing it from the buffer. int async_getblock(int comport, char *block, int size); Pulls up to size bytes from the RX buffer of comport and puts them into a block (block), removing them from the RX buffer. Returns the number of bytes actually pulled from the buffer. char async_peek(int comport); Returns the next character in the RX buffer of comport, leaving it in the buffer for later retrieval. void async_flushrx(int comport); Flushes the RX buffer on comport. void async_flushtx(int comport); Flushes the TX buffer on comport. ----------------------------------------------------------------------------