/** * Class constructor. Instantiates a new {@code DigiPointDevice} object in the * given serial port name and parameters. * * @param port Serial port name where point-to-multipoint device is attached to. * @param serialPortParameters Object containing the serial port parameters. * * @throws ArgumentNullException if {@code port == null} or * if {@code serialPortParameters == null}. * * @see SerialPortParameters */ public DigiPointDevice(String port, SerialPortParameters serialPortParameters) : this(XBee.CreateConnectiontionInterface(port, serialPortParameters)) { }
/** * Class constructor. Instantiates a new {@code Raw802Device} object in the * given serial port name and parameters. * * @param port Serial port name where 802.15.4 device is attached to. * @param serialPortParameters Object containing the serial port parameters. * * @throws ArgumentNullException if {@code port == null} or * if {@code serialPortParameters == null}. * * @see SerialPortParameters */ public Raw802Device(String port, SerialPortParameters serialPortParameters) : this(XBee.CreateConnectiontionInterface(port, serialPortParameters)) { }
/** * Retrieves a serial port connection interface for the provided port with * the given serial port parameters. * * @param port Serial port name. * @param serialPortParameters Serial port parameters. * * @return The serial port connection interface. * * @throws ArgumentNullException if {@code port == null} or * if {@code serialPortParameters == null}. * * @see #createConnectiontionInterface(String, int) * @see com.digi.xbee.api.connection.IConnectionInterface * @see com.digi.xbee.api.connection.serial.SerialPortParameters */ public static IConnectionInterface CreateConnectiontionInterface(string port, SerialPortParameters serialPortParameters) { IConnectionInterface connectionInterface = new MySerialPort(port, serialPortParameters); return connectionInterface; }
/*throws InvalidConfigurationException, ConnectionException*/ /** * Sets the new parameters of the serial port as * {@code SerialPortParameters}. * * @param parameters The new serial port parameters. * * @throws ConnectionException if any error occurs when setting the serial * port parameters. * @throws InvalidConfigurationException if the configuration is invalid. * @throws ArgumentNullException if {@code parameters == null}. * * @see #getPortParameters() * @see #setPortParameters(int, int, int, int, int) * @see SerialPortParameters */ public void SetPortParameters(SerialPortParameters parameters) { Contract.Requires<ArgumentNullException>(parameters != null, "Serial port parameters cannot be null."); baudRate = parameters.BaudRate; this.parameters = parameters; if (SerialPort.IsOpen) { SerialPort.Close(); SerialPort.Open(); } }
/** * Class constructor. Instantiates a new {@code AbstractSerialPort} object * with the given parameters. * * @param port COM port name to use. * @param parameters Serial port connection parameters. * * @throws ArgumentNullException if {@code port == null} or * if {@code parameters == null}. * * @see #AbstractSerialPort(String, int) * @see #AbstractSerialPort(String, int, int) * @see #AbstractSerialPort(String, SerialPortParameters, int) * @see SerialPortParameters */ public MySerialPort(String port, SerialPortParameters parameters) : this(port, parameters, DEFAULT_PORT_TIMEOUT) { }
/*throws InvalidConfigurationException, ConnectionException*/ /** * Sets the new parameters of the serial port. * * @param baudRate The new value of baud rate. * @param dataBits The new value of data bits. * @param stopBits The new value of stop bits. * @param parity The new value of parity. * @param flowControl The new value of flow control. * * @throws ConnectionException if any error occurs when setting the serial * port parameters * @throws ArgumentException if {@code baudRate < 0} or * if {@code dataBits < 0} or * if {@code stopBits < 0} or * if {@code parity < 0} or * if {@code flowControl < 0}. * @throws InvalidConfigurationException if the configuration is invalid. * * @see #getPortParameters() * @see #setPortParameters(SerialPortParameters) */ public void SetPortParameters(int baudRate, int dataBits, StopBits stopBits, Parity parity, Handshake flowControl) { SerialPortParameters parameters = new SerialPortParameters(baudRate, dataBits, stopBits, parity, flowControl); SetPortParameters(parameters); }
/** * Class constructor. Instantiates a new {@code AbstractSerialPort} object * with the given parameters. * * @param port COM port name to use. * @param parameters Serial port connection parameters. * @param receiveTimeout Serial connection receive timeout in milliseconds. * * @throws ArgumentException if {@code receiveTimeout < 0}. * @throws ArgumentNullException if {@code port == null} or * if {@code parameters == null}. * * @see #AbstractSerialPort(String, int) * @see #AbstractSerialPort(String, int, int) * @see #AbstractSerialPort(String, SerialPortParameters) * @see SerialPortParameters */ public MySerialPort(String port, SerialPortParameters parameters, int receiveTimeout) { Contract.Requires<ArgumentNullException>(port != null, "Serial port cannot be null"); Contract.Requires<ArgumentNullException>(parameters != null, "SerialPortParameters cannot be null"); Contract.Requires<ArgumentOutOfRangeException>(receiveTimeout >= 0, "Receive timeout cannot be less than 0"); this.port = port; this.baudRate = parameters.BaudRate; this.receiveTimeout = receiveTimeout; this.parameters = parameters; this._logger = LogManager.GetLogger<MySerialPort>(); SerialPort = new SerialPort(port, baudRate); SerialPort.DataBits = parameters.DataBits; SerialPort.StopBits = parameters.StopBits; SerialPort.Parity = parameters.Parity; SerialPort.Handshake = parameters.FlowControl; SerialPort.ReadTimeout = receiveTimeout; SerialPort.DataReceived += SerialPort_DataReceived; }
/** * Retrieves a serial port connection interface for the provided port with * the given serial port parameters. * * @param port Serial port name. * @param serialPortParameters Serial port parameters. * * @return The serial port connection interface. * * @throws ArgumentNullException if {@code port == null} or * if {@code serialPortParameters == null}. * * @see #createConnectiontionInterface(String, int) * @see com.digi.xbee.api.connection.IConnectionInterface * @see com.digi.xbee.api.connection.serial.SerialPortParameters */ public static IConnectionInterface CreateConnectiontionInterface(string port, SerialPortParameters serialPortParameters) { IConnectionInterface connectionInterface = new MySerialPort(port, serialPortParameters); return(connectionInterface); }
/** * Class constructor. Instantiates a new {@code XBeeDevice} object * physically connected to the given port name and configured to communicate * with the provided serial settings. * * @param port Serial port name where XBee device is attached to. * @param serialPortParameters Object containing the serial port parameters. * * @throws ArgumentNullException if {@code port == null} or * if {@code serialPortParameters == null}. * * @see #XBeeDevice(IConnectionInterface) * @see #XBeeDevice(String, int) * @see #XBeeDevice(String, int, int, int, int, int) * @see com.digi.xbee.api.connection.serial.SerialPortParameters */ public XBeeDevice(String port, SerialPortParameters serialPortParameters) : base(port, serialPortParameters) { resetStatusListener = new CustomModemStatusReceiveListener(this); }
/** * Class constructor. Instantiates a new {@code XBeeDevice} object in the * given serial port name and parameters. * * @param port Serial port name where XBee device is attached to. * @param serialPortParameters Object containing the serial port parameters. * * @throws ArgumentNullException if {@code port == null} or * if {@code serialPortParameters == null}. * * @see #AbstractXBeeDevice(IConnectionInterface) * @see #AbstractXBeeDevice(String, int) * @see #AbstractXBeeDevice(XBeeDevice, XBee64BitAddress) * @see #AbstractXBeeDevice(XBeeDevice, XBee64BitAddress, XBee16BitAddress, String) * @see #AbstractXBeeDevice(String, int, int, int, int, int) * @see com.digi.xbee.api.connection.serial.SerialPortParameters */ public AbstractXBeeDevice(String port, SerialPortParameters serialPortParameters) : this(XBee.CreateConnectiontionInterface(port, serialPortParameters)) { }