# Connecting via USB (CreateUsb)

This guide explains how to establish a connection with an Integrated POS using the USB (serial) transport.

## What is the USB connection

The USB connection model establishes a direct physical link between the automation system and the POS terminal using a serial interface. You call `CreateUsb` with the required parameters for your platform; the function returns a Connector instance that exposes the same device operation functions as HTTP connectors.

## When to use the USB connection

Use a USB connection when:

* The POS terminal is physically close to the automation system
* Network connectivity is unavailable or restricted
* A direct, point-to-point connection is required

USB provides a simple and deterministic channel but is sensitive to physical disconnection—if the cable is unplugged, the channel is lost and must be re-established.

<Callout type="warning">

If you use `setupParams` (Kotlin) or the Setup command (.NET) with the terminal, check the reconnection behavior sections in this documentation.

</Callout>

## Before you begin

Before connecting via USB, ensure that:

* The POS terminal is powered on and configured for Integrated POS Mode
* The USB cable is properly connected between the POS and the automation system
* The Integrated POS library is available in your application
* The operating system recognizes the POS as a serial device (e.g. COM port on Windows, `/dev/ttyACM0` on Linux)

## Step 1: Create the USB Connector

Create a Connector using `CreateUsb` with the required parameter for your platform.

**Parameters:**

| Parameter | Type | Required | Description | Availability |
| :--- | :--- | :--- | :--- | :--- |
| `address` | string | Yes | The local serial port address (e.g. Windows: `COM1`, `COM3`; Linux: `/dev/ttyACM0`). | .NET |
| `usbDevice` | UsbDevice | Yes | Android device object for the USB connection. | Kotlin |
| `setupParams` | HashMap&lt;String, String> | No | Terminal configuration (e.g. friendly name). See the reconnection flow section for details. | Kotlin |

**Example — C#:**

```csharp
Connector connector = Connector.CreateUsb("COM3");
```

**Example — Kotlin:**

```kotlin
fun setupConnectorInstance(context: Context): POSIntegrado? {
    val usbManager = context.getSystemService(Context.USB_SERVICE) as UsbManager
    
    // Retrieve available device for USB connection
    val deviceList: List<UsbDevice> = usbManager.deviceList.map { it.value }
    
    // Select a available device
    val selectedDevice = deviceList.firstOrNull()
    
    val connectorInstance = if (selectedDevice != null) {
        POSIntegrado.createUsb(
            context = context,
            usbDevice = selectedDevice,
            setupParams = hashMapOf(
                SetupParameters.SELLER_FRIENDLY_NAME to "My Store"
            )
        )
    } else {
        null
    }
    
    return connectorInstance
}
```

When the call succeeds, a Connector instance is returned. The connection is initialized but the terminal has not yet been validated.

## Step 2: Validate the terminal

Before executing any device operation, validate the terminal using `Polling`:

```csharp
var pollingResult = connector.PollingAsync();
```

Proceed only if the Polling response indicates that the terminal is ready.

## Step 3: Execute operations

Once validated, use the Connector to run device operations such as `Sale`, `Refund`, or `GetReports`. Only one operation can be processed at a time per Connector.

## Step 4: Close the connection

After completing all operations, release the connection:

```csharp
connector.Close();
```

The Connector instance becomes invalid after closure and cannot be reused.

## Next steps

* [Connection Models](/en/integrated-pos/first-steps-pos/connection-models) — Comparison of USB and network.
* [Connector and Communication Flows](/en/integrated-pos/core-concepts-pos/connector-communication-flows) — Lifecycle and sequential execution rule.
* [Reconnection, Polling, and Resilience](/en/integrated-pos/core-concepts-pos/polling-reconnection) — When to poll and how reconnection works.
* [Methods and Parameters Reference](/en/integrated-pos/reference/methods-parameters) — Detailed parameter list and code examples for .NET and Kotlin.