> Please always detail precisely *one* example of what you did and
> that didn't work, else it takes us quite some time to find out
> what is not working and you wanted to work.

> Note: if you want to get dot patterns as such, for now you need
> to modify the brltty source: in Programs/brlapi_server.c


It seems I had forgotten to set retainDots = 1, when I compiled with
MinGW. Now I tried to compile with retainDots = 1, but it didn't work, I
got an error message when compiling.

I went back to Cygwin. Here I have set retainDots = 1, but I couldn't
receive all dot patterns, as I have mailed already. Now I run my test
program again, to get a more complete documentation.
All steps (I use Windows XP):

1. installed Cygwin, unpacked brltty-4.2.tar.gz and copied folder
brltty-4.2 to C:\Cygwin\home\Thomas\

2. changed retainDots to 1 in file brlapi.server.c

3. opened the Cygwin shell and run "./configure" and "make install"
without command line options.

4. in C:\Cygwin\etc\brltty.conf I made the following settings:
braille-driver    ht
braille-device    serial:ttyS2
text-table        de
contraction-table de-basis
screen-driver     wn

5. compiled test program (attached file main.cpp) with Visual C++.

6. attached the Handytech braille star 40 to an USB plug and run
brltty -e -l debug > debug.log 2>&1

7. started test program and entered some braille characters


In the file log.txt is what my program has received from the braille
input. I also attached the debug.log written by brltty in the same run.

My program starts a second thread which calls brlapi_readKey (1, &key);
within a loop and writes all result to log.txt, in hexadecimal and binary.
The main thread is to enter and write the dots I want to press. I entered
the dots first, say 134, and "134:" is written into log.txt by the main
thread. Then I pressed the keys 1, 3 and 4 together on the braille
terminal, and the second thread writes the result(s) of brlapi_readKey to
log.txt.

I tried all characters with one dot and some with two or more dots. From
the attached file log.txt one can see that the characters with one dot
seem to be received correctly, but not all of those with two dots, and
none of those with >2 dots I have tried.

Seemingly every press gives a return of brlapi_readKey (1, &key) with key
= 00000000 20000000(hex), and releasing the keys gives one more return
which contains the entered character's dots in the lowest byte (but
somehow encrypted: 1 -> 01  2 -> 1e  3 -> 0b  4 -> 02)

Sometimes the last result telling about the dots is missing and all one
gets is 00000000 20000000.


Greets, Thomas Marquardt

Attachment: debug.log
Description: Binary data

#include <iostream>
#include <fstream>
using namespace std;
#include "C:\cygwin\usr\include\brlapi.h"

ofstream *logp = 0;
bool error = false;

// thread to read braille input and write it into a file:
long WINAPI Validate (long lParam) {
        brlapi_keyCode_t key;
        for (;;) {
                int e = brlapi_readKey (1, &key);
                if (e <= 0) {
                        brlapi_perror("brlapi_readKey");
                        cout << " error brlapi_readKey: " << e << '\n';
                        if (logp) *logp << " error brlapi_readKey: " << e << 
'\n';
                        error = true;
                        return 0;
                }
                if (e < 10) { cout << ' '; if (logp) *logp << ' '; }
                cout << e << ' '; if (logp) *logp << e << ' ';
                for (int i=60 ; i>=0 ; i-=4) {
                        unsigned d = key >> i & 0xf;
                        char b = (d < 10) ? '0'+d : 'a'-10+d;
                        cout << b; if (logp) *logp << b;
                        if (i == 32) { cout << ' '; if (logp) *logp << ' '; }
                }
                cout << ' '; if (logp) *logp << ' ';
                for (int i=64 ; --i >= 0 ;) {
                        char b = (key >> i & 1) ? '1' : '-';
                        cout << b; if (logp) *logp << b;
                        if (i && (i & 7) == 0) { cout << ' '; if (logp) *logp 
<< ' '; }
                }
                cout << endl; if (logp) *logp << '\n';
        }
}


