//
//  MiscSerialPort.h -- Serial port I/O support
//          Written by W. Eric Norum Copyright (c) 1997 by W. Eric Norum.
//          $Revision: 2.1 $   $Date: 1997/04/02 15:32:59 $
//          All rights reserved.
//          This notice may not be removed from this source code.
//
//      This object is included in the MiscKit by permission from the author
//      and its use is governed by the MiscKit license, found in the file
//      "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//      for a list of all applicable permissions and restrictions.
//      

#import <Foundation/NSData.h>
#import <Foundation/NSFileHandle.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSString.h>

extern NSString *MiscSerialPortReadCompletionNotification;
extern NSString *MiscSerialPortNotificationDataItem;

enum MiscSerialPortParity {
	MiscSerialPortNoParity = 0,
	MiscSerialPortEvenParity,
	MiscSerialPortOddParity
};

@interface MiscSerialPort: NSObject
{
	BOOL						isOpen;
    int							fd;

    NSString					*portName;
	int							baud;
	enum MiscSerialPortParity	parity;
	int							characterLength;

    NSString					*errorString;
    NSFileHandle				*fileHandle;
}

- (NSString *)errorString;

- initWithPort:(NSString *)aString baud:(int)anInt;

- (BOOL)setCharacterLength:(int)clen parity:(int)par;

- (BOOL)writeData:(NSData *)data;
- (BOOL)writeString:(NSString *)aString;

@end

@interface MiscSerialPort (SubclassMethods)
/*
 * These methods are declared so that subclasses can call them
 * or override them.  They should not be used by other objects.
 */
- (void)_setErrorString:(NSString *)format, ...;
- (void)_serialDataArrived:(NSNotification *)notification;
- (BOOL)_writeRawBuffer:(const void *)buf length:(unsigned int)length;

@end
