# Barcode Application

The Host Control Interface defines the message packet format between the host application on the Tablet/Phone and the Barcode application on e280s Scanner. These message packets reflect an encapsulated data field between the host application and the Barcode application.

Figure 2 illustrates the barcode command request and response packet length and sequence. The maximum size of the command request and response packets are 2048 bytes.

| **REQUEST PACKET IN BYTES**                                  |
| ------------------------------------------------------------ |
| **4**                                                        |
| **2**                                                        |
| **1**                                                        |
|                                                              |
| **REQUEST LENGTH**                                           |
| <p><strong>REQUEST</strong><br><strong>SEQUENCE</strong></p> |
|                                                              |
|                                                              |
| **RESPONSE PACKET (BYTES)**                                  |

| **4**                                                         | **4**                      | **4**                                                                                  | **VARIABLE** |
| ------------------------------------------------------------- | -------------------------- | -------------------------------------------------------------------------------------- | ------------ |
|                                                               |                            |                                                                                        |              |
| **RESPONSE LENGTH**                                           | **RESPONSE\*\*\*\*STATUS** | <p><strong>OPTIONAL</strong><br><strong>RESPONSE</strong><br><strong>DATA</strong></p> |              |
| <p><strong>RESPONSE</strong><br><strong>SEQUENCE</strong></p> |                            |                                                                                        |              |

**Figure 2: Request and Response Packet Format**

The sequence number is in the packet header before the payload and is generated by the host device. It is used for proper handshaking and error handling.

### Command Request Packet

As shown in Figure 2, the Command Request packet is comprised of the following data packets:

* Request Length – The total size of the command request packet, including this packet (maximum 2048 bytes).
* Request Sequence – Supplied by the host and unique per command, each response packet sequence number is linked to the sequence number of the Request packet. However, asynchronous Response packets have random sequence numbers. Asynchronous responses are sent after the following events:
  * A successful barcode scan.
  * A button change-status notification is sent in edge, level, and soft trigger mode.
* Command Packet – This structure comprises the command length, protocol version, command number, and parameter packets.
* Parameter Packet – There are a variable number of Parameter packets in the Command packet. The format of the Parameter packet is parameter length, parameter ID, and parameter value.

Multiple parameter packets can be sent in the same Command Request packet, which is useful for sending multiple parameters of a symbology in a single Command packet.

### Command Response Packet

The Response packet is comprised of the following data packets:

* Response Length – The total size of command response packet including this packet (maximum 2048 bytes).
* Response Sequence – This is usually the sequence number that the command supplied in a Request packet. However, asynchronous responses have a random sequence number, which cannot be related to the request sequence number.
* Response Status – The process status of the previous request:
  * 0x00000000 = Success
  * 0x00000001 = Failure
  * 0x80000000 = Asynchronous scanned data
  * 0x80000001 = Asynchronous button change status
* Response Data (optional) – Some responses have optional data with the status update. For example, scanned data response and failure responses have optional data.

The below figure illustrates the data format of asynchronous responses:

| **4**        | **4**                                                   | **4**                                                     | **2**         | **1** | **1** | **VARIABLE** |
| ------------ | ------------------------------------------------------- | --------------------------------------------------------- | ------------- | ----- | ----- | ------------ |
|              |                                                         |                                                           |               |       |       |              |
| **LENGTH**   | **STATUS**                                              | **AIM ID**                                                | **SCAN DATA** |       |       |              |
| **SEQUENCE** | <p><strong>SYMBOL</strong><br><strong>NAME</strong></p> | **CODE ID**                                               |               |       |       |              |
|              |                                                         |                                                           |               |       |       |              |
|              | **BUTTON CHANGE STATUS (BYTES)**                        |                                                           |               |       |       |              |
|              | **4**                                                   | **4**                                                     | **4**         | **1** |       |              |
|              |                                                         |                                                           |               |       |       |              |
|              | **LENGTH**                                              | **STATUS**                                                |               |       |       |              |
|              | **SEQUENCE**                                            | <p><strong>BUTTON</strong><br><strong>STATUS</strong></p> |               |       |       |              |

**Figure 3: Asynchronous Response Packet Format**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verifone.com/xpi/tbd-documentation/barcode-programmers-guide/barcode-application.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
