An example of how to use the Serial class
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
class MyClass : public sigc::trackable
{
public:
MyClass(void)
{
serial =
new Serial(
"/dev/ttyS0");
serial->charactersReceived.connect(
mem_fun(*this, &MyClass::onCharactersReceived));
if (!serial->open(true))
{
perror("Open serial port failed");
exit(1);
}
serial->setParams(9600, Serial::PARITY_NONE, 8, 1, Serial::FLOW_NONE);
serial->write("Hello, serial\n", 14);
}
~MyClass(void)
{
serial->close();
delete serial;
}
private:
void onCharactersReceived(char *buf, int count)
{
cout << "Read " << count << " characters from serial port: "
<< buf << endl;
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}
The core class for writing asyncronous cpp applications.
A class for using asynchronous serial communications.
An application class for writing non GUI applications.
void exec(void)
Execute the application main loop.
A class for using asyncronous serial communications.
Namespace for the asynchronous programming classes.