13
* @defgroup BRAILLEint Braille devices
14
* @ingroup libhdDEVint
15
* @brief Braille displays functions
20
#if !defined(LIBHD_TINY) && !defined(__sparc__)
22
static unsigned do_alva(hd_data_t *hd_data, char *dev_name, int cnt);
23
static unsigned do_fhp(hd_data_t *hd_data, char *dev_name, unsigned baud, int cnt);
24
static unsigned do_ht(hd_data_t *hd_data, char *dev_name, int cnt);
25
static unsigned do_baum(hd_data_t *hd_data, char *dev_name, int cnt);
27
void hd_scan_braille(hd_data_t *hd_data)
33
if(!hd_probe_feature(hd_data, pr_braille)) return;
35
hd_data->module = mod_braille;
38
remove_hd_entries(hd_data);
40
for(hd = hd_data->hd; hd; hd = hd->next) {
42
hd->base_class.id == bc_comm &&
43
hd->sub_class.id == sc_com_ser &&
46
!has_something_attached(hd_data, hd)
51
if(hd_probe_feature(hd_data, pr_braille_alva)) {
52
PROGRESS(1, cnt, "alva");
53
vend = MAKE_ID(TAG_SPECIAL, 0x5001);
54
dev = do_alva(hd_data, hd->unix_dev_name, cnt);
57
if(!dev && hd_probe_feature(hd_data, pr_braille_fhp)) {
58
PROGRESS(1, cnt, "fhp_old");
59
vend = MAKE_ID(TAG_SPECIAL, 0x5002);
60
dev = do_fhp(hd_data, hd->unix_dev_name, B19200, cnt);
62
PROGRESS(1, cnt, "fhp_el");
63
dev = do_fhp(hd_data, hd->unix_dev_name, B38400, cnt);
67
if(!dev && hd_probe_feature(hd_data, pr_braille_ht)) {
68
PROGRESS(1, cnt, "ht");
69
vend = MAKE_ID(TAG_SPECIAL, 0x5003);
70
dev = do_ht(hd_data, hd->unix_dev_name, cnt);
73
if(!dev && hd_probe_feature(hd_data, pr_braille_baum)) {
74
PROGRESS(1, cnt, "baum");
75
vend = MAKE_ID(TAG_SPECIAL, 0x5004);
76
dev = do_baum(hd_data, hd->unix_dev_name, cnt);
80
hd_tmp = add_hd_entry(hd_data, __LINE__, 0);
81
hd_tmp->base_class.id = bc_braille;
82
hd_tmp->bus.id = bus_serial;
83
hd_tmp->unix_dev_name = new_str(hd->unix_dev_name);
84
hd_tmp->attached_to = hd->idx;
85
hd_tmp->vendor.id = vend;
86
hd_tmp->device.id = dev;
94
* autodetect for Alva Braille-displays
95
* Author: marco Skambraks <marco@suse.de>
98
* This is free software, placed under the terms of the
99
* GNU General Public License, as published by the Free Software
100
* Foundation. Please see the file COPYING for details.
103
/* Communication codes */
104
#define BRL_ID "\033ID="
107
#define WAIT_DTR 700000
108
#define WAIT_FLUSH 200
110
unsigned do_alva(hd_data_t *hd_data, char *dev_name, int cnt)
112
int fd, i, timeout = 100;
113
struct termios oldtio, newtio; /* old & new terminal settings */
115
unsigned char buffer[sizeof BRL_ID];
118
PROGRESS(2, cnt, "alva open");
120
/* Open the Braille display device for random access */
121
fd = open(dev_name, O_RDWR | O_NOCTTY);
124
tcgetattr(fd, &oldtio); /* save current settings */
126
/* Set flow control and 8n1, enable reading */
127
memset(&newtio, 0, sizeof newtio);
128
newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD;
129
/* Ignore bytes with parity errors and make terminal raw and dumb */
130
newtio.c_iflag = IGNPAR;
131
newtio.c_oflag = 0; /* raw output */
132
newtio.c_lflag = 0; /* don't echo or generate signals */
133
newtio.c_cc[VMIN] = 0; /* set nonblocking read */
134
newtio.c_cc[VTIME] = 0;
136
PROGRESS(3, cnt, "alva init ok");
138
PROGRESS(4, cnt, "alva read data");
140
/* autodetecting ABT model */
141
/* to force DTR off */
142
cfsetispeed(&newtio, B0);
143
cfsetospeed(&newtio, B0);
144
tcsetattr(fd, TCSANOW, &newtio); /* activate new settings */
147
tcflush(fd, TCIOFLUSH); /* clean line */
151
cfsetispeed(&newtio, B9600);
152
cfsetospeed(&newtio, B9600);
153
tcsetattr(fd, TCSANOW, &newtio); /* activate new settings */
154
usleep(WAIT_DTR); /* give time to send ID string */
156
if((i = read(fd, buffer, sizeof buffer)) == sizeof buffer) {
157
if(!strncmp(buffer, BRL_ID, sizeof BRL_ID - 1)) {
158
/* Find out which model we are connected to... */
159
switch(model = buffer[sizeof buffer - 1])
168
dev = MAKE_ID(TAG_SPECIAL, model);
173
ADD2LOG("alva.%d@%s[%d]: ", timeout, dev_name, i);
174
if(i > 0) hexdump(&hd_data->log, 1, i, buffer);
177
PROGRESS(5, cnt, "alva read done");
179
/* reset serial lines */
180
tcflush(fd, TCIOFLUSH);
181
tcsetattr(fd, TCSAFLUSH, &oldtio);
189
* autodetect for Papenmeier Braille-displays
190
* Author: marco Skambraks <marco@suse.de>
191
* Suse GmbH Nuernberg
193
* This is free software, placed under the terms of the
194
* GNU General Public License, as published by the Free Software
195
* Foundation. Please see the file COPYING for details.
198
unsigned do_fhp(hd_data_t *hd_data, char *dev_name, unsigned baud, int cnt)
201
char crash[] = { 2, 'S', 0, 0, 0, 0 };
202
unsigned char buf[10];
203
struct termios oldtio, newtio; /* old & new terminal settings */
206
PROGRESS(2, cnt, "fhp open");
208
/* Now open the Braille display device for random access */
209
fd = open(dev_name, O_RDWR | O_NOCTTY);
212
tcgetattr(fd, &oldtio); /* save current settings */
214
/* Set bps, flow control and 8n1, enable reading */
215
memset(&newtio, 0, sizeof newtio);
216
newtio.c_cflag = baud | CS8 | CLOCAL | CREAD;
218
/* Ignore bytes with parity errors and make terminal raw and dumb */
219
newtio.c_iflag = IGNPAR;
220
newtio.c_oflag = 0; /* raw output */
221
newtio.c_lflag = 0; /* don't echo or generate signals */
222
newtio.c_cc[VMIN] = 0; /* set nonblocking read */
223
newtio.c_cc[VTIME] = 0;
224
tcflush(fd, TCIFLUSH); /* clean line */
225
tcsetattr(fd, TCSANOW, &newtio); /* activate new settings */
227
PROGRESS(3, cnt, "fhp init ok");
229
crash[2] = 0x200 >> 8;
230
crash[3] = 0x200 & 0xff;
231
crash[5] = (7+10) & 0xff;
233
write(fd, crash, sizeof crash);
234
write(fd, "1111111111",10);
238
crash[3] = 0x0 & 0xff;
241
write(fd, crash, sizeof crash);
242
write(fd, "1111111111", 10);
245
usleep(500000); /* 100000 should be enough */
247
PROGRESS(4, cnt, "fhp write ok");
249
i = read(fd, &buf, 10);
251
PROGRESS(5, cnt, "fhp read done");
253
ADD2LOG("fhp@%s[%d]: ", dev_name, i);
254
if(i > 0) hexdump(&hd_data->log, 1, i, buf);
258
if(i == 10 && buf[0] == 0x02 && buf[1] == 0x49) {
269
dev = MAKE_ID(TAG_SPECIAL, dev);
273
if(!dev) ADD2LOG("no fhp display: 0x%02x\n", i >= 2 ? buf[2] : 0);
275
/* reset serial lines */
276
tcflush(fd, TCIOFLUSH);
277
tcsetattr(fd, TCSAFLUSH, &oldtio);
285
* autodetect for Handy Tech Braille-displays
286
* Author: marco Skambraks <marco@suse.de>
287
* Suse GmbH Nuernberg
289
* This is free software, placed under the terms of the
290
* GNU General Public License, as published by the Free Software
291
* Foundation. Please see the file COPYING for details.
294
unsigned do_ht(hd_data_t *hd_data, char *dev_name, int cnt)
297
unsigned char code = 0xff, buf[2] = { 0, 0 };
298
struct termios oldtio, newtio;
301
PROGRESS(2, cnt, "ht open");
303
fd = open(dev_name, O_RDWR | O_NOCTTY);
306
tcgetattr(fd, &oldtio);
309
newtio.c_cflag = CLOCAL | PARODD | PARENB | CREAD | CS8;
310
newtio.c_iflag = IGNPAR;
313
newtio.c_cc[VMIN] = 0;
314
newtio.c_cc[VTIME] = 0;
318
* Force down DTR, flush any pending data and then the port to what we
323
cfsetispeed(&newtio, B0) ||
324
cfsetospeed(&newtio, B0) ||
325
tcsetattr(fd, TCSANOW, &newtio) ||
326
tcflush(fd, TCIOFLUSH) ||
327
cfsetispeed(&newtio, B19200) ||
328
cfsetospeed(&newtio, B19200) ||
329
tcsetattr(fd, TCSANOW, &newtio)
332
/* Pause to let them take effect */
335
PROGRESS(3, cnt, "ht init ok");
337
write(fd, &code, 1); /* reset brl */
338
usleep(5000); /* wait for reset */
340
PROGRESS(4, cnt, "ht write ok");
345
PROGRESS(5, cnt, "ht read done");
347
if(buf[0] == 0xfe) { /* resetok now read id */
349
read(fd, buf + 1, 1);
352
PROGRESS(6, cnt, "ht read done");
364
dev = MAKE_ID(TAG_SPECIAL, dev);
370
ADD2LOG("ht@%s[%d]: ", dev_name, i);
371
if(i > 0) hexdump(&hd_data->log, 1, i, buf);
374
if(!dev) ADD2LOG("no ht display: 0x%02x\n", buf[1]);
376
/* reset serial lines */
377
tcflush(fd, TCIOFLUSH);
378
tcsetattr(fd, TCSAFLUSH, &oldtio);
386
* autodetect for Baum Braille-displays
387
* Author: marco Skambraks <marco@suse.de>
388
* Suse GmbH Nuernberg
390
* This is free software, placed under the terms of the
391
* GNU General Public License, as published by the Free Software
392
* Foundation. Please see the file COPYING for details.
395
#define BAUDRATE B19200 /* But both run at 19k2 */
398
unsigned do_baum(hd_data_t *hd_data, char *dev_name, int cnt)
400
static char device_id[] = { 0x1b, 0x84 };
402
struct termios oldtio, curtio;
403
unsigned char buf[MAXREAD + 1];
406
PROGRESS(2, cnt, "baum open");
408
fd = open(dev_name, O_RDWR | O_NOCTTY);
411
tcgetattr(fd, &curtio);
416
/* no SIGTTOU to backgrounded processes */
417
curtio.c_lflag &= ~TOSTOP;
418
curtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD;
419
/* no input parity check, no XON/XOFF */
420
curtio.c_iflag &= ~(INPCK | ~IXOFF);
422
curtio.c_cc[VTIME] = 1; /* 0.1s timeout between chars on input */
423
curtio.c_cc[VMIN] = 0; /* no minimum input */
425
tcsetattr(fd, TCSAFLUSH, &curtio);
427
/* write ID-request */
428
write(fd, device_id, sizeof device_id);
430
/* wait for response */
433
PROGRESS(3, cnt, "baum write ok");
435
i = read(fd, buf, sizeof buf - 1);
436
buf[sizeof buf - 1] = 0;
438
PROGRESS(4, cnt, "baum read done");
440
ADD2LOG("baum@%s[%d]: ", dev_name, i);
441
if(i > 0) hexdump(&hd_data->log, 1, i, buf);
444
/* reset serial lines */
445
tcflush(fd, TCIOFLUSH);
446
tcsetattr(fd, TCSAFLUSH, &oldtio);
449
if(!strcmp(buf + 2, "Baum Vario40")) return 1;
450
if(!strcmp(buf + 2, "Baum Vario80")) return 2;
456
#endif /* !defined(LIBHD_TINY) && !defined(__sparc__) */