# What's the best way to handle camera disconnections in CVB

**URL:** <https://forum.commonvisionblox.com/t/whats-the-best-way-to-handle-camera-disconnections-in-cvb/157>\
**Category:** Programming Questions\
**Tags:** acquisition\
**Created:** [July 14, 2017, 9:12am UTC](https://forum.commonvisionblox.com/t/whats-the-best-way-to-handle-camera-disconnections-in-cvb/157 "2017-07-14T09:12:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://forum.commonvisionblox.com/u/Greg)\
**Post date:** [July 14, 2017, 9:12am UTC](https://forum.commonvisionblox.com/t/whats-the-best-way-to-handle-camera-disconnections-in-cvb/157/1 "2017-07-14T09:12:19Z")

</div>

Please imagine following scenario:  
While G2Grab is active, no matter if G2Wait is waiting or not, someone unplugs your networkable where your GigEVision camera is used to be connected to your PC (lets reduce it to GigEVision cameras).

How this can be handled in Common Vision Blox?

Best Greg

---

<div class="post-metadata">

**Author:** ![Sebastian](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/sebastian/32/1267_2.png) [@Sebastian](https://forum.commonvisionblox.com/u/Sebastian)\
**Post date:** [July 14, 2017, 9:50am UTC](https://forum.commonvisionblox.com/t/whats-the-best-way-to-handle-camera-disconnections-in-cvb/157/2 "2017-07-14T09:50:18Z")

</div>

Hi Greg,

How to do this is documented in Our CVB User Guide for the GenICam Driver and is called Connection Monitoring.  
This is the link to our Online Version of the document:  
[https://help.commonvisionblox.com/NextGen/14.0/md\_theory\_of\_operation\_hardware\_\_gen\_i\_cam\_\_c\_v\_b\_\_user\_guide.html#gcug\_chmtopic59](https://help.commonvisionblox.com/NextGen/14.0/md_theory_of_operation_hardware __gen_i_cam__ c_v_b__user_guide.html#gcug_chmtopic59)

There you also find C++ and a C# example code which shows how to do it.

---

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://forum.commonvisionblox.com/u/Greg)\
**Post date:** [July 14, 2017, 10:26am UTC](https://forum.commonvisionblox.com/t/whats-the-best-way-to-handle-camera-disconnections-in-cvb/157/3 "2017-07-14T10:26:10Z")

</div>

Hello @Sebastian,  
thank you for your quick answer. Actually, my question was not about how to get informed about disconnections or reconnection, but more how to handle these events, even if these notifications be useful.  
So may question was more related to the behaviour of G2Wait(), does it return immediately, what is the error code in this case, do I need to call G2Freeze(), etc…

Thank you very much in advance.

Cheers

---

<div class="post-metadata">

**Author:** ![Sebastian](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/sebastian/32/1267_2.png) [@Sebastian](https://forum.commonvisionblox.com/u/Sebastian)\
**Post date:** [July 14, 2017, 1:24pm UTC](https://forum.commonvisionblox.com/t/whats-the-best-way-to-handle-camera-disconnections-in-cvb/157/4 "2017-07-14T13:24:29Z")

</div>

Hi Greg,

OK, I understand.

You should call G2Freeze() when a disconnect was detected. Then G2Wait returns with a CVC\_E\_GRABABORTED error. If you do not call G2Freeze() in time the G2Wait will return with a CVC\_E\_TIMEOUT error.

Beyond that i realized that the current Online Help is wrong with one statement: You do not need to reload the driver when the reconnected event is fired. You only need to start the grab.

One more thing which is important with the callbacks and the G2Grab Interface functions: You **should not** call G2Freeze() and G2Grab() within the callback itself. These functions need to be called in another thread context. The callback functions should only be used to inform the thread which controls the acquisition that it need to be stopped or started.
