TwiceAsNice  2019-02-18
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
DSI::Device Class Reference

#include <DsiDevice.h>

Inheritance diagram for DSI::Device:
Inheritance graph
Collaboration diagram for DSI::Device:
Collaboration graph

Public Member Functions

 Device (const char *devname=0)
 Initialize a generic (base class) DSI device. More...
 
virtual ~Device ()
 
virtual unsigned int getReadWidth ()
 
virtual unsigned int getReadHeightEven ()
 
virtual unsigned int getReadHeightOdd ()
 
virtual unsigned int getReadHeight ()
 
virtual unsigned int getReadBpp ()
 
virtual unsigned int getImageWidth ()
 
virtual unsigned int getImageHeight ()
 
virtual unsigned int getImageOffsetX ()
 
virtual unsigned int getImageOffsetY ()
 
virtual float getPixelSizeX ()
 
virtual float getPixelSizeY ()
 
virtual bool isColor ()
 
virtual bool isBinnable ()
 
virtual bool hasTempSensor ()
 
virtual float ccdTemp ()
 
virtual void abortExposure ()
 Set the device state to "abort exposure requested." The exposure will not be aborted as soon as possible. More...
 
virtual unsigned int getAdRegister (DSI::AdRegister reg)
 Return the value of the specified A-D register. More...
 
virtual void setAdRegister (DSI::AdRegister reg, unsigned int newval)
 Set the value of the specified A-D register. More...
 
virtual std::string getCcdChipName ()
 Return the CCD chip name for this device. More...
 
virtual std::string getCameraName ()
 
virtual void setCameraName (std::string &)
 
virtual unsigned char * getTestPattern ()
 
virtual unsigned char * getImage ()
 
virtual void setExposureTime (double exptime)
 
virtual double getExposureTime ()
 
virtual unsigned char * downloadImage ()
 
virtual int startExposure (int howlong, int gain=0, int offs=0x0ff)
 
virtual int ExposureInProgress ()
 
virtual unsigned char * ccdFramebuffer ()
 
virtual void set1x1Binning ()
 
virtual void set2x2Binning ()
 
virtual void enable2x2Binning ()
 
virtual void disable2x2Binning ()
 
virtual int getGain ()
 
virtual int setGain (int gain)
 
virtual void setVddOn (bool s)
 
void setDebug (bool turnOn)
 
bool isDebug ()
 

Protected Member Functions

void print_data (std::string command, unsigned char buffer[], size_t length)
 
void loadSerialNumber ()
 Initialize the DSI serial number by reading the EEPROM data. More...
 
void loadCcdChipName ()
 Initialize the CCD chip name by reading the EEPROM data where it is stored. More...
 
void loadStatus ()
 Initialize the internal state to reflect the USB bus speed and whether or not the DSI device has firmware debugging(?) enabled. More...
 
void loadVersion ()
 Initialized DSI device version information. More...
 
void loadEepromLength ()
 
void loadCameraName ()
 
virtual ReadoutMode getReadoutMode ()
 Retrieve the DSI device current readout mode. More...
 
virtual void setReadoutMode (DSI::ReadoutMode rm)
 Set the DSI device readout mode. More...
 
unsigned int command (DeviceCommand __command)
 Internal helper for sending a command to the DSI device. More...
 
unsigned int command (DeviceCommand __command, int __option)
 Internal helper for sending a command to the DSI device. More...
 
unsigned int command (DeviceCommand __command, int __option, int __length)
 Internal helper for sending a command to the DSI device. More...
 
unsigned int command (DeviceCommand __command, int __option, int __length, int __expected)
 Internal helper for sending a command to the DSI device. More...
 
std::string * getString (int __offset, int __length)
 Retrieve a string value from the specified EEPROM region. More...
 
void setString (std::string __value, int __offset, int __length)
 
unsigned int getEepromLength ()
 Retrieve the EEPROM length. More...
 
unsigned char getEepromByte (int __offset)
 Read one byte value from the EEPROM. More...
 
unsigned char * getEepromData (int ___offset, int __length)
 Retrieve a segment of the EEPROM data as a sequence of bytes. More...
 
unsigned char setEepromByte (unsigned char __byte, int __offset)
 
void setEepromData (unsigned char *__buffer, int ___offset, int __length)
 
unsigned int command (unsigned char *__buffer, int __length, int __expected)
 Write a command buffer to the DSI device and decode the return buffer. More...
 
unsigned int getByteResult (unsigned char *__buffer)
 Decode byte 4 of the buffer as an 8-bit unsigned integer. More...
 
