Repository: nvaccess/nvda

Issue:
Repeated exceptions when active braille display is disconnected
**Reported by ianr on 2011-06-08 20:16**
My log file was 282 megs.  It seemed to be filled with this error which happened multiple times per second over a 16 hour period.

I only looked at the log file because NVDA crashed, not sure if that is related to this error filling up the log file or not.

I should note that I hibernate my laptop to bring it home and then hibernate again to take it back to work. .
It is possible this error started firing when I took the laptop home without the braille display attached.

Can this error be fixed or can it change behavior so that after firing it stops whatever behavior is occurring that makes it continuously fire?

I will attach the last few pages from my log file.

**Blocked by #1271**



Discussion:
Attachment nvda.log added by ianr on 2011-06-08 20:18
Description:

Comment 1 by jteh on 2011-06-08 21:25
NVDA can't currently gracefully handle detaching a braille display. You need to manually set NVDA to "No braille" to stop these errors (or restart NVDA).
Changes:
Changed title from "SerialException: call to ClearCommError failed" to "Repeated exceptions when active braille display is disconnected"
Milestone changed from None to near-term

Comment 2 by jteh on 2011-06-09 07:06
Changes:
Milestone changed from near-term to 2011.3

Comment 3 by jteh on 2011-10-11 03:33
Changes:
Milestone changed from 2011.3 to near-term

Comment 4 by jteh on 2013-11-29 07:29
Changes:
Milestone changed from near-term to next

Comment 6 by James Teh &lt;jamie@... on 2013-11-29 08:30
In [c66d82a6beb5c1d5156807b14b76a6352e1aa64e]:
```CommitTicketReference repository="" revision="c66d82a6beb5c1d5156807b14b76a6352e1aa64e"
If NVDA is unable to communicate with a braille display (e.g. because it has been disconnected), it will automatically disable use of the display.

This eliminates problems such as excessive log file size and lag when this occurs.
Re #1555.

```
```

Comment 7 by James Teh &lt;jamie@... on 2013-11-29 08:30
In [aed6685c6985b1435d3f315bae0a415800f8868c]:
```CommitTicketReference repository="" revision="aed6685c6985b1435d3f315bae0a415800f8868c"
Merge branch 't1555' into next

Incubates #1555.

```
Changes:
Added labels: incubating
```

Comment 8 by jteh on 2013-12-16 06:32
I'm going to change the way this works slightly based on things learned while doing #1271. It will most likely be committed as part of t1271.

Comment 9 by jteh on 2013-12-23 08:57
As per comment:8, this is now incorporated into #1271. I've removed the incubation from next.
Changes:
Removed labels: incubating

Comment 10 by bdorer on 2014-12-14 20:25
hmm, it seams you aren't working on #2171 so may you could commit the fix to next?


Resolving patch:
diff --git a/source/braille.py b/source/braille.py
--- a/source/braille.py
+++ b/source/braille.py
@@ -2,7 +2,7 @@
 #A part of NonVisual Desktop Access (NVDA)
 #This file is covered by the GNU General Public License.
 #See the file COPYING for more details.
-#Copyright (C) 2008-2015 NV Access Limited
+#Copyright (C) 2008-2016 NV Access Limited
 
 import sys
 import itertools
@@ -1480,7 +1480,11 @@ def _updateDisplay(self):
 
 	def _writeCells(self, cells):
 		if not self.display.isThreadSafe:
-			self.display.display(cells)
+			try:
+				self.display.display(cells)
+			except:
+				log.error("Error displaying cells. Disabling display", exc_info=True)
+				self.setDisplayByName("noBraille", isFallback=True)
 			return
 		with _BgThread.queuedWriteLock:
 			alreadyQueued = _BgThread.queuedWrite
@@ -1714,7 +1718,11 @@ def executor(param):
 			_BgThread.queuedWrite = None
 		if not data:
 			return
-		handler.display.display(data)
+		try:
+			handler.display.display(data)
+		except:
+			log.error("Error displaying cells. Disabling display", exc_info=True)
+			handler.setDisplayByName("noBraille", isFallback=True)
 
 	@classmethod
 	def func(cls):


Test patch: