Once the device has been selected, the update process will be started. Depending on the selected device and parameters the console output might and the duration might differ.
If desired, this sample can also be used as a command-line tool to update Balluff/MATRIX VISION devices. The following command-line parameters might be useful in this case.
The update process itself is very straight forward. It is just necessary to create an instance of mvIMPACT::acquire::FirmwareUpdater. To configure the update process itself it is necessary to pass the correct parameters to the constructor. Afterwards it is sufficient to call mvIMPACT::acquire::FirmwareUpdater::update.
The callbacks can be customized to get the required behavior. In this example the update status callbacks just return some message to the shell and look like this:
{
public:
explicit MyFirmwareUpdater(
mvIMPACT::acquire::Device* pDev,
bool boForceOverideSameVersion =
false,
bool boForceDowngrade =
false,
bool boForceSameVersion =
false,
bool boForceBreakingChange =
false ) :
mvIMPACT::acquire::FirmwareUpdater( pDev, boForceOverideSameVersion, boForceDowngrade, boForceSameVersion, oForceBreakingChange ) }
virtual int onErrorMessage( const double timeElapsed_s ) const
{
cout << "Error: " << statusMessage() << "@" << timeElapsed_s << " s" << endl;
return fuaCancel;
}
virtual int onErasingFlash( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Erasing - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onUnzippingFirmwareArchive( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Unzipping firmware archive - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onUpdatingBootProgrammer( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Updating boot programmer - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onUploadingImage( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Uploading - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onRebooting( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Rebooting - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onHardResetRequired( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Rebooting - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl
<< "Manual hard reset required." << endl;
}
virtual int onSavingUserSets( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Saving sets - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onLoadingUserSets( const int currentProgress_pc, const double timeElapsed_s ) const
{
cout << "Loading sets - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
};
This class and its functions represent an actual device detected by this interface in the current sys...
Definition mvIMPACT_acquire.h:6118
A class to perform a firmware update of a specific device.
Definition mvIMPACT_acquire.h:23365
@ fuaContinue
The default return value to tell the driver to continue processing the firmware update.
Definition mvDriverBaseEnums.h:3035
@ fuaCancel
Return this value to request the driver to terminate an ongoing firmware update as soon as possible.
Definition mvDriverBaseEnums.h:3037
For mvBlueFOX3 or mvBlueCOUGAR-X/XD/XT devices it is necessary to provide the path to a firmware archive (*.mvu file). Some cases might require some specific parameters to be changed e.g. in case of downgrading a device or if there might be a breaking change within the device's software interface.
As BVS CA-BN (mvBlueNAOS) devices are very much integrated within the host system, there is no separate firmware file which can be downloaded. The devices firmware is embedded into the Impact Acquire framework and has to be updated once the Impact Acquire framework on the host system contains breaking changes. This applies for upgrades as well as for downgrades.
As mvBlueFOX devices are not capable of the complex functionalities provided by GenICam™ compliant devices the set of configurable parameters is much more limited. There is no specific firmware file available, instead different firmware versions are shipped within the mvBlueFOX package and can be selected for the update via the mvIMPACT::acquire::FirmwareUpdater::firmwareVersionToUpload property.
#ifdef _MSC_VER
# if _MSC_VER < 1300
# pragma warning( disable : 4786 )
# endif
# include <windows.h>
#endif
#include <iostream>
#include <apps/Common/exampleHelper.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
using namespace std;
enum DeviceFamily
{
dfBVS_CA_BN,
dfMvBlueCOUGAR,
dfMvBlueFOX3,
dfMvBlueFOX,
dfUnknown
};
{
public:
explicit MyFirmwareUpdater(
mvIMPACT::acquire::Device* pDev,
bool boForceOverideSameVersion =
false,
bool boForceDowngrade =
false,
bool boForceSameVersion =
false,
bool boForceBreakingChange =
false ) :
mvIMPACT::acquire::
FirmwareUpdater( pDev, boForceOverideSameVersion, boForceDowngrade, boForceSameVersion, boForceBreakingChange ) {}
{
cout <<
"Error: " <<
statusMessage() <<
"@" << timeElapsed_s <<
" s" << endl;
}
virtual int onErasingFlash(
const int currentProgress_pc,
const double timeElapsed_s )
const
{
cout << "Erasing - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
{
cout << "Unzipping firmware archive - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
{
cout << "Updating boot programmer - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onUploadingImage(
const int currentProgress_pc,
const double timeElapsed_s )
const
{
cout << "Uploading - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onRebooting(
const int currentProgress_pc,
const double timeElapsed_s )
const
{
cout << "Rebooting - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onHardResetRequired(
const int currentProgress_pc,
const double timeElapsed_s )
const
{
cout << "Rebooting - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl
<< "Manual hard reset required." << endl;
}
virtual int onSavingUserSets(
const int currentProgress_pc,
const double timeElapsed_s )
const
{
cout << "Saving sets - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
virtual int onLoadingUserSets(
const int currentProgress_pc,
const double timeElapsed_s )
const
{
cout << "Loading sets - Update progress: " << currentProgress_pc << ", time " << timeElapsed_s << " s" << endl;
}
};
bool IsGigEVisionDevice(
const Device* pDev )
{
if( locator.bindComponent( deviceIPAddress,
"DeviceIPAddress" ) && ( deviceIPAddress.
readS() !=
"Unavailable" ) )
{
return true;
}
return false;
}
DeviceFamily GetDeviceFamily(
const Device* pDev )
{
if( ( pDev->
family.
readS() ==
"mvBlueCOUGAR" || pDev->
family.
readS() ==
"BVS CA" ) && IsGigEVisionDevice( pDev ) )
{
return dfMvBlueCOUGAR;
}
{
return dfMvBlueFOX3;
}
else if( ( pDev->
family.
read().find(
"mvBlueNAOS" ) == 0 ) || ( pDev->
family.
read().find(
"BVS CA-BN" ) == 0 ) )
{
return dfBVS_CA_BN;
}
{
return dfMvBlueFOX;
}
return dfUnknown;
}
bool GetLatestLocalFirmwareVersion(
const Device* pDev,
string& latestFirmwareVersion )
{
if( !locator.bindComponent( firmwareVersionLatest, "FirmwareVersionLatest" ) )
{
return false;
}
latestFirmwareVersion = firmwareVersionLatest.
readS();
return ( currentFirmwareVersion == latestFirmwareVersion );
}
TDMR_ERROR updateBlueCOUGAROrBlueFOX3(
Device* pDev,
const string& pathToFirmwareArchive,
bool boForceOverideSameVersion,
bool boForceDowngrade,
bool boForceSameVersion,
bool boForceBreakingChange,
string& status )
{
MyFirmwareUpdater fwu( pDev, boForceOverideSameVersion, boForceDowngrade, boForceSameVersion, boForceBreakingChange );
result = fwu.update( pathToFirmwareArchive );
if( result == DMR_NO_ERROR )
{
result = fwu.verifyFirmwareChecksum( pDev, pathToFirmwareArchive, nullptr );
if( result != DMR_NO_ERROR )
{
cout << "Firmware checksum verification: " << fwu.statusMessage() << endl;
}
else
{
cout << "Firmware checksum verified successful! " << endl;
}
}
if( result != DMR_NO_ERROR )
{
status = fwu.statusMessage();
}
return result;
}
{
MyFirmwareUpdater fwu( pDev );
if( !version.empty() )
{
fwu.firmwareVersionToUpload.writeS( version );
}
cout <<
"Updating device " << pDev->
serial.
read() <<
" from FW version "
<< " to " << fwu.firmwareVersionToUpload.readS() << "." << endl;
result = fwu.update();
if( result != DMR_NO_ERROR )
{
status = fwu.statusMessage();
}
return result;
}
{
string latestFirmwareVersion;
if( GetLatestLocalFirmwareVersion( pDev, latestFirmwareVersion ) )
{
if( !boForce )
{
cout <<
"Skipping device " << pDev->
serial.
read() <<
" because it already uses the current FW version ("
}
cout <<
"Device " << pDev->
serial.
read() <<
" already uses the current FW version ("
<< "Not skipping because 'force' specified'." << endl;
}
cout <<
"Updating device " << pDev->
serial.
read() <<
" from FW version "
<< " to " << latestFirmwareVersion << "." << endl;
MyFirmwareUpdater fwu( pDev );
result = fwu.update();
if( result != DMR_NO_ERROR )
{
status = fwu.statusMessage();
}
return result;
}
bool isDeviceSupportedBySample(
const Device*
const pDev )
{
return GetDeviceFamily( pDev ) != dfUnknown;
}
void displayCommandLineOptions( void )
{
cout << "Available command-line parameters:" << endl
<< " General:" << endl
<< " 'serial' or 's' to specify the serial number of the device to use (if not specified the user will be asked to select a device)" << endl
<< " 'unattended' or 'u' to specify no questions asked, if possible" << endl
<< " 'force' or 'f' to specify force update even if FW is already up-to-date" << endl
<< " 'help' or 'h' displays this help text" << endl
<< " mvBlueCOUGAR-(X/XD/XT) and mvBlueFOX3:" << endl
<< " 'forceDowngrade' or 'd' to force an update even if the specified FW is older than the version already installed" << endl
<< " 'keepUserSets' or 'k' if UserSets stored on the device should still be present after the update" << endl
<< " 'forceBreakingChange' or 'b' if the device should be updated even if the interface might be different afterwards" << endl
<< " 'pathToFWArchive' or 'p' to specify the firmware archive which should be used to update the device" << endl
<< " mvBlueFOX:" << endl
<< " 'version' or 'v' to specify the version that should be used to update the device" << endl
<< endl
<< "USAGE EXAMPLES:" << endl
<< " FirmwareUpdate s=BN* f=1" << endl
<< " FirmwareUpdate s=GX* p=\"path to firmware archive\" k=0" << endl
<< " FirmwareUpdate s=BF* v=49" << endl << endl;
}
int main( int argc, char* argv[] )
{
bool boUnattended = false;
bool boForceSameVersion = false;
bool boForceDowngrade = false;
bool boKeepUserSets = true;
bool boForceBreakingChange = false;
string version;
string pathToFirmwareArchive;
if( argc > 1 )
{
bool boInvalidCommandLineParameterDetected = false;
for( int i = 1; i < argc; i++ )
{
const string param( argv[i] );
const string::size_type keyEnd = param.find_first_of( "=" );
if( ( keyEnd == string::npos ) || ( keyEnd == param.length() - 1 ) )
{
cout << "Invalid command-line parameter: '" << param << "' (ignored)." << endl;
boInvalidCommandLineParameterDetected = true;
}
else
{
const string key = param.substr( 0, keyEnd );
const string value = param.substr( keyEnd + 1 );
if( ( key == "serial" ) || ( key == "s" ) )
{
}
else if( ( key == "unattended" ) || ( key == "u" ) )
{
boUnattended = ( atoi( value.c_str() ) != 0 );
}
else if( ( key == "force" ) || ( key == "f" ) )
{
boForceSameVersion = ( atoi( value.c_str() ) != 0 );
}
else if( ( key == "forceDowngrade" ) || ( key == "d" ) )
{
boForceDowngrade = ( atoi( value.c_str() ) != 0 );
}
else if( ( key == "keepUserSets" ) || ( key == "k" ) )
{
boKeepUserSets = ( atoi( value.c_str() ) != 0 );
}
else if( ( key == "forceBreakingChange" ) || ( key == "b" ) )
{
boForceBreakingChange = ( atoi( value.c_str() ) != 0 );
}
else if( ( key == "version" ) || ( key == "v" ) )
{
version = value;
}
else if( ( key == "pathToFWArchive" ) || ( key == "p" ) )
{
pathToFirmwareArchive = value;
}
else if( ( key == "help" ) || ( key == "h" ) )
{
displayCommandLineOptions();
}
else
{
cout << "Invalid command-line parameter: '" << param << "' (ignored)." << endl;
boInvalidCommandLineParameterDetected = true;
}
}
}
if( boInvalidCommandLineParameterDetected )
{
displayCommandLineOptions();
}
}
else
{
cout << endl << "No command-line parameters specified." << endl << endl;
displayCommandLineOptions();
}
if( pDev == nullptr )
{
pDev = getDeviceFromUserInput( devMgr, isDeviceSupportedBySample );
}
if( pDev == nullptr )
{
cout << "Unable to continue!" << endl;
return 1;
}
const DeviceFamily deviceFamily = GetDeviceFamily( pDev );
if( deviceFamily == dfUnknown )
{
cout << "The selected device is not supported by this sample. Unable to continue!" << endl;
if( !boUnattended )
{
cout << "Press [ENTER] to end the application" << endl;
cin.get();
}
return 1;
}
if( !boUnattended )
{
cout << "Press [ENTER] to update the device." << endl;
cin.get();
}
cout <<
"Updating " << pDev->
serial.
read() <<
"..." << endl;
string status;
try
{
switch( deviceFamily )
{
case dfMvBlueCOUGAR:
case dfMvBlueFOX3:
updateResult = updateBlueCOUGAROrBlueFOX3( pDev, pathToFirmwareArchive, boForceSameVersion, boForceDowngrade, boKeepUserSets, boForceBreakingChange, status );
break;
case dfMvBlueFOX:
updateResult = updateBlueFOX( pDev, version, status );
break;
case dfBVS_CA_BN:
updateResult = updateBVS_CA_BN( pDev, boForceSameVersion, status );
break;
case dfUnknown:
break;
}
}
{
cout <<
"An error occurred while updating the firmware of the device " << pDev->
serial.
read()
cout << "Status: " << status << endl;
}
cout << "Result code after updating: " << updateResult << "(" << ImpactAcquireException::getErrorCodeAsString( updateResult ) << ")" << endl;
if( !boUnattended )
{
cout << "Press [ENTER] to end the application" << endl;
cin.get();
}
}
A class to locate components within the driver.
Definition mvIMPACT_acquire.h:8043
Grants access to devices that can be operated by this software interface.
Definition mvIMPACT_acquire.h:7171
Device * getDeviceBySerial(const std::string &serial="", unsigned int devNr=0, char wildcard=' *') const
Tries to locate a device via the serial number.
Definition mvIMPACT_acquire.h:7524
void updateDeviceList(void) const
Updates the internal device list.
Definition mvIMPACT_acquire.h:7436
PropertyI firmwareVersion
An integer property (read-only) containing the firmware version of this device.
Definition mvIMPACT_acquire.h:6610
PropertyS serial
A string property (read-only) containing the serial number of this device.
Definition mvIMPACT_acquire.h:6551
PropertyS family
A string property (read-only) containing the family name of this device.
Definition mvIMPACT_acquire.h:6526
HDEV hDev(void) const
A unique identifier for this device.
Definition mvIMPACT_acquire.h:6318
virtual int onErasingFlash(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called once the devices flash memory is erased.
Definition mvIMPACT_acquire.h:23536
virtual int onUploadingImage(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called once the actual firmware file is uploaded to the device's flash memory.
Definition mvIMPACT_acquire.h:23599
std::string statusMessage(void) const
Returns the current status from the status property.
Definition mvIMPACT_acquire.h:23738
virtual int onUpdatingBootProgrammer(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called once the boot programmer of an mvBlueFOX3 camera is updated.
Definition mvIMPACT_acquire.h:23576
virtual int onRebooting(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called once the device reboots to make sure the new firmware is applied to the ...
Definition mvIMPACT_acquire.h:23619
virtual int onErrorMessage(const double timeElapsed_s) const
This function will be called once a message is waiting to be passed to the user.
Definition mvIMPACT_acquire.h:23519
virtual int onLoadingUserSets(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called when the settings of the device are written back after updating the firm...
Definition mvIMPACT_acquire.h:23679
virtual int onSavingUserSets(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called when the settings of the device are stored before updating the firmware.
Definition mvIMPACT_acquire.h:23659
virtual int onHardResetRequired(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called once the device reboots and a manual hard reset is required.
Definition mvIMPACT_acquire.h:23639
virtual int onUnzippingFirmwareArchive(const int currentProgress_pc, const double timeElapsed_s) const
This function will be called once firmware archive (*.mvu) is unzipped to provide the correct firmwar...
Definition mvIMPACT_acquire.h:23554
A base class for exceptions generated by Impact Acquire.
Definition mvIMPACT_acquire.h:256
std::string getErrorCodeAsString(void) const
Returns a string representation of the error associated with the exception.
Definition mvIMPACT_acquire.h:288
std::string read(int index=0) const
Reads a value from a property.
Definition mvIMPACT_acquire.h:5323
std::string readS(int index=0, const std::string &format="") const
Reads data from this property as a string.
Definition mvIMPACT_acquire.h:3340
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.h:2601
@ DMR_NO_ERROR
The function call was executed successfully.
Definition mvDriverBaseEnums.h:2603
This namespace contains classes and functions belonging to the image acquisition module of this SDK.
Definition mvCommonDataTypes.h:34
Definition mvCommonDataTypes.h:32