unsigned int getShortResult (unsigned char *__buffer)
 Decode bytes 4-5 of the buffer as a 16-bit big-endian unsigned integer. More...
 
unsigned int getIntResult (unsigned char *__buffer)
 Decode bytes 4-7 of the buffer as a 32-bit big-endian unsigned integer. More...
 
virtual void initImager (const char *devname=0)
 
virtual unsigned char * getImage (int howlong)
 
virtual unsigned char * getImage (DeviceCommand __command, int howlong)
 
void sendRegister (AdRegister adr, unsigned int arg)
 

Protected Attributes

unsigned char * framebuffer
 
unsigned int read_width
 
unsigned int read_height_even
 
unsigned int read_height_odd
 
unsigned int read_height
 
unsigned int read_bpp
 
unsigned int image_width
 
unsigned int image_height
 
unsigned int image_offset_x
 
unsigned int image_offset_y
 
float pixel_size_x
 
float pixel_size_y
 
unsigned int exposure_time
 
float ccd_temp
 
bool test_pattern
 
bool is_color
 
bool is_high_gain
 
bool is_binnable
 
bool has_tempsensor
 
bool vdd_on
 
double aspect_ratio
 
libusb_device * dev
 
libusb_device_handlehandle
 
unsigned char command_sequence_number
 
ReadoutMode readout_mode
 
UsbSpeed usb_speed
 
bool firmware_debug
 
bool binning2x2
 
unsigned int dsi_family
 
unsigned int dsi_model
 
unsigned int dsi_firmware_version
 
unsigned int dsi_firmware_revision
 
unsigned long long serial_number
 
std::string ccd_chip_name
 
bool abort_requested
 
unsigned int timeout_response
 
unsigned int timeout_request
 
unsigned int timeout_image
 

Static Protected Attributes

static const unsigned int TIMEOUT_FULL_MAX_IMAGE = 0x1770
 
static const unsigned int TIMEOUT_HIGH_MAX_IMAGE = 0x0fa0
 
static const unsigned int TIMEOUT_FULL_MAX_RESPONSE = 0x03e8
 
static const unsigned int TIMEOUT_HIGH_MAX_RESPONSE = 0x03e8
 
static const unsigned int TIMEOUT_FULL_MAX_REQUEST = 0x03e8
 
static const unsigned int TIMEOUT_HIGH_MAX_REQUEST = 0x03e8
 

Private Attributes

bool log_commands
 
int eeprom_length
 
std::string camera_name
 

Constructor & Destructor Documentation

◆ Device()

DSI::Device::Device ( const char *  devname = 0)

Initialize a generic (base class) DSI device.

The generic device will initialize the image size parameters to correspond to a test pattern as well as set the test pattern flag to true. The generic device has no way of knowing the correct CCD size parameters. Derived classes are responsible for overriding these settings. If they do not, all you will be able to retrieve is a test pattern image.

Parameters
devname
Returns

◆ ~Device()

DSI::Device::~Device ( )
virtual

Member Function Documentation

◆ abortExposure()

void DSI::Device::abortExposure ( )
virtual

Set the device state to "abort exposure requested." The exposure will not be aborted as soon as possible.

◆ ccdFramebuffer()

unsigned char * DSI::Device::ccdFramebuffer ( )
virtual

◆ ccdTemp()

virtual float DSI::Device::ccdTemp ( )
inlinevirtual

◆ command() [1/5]

unsigned int DSI::Device::command ( DeviceCommand  __command)
protected

Internal helper for sending a command to the DSI device.

If the command is one which requires no parameters, then the actual execution will be delegated to command(DeviceCommand,int,int), otherwise a dsi_exception is thrown.

Parameters
__commandcommand to be executed.
Returns
decoded command response.

◆ command() [2/5]

unsigned int DSI::Device::command ( DeviceCommand  __command,
int  __option 
)
protected

Internal helper for sending a command to the DSI device.

This determines what the length of the actual command will be and then delgates to command(DeviceCommand,int,int) or command(DeviceCommand).

Parameters
__commandcommand to be executed.
__optioncommand argument, ignored for SOME commands.
Returns
decoded command response.

◆ command() [3/5]

unsigned int DSI::Device::command ( DeviceCommand  __command,
int  __option,
int  __length 
)
protected

Internal helper for sending a command to the DSI device.

This determines what the expected response length is and then delegates actually processing to command(DeviceCommand,int,int,int).

Parameters
__commandcommand to be executed.
__option
__length
Returns
decoded command response.

◆ command() [4/5]

unsigned int DSI::Device::command ( DeviceCommand  __command,
int  __option,
int  __length,
int  __expected 
)
protected

Internal helper for sending a command to the DSI device.

