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
check device connection
-
- Posts: 20
- Joined: Fri Feb 04, 2022 3:32 pm
-
- Posts: 123
- Joined: Mon Mar 25, 2019 1:12 pm
Re: check device connection
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.
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.
-
- Posts: 20
- Joined: Fri Feb 04, 2022 3:32 pm
Re: check device connection
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
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
-
- Posts: 123
- Joined: Mon Mar 25, 2019 1:12 pm
Re: check device connection
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?
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?
-
- Posts: 20
- Joined: Fri Feb 04, 2022 3:32 pm
Re: check device connection
I've tried
then detach the nework and
The execution remains stuck in internal::ParameterTransfer, no exception raise
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];
Code: Select all
try{
internal::ParameterTransfer pt(mDevice.getIpAddress().c_str());
}catch(...){
return setError("No IP address");
}
-
- Posts: 20
- Joined: Fri Feb 04, 2022 3:32 pm
Re: check device connection
To be precise remains stuck in "connect" ar line 67 of Networking::connectTcpSocket
-
- Posts: 20
- Joined: Fri Feb 04, 2022 3:32 pm
Re: check device connection
Any news?
-
- Posts: 123
- Joined: Mon Mar 25, 2019 1:12 pm
Re: check device connection
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).
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).
-
- Posts: 20
- Joined: Fri Feb 04, 2022 3:32 pm
Re: check device connection
I've downloaded the beta version but is unclear how to check connection
-
- Posts: 123
- Joined: Mon Mar 25, 2019 1:12 pm
Re: check device connection
It doesn't have a connection check but it will timeout after 500ms when establishing a connection.