2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FIoSerialPort.h
20 * @brief This is the header file for the %SerialPort class.
22 * This header file contains the declarations of the %SerialPort class.
25 #ifndef _FIO_SERIAL_PORT_H_
26 #define _FIO_SERIAL_PORT_H_
30 namespace Tizen { namespace Io
33 class ISerialPortEventListener;
37 * @brief This class provides an interface for controlling a serial port resource.
41 * @final This class is not intended for extension.
43 * @remarks The serial communication feature is reset when the USB connection is broken or a host device sends the
44 * deactivate command. Any serial port options are not supported by the current version.
46 * The %SerialPort class provides an interface for controlling a serial port resource. @n
48 * 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>.
51 * @see ISerialPortEventListener
53 * The following example demonstrates how to use the %SerialPort class.
59 * using namespace Tizen::Base;
60 * using namespace Tizen::Io;
63 * : public Tizen::Io::ISerialPortEventListener
65 * void OnSerialPortDataReceivedN(Tizen::Base::ByteBuffer& byteBuffer)
70 * void OnSerialPortErrorOccured(result r)
72 * //Check error status.
76 * MyClass::SerialPortSample(void)
78 * SerialPort serialPort;
80 * String szMessage = L"Hello";
81 * SerialRecv listener;
83 * buf.Construct(1024);
84 * buf.SetArray(szMessage.GetPointer(), 0, 6);
87 * //Construct serial port.
88 * serialPort.Construct(listener);
90 * //Write buf on output buffer.
91 * serialPort.Write(buf);
99 class _OSP_EXPORT_ SerialPort
100 : public Tizen::Base::Object
105 * 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.
112 * This destructor overrides Tizen::Base::Object::~Object().
116 virtual ~SerialPort(void);
119 * Constructs a new serial port connection. @n
120 * If the specified port is open, E_SYSTEM is returned.
124 * @return An error code
125 * @param[in] listener The serial port event listener
126 * @exception E_SUCCESS The method is successful.
127 * @exception E_SYSTEM A system error has occurred.
129 result Construct(ISerialPortEventListener& listener);
132 * Writes data to the output buffer synchronously.
136 * @return An error code
137 * @param[in] byteBuffer A reference to the buffer that contains the string data to write
138 * @exception E_SUCCESS The method is successful.
139 * @exception E_MAX_EXCEEDED The buffer size has exceeded the maximum limit of the current device.
140 * @exception E_SYSTEM A system error has occurred.
141 * @see GetWriteBufferSize()
143 result Write(const Tizen::Base::ByteBuffer& byteBuffer);
146 * Gets the size of the write buffer.
150 * @return The size of the write buffer
151 * @remarks The size of the write buffer depends on the device.
153 int GetWriteBufferSize(void) const;
157 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
159 SerialPort(const SerialPort& serialPort);
162 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
164 SerialPort& operator =(const SerialPort& serialPort);
167 class _SerialPortImpl* __pSerialPortImpl;
169 friend class _SerialPortImpl;
175 #endif // _FIO_SERIAL_PORT_H_