This formats the command as a sequence of bytes and delegates to command(unsigned char *,int,int)

Parameters
__commandcommand to be executed.
__option
__length
__expected
Returns
decoded command response.

◆ command() [5/5]

unsigned int DSI::Device::command ( unsigned char *  __buffer,
int  __length,
int  __expected 
)
protected

Write a command buffer to the DSI device and decode the return buffer.

Parameters
__bufferraw command buffer.
__lengthlength of the command buffer, in bytes.
__expectedexpected length of the response buffer, in bytes.
Returns
decoded response as appropriate for the command.

DSI commands return either 0, 1, 2, or 4 byte results. The results are nominally unsigned integers although in some cases (e.g. GET_VERSION), the 4 bytes are actually 4 separate bytes. However, all 4-byte responses are treated as 32-bit unsigned integers and are decoded and returned that way. Similarly, 2-byte responses are treated as 16-bit unsigned integers and are decoded and returned that way.

◆ disable2x2Binning()

void DSI::Device::disable2x2Binning ( )
virtual

◆ downloadImage()

unsigned char * DSI::Device::downloadImage ( )
virtual

◆ enable2x2Binning()

void DSI::Device::enable2x2Binning ( )
virtual

◆ ExposureInProgress()

int DSI::Device::ExposureInProgress ( )
virtual

◆ getAdRegister()

unsigned int DSI::Device::getAdRegister ( DSI::AdRegister  reg)
virtual

Return the value of the specified A-D register.

Parameters
regwhich register to query.
Returns
register value.

◆ getByteResult()

unsigned int DSI::Device::getByteResult ( unsigned char *  __buffer)
protected

Decode byte 4 of the buffer as an 8-bit unsigned integer.

Parameters
__bufferraw query result buffer from DSI.
Returns
decoded value as an unsigned integer.

◆ getCameraName()

std::string DSI::Device::getCameraName ( )
virtual

◆ getCcdChipName()

std::string DSI::Device::getCcdChipName ( )
virtual

Return the CCD chip name for this device.

Returns
string value for the CCD chip name.

◆ getEepromByte()

unsigned char DSI::Device::getEepromByte ( int  __offset)
protected

Read one byte value from the EEPROM.

Parameters
__offsetoffset from EEPROM start of byte to read
Returns
the value of the EEPROM byte at __offset.

◆ getEepromData()

unsigned char * DSI::Device::getEepromData ( int  __offset,
int  __length 
)
protected

Retrieve a segment of the EEPROM data as a sequence of bytes.

The result will be allocated on the heap as an array of unsigned bytes and must be deleted by the caller.

unsigned char *eepromData = DSI::Device::getEepromData(0,8);
...
delete [] eepromData;
Parameters
__offsetEEPROM offset for start of data.
__lengthlength of EEPROM region to read.
Returns

◆ getEepromLength()

unsigned int DSI::Device::getEepromLength ( )
protected

Retrieve the EEPROM length.

Returns
EEPROM length, in bytes.

◆ getExposureTime()

double DSI::Device::getExposureTime ( )
virtual

◆ getGain()

int DSI::Device::getGain ( )
virtual

◆ getImage() [1/3]

unsigned char * DSI::Device::getImage ( int  howlong)
protectedvirtual

◆ getImage() [2/3]

unsigned char * DSI::Device::getImage ( DeviceCommand  __command,
int  howlong 
)
protectedvirtual

◆ getImage() [3/3]

unsigned char * DSI::Device::getImage ( )
virtual

◆ getImageHeight()

virtual unsigned int DSI::Device::getImageHeight ( )
inlinevirtual

◆ getImageOffsetX()

virtual unsigned int DSI::Device::getImageOffsetX ( )
inlinevirtual

◆ getImageOffsetY()

virtual unsigned int DSI::Device::getImageOffsetY ( )
inlinevirtual

◆ getImageWidth()

virtual unsigned int DSI::Device::getImageWidth ( )
inlinevirtual

◆ getIntResult()

unsigned int DSI::Device::getIntResult ( unsigned char *  __buffer)
protected

Decode bytes 4-7 of the buffer as a 32-bit big-endian unsigned integer.

Parameters
__bufferraw query result buffer from DSI.
Returns
decoded value as an unsigned integer.

◆ getPixelSizeX()

virtual float DSI::Device::getPixelSizeX ( )
inlinevirtual

◆ getPixelSizeY()

virtual float DSI::Device::getPixelSizeY ( )
inlinevirtual

◆ getReadBpp()

virtual unsigned int DSI::Device::getReadBpp ( )
inlinevirtual

◆ getReadHeight()

