<commit_before># Serial Binding

The Serial binding allows openHAB to communicate over serial ports attached to the openHAB server.

The binding allows data to be sent and received from a serial port. 
The binding does not support any particular serial protocols and simply reads what is available and sends what is provided.

The binding can be used to communicate with simple serial devices for which a dedicated openHAB binding does not exist.

## Overview

The Serial binding represents a serial port as a bridge thing and data matching defined patterns as things connected to the bridge.

### Serial Bridge

A Serial Bridge thing (`serialBridge`) represents a single serial port.

The bridge supports a String channel which is set to the currently received data from the serial port. 
Sending a command to this channel sends the command as a string to the serial port.

The bridge also supports a String channel which encodes the received data as the string representation of a RawType to handle data that is 
not supported by the REST interface. 
A command sent to this channel will only be sent to the serial port if it is encoded as the string representation of a RawType.

A trigger channel is also provided which triggers when data is received.

### Serial Device

A Serial Device thing (`serialDevice`) can be used to represent data matching a defined pattern as a device. 
The serial port may be providing data for many different devices/sensors, such as a temperature sensor or a doorbell. 
Usually such devices can be identified by performing a pattern match on the received data. 
For example, a Serial Device could be configured to represent a temperature sensor.

The thing will only update its channels if the received data matches the defined pattern. 

The thing supports generic String and Number channels which can apply a transform on the received data to set the channel state. 
Commands sent to the channels can be formatted and transformed before being sent to the device.

The thing also supports Switch and Rollershutter channels which provide simple mappings for the ON, OFF, UP, DOWN and STOP commands.

When using a Serial Device the expectation is that the received data for each device is terminated by a line break.

## Thing Configuration

The configuration for the `serialBridge` consists of the following parameters:

| Parameter           | Description                                                                                            |
|---------------------|--------------------------------------------------------------------------------------------------------|
| serialPort          | The serial port to use (e.g. Linux: /dev/ttyUSB0, Windows: COM1) (mandatory)                           |
| baudRate            | Set the baud rate. Valid values: 4800, 9600, 19200, 38400, 57600, 115200 (default 9600)                |
| dataBits            | Set the data bits. Valid values: 5, 6, 7, 8 (default 8)                                                |
| parity              | Set the parity. Valid values: N(one), O(dd), E(even), M(ark), S(pace) (default N)                      |
| stopBits            | Set the stop bits. Valid values: 1, 1.5, 2 (default 1)                                                 |
| charset             | The charset to use for converting between bytes and string (e.g. UTF-8,ISO-8859-1)                     |

The configuration for the `serialDevice` consists of the following parameters:

| Parameter           | Description                                                                                            |
|---------------------|--------------------------------------------------------------------------------------------------------|
| patternMatch        | Regular expression used to identify device from received data (must match the whole line) (mandatory)  |

## Channels

The channels supported by the `serialBridge` are:

