Release 1.0  Copyright ã1993 by Matt Brandt.  All Rights Reserved.

MiscSerialPort

Inherits From:	Object

Declared In:	misckit/MiscSerialPort.h

Class Description

The MiscSerialPort class provides a wrapper around the serial ports in NeXTSTEP. It includes the ability to set the port's baudrate, parity, bits per character and to control the modem line DTR. A MiscSerialPort is initialized with the init method and then the various parameters are established for the line. A delegate provides a means to pass received characters to another object to be processed. Sending data is done by calling the sendChars:length: method. The line may be paused using the suspend and restarted by the continue methods in the event that it is desired to allow another mechanism (such as a subprocess) to have access to the port for a time.

Instance Variables

	char portName[64];	BOOL connected;	BOOL suspended;	int fd;	id delegate;	int currentBaud;	int currentParity;	DPSTimedEntry *tentry;	

portName	Full path to the serial device.

connected	YES if the port is currently active.

suspended	YES if the port has been paused.

fd	file descriptor for an active port.

delegate	points to the delegate object. This object must answer the methods described for the MiscSerialPortDelegate category.

currentBaud	current baud rate (i.e. B9600)

currentParity	parity for the port as described in MiscSerialPort.h

tentry	a timed entry used to poll for received data

Method Types

Initializing the serial port	± init

Setting and examining parameters	± setDeviceName:
	± setBaud:
	± setBaudByName:
	± setParity:
	± setDelegate:
	- (int)filedes
	- (BOOL)suspended

Controlling Communications	- (BOOL)connect
	- disconnect
	- suspend
	- continue
	- dropDTR
	- raiseDTR

Sending Data	- transmitChars:length:

Delegate methods	receiveChars:length:
	hangup

Instance Methods

connect
- (BOOL)connect

Opens the port with the current parameters. Be sure to set a valid delegate before doing this.  Returns YES if the connect succeded and  NO if the connection failed.

See also:  - disconnect

continue
- continue

Restarts communications after the port has been suspended.  Returns self.

See also:  - suspend

delegate
- delegate

Returns the pointer to the current delegate.

See also:  - setDelegate:

disconnect
- disconnect

Closes the serial port.  Returns self.

See also:  -connect

init
- init

Initializes an instance of MiscSerialPort.  Returns self.

dropDTR
- dropDTR

Lowers the DTR line to the port. This is usefull for hanging up on a modem.  Returns self.

See also:  -raiseDTR

filedes
- (int)filedes

Returns the file descriptor for an open port.

raiseDTR
- raiseDTR

Raises the DTR line for the port.  Returns self.

See also:  - dropDTR

setBaud:
- setBaud: (int)baud

Sets the baudrate for the port. Baud should be one of the declared values in <sgtty.h>.  Returns self.

See also:  - setBaudByName:

setBaudByName:
- setBaudByName: (const char *)speed

Allows the setting of baud rate by a string value such as "9600".  Returns self.

See also:  - setBaud:

setDelegate:
- setDelegate: theConsumer

Sets the object that received characters and status changes will be sent to.  Returns self.

See also:  - delegate

setDeviceName:
- setDeviceName: (const char *)name

Sets the path to the port's device file. This should be done before calling connect. If the port is connected and this routine is called with a name that does not match the current name then the port will be disconnected and reconnected (this is not recomended since there is no way to get the connect status).  Returns self.

setParity
- setParity: (int)parity

Sets the parity of the port. This is currently stubbed in and not implemented.  Returns self.

transmitChars:length:
- transmitChars: (const char *)buffer length: (int)length

Transmits a buffer of characters through the port.  Returns self.

Delegate Methods

receiveChars: length:
- receiveChars: (char *)buffer length: (int)length

Called when characters are received on the port to give the delegate a chance to process them. .  Returns self.

hangup
- receiveChars: (char *)buffer length: (int)length

Called on a high to low transition of DCD. Not currently implemented .  Returns self.