[BRLTTY] Getting my braille driver for the FCHAD working.

Dave Mielke dave at mielke.cc
Thu Oct 11 18:21:08 EDT 2012


[quoted lines by timothyhobbs at seznam.cz on 2012/10/11 at 22:19 +0200]

>Dear Mike,

Dave. :-) You're not the only one who calls me Mike, by the way.

>Setting the length to 0 is useful because it allows me to be in a state of
>consistency on my side.  I wait for an initialization packet from the device
>and before I receive that initialization packet the size of the buffer is 
>undefined.  

After brltty's core receives a successful return from the driver's construct() 
method, it assumes that it can begin to write data. As such, it already needs 
to know the size of the buffer it needs to allocate and work with. That's why 
setting the size to 0 is a bad idea.

That being said, the core is, of course, a bit more robust than that. It checks 
for this case, and assumes a size, but that's just to deal with incorrect 
driver coding. The driver should set the correct size. If it can't, then it 
should set a nonzero size which it's prepared to deal with on writes.

>Within my protocol the size of the buffer could theoretically
>change at any time.  Is brltty capable of handling this?  

Yes. The readCommand() method may change the size at any time. If it does 
change the size, it must also set brl->resizeRequired to 1.

>After having read your message, I realized that the reason my messages were
>not being displayed was quite simple.  I must include a \n at the end of the
>message for the message to be flushed onto the screen.

Please don't use standard output or standard error. They aren't guaranteed to 
work unless you've specified the -e [--standard-error] option. It'd be far 
better if you were to use logMessage() et al (see brltty's log.h).

>I tried changing my printf s to the format:
>
>  logMessage(LOG_INFO,"Line 457\n");

Don't use \n when calling brltty's logging functions.

>No messages were displayed on my screen. Could you please enlighten me as to
>the proper syntax/runtime flags I must use in order to see these log
>messages?

Logging is to the system log (usually /var/log/messagews) by default, and to 
standard error (your screen if you haven't redirected it) if you specify the -e 
(or --standard-error) option. You can also specify -L/path/to/file (that -L is 
uppercase) if you wish the logs to be concurrently written to a specific file.

>Regarding the saving of the brl pointer, I have now fixed that, in that I 
>reset thisBrl in every function that takes * brl as an argument gets run. 
>However keeping that as a global makes the code much easier to read than if
>I were to pass it as an argument all over the place.  

That, ultimately, is an argument I'd give you a failing grade for were I your 
professor. Global variables never make code easier to read, and, more often 
than not, are the sources of really difficult-to-analyze problems. I'm 
surprised that no professor has called you on this, given that you're up at 
some level which requires a thesis to be written.

>I do take your advice very seriously and read your messages multiple times.  
>However, Samuel had also responded to my message and told me "It is 
>essentially constant throughout the runtime of brltty."  

I'm quite sure Samuel agrees with me on the use of global variables. He was 
just answering your precise question - that's all. He also, very wisely, used 
the word "essentially", which was still a caution not to do so.

>So I worked under the assumption that he was correct.

He was correct. When he said "essentially", he was warning you that it can 
change. Also, he probalby just didn't want to get into advising you on how to 
write quality, robust, easy-to-maintain, less error-rone code.

>Regarding the EOF, thanks for pointing that out!  I have now fixed it.  I
>now return 1 every time.  I'm not sure what brltty supposes to do in the
>case of a failure.

The driver fails to start, and the core retries later.

-- 
Dave Mielke           | 2213 Fox Crescent | The Bible is the very Word of God.
Phone: 1-613-726-0014 | Ottawa, Ontario   | 2011 May 21 is the End of Salvation.
EMail: dave at mielke.cc | Canada  K2A 1H7   | http://Mielke.cc/now.html
http://FamilyRadio.com/                   | http://Mielke.cc/bible/


More information about the BRLTTY mailing list