int main() {
        char txt[40];
        brlapi_connectionSettings_t settings, actsettings;
        settings.auth = "C:\\cygwin\\etc\\brlapi.key";
        settings.host = 0;

// connect to brlapi
        int e = brlapi_openConnection (&settings, &actsettings);
        if (e < 0) {
                brlapi_perror("brlapi_openConnection");
                cout << "brlapi_openConnection failed: " << e << endl;
                cout << "cin:"; cout.flush(); cin >> txt;
                return 1;
        }
        cout << "brlapi_openConnection ok: " << e << endl;
        cout << " auth: " << actsettings.auth << endl;
        cout << " host: " << actsettings.host << endl;

// get driver name and display size
        char name[BRLAPI_MAXNAMELENGTH+1];
        if ((e = brlapi_getDriverName(name, sizeof(name))) < 0) {
                brlapi_perror("brlapi_getDriverName");
                cout << "error: brlapi_getDriverName: " << e << endl;
                brlapi_closeConnection();
                cout << "cin:"; cout.flush(); cin >> txt;
                return 1;
        }
        cout << "Driver name: " << name << ", e = " << e << endl;
        unsigned x, y;
        if ((e = brlapi_getDisplaySize(&x, &y)) < 0) {
                brlapi_perror("brlapi_getDisplaySize");
                cout << "error: brlapi_getDisplaySize: " << e << endl;
                brlapi_closeConnection();
                cout << "cin:"; cout.flush(); cin >> txt;
                return 1;
        }
        else {
                cout << "Braille display has " << y << " lines, " << x << " 
columns";
                cout << ", e = " << e << endl;
        }

// TTY mode
        cout << "Taking control of the tty..." << endl;
        if ((e = brlapi_enterTtyModeWithPath(NULL,0,NULL)) < 0) {
                brlapi_perror("brlapi_enterTtyModeWithPath");
                cout << "error: brlapi_enterTtyModeWithPath: " << e << endl;
                brlapi_closeConnection();
                cout << "cin:"; cout.flush(); cin >> txt;
                return 1;
        }
        cout << "now in tty mode: " << e << endl;

// test text output:
        if ((e = brlapi_writeText(BRLAPI_CURSOR_OFF, "abc test")) < 0) {
                brlapi_perror("brlapi_writeText");
                cout << "error brlapi_writeText: " << e << endl;
                brlapi_closeConnection();
                cout << "cin:"; cout.flush(); cin >> txt;
                return 1;
        }
        cout << "brlapi_writeText ok: " << e << endl;

        cout << "cin:"; cout.flush(); cin >> txt; // wait

// test braille output:
        unsigned char dp[40];
        for (int i=0 ; i<40 ; ++i)
                dp[i] = i;
        if ((e = brlapi_writeDots(dp)) != 0) {
                brlapi_perror("brlapi_writeDots");
                cout << "error brlapi_writeDots: " << e << endl;
                brlapi_closeConnection();
                cout << "cin:"; cout.flush(); cin >> txt;
                return 1;
        }

        e = brlapi_acceptAllKeys();
        cout << "brlapi_acceptAllKeys: " << e << endl;

// start 2nd thread to read the braille keys:
        error = false;
        DWORD tID;
        HANDLE hThread;
        hThread = CreateThread (0, 0, (LPTHREAD_START_ROUTINE)Validate, 0, 0, 
&tID);

        ofstream log ("log.txt");
        logp = &log; // write braille input to *logp

        for (;;)
        {
                cin >> txt; // enter the dots to be pressed..
                if (error || txt[0] == 'q') break;
                log << txt << ":\n"; // ..and write them,
                        // then press according braille keys on the terminal,
                        // so that 2nd thread writes the received input.
        }

        brlapi_closeConnection();
        cout << "cin:"; cout.flush(); cin >> txt;
        return 0;
}
1:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000001 -------- -------- -------- -------- --1----- -------- 
-------- -------1
2:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 2000001e -------- -------- -------- -------- --1----- -------- 
-------- ---1111-
3:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 2000000b -------- -------- -------- -------- --1----- -------- 
-------- ----1-11
4:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000002 -------- -------- -------- -------- --1----- -------- 
-------- ------1-
5:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000021 -------- -------- -------- -------- --1----- -------- 
-------- --1----1
6:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000022 -------- -------- -------- -------- --1----- -------- 
-------- --1---1-
7:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 2000001d -------- -------- -------- -------- --1----- -------- 
-------- ---111-1
8:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000031 -------- -------- -------- -------- --1----- -------- 
-------- --11---1
12:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000011 -------- -------- -------- -------- --1----- -------- 
-------- ---1---1
13:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 2000000f -------- -------- -------- -------- --1----- -------- 
-------- ----1111
14:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
15:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000007 -------- -------- -------- -------- --1----- -------- 
-------- -----111
123:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
146:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
1238:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
13457:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
1235678:
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
 1 00000000 20000000 -------- -------- -------- -------- --1----- -------- 
-------- --------
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty

Reply via email to