orca-robotics INTRODUCTION Overview Download and Install Documentation REPOSITORY Interfaces Drivers Libraries Utilities Software Map DEVELOPER Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
usbftdirmpio.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef ORCA2_SEGWAY_USB_FTDI_RMP_IO_H 00012 #define ORCA2_SEGWAY_USB_FTDI_RMP_IO_H 00013 00014 #include <queue> 00015 #include <ftd2xx.h> 00016 #include "../canpacket.h" 00017 #include "../rmpio.h" 00018 00019 namespace usbftdi { 00020 class UsbFtdi; 00021 } 00022 00023 namespace segwayrmpacfr 00024 { 00025 00026 // 00027 // 00028 // 00029 class UsbFtdiRmpIo : public RmpIo 00030 { 00031 public: 00032 00033 UsbFtdiRmpIo(); 00034 ~UsbFtdiRmpIo(); 00035 00036 // from RmpIo 00037 virtual void enable(int debugLevel); 00038 virtual void disable(void); 00039 virtual RmpIo::RmpIoStatus readPacket( CanPacket &pkt ); 00040 virtual void writePacket( const CanPacket &pkt ); 00041 00042 private: 00043 00044 // STORAGE 00045 00046 bool isEnabled_; 00047 00048 // a char buffer to read USB stream into 00049 std::vector<unsigned char> charBuffer_; 00050 // have to remember how many char are left in the buffer 00051 unsigned int charBufferBytes_; 00052 // a buffer to store parsed CAN messages 00053 std::queue<CanPacket> canBuffer_; 00054 00055 // HARDWDARE 00056 00057 // handle to the USB device inside our Segway 00058 usbftdi::UsbFtdi *usbFtdi_; 00059 00060 // Don't call this if the buffer's empty. 00061 void getPacketFromCanBuffer( CanPacket* pkt ); 00062 00063 RmpIo::RmpIoStatus readPacketNonBlocking( CanPacket* pkt ); 00064 RmpIo::RmpIoStatus readPacketBlocking( CanPacket* pkt ); 00065 // Not used but keep for reference 00066 //RmpUsbIoStatus readPacketPolling( CanPacket* pkt ); 00067 00068 RmpIo::RmpIoStatus readFromUsbToBufferNonBlocking(); 00069 RmpIo::RmpIoStatus readFromUsbToBufferBlocking(); 00070 void readFromBufferToQueue(); 00071 00072 int parseUsbToCan( CanPacket *pkt, const unsigned char *bytes ); 00073 int parseCanToUsb( const CanPacket *pkt, unsigned char *bytes ); 00074 00075 unsigned char usbMessageChecksum( unsigned char *msg ); 00076 00077 int debugLevel_; 00078 }; 00079 00080 } // namespace 00081 00082 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)