# Reconfiguring an RS 232 Device Through Script

If you have already created and connected to an RS232 device, and then want to deploy the project to a new environment that has another RS232 device with different configuration options, the script options allow you to make changes while the project is in deployment mode (aka runtime).

Note:

- More than one property can be reconfigured at a time.
- Every time that the reconfiguration method is called, the RS 232 Device will be disconnected and the connection will then attempt to be reconnected.
- You can verify that the reconnection was successful by monitoring the RS 232 Device's IsConnected property.

The properties of the RS 232 Device are:

Property Name | Data Type | Default Value
--- | --- | ---
Port | String | "COM1"
BaudRate | Integer | 19200
DataBits | Integer | 8
Parity | Parity | System.IO.Ports.Parity.None
StopBits | StopBits | System.IO.Ports.StopBits.One
DtrEnable | Boolean | False
BufferSize | Integer | 4096
NumberOfBuffers | Integer | 10

Example:

    //Get the port to use
    string portToUse = "COM2";
    int baudRateToUse = 9600;

    //Create the collection of property names - value pairs.
    var newProperties = new Dictionary<string, object>();

    //Add the properties that you wish to change.
    newProperties.Add("Port", portToUse);
    newProperties.Add("BaudRate", baudRateToUse);

    //Apply the new property values.
    $Devices.[SerialDeviceName].Reconfigure(newProperties);