virtual unsigned int DSI::Device::getReadHeight ( )
inlinevirtual

◆ getReadHeightEven()

virtual unsigned int DSI::Device::getReadHeightEven ( )
inlinevirtual

◆ getReadHeightOdd()

virtual unsigned int DSI::Device::getReadHeightOdd ( )
inlinevirtual

◆ getReadoutMode()

DSI::ReadoutMode DSI::Device::getReadoutMode ( )
protectedvirtual

Retrieve the DSI device current readout mode.

Returns
current readout mode.

◆ getReadWidth()

virtual unsigned int DSI::Device::getReadWidth ( )
inlinevirtual

◆ getShortResult()

unsigned int DSI::Device::getShortResult ( unsigned char *  __buffer)
protected

Decode bytes 4-5 of the buffer as a 16-bit big-endian unsigned integer.

Parameters
__bufferraw query result buffer from DSI.
Returns
decoded value as an unsigned integer.

◆ getString()

std::string * DSI::Device::getString ( int  __offset,
int  __length 
)
protected

Retrieve a string value from the specified EEPROM region.

The string will be allocated on the heap and must be deleted by the caller.

std::string *foo = DSI::Device::getString(8, 20);
...
delete [] foo;
Parameters
__offsetEEPROM offset for start of string.
__lengthlength of EEPROM region to read.
Returns
allocated string formed from EEPROM data.

◆ getTestPattern()

unsigned char * DSI::Device::getTestPattern ( )
virtual

◆ hasTempSensor()

virtual bool DSI::Device::hasTempSensor ( )
inlinevirtual

◆ initImager()

void DSI::Device::initImager ( const char *  devname = 0)
protectedvirtual

◆ isBinnable()

virtual bool DSI::Device::isBinnable ( )
inlinevirtual

◆ isColor()

virtual bool DSI::Device::isColor ( )
inlinevirtual

◆ isDebug()

bool DSI::Device::isDebug ( )
inline

◆ loadCameraName()

void DSI::Device::loadCameraName ( )
protected

◆ loadCcdChipName()

void DSI::Device::loadCcdChipName ( )
protected

Initialize the CCD chip name by reading the EEPROM data where it is stored.

◆ loadEepromLength()

void DSI::Device::loadEepromLength ( )
protected

◆ loadSerialNumber()

void DSI::Device::loadSerialNumber ( )
protected

Initialize the DSI serial number by reading the EEPROM data.

NB: the Meade driver appears to write to the EEPROM if the serial number looks bogus. It write a "serial number" generated from the current date/time which is just plain weird. I suspect that code was an artifact of early engineering samples provided to the original developer that may not have had serial number information burned in the EEPROM. At least, that would make some sense.

◆ loadStatus()

void DSI::Device::loadStatus ( )
protected

Initialize the internal state to reflect the USB bus speed and whether or not the DSI device has firmware debugging(?) enabled.

◆ loadVersion()

void DSI::Device::loadVersion ( )
protected

Initialized DSI device version information.

This queries the device to determine the device family, model, version, and revision. However, the device does not actually identify itself at all. All DSI devices claim to be family 10, model 1, revision 1. If you really want to know what you have, you need to

See also
getCCDNumber().

◆ print_data()

void DSI::Device::print_data ( std::string  command,
unsigned char  buffer[],
size_t  length 
)
protected

◆ sendRegister()

void DSI::Device::sendRegister ( AdRegister  adr,
unsigned int  arg 
)
protected

◆ set1x1Binning()

void DSI::Device::set1x1Binning ( )
virtual

◆ set2x2Binning()

void DSI::Device::set2x2Binning ( )
virtual

◆ setAdRegister()

void DSI::Device::setAdRegister ( DSI::AdRegister  reg,
unsigned int  newval 
)
virtual

Set the value of the specified A-D register.

Parameters
regwhich register to set.
newvalnew value to be assigned.

XXX: What does the value mean?

◆ setCameraName()

void DSI::Device::setCameraName ( std::string &  newname)
virtual

◆ setDebug()

void DSI::Device::setDebug ( bool  turnOn)
inline

◆ setEepromByte()

unsigned char DSI::Device::setEepromByte ( unsigned char  __byte,
int  __offset 
)
protected

◆ setEepromData()

void DSI::Device::setEepromData ( unsigned char *  __buffer,
int  ___offset,
int  __length 
)
protected

◆ setExposureTime()

void DSI::Device::setExposureTime ( double  exptime)
virtual

◆ setGain()

int DSI::Device::setGain ( int  gain)
virtual

◆ setReadoutMode()

void DSI::Device::setReadoutMode ( DSI::ReadoutMode  rm)
protectedvirtual

Set the DSI device readout mode.

Parameters
rm

◆ setString()

void DSI::Device::setString ( std::string  __value,
int  __offset,
int  __length 
)
protected

◆ setVddOn()

void DSI::Device::setVddOn ( bool  s)
virtual

◆ startExposure()

int DSI::Device::startExposure ( int  howlong,
int  gain = 0,
int  offs = 0x0ff 
)
virtual

Member Data Documentation

◆ abort_requested

bool DSI::Device::abort_requested
protected

◆ aspect_ratio

double DSI::Device::aspect_ratio
protected

◆ binning2x2

bool DSI::Device::binning2x2
protected

◆ camera_name

std::string DSI::Device::camera_name
private

◆ ccd_chip_name

std::string DSI::Device::ccd_chip_name
protected

◆ ccd_temp

float DSI::Device::ccd_temp
protected

◆ command_sequence_number

unsigned char DSI::Device::command_sequence_number
protected

◆ dev

libusb_device* DSI::Device::dev
protected

◆ dsi_family

unsigned int DSI::Device::dsi_family
protected

◆ dsi_firmware_revision

unsigned int DSI::Device::dsi_firmware_revision
protected

◆ dsi_firmware_version

unsigned int DSI::Device::dsi_firmware_version
protected

◆ dsi_model

unsigned int DSI::Device::dsi_model
protected

◆ eeprom_length

int DSI::Device::eeprom_length
private

◆ exposure_time

unsigned int DSI::Device::exposure_time
protected

◆ firmware_debug

bool DSI::Device::firmware_debug
protected

◆ framebuffer

unsigned char* DSI::Device::framebuffer
protected

◆ handle

libusb_device_handle* DSI::Device::handle
protected

◆ has_tempsensor

bool DSI::Device::has_tempsensor
protected

◆ image_height

unsigned int DSI::Device::image_height
protected

◆ image_offset_x

unsigned int DSI::Device::image_offset_x
protected

◆ image_offset_y

unsigned int DSI::Device::image_offset_y
protected

◆ image_width

unsigned int DSI::Device::image_width
protected

◆ is_binnable

bool DSI::Device::is_binnable
protected

◆ is_color

bool DSI::Device::is_color
protected

◆ is_high_gain

bool DSI::Device::is_high_gain
protected

◆ log_commands

bool DSI::Device::log_commands
private

◆ pixel_size_x

float DSI::Device::pixel_size_x
protected

◆ pixel_size_y

float DSI::Device::pixel_size_y
protected

◆ read_bpp

unsigned int DSI::Device::read_bpp
protected

◆ read_height

unsigned int DSI::Device::read_height
protected

◆ read_height_even

unsigned int DSI::Device::read_height_even
protected

◆ read_height_odd

unsigned int DSI::Device::read_height_odd
protected

◆ read_width

unsigned int DSI::Device::read_width
protected

◆ readout_mode

ReadoutMode DSI::Device::readout_mode
protected

◆ serial_number

unsigned long long DSI::Device::serial_number
protected

◆ test_pattern

bool DSI::Device::test_pattern
protected

◆ TIMEOUT_FULL_MAX_IMAGE

const unsigned int DSI::Device::TIMEOUT_FULL_MAX_IMAGE = 0x1770
staticprotected

◆ TIMEOUT_FULL_MAX_REQUEST

const unsigned int DSI::Device::TIMEOUT_FULL_MAX_REQUEST = 0x03e8
staticprotected

◆ TIMEOUT_FULL_MAX_RESPONSE

const unsigned int DSI::Device::TIMEOUT_FULL_MAX_RESPONSE = 0x03e8
staticprotected

◆ TIMEOUT_HIGH_MAX_IMAGE

const unsigned int DSI::Device::TIMEOUT_HIGH_MAX_IMAGE = 0x0fa0
staticprotected

◆ TIMEOUT_HIGH_MAX_REQUEST

const unsigned int DSI::Device::TIMEOUT_HIGH_MAX_REQUEST = 0x03e8
staticprotected

◆ TIMEOUT_HIGH_MAX_RESPONSE

const unsigned int DSI::Device::TIMEOUT_HIGH_MAX_RESPONSE = 0x03e8
staticprotected

◆ timeout_image

unsigned int DSI::Device::timeout_image
protected

◆ timeout_request

unsigned int DSI::Device::timeout_request
protected

◆ timeout_response

unsigned int DSI::Device::timeout_response
protected

◆ usb_speed

UsbSpeed DSI::Device::usb_speed
protected

◆ vdd_on

bool DSI::Device::vdd_on
protected

The documentation for this class was generated from the following files: