Libbarrett  1.2.4
include/barrett/bus/abstract/communications_bus.h
00001 
00027 /*
00028  * @file communications_bus.h
00029  * @date 08/26/2010
00030  * @author Dan Cody
00031  *
00032  */
00033 
00034 #ifndef BARRETT_BUS_ABSTRACT_COMMUNICATIONS_BUS_H_
00035 #define BARRETT_BUS_ABSTRACT_COMMUNICATIONS_BUS_H_
00036 
00037 
00038 #include <barrett/thread/abstract/mutex.h>
00039 
00040 
00041 namespace barrett {
00042 namespace bus {
00043 
00044 
00045 class CommunicationsBus {
00046 public:
00047         static const size_t MAX_MESSAGE_LEN = 8;  
00048         static const double TIMEOUT = 1.0;  
00050         virtual ~CommunicationsBus() {} 
00052         virtual thread::Mutex& getMutex() const = 0;
00053 
00054         virtual void open(int port) = 0;
00055         virtual void close() = 0;
00056         virtual bool isOpen() const = 0;
00057 
00058         virtual int send(int busId, const unsigned char* data, size_t len) const = 0;
00059         virtual int receive(int expectedBusId, unsigned char* data, size_t& len, bool blocking = true, bool realtime = false) const;
00060         virtual int receiveRaw(int& busId, unsigned char* data, size_t& len, bool blocking = true) const = 0;
00061 };
00062 
00063 
00064 }
00065 }
00066 
00067 
00068 #endif /* BARRETT_BUS_ABSTRACT_COMMUNICATIONS_BUS_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines