test_serial.cpp
Go to the documentation of this file.
00001 /*
00002  * main.cpp
00003  *
00004  *  Created on: Oct 13, 2011
00005  *      Author: mriedel
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         //int i = 0000016;
00022         //std::cout << i;
00023 
00024 //      tcflag_t cflag = CS8 | CLOCAL | CREAD;
00025 //
00026 //      d.setTermiosAttrCFlag(cflag);
00027 //      d.setTermiosAttrSpeed(B115200,B115200);
00028 
00029 
00030         d.printTermiosAttr();
00031 
00032         return 0;
00033 
00034         //std::string sl("+++\r");
00035         //sl << d;
00036         //sl >> d;
00037 
00038         //result << d;
00039         //std:: cout << result << std::endl;
00040 
00041 //      sleep(1);
00042 //      char test[3] = { '+', '+', '+' };
00043 //      d.writeDevice(test, sizeof(test));
00044 //      usleep(1000);
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                         //std::cout<< "got somehing! n:" << n << std::endl;
00059                         s.clear(); s.append(buf,n);
00060                         std::cout << s << std::endl; // << std:: endl;
00061                         //d.writeDevice(buf,n);
00062                 }
00063                 sleep(1);
00064         }
00065 
00066         return 0;
00067 }
00068 
00069 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


telekyb_serial
Author(s): Martin Riedel
autogenerated on Mon Nov 11 2013 11:14:08