]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/hwinfo/src/hd/braille.c
12 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18 #if !defined(LIBHD_TINY) && !defined(__sparc__)
20 static unsigned do_alva(hd_data_t
*hd_data
, char *dev_name
, int cnt
);
21 static unsigned do_fhp(hd_data_t
*hd_data
, char *dev_name
, unsigned baud
, int cnt
);
22 static unsigned do_ht(hd_data_t
*hd_data
, char *dev_name
, int cnt
);
23 static unsigned do_baum(hd_data_t
*hd_data
, char *dev_name
, int cnt
);
25 void hd_scan_braille(hd_data_t
*hd_data
)
31 if(!hd_probe_feature(hd_data
, pr_braille
)) return;
33 hd_data
->module
= mod_braille
;
36 remove_hd_entries(hd_data
);
38 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
40 hd
->base_class
.id
== bc_comm
&&
41 hd
->sub_class
.id
== sc_com_ser
&&
44 !has_something_attached(hd_data
, hd
)
49 if(hd_probe_feature(hd_data
, pr_braille_alva
)) {
50 PROGRESS(1, cnt
, "alva");
51 vend
= MAKE_ID(TAG_SPECIAL
, 0x5001);
52 dev
= do_alva(hd_data
, hd
->unix_dev_name
, cnt
);
55 if(!dev
&& hd_probe_feature(hd_data
, pr_braille_fhp
)) {
56 PROGRESS(1, cnt
, "fhp_old");
57 vend
= MAKE_ID(TAG_SPECIAL
, 0x5002);
58 dev
= do_fhp(hd_data
, hd
->unix_dev_name
, B19200
, cnt
);
60 PROGRESS(1, cnt
, "fhp_el");
61 dev
= do_fhp(hd_data
, hd
->unix_dev_name
, B38400
, cnt
);
65 if(!dev
&& hd_probe_feature(hd_data
, pr_braille_ht
)) {
66 PROGRESS(1, cnt
, "ht");
67 vend
= MAKE_ID(TAG_SPECIAL
, 0x5003);
68 dev
= do_ht(hd_data
, hd
->unix_dev_name
, cnt
);
71 if(!dev
&& hd_probe_feature(hd_data
, pr_braille_baum
)) {
72 PROGRESS(1, cnt
, "baum");
73 vend
= MAKE_ID(TAG_SPECIAL
, 0x5004);
74 dev
= do_baum(hd_data
, hd
->unix_dev_name
, cnt
);
78 hd_tmp
= add_hd_entry(hd_data
, __LINE__
, 0);
79 hd_tmp
->base_class
.id
= bc_braille
;
80 hd_tmp
->bus
.id
= bus_serial
;
81 hd_tmp
->unix_dev_name
= new_str(hd
->unix_dev_name
);
82 hd_tmp
->attached_to
= hd
->idx
;
83 hd_tmp
->vendor
.id
= vend
;
84 hd_tmp
->device
.id
= dev
;
92 * autodetect for Alva Braille-displays
93 * Author: marco Skambraks <marco@suse.de>
96 * This is free software, placed under the terms of the
97 * GNU General Public License, as published by the Free Software
98 * Foundation. Please see the file COPYING for details.
101 /* Communication codes */
102 #define BRL_ID "\033ID="
105 #define WAIT_DTR 700000
106 #define WAIT_FLUSH 200
108 unsigned do_alva(hd_data_t
*hd_data
, char *dev_name
, int cnt
)
110 int fd
, i
, timeout
= 100;
111 struct termios oldtio
, newtio
; /* old & new terminal settings */
113 unsigned char buffer
[sizeof BRL_ID
];
116 PROGRESS(2, cnt
, "alva open");
118 /* Open the Braille display device for random access */
119 fd
= open(dev_name
, O_RDWR
| O_NOCTTY
);
122 tcgetattr(fd
, &oldtio
); /* save current settings */
124 /* Set flow control and 8n1, enable reading */
125 memset(&newtio
, 0, sizeof newtio
);
126 newtio
.c_cflag
= CRTSCTS
| CS8
| CLOCAL
| CREAD
;
127 /* Ignore bytes with parity errors and make terminal raw and dumb */
128 newtio
.c_iflag
= IGNPAR
;
129 newtio
.c_oflag
= 0; /* raw output */
130 newtio
.c_lflag
= 0; /* don't echo or generate signals */
131 newtio
.c_cc
[VMIN
] = 0; /* set nonblocking read */
132 newtio
.c_cc
[VTIME
] = 0;
134 PROGRESS(3, cnt
, "alva init ok");
136 PROGRESS(4, cnt
, "alva read data");
138 /* autodetecting ABT model */
139 /* to force DTR off */
140 cfsetispeed(&newtio
, B0
);
141 cfsetospeed(&newtio
, B0
);
142 tcsetattr(fd
, TCSANOW
, &newtio
); /* activate new settings */
145 tcflush(fd
, TCIOFLUSH
); /* clean line */
149 cfsetispeed(&newtio
, B9600
);
150 cfsetospeed(&newtio
, B9600
);
151 tcsetattr(fd
, TCSANOW
, &newtio
); /* activate new settings */
152 usleep(WAIT_DTR
); /* give time to send ID string */
154 if((i
= read(fd
, buffer
, sizeof buffer
)) == sizeof buffer
) {
155 if(!strncmp(buffer
, BRL_ID
, sizeof BRL_ID
- 1)) {
156 /* Find out which model we are connected to... */
157 switch(model
= buffer
[sizeof buffer
- 1])
166 dev
= MAKE_ID(TAG_SPECIAL
, model
);
171 ADD2LOG("alva.%d@%s[%d]: ", timeout
, dev_name
, i
);
172 if(i
> 0) hexdump(&hd_data
->log
, 1, i
, buffer
);
175 PROGRESS(5, cnt
, "alva read done");
177 /* reset serial lines */
178 tcflush(fd
, TCIOFLUSH
);
179 tcsetattr(fd
, TCSAFLUSH
, &oldtio
);
187 * autodetect for Papenmeier Braille-displays
188 * Author: marco Skambraks <marco@suse.de>
189 * Suse GmbH Nuernberg
191 * This is free software, placed under the terms of the
192 * GNU General Public License, as published by the Free Software
193 * Foundation. Please see the file COPYING for details.
196 unsigned do_fhp(hd_data_t
*hd_data
, char *dev_name
, unsigned baud
, int cnt
)
199 char crash
[] = { 2, 'S', 0, 0, 0, 0 };
200 unsigned char buf
[10];
201 struct termios oldtio
, newtio
; /* old & new terminal settings */
204 PROGRESS(2, cnt
, "fhp open");
206 /* Now open the Braille display device for random access */
207 fd
= open(dev_name
, O_RDWR
| O_NOCTTY
);
210 tcgetattr(fd
, &oldtio
); /* save current settings */
212 /* Set bps, flow control and 8n1, enable reading */
213 memset(&newtio
, 0, sizeof newtio
);
214 newtio
.c_cflag
= baud
| CS8
| CLOCAL
| CREAD
;
216 /* Ignore bytes with parity errors and make terminal raw and dumb */
217 newtio
.c_iflag
= IGNPAR
;
218 newtio
.c_oflag
= 0; /* raw output */
219 newtio
.c_lflag
= 0; /* don't echo or generate signals */
220 newtio
.c_cc
[VMIN
] = 0; /* set nonblocking read */
221 newtio
.c_cc
[VTIME
] = 0;
222 tcflush(fd
, TCIFLUSH
); /* clean line */
223 tcsetattr(fd
, TCSANOW
, &newtio
); /* activate new settings */
225 PROGRESS(3, cnt
, "fhp init ok");
227 crash
[2] = 0x200 >> 8;
228 crash
[3] = 0x200 & 0xff;
229 crash
[5] = (7+10) & 0xff;
231 write(fd
, crash
, sizeof crash
);
232 write(fd
, "1111111111",10);
236 crash
[3] = 0x0 & 0xff;
239 write(fd
, crash
, sizeof crash
);
240 write(fd
, "1111111111", 10);
243 usleep(500000); /* 100000 should be enough */
245 PROGRESS(4, cnt
, "fhp write ok");
247 i
= read(fd
, &buf
, 10);
249 PROGRESS(5, cnt
, "fhp read done");
251 ADD2LOG("fhp@%s[%d]: ", dev_name
, i
);
252 if(i
> 0) hexdump(&hd_data
->log
, 1, i
, buf
);
256 if(i
== 10 && buf
[0] == 0x02 && buf
[1] == 0x49) {
267 dev
= MAKE_ID(TAG_SPECIAL
, dev
);
271 if(!dev
) ADD2LOG("no fhp display: 0x%02x\n", i
>= 2 ? buf
[2] : 0);
273 /* reset serial lines */
274 tcflush(fd
, TCIOFLUSH
);
275 tcsetattr(fd
, TCSAFLUSH
, &oldtio
);
283 * autodetect for Handy Tech Braille-displays
284 * Author: marco Skambraks <marco@suse.de>
285 * Suse GmbH Nuernberg
287 * This is free software, placed under the terms of the
288 * GNU General Public License, as published by the Free Software
289 * Foundation. Please see the file COPYING for details.
292 unsigned do_ht(hd_data_t
*hd_data
, char *dev_name
, int cnt
)
295 unsigned char code
= 0xff, buf
[2] = { 0, 0 };
296 struct termios oldtio
, newtio
;
299 PROGRESS(2, cnt
, "ht open");
301 fd
= open(dev_name
, O_RDWR
| O_NOCTTY
);
304 tcgetattr(fd
, &oldtio
);
307 newtio
.c_cflag
= CLOCAL
| PARODD
| PARENB
| CREAD
| CS8
;
308 newtio
.c_iflag
= IGNPAR
;
311 newtio
.c_cc
[VMIN
] = 0;
312 newtio
.c_cc
[VTIME
] = 0;
316 * Force down DTR, flush any pending data and then the port to what we
321 cfsetispeed(&newtio
, B0
) ||
322 cfsetospeed(&newtio
, B0
) ||
323 tcsetattr(fd
, TCSANOW
, &newtio
) ||
324 tcflush(fd
, TCIOFLUSH
) ||
325 cfsetispeed(&newtio
, B19200
) ||
326 cfsetospeed(&newtio
, B19200
) ||
327 tcsetattr(fd
, TCSANOW
, &newtio
)
330 /* Pause to let them take effect */
333 PROGRESS(3, cnt
, "ht init ok");
335 write(fd
, &code
, 1); /* reset brl */
336 usleep(5000); /* wait for reset */
338 PROGRESS(4, cnt
, "ht write ok");
343 PROGRESS(5, cnt
, "ht read done");
345 if(buf
[0] == 0xfe) { /* resetok now read id */
347 read(fd
, buf
+ 1, 1);
350 PROGRESS(6, cnt
, "ht read done");
362 dev
= MAKE_ID(TAG_SPECIAL
, dev
);
368 ADD2LOG("ht@%s[%d]: ", dev_name
, i
);
369 if(i
> 0) hexdump(&hd_data
->log
, 1, i
, buf
);
372 if(!dev
) ADD2LOG("no ht display: 0x%02x\n", buf
[1]);
374 /* reset serial lines */
375 tcflush(fd
, TCIOFLUSH
);
376 tcsetattr(fd
, TCSAFLUSH
, &oldtio
);
384 * autodetect for Baum Braille-displays
385 * Author: marco Skambraks <marco@suse.de>
386 * Suse GmbH Nuernberg
388 * This is free software, placed under the terms of the
389 * GNU General Public License, as published by the Free Software
390 * Foundation. Please see the file COPYING for details.
393 #define BAUDRATE B19200 /* But both run at 19k2 */
396 unsigned do_baum(hd_data_t
*hd_data
, char *dev_name
, int cnt
)
398 static char device_id
[] = { 0x1b, 0x84 };
400 struct termios oldtio
, curtio
;
401 unsigned char buf
[MAXREAD
+ 1];
404 PROGRESS(2, cnt
, "baum open");
406 fd
= open(dev_name
, O_RDWR
| O_NOCTTY
);
409 tcgetattr(fd
, &curtio
);
414 /* no SIGTTOU to backgrounded processes */
415 curtio
.c_lflag
&= ~TOSTOP
;
416 curtio
.c_cflag
= BAUDRATE
| CS8
| CLOCAL
| CREAD
;
417 /* no input parity check, no XON/XOFF */
418 curtio
.c_iflag
&= ~(INPCK
| ~IXOFF
);
420 curtio
.c_cc
[VTIME
] = 1; /* 0.1s timeout between chars on input */
421 curtio
.c_cc
[VMIN
] = 0; /* no minimum input */
423 tcsetattr(fd
, TCSAFLUSH
, &curtio
);
425 /* write ID-request */
426 write(fd
, device_id
, sizeof device_id
);
428 /* wait for response */
431 PROGRESS(3, cnt
, "baum write ok");
433 i
= read(fd
, buf
, sizeof buf
- 1);
434 buf
[sizeof buf
- 1] = 0;
436 PROGRESS(4, cnt
, "baum read done");
438 ADD2LOG("baum@%s[%d]: ", dev_name
, i
);
439 if(i
> 0) hexdump(&hd_data
->log
, 1, i
, buf
);
442 /* reset serial lines */
443 tcflush(fd
, TCIOFLUSH
);
444 tcsetattr(fd
, TCSAFLUSH
, &oldtio
);
447 if(!strcmp(buf
+ 2, "Baum Vario40")) return 1;
448 if(!strcmp(buf
+ 2, "Baum Vario80")) return 2;
454 #endif /* !defined(LIBHD_TINY) && !defined(__sparc__) */