Skip to content
Snippets Groups Projects
Commit 16b69e31 authored by am0ebe's avatar am0ebe
Browse files

[crash after rec] add printfeatures to cam and stream. pingscan: add better...

[crash after rec] add printfeatures to cam and stream. pingscan: add better alternative to finding cam via mac
parent 2549e387
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ using namespace VmbCPP; ...@@ -18,7 +18,7 @@ using namespace VmbCPP;
using utils::DELIM; using utils::DELIM;
Cam::Cam(QString name, QString ip) : IPrinter(), Cam::Cam(QString name, QString ip) : IPrinter(),
_cam(nullptr), _vcam(nullptr),
_name(name), _name(name),
_ip(ip), _ip(ip),
_id(""), _id(""),
...@@ -29,12 +29,12 @@ _rec() ...@@ -29,12 +29,12 @@ _rec()
} }
// Cam::Cam(const Cam& other) : IPrinter(), std::enable_shared_from_this<Cam>(other) // Cam::Cam(const Cam& other) : IPrinter(), std::enable_shared_from_this<Cam>(other)
// _cam(other._cam), // _vcam(other._vcam),
// _name(other._name), // _name(other._name),
// _ip(other._ip), // _ip(other._ip),
// _id(other._id), // _id(other._id),
// _state(other._state)Cam::Cam(const Cam& other) : IPrinter(), std::enable_shared_from_this<Cam>(other) // _state(other._state)Cam::Cam(const Cam& other) : IPrinter(), std::enable_shared_from_this<Cam>(other)
// _cam(other._cam), // _vcam(other._vcam),
// _name(other._name), // _name(other._name),
// _ip(other._ip), // _ip(other._ip),
// _id(other._id), // _id(other._id),
...@@ -57,7 +57,7 @@ _rec() ...@@ -57,7 +57,7 @@ _rec()
Cam::~Cam() Cam::~Cam()
{ {
qDebug() << __FUNCTION__ << "():" << __LINE__ << "id:" << _id << ", usecount:" << _cam.use_count(); qDebug() << __FUNCTION__ << "():" << __LINE__ << "id:" << _id << ", usecount:" << _vcam.use_count();
if( _state == recording ) if( _state == recording )
rec()->stop(); rec()->stop();
...@@ -87,7 +87,7 @@ QString Cam::id() ...@@ -87,7 +87,7 @@ QString Cam::id()
if( _id.isEmpty() ) if( _id.isEmpty() )
{ {
std::string str; std::string str;
f(_cam->GetID( str )); f(_vcam->GetID( str ));
_id = QString::fromStdString(str); _id = QString::fromStdString(str);
} }
return _id; return _id;
...@@ -108,7 +108,7 @@ void Cam::open() ...@@ -108,7 +108,7 @@ void Cam::open()
if(_state != closed) if(_state != closed)
return error("cant open " + stateToString(_state) + " cam"); return error("cant open " + stateToString(_state) + " cam");
f(_cam->Open( VmbAccessModeFull ),"open cam #"+_id); f(_vcam->Open( VmbAccessModeFull ),"open cam #"+_id);
//state change will be handled by CamObserver::CameraStateChanged > Core::onCameraChanged > Cam::onChanged //state change will be handled by CamObserver::CameraStateChanged > Core::onCameraChanged > Cam::onChanged
} }
...@@ -117,39 +117,39 @@ void Cam::close() ...@@ -117,39 +117,39 @@ void Cam::close()
if(_state != opened) if(_state != opened)
return error("cant close " + stateToString(_state) + " cam"); return error("cant close " + stateToString(_state) + " cam");
f(_cam->Close(),"close cam #"+_id); f(_vcam->Close(),"close cam #"+_id);
//state change will be handled by CamObserver::CameraStateChanged > Core::onCameraChanged > Cam::onChanged //state change will be handled by CamObserver::CameraStateChanged > Core::onCameraChanged > Cam::onChanged
} }
void Cam::printFeatures( QString feature) void Cam::printStreamFeatures( QStringList features )
{ {
if(_state != opened) if(_state != opened && _state != recording )
return error("cant access features if cam is " + stateToString(_state) + " cam"); return error("cant access features on " + stateToString(_state) + " cam");
printFeatures(QStringList(feature)); StreamPtrVector streams;
_vcam->GetStreams(streams);
printFeatures(streams.at(0), features);
} }
void Cam::printFeatures( QStringList features) void Cam::printCamFeatures( QStringList features )
{ {
if(_state != opened ) if(_state != opened )
return error("cant access features if cam is " + stateToString(_state) + " cam"); return error("cant access features on " + stateToString(_state) + " cam");
printFeatures(_vcam, features);
}
void Cam::printFeatures( FeatureContainerPtr camOrStream, QStringList features)
{
for( auto feature : features ) for( auto feature : features )
{ {
try try
{ {
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
qDebug() << feature << "| " << feature.toStdString().c_str();
// auto vcam = _cam->getCameraPtr();
FeaturePtr pFeature; FeaturePtr pFeature;
g( _cam->GetFeatureByName(feature.toStdString().c_str(), pFeature) ); g( camOrStream->GetFeatureByName(feature.toStdString().c_str(), pFeature) ); //, QString("GetFeatureByName: %1").arg(feature)
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
VmbFeatureDataType type; VmbFeatureDataType type;
g( pFeature->GetDataType(type) ); g( pFeature->GetDataType(type) ); //"Feature->GetDataType"
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
switch(type) switch(type)
{ {
...@@ -196,7 +196,7 @@ void Cam::printFeatures( QStringList features) ...@@ -196,7 +196,7 @@ void Cam::printFeatures( QStringList features)
catch (const std::runtime_error& xx) catch (const std::runtime_error& xx)
{ {
qDebug() << __FUNCTION__ << "Exception caught: " << xx.what(); qDebug() << __FUNCTION__ << "Exception caught: " << xx.what();
break; // break;
} }
} }
} }
...@@ -218,13 +218,13 @@ QString Cam::camInfo() ...@@ -218,13 +218,13 @@ QString Cam::camInfo()
camInfo += id() + DELIM; camInfo += id() + DELIM;
std::string str; std::string str;
g(_cam->GetModel( str )); g(_vcam->GetModel( str ));
camInfo += QString::fromStdString(str) + DELIM; camInfo += QString::fromStdString(str) + DELIM;
g(_cam->GetSerialNumber( str )); g(_vcam->GetSerialNumber( str ));
camInfo += QString::fromStdString(str) + DELIM; camInfo += QString::fromStdString(str) + DELIM;
g(_cam->GetInterfaceID( str )); g(_vcam->GetInterfaceID( str ));
camInfo += QString::fromStdString(str) + DELIM; camInfo += QString::fromStdString(str) + DELIM;
camInfo += stateToString(_state) + DELIM; camInfo += stateToString(_state) + DELIM;
...@@ -266,12 +266,12 @@ void Cam::onChanged(UpdateTriggerType type) ...@@ -266,12 +266,12 @@ void Cam::onChanged(UpdateTriggerType type)
case UpdateTriggerType::UpdateTriggerPluggedIn: case UpdateTriggerType::UpdateTriggerPluggedIn:
info(name()+" connected"); info(name()+" connected");
setState(closed); setState(closed);
//_cam ptr set in core //_vcam ptr set in core
break; break;
case UpdateTriggerType::UpdateTriggerPluggedOut: case UpdateTriggerType::UpdateTriggerPluggedOut:
info(name()+" disconnected"); info(name()+" disconnected");
setState(disconnected); setState(disconnected);
_cam.reset(); _vcam.reset();
break; break;
case UpdateTriggerType::UpdateTriggerOpenStateChanged: case UpdateTriggerType::UpdateTriggerOpenStateChanged:
...@@ -299,7 +299,7 @@ void Cam::saveSettings() ...@@ -299,7 +299,7 @@ void Cam::saveSettings()
QString file="settings_"+name()+".xml"; QString file="settings_"+name()+".xml";
if (f(_cam->SaveSettings( file.toStdString().c_str(), &settingsStruct ))) if (f(_vcam->SaveSettings( file.toStdString().c_str(), &settingsStruct )))
error( "Could not save camera settings to '" + file + "'" ); error( "Could not save camera settings to '" + file + "'" );
else else
info("Saved settings to " + file); info("Saved settings to " + file);
...@@ -313,7 +313,7 @@ void Cam::loadSettings() ...@@ -313,7 +313,7 @@ void Cam::loadSettings()
if(_state != opened) if(_state != opened)
return error("can only save settings on opened cam. (its " + stateToString(_state) + ")"); return error("can only save settings on opened cam. (its " + stateToString(_state) + ")");
if(f(_cam->LoadSettings( settingsFile().toStdString().c_str()))) if(f(_vcam->LoadSettings( settingsFile().toStdString().c_str())))
error( "Could not load camera settings from '" + settingsFile() + "'" ); error( "Could not load camera settings from '" + settingsFile() + "'" );
else else
info("Loaded settings from " + settingsFile()); info("Loaded settings from " + settingsFile());
......
...@@ -38,20 +38,23 @@ public: ...@@ -38,20 +38,23 @@ public:
void close(); void close();
QString camInfo(); QString camInfo();
void printFeatures(QStringList); void printCamFeatures( QStringList );
void printFeatures(QString); void printStreamFeatures( QStringList );
void saveSettings(); void saveSettings();
void loadSettings(); void loadSettings();
inline CameraPtr getCameraPtr() { return _cam; } inline CameraPtr getCameraPtr() { return _vcam; }
inline void setCameraPtr( CameraPtr pCamera ) { _cam = pCamera; } inline void setCameraPtr( CameraPtr pCamera ) { _vcam = pCamera; }
friend class FrameObserver; friend class FrameObserver;
friend class Core; friend class Core;
private: private:
CameraPtr _cam; void printFeatures(VmbCPP::FeatureContainerPtr, QStringList);
CameraPtr _vcam;
QString _name; QString _name;
QString _ip; QString _ip;
QString _id; QString _id;
......
...@@ -181,7 +181,7 @@ void Core::stopRecording() ...@@ -181,7 +181,7 @@ void Core::stopRecording()
void Core::showRecordingStats() void Core::showRecordingStats()
{ {
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << ""; qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
if( cam() && cam()->rec() && cam()->_cam ) if( cam() && cam()->rec() && cam()->getCameraPtr() )
{ {
cam()->rec()->showStats(); cam()->rec()->showStats();
} }
......
...@@ -2,31 +2,51 @@ ...@@ -2,31 +2,51 @@
#scans class-B subnet 169.254.i.j #scans class-B subnet 169.254.i.j
#watch CPU usage and adapt max_jobs / timeout / step_size vars to ur system #watch CPU usage and adapt max_jobs / timeout / step_size vars to ur system
############################### Alternatives ###############################
## faster alternative:
# search MAC address (4m) !!
# sudo arp-scan --interface=enp0s31f6 --localnet | grep 00:0a:47:1d:2a:66
###############################
## other alternatives
## can also use nmap but takes long ~45m:
# sudo nmap -sP --script=broadcast-dhcp-discover 169.254.0.0/16
## smaller test:
# sudo nmap -sP 169.254.220.0-225.255
## or:
# sudo nmap -sP 169.254.0.0/16
# sudo arp-scan --localnet
## check server logs
# # http://192.168.0.1/common_page/login.html -> login?
## Wireshark
# and begin capturing packets on the network interface connected to your local network.
# Filter for Broadcast and Multicast Traffic: Look for packets that are broadcast or multicast, as these can reveal the presence of your device.
# Use filters like eth.dst == ff:ff:ff:ff:ff:ff for broadcast or ip.dst == 224.0.0.0/4 for multicast.
# Inspect the Traffic: Look for traffic that might come from the camera. If you know the MAC address of the camera,
# you can filter for it using eth.addr == xx:xx:xx:xx:xx:xx.
###############################
step_size=8 step_size=12
max_jobs=50 # Maximum number of concurrent pings max_jobs=100 # Maximum number of concurrent pings
timeout=3 # Timeout for each ping in seconds
for i in {0..255}; do for i in {0..255}; do
if [ $((i % step_size)) == 0 ]; then if [ $((i % step_size)) == 0 ]; then
read -rp "169.254.$i-$((i+step_size))" -t$timeout #wait s
echo "" echo ""
echo "169.254.$i-$((i+step_size))"
sleep 1
fi fi
echo -n "."
# echo $i
for j in {0..255}; do for j in {0..255}; do
if [[ "$i" == 255 && "$j" == 255 ]]; then if [[ "$i" == 255 && "$j" == 255 ]]; then
continue #ignore broadcast break #ignore broadcast
fi fi
ip="169.254.$i.$j" ip="169.254.$i.$j"
( (
if timeout "$timeout"s ping -c1 -W1"$ip" &> /dev/null; then if ping -c2 -W2 "$ip" &> /dev/null; then
echo -e "\n$ip <<<<<<<<<<<<<<<<<< !!\n" echo -e "\n$ip <<<<<<<<<<<<<<<<<< !!\n"
fi fi
) & ) &
# Wait for jobs to finish if max_jobs limit is reached # Wait for jobs to finish if max_jobs limit is reached
if (( $(jobs -r | wc -l) >= max_jobs )); then if (( $(jobs -r | wc -l) >= max_jobs )); then
wait -n wait -n
...@@ -34,8 +54,13 @@ for i in {0..255}; do ...@@ -34,8 +54,13 @@ for i in {0..255}; do
done done
done done
wait # Wait for all REMAINING
# timeout=1 # Timeout for each ping in seconds
# if timeout "$timeout"s ping -c1 -i0.5 "$ip" &> /dev/null; then #discard both
# if timeout "$timeout"s ping -c1 -i0.5 "$ip" > /dev/null; then #discard normal output
# if timeout "$timeout"s ping -c1 -i0.5 "$ip" 2> /dev/null; then #discard err only
# (ping "${ip}" -c 1 -W 1 &> /dev/null && echo -e "\n${ip} <<<<<<<<<<<<<<<<<< !!\n" &) ;
wait # Wait for all background pings in this step to complete before proceeding
# (ping "${ip}" -c 1 -W 1 &> /dev/null && echo -e "\n${ip} <<<<<<<<<<<<<<<<<< !!\n" &) ;
...@@ -28,7 +28,6 @@ _frames(FramePtrVector(utils::threadsPerCam())) ...@@ -28,7 +28,6 @@ _frames(FramePtrVector(utils::threadsPerCam()))
_updateTimer->setInterval(duration_cast<milliseconds>(updateInterval)); _updateTimer->setInterval(duration_cast<milliseconds>(updateInterval));
connect(_updateTimer, SIGNAL(timeout()), this, SLOT(showProgress())); connect(_updateTimer, SIGNAL(timeout()), this, SLOT(showProgress()));
connect(_updateTimer, SIGNAL(timeout()), this, SLOT(showStats()));
} }
void Record::init(CamPtr cam) void Record::init(CamPtr cam)
...@@ -86,7 +85,6 @@ void Record::start() ...@@ -86,7 +85,6 @@ void Record::start()
{ {
frame.reset(new Frame(_payloadSize)); frame.reset(new Frame(_payloadSize));
g( frame->RegisterObserver( IFrameObserverPtr( new FrameObserver(_cam) )),"register frame observer"); g( frame->RegisterObserver( IFrameObserverPtr( new FrameObserver(_cam) )),"register frame observer");
g( vcam->AnnounceFrame(frame), "announce frame"); g( vcam->AnnounceFrame(frame), "announce frame");
} }
...@@ -118,6 +116,7 @@ void Record::start() ...@@ -118,6 +116,7 @@ void Record::start()
*/ */
void Record::stop() void Record::stop()
{ {
_updateTimer->stop();
if(_timer->isActive()) if(_timer->isActive())
{ {
//user stop or error //user stop or error
...@@ -130,6 +129,7 @@ void Record::stop() ...@@ -130,6 +129,7 @@ void Record::stop()
info( progressBar(100) ); info( progressBar(100) );
} }
try try
{ {
FeaturePtr pFeature; FeaturePtr pFeature;
...@@ -156,12 +156,27 @@ void Record::stop() ...@@ -156,12 +156,27 @@ void Record::stop()
void Record::showStats() void Record::showStats()
{ {
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << ""; info("-------------------------------");
_cam->printFeatures("StatFrameDropped"); info("get cam features:");
_cam->printFeatures({ _cam->printCamFeatures({
// "StatFrameDropped", //unsigned int max 4294967295 "AcquisitionFrameRate",
"StatFrameRate", //float send by cam "AcquisitionFrameCount",
"StatLocalRate", //float rcvd by observer "DeviceTemperature",
"SensorWidth",
"SensorHeight",
"ExposureTime",
"Gain",
"FileSize",
"PayloadSize",
"PixelFormat",
"PixelSize",
});
info("-------------------------------");
info("get stream stats:");
_cam->printStreamFeatures({
"StatFrameDropped",
"StatLocalRate",
"StatFrameRescued", "StatFrameRescued",
"StatFrameShoved", "StatFrameShoved",
"StatFrameUnderrun", "StatFrameUnderrun",
...@@ -170,8 +185,8 @@ void Record::showStats() ...@@ -170,8 +185,8 @@ void Record::showStats()
"StatPacketReceived", "StatPacketReceived",
"StatPacketRequested", "StatPacketRequested",
"StatPacketResent", "StatPacketResent",
"StatTimeElapsed", //float - time elapsed since start of acquisition "StatTimeElapsed",
"StatFrameDelivered" "StatFrameDelivered",
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment