|
| ChatLine () |
| constructor More...
|
|
| ChatLine (const char *_device) |
| constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More...
|
|
| ChatLine (int _fd) |
| constructor with file descriptor More...
|
|
virtual | ~ChatLine () |
| destructor More...
|
|
virtual int | sendline (const std::string &_line) |
| send line _line More...
|
|
virtual int | recvline (std::string &_line) |
| recv line _line More...
|
|
int | dumpdata () |
| dump data in buffers More...
|
|
virtual int | tryReadlines (const int _max=-1) |
| check if you can savly read a line. More...
|
|
int | chat (int _num, const char *_cmd=NULL) |
| send line _cmd and wait for _num lines. More...
|
|
virtual int | chat (const char *_rsp, int _max, const char *_cmd=NULL) |
| send line _cmd and recv lines until a line _rsp is received or _max lines received. More...
|
|
virtual int | chat (const char *_rsp, const char *_cmd=NULL) |
| send line _cmd and recv lines until a line _rsp is received. More...
|
|
int | mprintf (int _num, const char *_cmd=NULL,...) |
| send line _cmd with params (like printf) and wait for _num lines. More...
|
|
int | printf (const char *_rsp_fmtstr, const char *_cmd_fmtstr=NULL,...) |
| send line _cmd with params (like printf) and recv lines until a line _rsp is received. More...
|
|
virtual int | nprintf (int _max, const char *_rsp_fmtstr, const char *_cmd_fmtstr=NULL,...) |
| send line _cmd with params (like printf) and recv lines until a line _rsp is received or _max lines received. More...
|
|
std::string | operator[] (int _num) |
| return recvd line number _num More...
|
|
std::size_t | size () |
| return number of recvd lines More...
|
|
Nice::SeqString | srbuffer () |
|
void | setLineEnd (const char *_end) |
| set the end of a rcvd- and sentline. More...
|
|
void | setLineEndSend (const char *_end) |
| the string _end is sent after every raw line. More...
|
|
void | setLineEndRecv (const char *_end) |
| characters from the string _end are used to detect the end of the line. More...
|
|
void | setMinLine (int _min_line) |
|
| ChatLine () |
| constructor More...
|
|
| ChatLine (const char *_device) |
| constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More...
|
|
| ChatLine (int _fd) |
| constructor with file descriptor More...
|
|
virtual | ~ChatLine () |
| destructor More...
|
|
virtual int | sendline (const std::string &_line) |
| send line _line More...
|
|
virtual int | recvline (std::string &_line) |
| recv line _line More...
|
|
int | dumpdata () |
| dump data in buffers More...
|
|
virtual int | tryReadlines (const int _max=-1) |
| check if you can savly read a line. More...
|
|
int | chat (int _num, const char *_cmd=NULL) |
| send line _cmd and wait for _num lines. More...
|
|
virtual int | chat (const char *_rsp, int _max, const char *_cmd=NULL) |
| send line _cmd and recv lines until a line _rsp is received or _max lines received. More...
|
|
virtual int | chat (const char *_rsp, const char *_cmd=NULL) |
| send line _cmd and recv lines until a line _rsp is received. More...
|
|
int | mprintf (int _num, const char *_cmd=NULL,...) |
| send line _cmd with params (like printf) and wait for _num lines. More...
|
|
int | printf (const char *_rsp_fmtstr, const char *_cmd_fmtstr=NULL,...) |
| send line _cmd with params (like printf) and recv lines until a line _rsp is received. More...
|
|
virtual int | nprintf (int _max, const char *_rsp_fmtstr, const char *_cmd_fmtstr=NULL,...) |
| send line _cmd with params (like printf) and recv lines until a line _rsp is received or _max lines received. More...
|
|
std::string | operator[] (int _num) |
| return recvd line number _num More...
|
|
std::size_t | size () |
| return number of recvd lines More...
|
|
Nice::SeqString | srbuffer () |
|
void | setLineEnd (const char *_end) |
| set the end of a rcvd- and sentline. More...
|
|
void | setLineEndSend (const char *_end) |
| the string _end is sent after every raw line. More...
|
|
void | setLineEndRecv (const char *_end) |
| characters from the string _end are used to detect the end of the line. More...
|
|
void | setMinLine (int _min_line) |
|
| ChatCore () |
| constructor More...
|
|
| ChatCore (const char *_device) |
| constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More...
|
|
| ChatCore (int _fd) |
| constructor with file descriptor More...
|
|
virtual | ~ChatCore () |
| destructor More...
|
|
virtual int | open () |
|
virtual int | open (const char *_device) |
| open device with name tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More...
|
|
virtual int | open (int _fd) |
| open device with file descriptor More...
|
|
virtual int | close () |
| closedevice More...
|
|
virtual bool | isConnected () const |
| check if its connected More...
|
|
virtual int | wait (Nice::Time _time) |
| wait _time sec for data, returns earlier as soon as data has arrived. More...
|
|
virtual int | openListenSocket (int _port) |
| open a listen socket. More...
|
|
virtual int | tryAccept (ChatCore &_newConnection) |
| try accepting for X secs. X is set by member setTimeout More...
|
|
void | setTimeout (Nice::Time _t) |
| set read timeout in seconds, -1 = wait forever. More...
|
|
Nice::Time | timeout () |
|
void | setVerbose (int _v) |
| set verbosity parameters More...
|
|
void | setName (std::string _name) |
|
std::string | name () |
|
| ChatCore () |
| constructor More...
|
|
| ChatCore (const char *_device) |
| constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More...
|
|
| ChatCore (int _fd) |
| constructor with file descriptor More...
|
|
virtual | ~ChatCore () |
| destructor More...
|
|
virtual int | open () |
|
virtual int | open (const char *_device) |
| open device with name tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More...
|
|
virtual int | open (int _fd) |
| open device with file descriptor More...
|
|
virtual int | close () |
| closedevice More...
|
|
virtual bool | isConnected () const |
| check if its connected More...
|
|
virtual int | wait (Nice::Time _time) |
| wait _time sec for data, returns earlier as soon as data has arrived. More...
|
|
virtual int | openListenSocket (int _port) |
| open a listen socket. More...
|
|
virtual int | tryAccept (ChatCore &_newConnection) |
| try accepting for X secs. X is set by member setTimeout More...
|
|
void | setTimeout (Nice::Time _t) |
| set read timeout in seconds, -1 = wait forever. More...
|
|
Nice::Time | timeout () |
|
void | setVerbose (int _v) |
| set verbosity parameters More...
|
|
void | setName (std::string _name) |
|
std::string | name () |
|
Line oriented communication class for serialized data streams, like tcp connections,
- Author
- Florian Briegel
- Version
- 11.02.04
- Date
- 2012-08-10 11:04:58 AM serial lines (tty), ...
Connection to a serial driven is done through a tcp connection (tcp://HOSTNAME:PORT) or a tty device (tty:/dev/ttyX:BAUD).
Blockbuilding of the streamd data to lines is done by enddelimiters.
The class can be uses for server and client applications.
Here is small example connecting to a serial device(tty or tcp):
#include <Nice/Log.h>
#include <Nice/Chat.h>
if (argc < 2) F_RETURN(-1, "Please give a adress: tcp://HOST:PORT or tty:/dev/TTY:BAUDRATE,DATA");
int main (int argc, char *argv[])
{
ChatLine myDevice;
try
{
myDevice.open(argv[1]);
myDevice.chat("1 21 0 *", "1 21 0 mpia");
myDevice.chat("1 21 1 *", "1 22 0 mpia");
}
catch(const Nice::ChatException & e)
{
E_LOG(e);
}
return 0;
}
Here is small example for a tcp server waiting for connections and only accepting one client.
#include <Nice/Log.h>
#include <Nice/Chat.h>
int main (int argc, char *argv[])
{
ChatLine myListenDevice;
ChatLine myDevice;
int rc;
try
{
while(1)
{
// open listen port.
myListenDevice.openListenSocket(4711);
// set timeout to listen forever.
myListenDevice.setTimeout(-1);
D_LOG("Waiting for connection");
myListenDevice.tryAccept(myDevice);
// close listen port.
myListenDevice.close();
// connected!
myDevice.setVerbose(SRDATA_VERBOSE | SRDATA_COLOR);
do
{
rc = srdata_chat(1, NULL);
srdata_printf(0, "echo %s", multi_buffer[0]);
}
while(rc > 0);
myDevice.close();
}
}
catch(const Nice::ChatException & e)
{
E_LOG(e);
}
return 0;
}
- Todo:
- Some c++ style parameter for chat call
- Author
- Florian Briegel
- Version
- 11.02.04
- Date
- 2012-08-10 11:04:58 AM serial lines (tty), ...
Connection to a serial driven is done through a tcp connection (tcp://HOSTNAME:PORT) or a tty device (tty:/dev/ttyX:BAUD).
Blockbuilding of the streamd data to lines is done by enddelimiters.
The class can be uses for server and client applications.
Here is small example connecting to a serial device(tty or tcp):
#include <Nice/Log.h>
#include <Nice/Chat.h>
if (argc < 2) F_RETURN(-1, "Please give a adress: tcp://HOST:PORT or tty:/dev/TTY:BAUDRATE,DATA");
int main (int argc, char *argv[])
{
ChatLine myDevice;
try
{
myDevice.open(argv[1]);
myDevice.chat("1 21 0 *", "1 21 0 mpia");
myDevice.chat("1 21 1 *", "1 22 0 mpia");
}
catch(const Nice::ChatException & e)
{
E_LOG(e);
}
return 0;
}
Here is small example for a tcp server waiting for connections and only accepting one client.
#include <Nice/Log.h>
#include <Nice/Chat.h>
int main (int argc, char *argv[])
{
ChatLine myListenDevice;
ChatLine myDevice;
int rc;
try
{
while(1)
{
// open listen port.
myListenDevice.openListenSocket(4711);
// set timeout to listen forever.
myListenDevice.setTimeout(-1);
D_LOG("Waiting for connection");
myListenDevice.tryAccept(myDevice);
// close listen port.
myListenDevice.close();
// connected!
myDevice.setVerbose(SRDATA_VERBOSE | SRDATA_COLOR);
do
{
rc = srdata_chat(1, NULL);
srdata_printf(0, "echo %s", multi_buffer[0]);
}
while(rc > 0);
myDevice.close();
}
}
catch(const Nice::ChatException & e)
{
E_LOG(e);
}
return 0;
}
- Todo:
- Some c++ style parameter for chat call