Pleora Technologies Inc. eBUS SDK v6.2.8.5877 API



PvDeviceSPIBus Class Reference

SPI serial controller. More...

Public Member Functions

 PvDeviceSPIBus ()
 Constructor.
 
 ~PvDeviceSPIBus ()
 Destructor.
 
PvResult Open (IPvDeviceAdapter *aDevice, PvDeviceSerial aPort=PvDeviceSerialBulk0)
 Open an SPI channel to the device on given port. More...
 
PvResult Close ()
 Close the SPI channel to the device. More...
 
bool IsOpened ()
 Test whether SPI is opened or not. More...
 
PvResult BurstRead (unsigned char *aBuffer, uint32_t aBufferSize, uint32_t &aBytesRead, uint32_t aTimeout=0)
 Retrieve bytes read back from a device. More...
 
PvResult BurstWriteAndRead (unsigned char *aWriteBuffer, uint32_t aWriteBufferSize, uint32_t aReadBufferSize=0, bool aWriteRead=false, bool aSSNFlagOn=false)
 Send a command to the camera and/or expect data back for maximum transfers of 255 bytes. More...
 

Static Public Member Functions

static bool IsSupported (IPvDeviceAdapter *aDevice, PvDeviceSerial aPort=PvDeviceSerialBulk0)
 Test whether the device supports SPI and if it is available. The device should be connected. The BulkSelector of the device should be set appropriately (e.g. if SPI is supposed to be on Bulk0, then BulkSelector should be set to Bulk0, otherwise even if the device supports SPI, this function will return false). Consult with device documentation on when and on which port SPI is supported and available. More...
 

Detailed Description

SPI serial controller.

The PvDeviceSPIBus lets you send commands to your camera and receive the camera's replies.

SPI uses the concept of a master and slave, where the master controls the clock and initiates reads and writes. For PvDeviceSPIBus, the Pleora Video Interface is the SPI master. The SPI slave is typically a camera, but could be any SPI-capable device connected to the Pleora Video Interface.

The PvDeviceSPIBus methods manage the entire Pleora Video Interface and camera communication required to send a message to the camera. It does not however do the configuration and setting the mode to SPI (these should be done through the GenICam interface before write/read functions are called). For example if SPI is on Bulk0, then BulkSelector needs to be set to Bulk0 The BurstWriteAndRead can be used to :

  1. Write a set of bytes to SPI; no data is expected to be read back
  2. write only but have SS_N flag on
  3. read only
  4. write read simultaneously

For the complete hardware-level transactions for all PvDeviceSPIBus methods, see your hardware guide.

To send SPI-protocol serial commands to your camera:

  1. Using GenICam interface, set the device in SPI mode (e.g. BulkSelector=Bulk0, BulkMode=SPI if this is what the documentation suggests)
  2. Create an SPI serial controller. Use PvDeviceSPIBus::PvDeviceSPIBus.
  3. Send a command to the camera. Use BurstWriteAndRead
  4. Test to ensure the message send succeeded. Check the PvResult returned by BurstWriteAndRead
  5. Retrieve the camera's reply. Use BurstRead.
  6. Test to ensure the message retrieval succeeded. Check the PvResult returned by BurstRead.
  7. Test the content of the message from the camera. Use aBuffer and aBufferSize parameters and your own code.

Member Function Documentation

PvResult PvDeviceSPIBus::BurstRead ( unsigned char *  aBuffer,
uint32_t  aBufferSize,
uint32_t &  aBytesRead,
uint32_t  aTimeout = 0 
)

Retrieve bytes read back from a device.

Wait aTimeOut milliseconds for the data read. The data read should have been initiated by either a ReadOnly or WriteRead using BurstWriteAndRead

Parameters
[out]aBufferA pointer to the data being received from the camera.
[in]aBufferSizeThe buffer's anticipated size. BurstRead never returns with a buffer size larger than the originally specified aBufferSize.
[out]aBytesReadThe number of bytes read. Maximum of 255 bytes
[in]aTimeoutTime out in milliseconds before returning if no data is received
Returns
PvResult
PvResult PvDeviceSPIBus::BurstWriteAndRead ( unsigned char *  aWriteBuffer,
uint32_t  aWriteBufferSize,
uint32_t  aReadBufferSize = 0,
bool  aWriteRead = false,
bool  aSSNFlagOn = false 
)

Send a command to the camera and/or expect data back for maximum transfers of 255 bytes.

The BurstWriteAndRead method sends a message, aBuffer, to the SPI-capable camera and or expects aReadBufferSize bytes to come back (read). There are four modes: 1) Write-Only: Write aWriteBufferSize bytes to SPI. Can hold SSNFlagOn high. aWriteRead should be false aReadBufferSize should be 0 2) Read-Only: schedule a read of aReadBufferSize bytes. aWriteBufferSize is 0. No write is done, but a read is scheduled 3) Write-Read: N bytes are written while M bytes are read back. aWriteRead and aSSNFlagOn should be false. 4) Write-Read: N bytes are written and read back. aWriteRead is true. aSSNFlagOn should be false

Parameters
[in]aWriteBufferA pointer to the data being sent to the camera. is ignored if Read-Only
[in]aWriteBufferSizeThe write buffer's size. Should be 0 in Read-only mode, Maximum of 255 bytes
[in]aReadBufferSizeNumber of bytes to read back (0 for Write-Only mode), Maximum of 255 bytes
[in]aWriteReadtrue for Write-Read of same number of bytes
[in]aSSNFlagOnwhen in Write-Only mode, whether to keep SS_N flag on
Returns
PvResult
PvResult PvDeviceSPIBus::Close ( )

Close the SPI channel to the device.

Returns
PvResult
bool PvDeviceSPIBus::IsOpened ( )

Test whether SPI is opened or not.

Returns
true if opened, false otherwise
bool PvDeviceSPIBus::IsSupported ( IPvDeviceAdapter aDevice,
PvDeviceSerial  aPort = PvDeviceSerialBulk0 
)
static

Test whether the device supports SPI and if it is available. The device should be connected. The BulkSelector of the device should be set appropriately (e.g. if SPI is supposed to be on Bulk0, then BulkSelector should be set to Bulk0, otherwise even if the device supports SPI, this function will return false). Consult with device documentation on when and on which port SPI is supported and available.

Parameters
[in]aDeviceA pointer to connected device to test support for SPI
[in]aPortPort to check support for SPI (Bulk0 default if not specified)
Returns
true if SPI is supported and available
PvResult PvDeviceSPIBus::Open ( IPvDeviceAdapter aDevice,
PvDeviceSerial  aPort = PvDeviceSerialBulk0 
)

Open an SPI channel to the device on given port.

aDevice should be connected already. Will return error if device is not connect or SPI is not supported or unavailable Note that the BulkSelector and BulkMode registers should be set appropriately before calling open. For example if SPI is supported on Bulk0, then BulkSelector should be set to Bulk0 and BulkMode set to SPI before calling open. Open does not set these. In other words, it is assumed that the bulk mode has been set to SPI already using GenICam Interface before open is called

Parameters
[in]aDeviceA pointer to connected device to open an SPI channel to
[in]aPortPort to use for SPI (Bulk0 default if not specified)
Returns
PvResult will return error if device is not connected or SPI is not supported or unavailable

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

Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com