Amulets & Armor  v1.02
Open Source Game
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Functions | Variables
COMM

Modem Driver. More...

Data Structures

struct  T_commPortStruct
 
struct  T_selfCommInfo
 

Macros

#define MAX_SIZE_LOOK_AHEAD   200
 
#define SELF_COMM_BUFFER_SIZE   1024
 

Functions

E_Boolean CommCheckClientAndServerExist (T_void)
 
T_void CommClearPort ()
 
T_void CommCloseAll (T_void)
 
T_void CommClosePort (T_commPort port)
 
T_word32 CommConvertBaudTo32 (E_commBaudRate baud)
 
E_commBaudRate CommGetBaudRate (T_void)
 
T_word16 CommGetLinkSubType (T_void)
 
T_word16 CommGetNumberPorts (T_void)
 
E_commType CommGetPortType ()
 
T_word16 CommGetReadBufferLength (T_void)
 
T_word16 CommGetSendBufferLength (T_void)
 
E_Boolean CommIsServer (T_void)
 
T_commPort CommOpenPort (E_commType type, T_word16 addressOrComNum, T_word16 irq, E_commBaudRate baud)
 
T_word16 CommReadByte (T_void)
 
T_word16 CommReadConfigFile (T_byte8 *p_mode, T_byte8 *p_otherData)
 
T_word16 CommReadData (T_byte8 *p_data, T_word16 numberBytes)
 
T_void CommRewindScan (T_word16 numChar)
 
T_word16 CommScanByte (T_void)
 
T_word16 CommScanData (T_byte8 *p_data, T_word16 numberBytes)
 
T_void CommSendByte (T_byte8 byte)
 
T_void CommSendData (T_byte8 *p_data, T_word16 numberBytes)
 
T_void CommSetActivePort (T_commPort port)
 
T_void CommSetActivePortN (T_word16 numOfPort)
 

Variables

T_commPortStructG_currentPort = COMM_PORT_BAD
 
T_word16(* LowLevelCommGetReadBufferLength )(T_void)
 
T_word16(* LowLevelCommGetWriteBufferLength )(T_void)
 
T_word16(* LowLevelCommReadByte )(T_void)
 
T_void(* LowLevelCommSendByte )(T_byte8 byte)
 

Detailed Description

Modem Driver.

See Also
http://www.amuletsandarmor.com/AALicense.txt

Macro Definition Documentation

#define MAX_SIZE_LOOK_AHEAD   200
#define SELF_COMM_BUFFER_SIZE   1024

Function Documentation

E_Boolean CommCheckClientAndServerExist ( T_void  )

This routine checks to see if this is a machine that has both a client and a server on the same machine/process.

T_void CommClearPort ( )

Clears out the incoming data.

T_void CommCloseAll ( T_void  )

CommCloseAll closes all the ports opened by CommReadConfigFile.

NOTE: You should not close any of the ports that were opened by CommRead... except by calling this routine.

T_void CommClosePort ( T_commPort  port)

CommClosePort finalizes the port's existence by removing it from memory and removing any interrupts tied to that port. It does not worry about hanging up the phone or sending last messages – this is up to the calling routines.

Parameters
port– Port to close
T_word32 CommConvertBaudTo32 ( E_commBaudRate  baud)

CommConvertBaudTo32 converts given enumerated baud type to a 32 bit integer.

Parameters
baud– Rate of baud as enumeration
Returns
Rate of baud as 32 bit integer
E_commBaudRate CommGetBaudRate ( T_void  )

CommGetBaudRate tells what the active port's baud rate is.

Returns
Enumerated value of baud rate.
T_word16 CommGetLinkSubType ( T_void  )
T_word16 CommGetNumberPorts ( T_void  )

CommGetNumberPorts tells the number of ports previously opened by CommReadConfigFile. This routine is usually used with CommSetActivePortN.

NOTE: You should of called CommReadConfigFile before calling this routine.

Returns
Number of opened ports.
E_commType CommGetPortType ( void  )

Tells what type of port is attached (modem, null modem, server, ...)

Returns
Comm type of active port.
T_word16 CommGetReadBufferLength ( T_void  )

CommGetReadBufferLength returns the number of characters in the read buffer.

Returns
Number of waiting characters.
T_word16 CommGetSendBufferLength ( T_void  )

CommGetSendBufferLength returns the number of USED locations (number of characters that can be sent) in the output buffer.

Returns
Number of free character spots.
E_Boolean CommIsServer ( T_void  )
T_commPort CommOpenPort ( E_commType  type,
T_word16  addressOrComNum,
T_word16  irq,
E_commBaudRate  baud 
)

CommOpenPort creates a port and initializes it to the given parameters. Pass in the type of connection (null modem, standard modem, or irq based modem), COM number or base address, baud rate, and irq (if an irq is needed).

Parameters
type– type of connection being used
addressOrComNum– base communication address if irq modem, or COM port number if null or standard modem (1 = COM1)
irq– Interrupt # for irq modem. Ignored for other modem types (just pass 0)
baud– Communications rate
Returns
Handle to comm port or COMM_PORT_BAD
T_word16 CommReadByte ( T_void  )

CommReadByte reads in one character in from the appropriate low level driver. However, if characters are in the look ahead buffer, they are taken out of there first.

Returns
Character found or 0xFFFF if none.
T_word16 CommReadConfigFile ( T_byte8 p_mode,
T_byte8 p_otherData 
)

CommReadConfigFile reads in the "PORT.CFG" file and opens all the ports counting the number of actually opened ports.

NOTE: No real errors are detected by this routine and ports that could not be opened are ignored.

Returns
Number of ports opened
T_word16 CommReadData ( T_byte8 p_data,
T_word16  numberBytes 
)

CommReadData is used to read n number of bytes from the input stream (taking from the look ahead buffer as needed).

NOTE: Make sure to only call this routine if there is already that many characters in the receive buffer.

Parameters
p_data– Pointer to where to store data
numberBytes– Number of bytes to read
Returns
Number of bytes actually read. Sometimes this is less than numberBytes when there are no more characters in the input buffer.
T_void CommRewindScan ( T_word16  numChar)

CommRewindScan moves the current position of the scanned data back the given number of bytes. This, in effect, allows the system to go to previous characters that were already scanned from the data stream (since they have not been "read" they are still in the scan buffer).

NOTE: Make sure that you don't rewind more than you have scanned MINUS what you have read. If you do, this will bomb.

Parameters
numChar– Number of characters to rewind
T_word16 CommScanByte ( T_void  )

CommScanByte looks ahead into the buffer and returns characters as they are found. If no more characters are found, a zero is returned.

NOTE: No more than MAX_SIZE_LOOK_AHEAD characters can be scanned ahead. If there are, this problem bombs since there is no more space to store the look ahead characters.

Returns
Character found (or 0xFFFF if none)
T_word16 CommScanData ( T_byte8 p_data,
T_word16  numberBytes 
)

CommScanData scans a number of bytes ahead into the read stream and stores the bytes into the given pointer.

NOTE: No more than MAX_SIZE_LOOK_AHEAD characters can be scanned ahead. If there are, this problem bombs since there is no more space to store the look ahead characters. Make sure to only call this routine if there is already that many characters in the receive buffer.

Parameters
p_data– Pointer to where to store data
numberBytes– Number of bytes to scan
Returns
Number of bytes actually scanned. Sometimes this is less than numberBytes when there are no more characters in the input buffer.
T_void CommSendByte ( T_byte8  byte)

CommSendByte puts a character on the output buffer for sending.

NOTE: If the output buffer is full, the character sent is discarded.

Parameters
byte– Data to send
T_void CommSendData ( T_byte8 p_data,
T_word16  numberBytes 
)

CommSendData sends n number of bytes out the output port.

Parameters
p_data– Pointer to where to get data
numberBytes– Number of bytes to send
T_void CommSetActivePort ( T_commPort  port)

CommSetActivePort declares what port is to be used in all the next Comm port routine calls. This also sets up faster ways to call the comm port routines.

Parameters
port– Port to make the active port
T_void CommSetActivePortN ( T_word16  numOfPort)

CommSetActivePortN sets the active port to be one of the already opened ports by CommReadConfigFile.

NOTE: Make sure you pass in a numOfPort that is less than the number of ports open (the first is 0, ..., number of ports-1).

Variable Documentation

T_commPortStruct* G_currentPort = COMM_PORT_BAD
T_word16(* LowLevelCommGetReadBufferLength)(T_void)
T_word16(* LowLevelCommGetWriteBufferLength)(T_void)
T_word16(* LowLevelCommReadByte)(T_void)
T_void(* LowLevelCommSendByte)(T_byte8 byte)