Page 1 of 1

check device connection

Posted: Fri Feb 04, 2022 3:37 pm
by matteolucarelli
Hi,
I'm working with a Scarlet and libvisiontransfer
I connect the camera using DeviceEnumeration discoverDevices and store deviceinfo as from your examples.

How can I check if the camera is still connected?

For example if I create the device, then detach the network cable some operation freezes.
How can I check it before and eventually, in case of network problem, redo the discoverDevices operation?

Thank you

Re: check device connection

Posted: Mon Feb 07, 2022 10:45 am
by k.schauwecker
In UDP mode, when the connection is interrupted, libvisiontransfer should automatically re-connect as soon as the device becomes reachable again. No additional steps need to be performed here. To check if a device is still reachable you can use the device enumeration or check the time since the last frame.

If you are using TCP mode, then a disconnection will be performed when the network cable is unplugged. In this case the AsyncTransfer::isConnected() or ImageTransfer::isConnected() will return false, and you will have to initiate a new connection when the device becomes reachable again. In this case I would recommend to use the device enumeration and wait for Scarlet to be detected again.

Re: check device connection

Posted: Mon Feb 07, 2022 2:42 pm
by matteolucarelli
To check if a device is still reachable you can use the device enumeration

You mean call DeviceEnumeration::DeviceList devices = deviceEnum.discoverDevices();
and check the size?

"or check the time since the last frame."

ok, but this works only during acquisition. What to do for to check the connection before any other operation? I mean:
-discover camera
- detach cable
- call, for example, map<string,ParameterInfo> params = pt.getAllParameters();

In the above case the operation freezes with no timeout.
A simple "bool device->checkConnection()" would be very handy in this case

Re: check device connection

Posted: Mon Feb 07, 2022 3:36 pm
by k.schauwecker
getAllParameters() should throw a TransferException if a network connection cannot be established.

Can you check if this exception is thrown in your case? Is it possible that the freeze you observe is caused by some exception handler in your application?

Re: check device connection

Posted: Tue Feb 08, 2022 1:52 pm
by matteolucarelli
I've tried

Code: Select all

	// Search for Nerian stereo devices
	DeviceEnumeration deviceEnum;
	DeviceEnumeration::DeviceList devices = deviceEnum.discoverDevices();

	if (devices.size() <= devnum) return setError("No device %u connected",devnum);

	mDevice = devices[devnum];
then detach the nework and

Code: Select all

	try{
		internal::ParameterTransfer pt(mDevice.getIpAddress().c_str());
	}catch(...){
		return setError("No IP address");
	}
The execution remains stuck in internal::ParameterTransfer, no exception raise

Re: check device connection

Posted: Tue Feb 08, 2022 2:33 pm
by matteolucarelli
To be precise remains stuck in "connect" ar line 67 of Networking::connectTcpSocket

Re: check device connection

Posted: Mon Jun 27, 2022 2:44 pm
by matteolucarelli
Any news?

Re: check device connection

Posted: Fri Jul 01, 2022 7:04 am
by k.schauwecker
Sorry for the late reply.

We could use a timeout for the connection. I have patched our current API and you can download the patched version here:
https://nerian.com/exchange/?d=5ac5e3b5fcae79c04c64501bd2c6fc02

If this solution works for you then we can integrate this into our official release. Please not that this API requires our brand new firmware which was just released yesterday (official announcement will still be mailed out).

Re: check device connection

Posted: Tue Jul 05, 2022 2:37 pm
by matteolucarelli
I've downloaded the beta version but is unclear how to check connection

Re: check device connection

Posted: Tue Jul 05, 2022 4:28 pm
by k.schauwecker
It doesn't have a connection check but it will timeout after 500ms when establishing a connection.