Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include <telekyb_serial/SerialDevice.h>
00009 
00010 #include <iostream>
00011 
00012 using namespace telekyb;
00013 
00014 int main(int argc, char **argv) {
00015 
00016 #ifdef __APPLE__
00017         SerialDevice d("/dev/tty.usbserial-A600eG5l");
00018 #else
00019         SerialDevice d("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A2002Rd3-if00-port0", true, O_RDWR | O_NOCTTY);
00020 #endif
00021         
00022         
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030         d.printTermiosAttr();
00031 
00032         return 0;
00033 
00034         
00035         
00036         
00037 
00038         
00039         
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047         sleep(1);
00048         char test2[] = "Das ist ein Test! 1234123423123\r";
00049         d.writeDevice(test2, sizeof(test2));
00050         std::cout << "Done writing " << sizeof(test2) << std::endl;
00051 
00052 
00053         std::string s;
00054         char buf[1024];
00055         int n;
00056         while(true) {
00057                 if ((n = d.readDevice(buf,1024,"\r\n ")) != 0) {
00058                         
00059                         s.clear(); s.append(buf,n);
00060                         std::cout << s << std::endl; 
00061                         
00062                 }
00063                 sleep(1);
00064         }
00065 
00066         return 0;
00067 }
00068 
00069