{
  "name": "Serial",
  "status": "experimental",
  "shortId": "serial",
  "camelName": "serial",
  "shortName": "serial",
  "extends": [
    "_base"
  ],
  "notes": {
    "short": "An asynchronous serial communication service capable of sending and receiving buffers of data.\nSettings default to 115200 baud 8N1."
  },
  "classIdentifier": 297461188,
  "enums": {
    "ParityType": {
      "name": "ParityType",
      "storage": 1,
      "members": {
        "None": 0,
        "Even": 1,
        "Odd": 2
      }
    }
  },
  "constants": {},
  "packets": [
    {
      "kind": "report",
      "name": "command_not_implemented",
      "identifier": 3,
      "description": "This report may be emitted by a server in response to a command (action or register operation)\nthat it does not understand.\nThe `service_command` and `packet_crc` fields are copied from the command packet that was unhandled.\nNote that it's possible to get an ACK, followed by such an error report.",
      "fields": [
        {
          "name": "service_command",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "packet_crc",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "identifierName": "command_not_implemented",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "const",
      "name": "instance_name",
      "identifier": 265,
      "description": "A friendly name that describes the role of this service instance in the device.\nIt often corresponds to what's printed on the device:\nfor example, `A` for button A, or `S0` for servo channel 0.\nWords like `left` should be avoided because of localization issues (unless they are printed on the device).",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "identifierName": "instance_name",
      "packFormat": "s",
      "derived": "_base"
    },
    {
      "kind": "ro",
      "name": "status_code",
      "identifier": 259,
      "description": "Reports the current state or error status of the device. ``code`` is a standardized value from \nthe Jacdac status/error codes. ``vendor_code`` is any vendor specific error code describing the device\nstate. This report is typically not queried, when a device has an error, it will typically\nadd this report in frame along with the announce packet. If a service implements this register,\nit should also support the ``status_code_changed`` event defined below.",
      "fields": [
        {
          "name": "code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "vendor_code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "optional": true,
      "identifierName": "status_code",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "rw",
      "name": "client_variant",
      "identifier": 9,
      "description": "An optional register in the format of a URL query string where the client can provide hints how\nthe device twin should be rendered. If the register is not implemented, the client library can simulate the register client side.",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "identifierName": "client_variant",
      "packFormat": "s",
      "derived": "_base"
    },
    {
      "kind": "event",
      "name": "status_code_changed",
      "identifier": 4,
      "description": "Notifies that the status code of the service changed.",
      "fields": [
        {
          "name": "code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "vendor_code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "optional": true,
      "identifierName": "status_code_changed",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "rw",
      "name": "connected",
      "identifier": 1,
      "description": "Indicates if the serial connection is active.",
      "fields": [
        {
          "name": "_",
          "type": "bool",
          "storage": 1
        }
      ],
      "identifierName": "intensity",
      "packFormat": "u8"
    },
    {
      "kind": "ro",
      "name": "connection_name",
      "identifier": 385,
      "description": "User-friendly name of the connection.",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "packFormat": "s"
    },
    {
      "kind": "rw",
      "name": "baud_rate",
      "identifier": 128,
      "description": "A positive, non-zero value indicating the baud rate at which serial communication is be established.",
      "fields": [
        {
          "name": "_",
          "unit": "baud",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true,
          "defaultValue": 115200
        }
      ],
      "packFormat": "u32"
    },
    {
      "kind": "rw",
      "name": "data_bits",
      "identifier": 129,
      "description": "The number of data bits per frame. Either 7 or 8.",
      "fields": [
        {
          "name": "_",
          "type": "u8",
          "storage": 1,
          "isSimpleType": true,
          "defaultValue": 8,
          "absoluteMin": 7,
          "absoluteMax": 8
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "stop_bits",
      "identifier": 130,
      "description": "The number of stop bits at the end of a frame. Either 1 or 2.",
      "fields": [
        {
          "name": "_",
          "unit": "#",
          "type": "u8",
          "storage": 1,
          "isSimpleType": true,
          "defaultValue": 1,
          "absoluteMin": 1,
          "absoluteMax": 2
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "parity_mode",
      "identifier": 131,
      "description": "The parity mode.",
      "fields": [
        {
          "name": "_",
          "type": "ParityType",
          "storage": 1,
          "defaultValue": 0
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "buffer_size",
      "identifier": 132,
      "description": "A positive, non-zero value indicating the size of the read and write buffers that should be created.",
      "fields": [
        {
          "name": "_",
          "unit": "#",
          "type": "u8",
          "storage": 1,
          "isSimpleType": true
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "command",
      "name": "send",
      "identifier": 128,
      "description": "Send a buffer of data over the serial transport.",
      "fields": [
        {
          "name": "data",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "unique": true,
      "packFormat": "b"
    },
    {
      "kind": "report",
      "name": "received",
      "identifier": 128,
      "description": "Raised when a buffer of data is received.",
      "fields": [
        {
          "name": "data",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "packFormat": "b"
    }
  ],
  "tags": [
    "io"
  ]
}