home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 0 Macintosh 29Sep94 / SerialPort.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  2.9 KB  |  102 lines  |  [TEXT/KAHL]

  1. /* SerialPort.h */
  2.  
  3. #ifndef Included_SerialPort_h
  4. #define Included_SerialPort_h
  5.  
  6. /* SerialPort module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12. /* EventLoop */
  13. /* Array */
  14.  
  15. /* definitions for serial communcation attributes */
  16. typedef enum
  17.     {
  18.         eParityNone EXECUTE(= -24321),
  19.         eParityOdd,
  20.         eParityEven
  21.     } ParityTypes;
  22.  
  23. typedef enum
  24.     {
  25.         e8DataBits EXECUTE(= -1656),
  26.         e7DataBits,
  27.         e6DataBits,
  28.         e5DataBits
  29.     } DataBitTypes;
  30.  
  31. typedef enum
  32.     {
  33.         eOneStopBit EXECUTE(= -4341),
  34.         eOneAndAHalfStopBits,
  35.         eTwoStopBits
  36.     } StopBitTypes;
  37.  
  38. typedef enum
  39.     {
  40.         eHandShakeNone EXECUTE(= -341),
  41.         eHandShakeXonXoff,
  42.         eHandShakeDtrCts,
  43.         eHandShakeDtrOnly,
  44.         eHandShakeCtsOnly
  45.     } HandShakeTypes;
  46.  
  47. struct SerialPortRec;
  48. typedef struct SerialPortRec SerialPortRec;
  49.  
  50. struct SerialRefRec;
  51. typedef struct SerialRefRec SerialRefRec;
  52.  
  53. /* initialize serial port subsystem.  the user calls this.  this is not called */
  54. /* from the normal Level 0 initialization since this module is optional. */
  55. MyBoolean                        InitializeSerialPorts(void);
  56.  
  57. /* shut down serial ports */
  58. void                                ShutdownSerialPorts(void);
  59.  
  60. /* request a port.  if the port can not be allocated, it will return NIL. */
  61. SerialPortRec*            RequestSerialPort(long BitsRate, SerialRefRec* PortIdentifier,
  62.                                             ParityTypes Parity, HandShakeTypes HandShake,
  63.                                             DataBitTypes NumDataBits, StopBitTypes NumStopBits);
  64.  
  65. /* close a port */
  66. void                                CloseSerialPort(SerialPortRec* SerialPort);
  67.  
  68. /* get how many serial ports there are on the system */
  69. long                                GetNumSerialPorts(void);
  70.  
  71. /* get the ID of a serial port from the list */
  72. SerialRefRec*                GetIndexedSerialPort(long Index);
  73.  
  74. /* get the name associated with a serial port identifier (not null terminated) */
  75. char*                                GetSerialPortName(SerialRefRec* TheIdentifier);
  76.  
  77. /* dispose of a serial port reference */
  78. void                                DisposeSerialRef(SerialRefRec* TheIdentifier);
  79.  
  80. /* find out the closest available baud rate to the one requested.  if the */
  81. /* requested baud rate is supported, it is returned.  if not, then the closest */
  82. /* available rate is returned. */
  83. long                                GetClosestAvailableBaudRate(long RequestedRate,
  84.                                             SerialRefRec* PortIdentifier);
  85.  
  86. /* find out how much data is waiting to be read */
  87. long                                NumSerialPortBytesWaitingToRead(SerialPortRec* SerialPort);
  88.  
  89. /* find out how much data is waiting to leave the local buffers */
  90. long                                NumSerialPortBytesWaitingToWrite(SerialPortRec* SerialPort);
  91.  
  92. /* read some bytes from the port buffer into the specified buffer.  it is an */
  93. /* error to read more bytes than there are waiting. */
  94. void                                ReadSerialPort(SerialPortRec* SerialPort, long NumBytesToRead,
  95.                                             char* Buffer);
  96.  
  97. /* submit bytes to be written.  it returns True if successful, or False if */
  98. /* the operation timed out or another error occurred */
  99. MyBoolean                        WriteSerialPort(SerialPortRec* SerialPort, long Length, char* Data);
  100.  
  101. #endif
  102.