00001
00002
00003
00004 #ifndef LASERDEVICE_H
00005 #define LASERDEVICE_H
00006
00007 namespace RobotFlow {
00008
00009 enum eMeasurementMode {
00010 E_MMODE_MM,
00011 E_MMODE_CM,
00012 };
00013
00014
00015 class LaserDevice
00016 {
00017
00018 friend void* receive_threadLaser (void *myLaser);
00019
00020 public:
00021
00022 LaserDevice(std::string serial_port);
00023
00024
00025 ~LaserDevice();
00026
00027
00028
00029 bool EstablishCommunication();
00030
00031
00032
00033 bool ReadLaserData(unsigned short *data, unsigned long datalen);
00034
00035
00036 int SetLaserMeasurement(eMeasurementMode eMeasureMode, bool bIntensity);
00037
00038
00039
00040
00041 bool SetLaserResolution(int width, int res);
00042
00043
00044 bool SetLaserSpeed(int speed);
00045
00046
00047 bool StartDataAcquisition();
00048
00049
00050 bool StopDataAcquisition();
00051
00052
00053 private:
00054
00055
00056 int SetSerialBaudrate(int nBaudrate);
00057
00058
00059 unsigned short CreateCRC(unsigned char* data, unsigned long len);
00060
00061
00062 void End_session(int fd);
00063
00064
00065 int Port_initialisation(const char *serial_port);
00066
00067
00068 int ReadFromLaser(unsigned char* data, unsigned long maxLen, bool ack, bool timeout);
00069
00070
00071
00072 void Receive();
00073
00074
00075
00076 bool SetLaserMode();
00077
00078
00079 int WriteToLaser(unsigned char* data, unsigned long len);
00080
00081
00082
00083
00084 int m_Laser_fd;
00085 int m_killed;
00086 unsigned short* m_pLastDataBuffer;
00087
00088 pthread_t m_Receiving_thread;
00089 pthread_mutex_t m_list_lock;
00090 std::list<std::string> m_received;
00091 };
00092
00093 }
00094 #endif