2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FIoSerialPort.h
19 * @brief This is the header file for the %SerialPort class.
21 * This header file contains the declarations of the %SerialPort class.
24 #ifndef _FIO_SERIAL_PORT_H_
25 #define _FIO_SERIAL_PORT_H_
29 namespace Tizen { namespace Io
32 class ISerialPortEventListener;
36 * @brief This class provides an interface for controlling a serial port resource.
40 * @final This class is not intended for extension.
42 * @remarks The serial communication feature is reset when the USB connection is broken or a host device sends the
43 * deactivate command. Any serial port options are not supported by the current version.
45 * The %SerialPort class provides an interface for controlling a serial port resource. @n
47 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/io/serial_port_comm.htm">Serial Port Communication</a>.
50 * @see ISerialPortEventListener
52 * The following example demonstrates how to use the %SerialPort class.
58 * using namespace Tizen::Base;
59 * using namespace Tizen::Io;
62 * : public Tizen::Io::ISerialPortEventListener
64 * void OnSerialPortDataReceivedN(Tizen::Base::ByteBuffer& byteBuffer)
69 * void OnSerialPortErrorOccured(result r)
71 * //Check error status.
75 * MyClass::SerialPortSample(void)
77 * SerialPort serialPort;
79 * String szMessage = L"Hello";
80 * SerialRecv listener;
82 * buf.Construct(1024);
83 * buf.SetArray(szMessage.GetPointer(), 0, 6);
86 * //Construct serial port.
87 * serialPort.Construct(listener);
89 * //Write buf on output buffer.
90 * serialPort.Write(buf);
98 class _OSP_EXPORT_ SerialPort
99 : public Tizen::Base::Object
104 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
111 * This destructor overrides Tizen::Base::Object::~Object().
115 virtual ~SerialPort(void);
118 * Constructs a new serial port connection. @n
119 * If the specified port is open, E_SYSTEM is returned.
123 * @return An error code
124 * @param[in] listener The serial port event listener
125 * @exception E_SUCCESS The method is successful.
126 * @exception E_SYSTEM A system error has occurred.
128 result Construct(ISerialPortEventListener& listener);
131 * Writes data to the output buffer synchronously.
135 * @return An error code
136 * @param[in] byteBuffer A reference to the buffer that contains the string data to write
137 * @exception E_SUCCESS The method is successful.
138 * @exception E_MAX_EXCEEDED The buffer size has exceeded the maximum limit of the current device.
139 * @exception E_SYSTEM A system error has occurred.
140 * @see GetWriteBufferSize()
142 result Write(const Tizen::Base::ByteBuffer& byteBuffer);
145 * Gets the size of the write buffer.
149 * @return The size of the write buffer
150 * @remarks The size of the write buffer depends on the device.
152 int GetWriteBufferSize(void) const;
156 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
158 SerialPort(const SerialPort& serialPort);
161 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
163 SerialPort& operator =(const SerialPort& serialPort);
166 class _SerialPortImpl* __pSerialPortImpl;
168 friend class _SerialPortImpl;
174 #endif // _FIO_SERIAL_PORT_H_