<!--
{
  "availability" : [
    "DriverKit: 19.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SerialDriverKit",
  "identifier" : "/documentation/SerialDriverKit/IOUserSerial",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "SerialDriverKit"
    ],
    "preciseIdentifier" : "c:@S@IOUserSerial"
  },
  "title" : "IOUserSerial"
}
-->

# IOUserSerial

The class for building a service that communicates using a serial connection.

```
class IOUserSerial;
```

## Overview

Subclass `IOUserSerial` and use it to implement a service for communicating with serial devices. This class automatically manages the buffers used to store incoming and outgoing data. You are responsible for configuring your hardware, and for reading and writing data at appropriate times. This class supports configuration through standard modem commands or using universal asynchronous receiver/transmitter (UART) hardware.

If your driver communicates with your device over USB, subclass <doc://com.apple.documentation/documentation/USBSerialDriverKit/IOUserUSBSerial> (in the USBSerialDriverKit framework) instead of this class.

## Topics

### Configuring the Service

[`virtual bool init();`](/documentation/SerialDriverKit/IOUserSerial/init)

Handles the basic initialization of the service.

[`virtual kern_return_t Start(IOService *provider);`](/documentation/SerialDriverKit/IOUserSerial/Start)

Starts the current service and associates it with the specified provider.

[`virtual kern_return_t Stop(IOService *provider);`](/documentation/SerialDriverKit/IOUserSerial/Stop)

Stops the service associated with the specified provider.

[`virtual void free();`](/documentation/SerialDriverKit/IOUserSerial/free)

Performs any final cleanup for the service.

[`virtual bool initWith(IOBufferMemoryDescriptor *ifmd);`](/documentation/SerialDriverKit/IOUserSerial/initWith)

Initializes the private data structures associated with this class.

### Activating and Deactivating the Service

[`virtual kern_return_t HwActivate();`](/documentation/SerialDriverKit/IOUserSerial/HwActivate)

Opens the communication channel to the device.

[`virtual kern_return_t HwDeactivate();`](/documentation/SerialDriverKit/IOUserSerial/HwDeactivate)

Closes the communication channel to the device.

### Configuring the Serial Data Queues

[`virtual kern_return_t ConnectQueues(IOBufferMemoryDescriptor **ifmd, IOMemoryDescriptor **rxqmd, IOMemoryDescriptor **txqmd, IOMemoryDescriptor *in_rxqmd, IOMemoryDescriptor *in_txqmd, uint32_t in_rxqoffset, uint32_t in_txqoffset, uint8_t in_rxqlogsz, uint8_t in_txqlogsz);`](/documentation/SerialDriverKit/IOUserSerial/ConnectQueues)

Creates and configures the buffers that store the data moving to and from the device.

[`virtual kern_return_t DisconnectQueues();`](/documentation/SerialDriverKit/IOUserSerial/DisconnectQueues)

Releases the buffers that manage data moving to and from the device.

### Programming the Modem

[`virtual kern_return_t HwGetModemStatus(bool *cts, bool *dsr, bool *ri, bool *dcd);`](/documentation/SerialDriverKit/IOUserSerial/HwGetModemStatus)

Gets the current status of the modem from the hardware.

[`virtual kern_return_t SetModemStatus(bool cts, bool dsr, bool ri, bool dcd);`](/documentation/SerialDriverKit/IOUserSerial/SetModemStatus)

Sets the modem status to the specified values.

[`virtual kern_return_t HwResetFIFO(bool tx, bool rx);`](/documentation/SerialDriverKit/IOUserSerial/HwResetFIFO)

Sends a command to reset the specified device queues.

[`virtual kern_return_t HwSendBreak(bool sendBreak);`](/documentation/SerialDriverKit/IOUserSerial/HwSendBreak)

Sends a linebreak command to the device.

[`virtual kern_return_t HwProgramBaudRate(uint32_t baudRate);`](/documentation/SerialDriverKit/IOUserSerial/HwProgramBaudRate)

Sets the communication baud rate to the specified value.

[`virtual kern_return_t HwProgramLatencyTimer(uint32_t latency);`](/documentation/SerialDriverKit/IOUserSerial/HwProgramLatencyTimer)

Sets the amount of time to wait before sending the current buffer to the device.

[`virtual kern_return_t HwProgramMCR(bool dtr, bool rts);`](/documentation/SerialDriverKit/IOUserSerial/HwProgramMCR)

Configure the setings for the device’s modem control register (MCR).

[`virtual kern_return_t HwProgramUART(uint32_t baudRate, uint8_t nDataBits, uint8_t nHalfStopBits, uint8_t parity);`](/documentation/SerialDriverKit/IOUserSerial/HwProgramUART)

Configure the settings for the device’s universal asynchronous receiver/transmitter (UART).

[Hardware Constants](/documentation/SerialDriverKit/hardware-constants)

Configure your device with the appropriate parity and flow-control options.

### Transmitting and Receiving Data

[`virtual void RxDataAvailable();`](/documentation/SerialDriverKit/IOUserSerial/RxDataAvailable)

Notifies the system that data from the device is now available.

[`virtual void RxFreeSpaceAvailable();`](/documentation/SerialDriverKit/IOUserSerial/RxFreeSpaceAvailable)

Notifies your driver that buffer space is available for your device’s data.

[`virtual void TxDataAvailable();`](/documentation/SerialDriverKit/IOUserSerial/TxDataAvailable)

Notifies your driver that the system has data for you to transmit to the device.

[`virtual void TxFreeSpaceAvailable();`](/documentation/SerialDriverKit/IOUserSerial/TxFreeSpaceAvailable)

Notifies the system that the device is ready to accept more data.

[`virtual kern_return_t RxError(bool overrun, bool gotBreak, bool framingError, bool parityError);`](/documentation/SerialDriverKit/IOUserSerial/RxError)

Reports errors that occurred when receiving data from the device.

### Instance Methods

[`virtual kern_return_t HwProgramFlowControl(uint32_t arg, uint8_t xon, uint8_t xoff);`](/documentation/SerialDriverKit/IOUserSerial/HwProgramFlowControl)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)