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


rplidar_ros
Author(s):
autogenerated on Fri Aug 28 2015 12:46:43