#include <connectionDevice.h>


Public Types | |
| enum | { NotConnected = -2, DeviceOpenFail = -3, InvalidBaudrate = -4, BaudrateAdjustFail = -5, RecvTimeout = -6, LibraryInitFail = -7, RetryFail = -8, FailCheckVersion = -9 } |
Public Member Functions | |
| ConnectionDevice (int buffer_size=BufferSize-1) | |
| バッファサイズ指定のコンストラクタ | |
| virtual const char * | what (void)=0 |
| エラーメッセージ文字列を返す | |
| int | connect (const char *device, long baudrate) |
| 接続 | |
| void | disconnect (void) |
| 切断 | |
| int | setBaudrate (long baudrate) |
| ボーレートの変更 | |
| virtual bool | isConnected (void)=0 |
| 接続済みかどうかを返す | |
| void | flush (void) |
| データのフラッシュ | |
| int | send (const char *data, int len) |
| 送信 | |
| virtual int | recv (char *data, int maxlen, long timeout=0) |
| 受信 | |
| int | copy (char *data, int maxlen) |
| バッファの状態を変更せずに受信 | |
| int | size (void) |
| 読み出し可能なデータサイズを返す | |
| int | capacity (void) |
| 追加で受信可能なデータサイズを返す | |
| const char * | getDevice (void) |
| 接続デバイス名を返す | |
| long | getBaudrate (void) |
| 接続ボーレートを返す | |
Protected Types | |
| enum | { BufferSize = 4096 } |
Protected Attributes | |
| RingBuffer< char > * | recv_buffer |
Definition at line 21 of file connectionDevice.h.
| ConnectionDevice::ConnectionDevice | ( | int | buffer_size = BufferSize-1 |
) |
バッファサイズ指定のコンストラクタ
| buffer_size | [i] バッファサイズ |
Definition at line 10 of file connectionDevice.cpp.
| int ConnectionDevice::connect | ( | const char * | device, | |
| long | baudrate | |||
| ) |
接続
| device | [i] 接続デバイス | |
| baudrate | [i] 接続ボーレート |
| 0 | 正常終了 | |
| 戻り値 | < 0 エラー |
Definition at line 21 of file connectionDevice.cpp.
References disconnect(), flush(), and isConnected().
Referenced by URGManualCapture::connect(), URGManualCapture::connectSocket(), RunCtrl::connectSocket(), ConnectionHub::preUpdate(), RunCtrl::raw_connect(), and MultiConnectionDevice::subConnect().
| int ConnectionDevice::setBaudrate | ( | long | baudrate | ) |
ボーレートの変更
| baudrate | ボーレート |
| 0 | 正常終了 | |
| 戻り値 | < 0 エラー |
Definition at line 46 of file connectionDevice.cpp.
References isConnected().
Referenced by URGManualCapture::connect().
| virtual bool ConnectionDevice::isConnected | ( | void | ) | [pure virtual] |
接続済みかどうかを返す
| true | 接続済み | |
| false | 切断状態 |
Implemented in PeerConnection, SerialDevice, and TcpipDevice.
Referenced by connect(), disconnect(), flush(), URGManualCapture::isConnected(), RunCtrl::isConnected(), recv(), send(), setBaudrate(), and ConnectionHub::update().
| int ConnectionDevice::send | ( | const char * | data, | |
| int | len | |||
| ) |
送信
| data | [i] 送信データ | |
| len | [i] データサイズ |
| 戻り値 | > 0 送信バイト数 | |
| 戻り値 | < 0 エラー |
Definition at line 82 of file connectionDevice.cpp.
References isConnected().
Referenced by URGManualCapture::capture(), URGManualCapture::connect(), URGManualCapture::send(), ConnectionHub::update(), and RunCtrlHub::update().
| int ConnectionDevice::recv | ( | char * | data, | |
| int | maxlen, | |||
| long | timeout = 0 | |||
| ) | [virtual] |
受信
| data | [o] 受信バッファ | |
| maxlen | [i] 受信バッファの最大幅 | |
| timeout | [i] タイムアウト時間 [msec] |
| 戻り値 | > 0 受信バイト数 | |
| 戻り値 | < 0 エラー |
Reimplemented in PeerConnection.
Definition at line 88 of file connectionDevice.cpp.
References RingBuffer< C >::get(), isConnected(), recv_buffer, and RingBuffer< C >::size().
Referenced by URGManualCapture::connect(), PeerConnection::recv(), URGManualCapture::recv(), URGManualCapture::recv_line(), ConnectionHub::update(), and RunCtrlHub::update().
| int ConnectionDevice::copy | ( | char * | data, | |
| int | maxlen | |||
| ) |
バッファの状態を変更せずに受信
受信バッファの内容を減らすことなくデータを取得する
| data | [o] 受信バッファ | |
| maxlen | [i] 受信バッファの最大幅 |
| 戻り値 | > 0 受信バイト数 | |
| 戻り値 | < 0 エラー |
Definition at line 105 of file connectionDevice.cpp.
References RingBuffer< C >::copy(), and recv_buffer.
| int ConnectionDevice::size | ( | void | ) |
読み出し可能なデータサイズを返す
| 読み出し可能なデータサイズ |
Definition at line 110 of file connectionDevice.cpp.
References recv_buffer, and RingBuffer< C >::size().
Referenced by ConnectionHub::update(), and RunCtrlHub::update().
| int ConnectionDevice::capacity | ( | void | ) |
追加で受信可能なデータサイズを返す
| 追加で受信可能なデータサイズ |
Definition at line 116 of file connectionDevice.cpp.
References RingBuffer< C >::free_size(), and recv_buffer.
| const char * ConnectionDevice::getDevice | ( | void | ) |
| long ConnectionDevice::getBaudrate | ( | void | ) |
RingBuffer<char>* ConnectionDevice::recv_buffer [protected] |
受信バッファ
Definition at line 57 of file connectionDevice.h.
Referenced by capacity(), copy(), flush(), recv(), and size().
1.5.7.1