File: GenOneLinuxUSB.h

package info (click to toggle)
libapogee3 3.2%2B20221221183454-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 9,284 kB
  • sloc: cpp: 26,737; sh: 8; makefile: 3
file content (98 lines) | stat: -rw-r--r-- 2,606 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*! 
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright(c) 2010 Apogee Instruments, Inc. 
* \class GenOneLinuxUSB 
* \brief Usb interface for *nix systems.
* 
*/ 


#ifndef GENONELINUXUSB_INCLUDE_H__ 
#define GENONELINUXUSB_INCLUDE_H__ 

#include <string>
#include <vector>

#ifdef OSX_EMBEDED_MODE
	#include <libusb.h>
#else
	#include <libusb-1.0/libusb.h>
#endif

#include "../IUsb.h"

class GenOneLinuxUSB : public IUsb
{ 
    public: 
		GenOneLinuxUSB( const uint16_t DeviceNum );
		virtual ~GenOneLinuxUSB();

		uint16_t ReadReg(uint16_t FpgaReg);

		void WriteReg(uint16_t FpgaReg,
			const uint16_t FpgaData );

		void GetVendorInfo(uint16_t & VendorId,
			uint16_t & ProductId, uint16_t  & DeviceId);

		void SetupSingleImgXfer(uint16_t Rows,
			uint32_t Cols);

		void SetupSequenceImgXfer(uint16_t Rows,
			uint16_t Cols, uint16_t NumOfImages);

        void CancelImgXfer();

		void ReadImage(uint16_t * ImageData,
					   const uint32_t InSizeInBytes,
					   uint32_t &OutSizeInBytes);

		void GetStatus(uint8_t * status, uint32_t NumBytes);

		void UsbRequestIn(uint8_t RequestCode,
			uint16_t	Index, uint16_t	Value,
			uint8_t * ioBuf, uint32_t BufSzInBytes);

		void UsbRequestOut(uint8_t RequestCode,
			uint16_t	Index, uint16_t Value,
			const uint8_t * ioBuf, uint32_t BufSzInBytes);

		void GetSerialNumber(int8_t * ioBuf, uint32_t BufSzInBytes);

		void GetUsbFirmwareVersion(int8_t * ioBuf, uint32_t BufSzInBytes);

        std::string GetDriverVersion();

        bool IsError();

        uint16_t GetDeviceNum() { return m_DeviceNum; }

        void UsbReqOutWithExtendedTimeout(uint8_t RequestCode,
            uint16_t Index, uint16_t	Value,
            const uint8_t * ioBuf, uint32_t BufSzInBytes);

        void ReadSerialPort( uint16_t PortId, 
            uint8_t * ioBuf, uint16_t BufSzInBytes );

    private:
		 bool OpenDeviceHandle(const uint16_t DeviceNum, std::string & err);
		 libusb_context * m_Context;
		 libusb_device_handle  * m_Device;
		 libusb_device_descriptor m_DeviceDescriptor;
		 const std::string m_fileName;
         bool m_ReadImgError;
         bool m_IoError;
         int32_t m_NumRegWriteRetries;
         uint16_t m_DeviceNum;

        //disabling the copy ctor and assignment operator
        //generated by the compiler - don't want them
        //Effective C++ Item 6
        GenOneLinuxUSB(const GenOneLinuxUSB&);
        GenOneLinuxUSB& operator=(GenOneLinuxUSB&);
}; 

#endif