net_serial.h
Go to the documentation of this file.
00001 /*
00002  *  RPLIDAR SDK
00003  *
00004  *  Copyright (c) 2009 - 2014 RoboPeak Team
00005  *  http://www.robopeak.com
00006  *  Copyright (c) 2014 - 2016 Shanghai Slamtec Co., Ltd.
00007  *  http://www.slamtec.com
00008  *
00009  */
00010 /*
00011  * Redistribution and use in source and binary forms, with or without
00012  * modification, are permitted provided that the following conditions are met:
00013  *
00014  * 1. Redistributions of source code must retain the above copyright notice,
00015  *    this list of conditions and the following disclaimer.
00016  *
00017  * 2. Redistributions in binary form must reproduce the above copyright notice,
00018  *    this list of conditions and the following disclaimer in the documentation
00019  *    and/or other materials provided with the distribution.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00023  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00024  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00025  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00026  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00027  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00028  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00029  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00030  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00031  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  */
00034 
00035 #pragma once
00036 
00037 #include "hal/abs_rxtx.h"
00038 
00039 namespace rp{ namespace arch{ namespace net{
00040 
00041 class raw_serial : public rp::hal::serial_rxtx
00042 {
00043 public:
00044     enum{
00045         SERIAL_RX_BUFFER_SIZE = 512,
00046         SERIAL_TX_BUFFER_SIZE = 128,
00047     };
00048 
00049     raw_serial();
00050     virtual ~raw_serial();
00051     virtual bool bind(const char * portname, uint32_t baudrate, uint32_t flags = 0);
00052     virtual bool open();
00053     virtual void close();
00054     virtual void flush( _u32 flags);
00055     
00056     virtual int waitfordata(_word_size_t data_count,_u32 timeout = -1, _word_size_t * returned_size = NULL);
00057 
00058     virtual int senddata(const unsigned char * data, _word_size_t size);
00059     virtual int recvdata(unsigned char * data, _word_size_t size);
00060 
00061     virtual int waitforsent(_u32 timeout = -1, _word_size_t * returned_size = NULL);
00062     virtual int waitforrecv(_u32 timeout = -1, _word_size_t * returned_size = NULL);
00063 
00064     virtual size_t rxqueue_count();
00065 
00066     virtual void setDTR();
00067     virtual void clearDTR();
00068 
00069     _u32 getTermBaudBitmap(_u32 baud);
00070 protected:
00071     bool open(const char * portname, uint32_t baudrate, uint32_t flags = 0);
00072     void _init();
00073 
00074     char _portName[200];
00075     uint32_t _baudrate;
00076     uint32_t _flags;
00077 
00078     int serial_fd;
00079 
00080     size_t required_tx_cnt;
00081     size_t required_rx_cnt;
00082 };
00083 
00084 }}}


rplidar_ros
Author(s):
autogenerated on Fri Dec 16 2016 03:59:16