Skip to content

Commit

Permalink
Include libusb.h directly
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Sep 8, 2024
1 parent c6df6cf commit e34041a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
1 change: 1 addition & 0 deletions libapogee/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR})
include_directories( ${CMAKE_CURRENT_SOURCE_DIR})
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/linux)
include_directories( ${CURL_INCLUDE_DIR})
include_directories( ${USB1_INCLUDE_DIR})

# This is for craft builds
include_directories("${CMAKE_INSTALL_PREFIX}/include")
Expand Down
107 changes: 53 additions & 54 deletions libapogee/linux/GenOneLinuxUSB.h
Original file line number Diff line number Diff line change
@@ -1,98 +1,97 @@
/*!
/*!
* 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
* Copyright(c) 2010 Apogee Instruments, Inc.
* \class GenOneLinuxUSB
* \brief Usb interface for *nix systems.
*
*/
*
*/


#ifndef GENONELINUXUSB_INCLUDE_H__
#define GENONELINUXUSB_INCLUDE_H__
#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 <libusb.h>

#include "../IUsb.h"

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

uint16_t ReadReg(uint16_t FpgaReg);
uint16_t ReadReg(uint16_t FpgaReg);

void WriteReg(uint16_t FpgaReg,
const uint16_t FpgaData );
void WriteReg(uint16_t FpgaReg,
const uint16_t FpgaData );

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

void SetupSingleImgXfer(uint16_t Rows,
uint32_t Cols);
void SetupSingleImgXfer(uint16_t Rows,
uint32_t Cols);

void SetupSequenceImgXfer(uint16_t Rows,
uint16_t Cols, uint16_t NumOfImages);
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 ReadImage(uint16_t * ImageData,
const uint32_t InSizeInBytes,
uint32_t &OutSizeInBytes);

void GetStatus(uint8_t * status, uint32_t NumBytes);
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 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 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 GetSerialNumber(int8_t * ioBuf, uint32_t BufSzInBytes);

void GetUsbFirmwareVersion(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; }
uint16_t GetDeviceNum()
{
return m_DeviceNum;
}

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

void ReadSerialPort( uint16_t PortId,
uint8_t * ioBuf, uint16_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;
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&);
};
GenOneLinuxUSB(const GenOneLinuxUSB &);
GenOneLinuxUSB &operator=(GenOneLinuxUSB &);
};

#endif

0 comments on commit e34041a

Please sign in to comment.