| Channel  | Type             | Description                                                                                              |
|----------|------------------|----------------------------------------------------------------------------------------------------------|
| `string`   | String           | Channel for sending/receiving data as a string to/from the serial port. The channel will update its state to a StringType that is the data received from the serial port. A command sent to this channel will be sent out as data through the serial port. |
| `binary`   | String           | Channel for sending/receiving data in Base64 format to/from the serial port. The channel will update its state to a StringType which is the string representation of a RawType that contains the data received from the serial port. A command sent to this channel must be encoded as the string representation of a RawType, e.g. `"data:application/octet-stream;base64 MjA7MDU7Q3Jlc3RhO0lEPTI4MDE7VEVNUD0yNTtIVU09NTU7QkFUPU9LOwo="` |
| `data`     | system.rawbutton | Trigger which emits `PRESSED` events (no `RELEASED` events) whenever data is available on the serial port                                                                                                                                     |<commit_msg>Missing comma in base64 message (#9539)<commit_after># Serial Binding

The Serial binding allows openHAB to communicate over serial ports attached to the openHAB server.

The binding allows data to be sent and received from a serial port. 
The binding does not support any particular serial protocols and simply reads what is available and sends what is provided.

The binding can be used to communicate with simple serial devices for which a dedicated openHAB binding does not exist.

## Overview

The Serial binding represents a serial port as a bridge thing and data matching defined patterns as things connected to the bridge.

### Serial Bridge

A Serial Bridge thing (`serialBridge`) represents a single serial port.

The bridge supports a String channel which is set to the currently received data from the serial port. 
Sending a command to this channel sends the command as a string to the serial port.

The bridge also supports a String channel which encodes the received data as the string representation of a RawType to handle data that is 
not supported by the REST interface. 
A command sent to this channel will only be sent to the serial port if it is encoded as the string representation of a RawType.

A trigger channel is also provided which triggers when data is received.

### Serial Device

A Serial Device thing (`serialDevice`) can be used to represent data matching a defined pattern as a device. 
The serial port may be providing data for many different devices/sensors, such as a temperature sensor or a doorbell. 
Usually such devices can be identified by performing a pattern match on the received data. 
For example, a Serial Device could be configured to represent a temperature sensor.

The thing will only update its channels if the received data matches the defined pattern. 

The thing supports generic String and Number channels which can apply a transform on the received data to set the channel state. 
Commands sent to the channels can be formatted and transformed before being sent to the device.

The thing also supports Switch and Rollershutter channels which provide simple mappings for the ON, OFF, UP, DOWN and STOP commands.

When using a Serial Device the expectation is that the received data for each device is terminated by a line break.

## Thing Configuration

The configuration for the `serialBridge` consists of the following parameters:

| Parameter           | Description                                                                                            |
|---------------------|--------------------------------------------------------------------------------------------------------|
| serialPort          | The serial port to use (e.g. Linux: /dev/ttyUSB0, Windows: COM1) (mandatory)                           |
| baudRate            | Set the baud rate. Valid values: 4800, 9600, 19200, 38400, 57600, 115200 (default 9600)                |
| dataBits            | Set the data bits. Valid values: 5, 6, 7, 8 (default 8)                                                |
| parity              | Set the parity. Valid values: N(one), O(dd), E(even), M(ark), S(pace) (default N)                      |
| stopBits            | Set the stop bits. Valid values: 1, 1.5, 2 (default 1)                                                 |
| charset             | The charset to use for converting between bytes and string (e.g. UTF-8,ISO-8859-1)                     |

The configuration for the `serialDevice` consists of the following parameters:

| Parameter           | Description                                                                                            |
|---------------------|--------------------------------------------------------------------------------------------------------|
| patternMatch        | Regular expression used to identify device from received data (must match the whole line) (mandatory)  |

## Channels

The channels supported by the `serialBridge` are:

| Channel  | Type             | Description                                                                                              |
|----------|------------------|----------------------------------------------------------------------------------------------------------|
| `string`   | String           | Channel for sending/receiving data as a string to/from the serial port. The channel will update its state to a StringType that is the data received from the serial port. A command sent to this channel will be sent out as data through the serial port. |
| `binary`   | String           | Channel for sending/receiving data in Base64 format to/from the serial port. The channel will update its state to a StringType which is the string representation of a RawType that contains the data received from the serial port. A command sent to this channel must be encoded as the string representation of a RawType, e.g. `"data:application/octet-stream;base64,MjA7MDU7Q3Jlc3RhO0lEPTI4MDE7VEVNUD0yNTtIVU09NTU7QkFUPU9LOwo="` |
| `data`     | system.rawbutton | Trigger which emits `PRESSED` events (no `RELEASED` events) whenever data is available on the serial port                                                                                                                                     |
{'fraction_non_alphanumeric': 0.11363203050524309, 'fraction_numerical': 0.01334604385128694, 'mean_word_length': 1.8178887993553585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 45, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4659504', 'n_tokens_mistral': 2258, 'n_tokens_neox': 2095, 'n_words': 1250}