static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if (!isSerialDevice(&device)) { unsupportedDevice(device); return 0; } if ((serialDevice = serialOpenDevice(device))) { if (serialRestartDevice(serialDevice, serialBaud)) { static const unsigned char request[] = {BNO_DESCRIBE}; charactersPerSecond = serialBaud / 10; if (writePacket(brl, request, sizeof(request)) != -1) { while (serialAwaitInput(serialDevice, 100)) { ResponsePacket response; int size = getPacket(&response); if (size) { if (response.data.code == BNI_DESCRIBE) { statusCells = response.data.values.description.statusCells; brl->textColumns = response.data.values.description.textCells; brl->textRows = 1; brl->keyBindings = "keys"; if ((statusCells == 5) && (brl->textColumns == 30)) { statusCells -= 2; brl->textColumns += 2; } dataCells = brl->textColumns * brl->textRows; cellCount = statusCells + dataCells; makeOutputTable(dotsTable_ISO11548_1); makeInputTable(); if ((cellBuffer = malloc(cellCount))) { memset(cellBuffer, 0, cellCount); statusArea = cellBuffer; dataArea = statusArea + statusCells; refreshCells(brl); persistentKeyboardMode = KBM_NAVIGATE; temporaryKeyboardMode = persistentKeyboardMode; persistentRoutingOperation = BRL_BLK_ROUTE; temporaryRoutingOperation = persistentRoutingOperation; return 1; } else { logSystemError("cell buffer allocation"); } } else { logUnexpectedPacket(response.bytes, size); } } } } } serialCloseDevice(serialDevice); serialDevice = NULL; } return 0; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if ((brl->data = malloc(sizeof(*brl->data)))) { memset(brl->data, 0, sizeof(*brl->data)); brl->data->brailleDevice = -1; #ifdef KEYBOARD_DEVICE_NAME brl->data->keyboardDevice = -1; #endif /* KEYBOARD_DEVICE_NAME */ if (openBrailleDevice(brl, device)) { logBrailleVersion(brl); #ifdef KEYBOARD_DEVICE_NAME if (openKeyboardDevice(brl)) { #endif /* KEYBOARD_DEVICE_NAME */ if (clearBrailleCells(brl)) { #ifdef KEYBOARD_DEVICE_NAME { const KeyTableDefinition *ktd = &KEY_TABLE_DEFINITION(all); brl->keyBindings = ktd->bindings; brl->keyNames = ktd->names; } #endif /* KEYBOARD_DEVICE_NAME */ brl->textColumns = BRAILLE_CELL_COUNT; makeOutputTable(dotsTable_ISO11548_1); brl->data->forceRewrite = 1; return 1; } #ifdef KEYBOARD_DEVICE_NAME closeKeyboardDevice(brl); } #endif /* KEYBOARD_DEVICE_NAME */ closeBrailleDevice(brl); } free(brl->data); } else { logMallocError(); } return 0; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if (!isSerialDevice(&device)) { unsupportedDevice(device); return 0; } if ((serialDevice = serialOpenDevice(device))) { if (serialRestartDevice(serialDevice, serialBaud)) { serialCharactersPerSecond = serialBaud / serialGetCharacterBits(serialDevice); /* hm, how to switch to 38400 ? static const unsigned char sequence[] = {ESC, 'V', CR}; writeData(brl, sequence, sizeof(sequence)); serialDiscardInput(serialDevice); serialSetBaud(serialDevice, 38400); */ { static const DotsTable dots = { 0X01, 0X02, 0X04, 0X80, 0X40, 0X20, 0X08, 0X10 }; makeOutputTable(dots); } clearCells(textCells, sizeof(textCells)); clearCells(statusCells, sizeof(statusCells)); resetInputMode(); cursorDots = 0XFF; cursorOffset = sizeof(textCells) / 2; brl->textColumns = sizeof(textCells); brl->textRows = 1; brl->statusColumns = sizeof(statusCells); brl->statusRows = 1; beep(brl); return 1; } serialCloseDevice(serialDevice); serialDevice = NULL; } return 0; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if (connectResource(device)) { ResponsePacket response; if (probeBrailleDisplay(brl, 0, gioEndpoint, 100, writeIdentifyRequest, readResponse, &response, sizeof(response), isIdentityResponse)) { statusCells = response.data.values.description.statusCells; brl->textColumns = response.data.values.description.textCells; brl->textRows = 1; if ((statusCells == 5) && (brl->textColumns == 30)) { statusCells -= 2; brl->textColumns += 2; } dataCells = brl->textColumns * brl->textRows; cellCount = statusCells + dataCells; { const KeyTableDefinition *ktd = &KEY_TABLE_DEFINITION(all); brl->keyBindings = ktd->bindings; brl->keyNameTables = ktd->names; } makeOutputTable(dotsTable_ISO11548_1); makeInputTable(); if ((cellBuffer = malloc(cellCount))) { memset(cellBuffer, 0, cellCount); statusArea = cellBuffer; dataArea = statusArea + statusCells; refreshCells(brl); return 1; } else { logSystemError("cell buffer allocation"); } } disconnectResource(); } return 0; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if ((brl->data = malloc(sizeof(*brl->data)))) { memset(brl->data, 0, sizeof(*brl->data)); brl->data->gioEndpoint = NULL; if (connectResource(brl, device)) { unsigned char response[MAXIMUM_RESPONSE_SIZE]; if (probeBrailleDisplay(brl, PROBE_RETRY_LIMIT, brl->data->gioEndpoint, PROBE_INPUT_TIMEOUT, writeIdentityRequest, readPacket, &response, sizeof(response), isIdentityResponse)) { { const KeyTableDefinition *ktd = &KEY_TABLE_DEFINITION(all); brl->keyBindings = ktd->bindings; brl->keyNameTables = ktd->names; } { static const DotsTable dots = { 0X01, 0X04, 0X10, 0X02, 0X08, 0X20, 0X40, 0X80 }; makeOutputTable(dots); } brl->textColumns = MAXIMUM_CELL_COUNT; brl->data->forceRewrite = 1; return 1; } gioDisconnectResource(brl->data->gioEndpoint); } free(brl->data); } else { logMallocError(); } return 0; }
static int vbinit() { if (enablePorts(LOG_ERR, LPTPORT, 3)) { if (enablePorts(LOG_ERR, 0X80, 1)) { makeOutputTable(dotsTable_ISO11548_1); { unsigned char alldots[40]; memset(alldots, 0XFF, 40); vbdisplay(alldots); } return 0; } disablePorts(LPTPORT, 3); } logMessage(LOG_ERR, "Error: must be superuser"); return -1; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if (!isSerialDevice(&device)) { unsupportedDevice(device); return 0; } if ((serialDevice = serialOpenDevice(device))) { unsigned int baud = 19200; charactersPerSecond = baud / 11; if (serialRestartDevice(serialDevice, baud)) { if (serialSetParity(serialDevice, SERIAL_PARITY_EVEN)) { if (writePacket(brl, 4, NULL, 0)) { while (serialAwaitInput(serialDevice, 500)) { unsigned char response[3]; int size = readPacket(brl, response, sizeof(response)); if (size <= 0) break; if (response[1] == 4) { brl->textColumns = response[2]; brl->textRows = 1; makeOutputTable(dotsTable_ISO11548_1); makeInputTable(); if (!clearBrailleCells(brl)) break; if (!clearVisualText(brl)) break; if (!writeBrailleCells(brl)) break; return 1; } } } } } serialCloseDevice(serialDevice); serialDevice = NULL; } return 0; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if (!isSerialDevice(&device)) { unsupportedDevice(device); return 0; } if ((serialDevice = serialOpenDevice(device))) { static const unsigned int baud = 9600; charactersPerSecond = baud / 10; if (serialRestartDevice(serialDevice, baud)) { if (identifyDisplay(brl)) { { static const DotsTable dots = { 0X01, 0X02, 0X04, 0X10, 0X20, 0X40, 0X08, 0X80 }; makeOutputTable(dots); } if ((outputBuffer = malloc(brl->textColumns))) { if (setTable(brl, 0)) { memset(outputBuffer, 0, brl->textColumns); writeCells(brl); return 1; } free(outputBuffer); outputBuffer = NULL; } else { logSystemError("Output buffer allocation"); } } } serialCloseDevice(serialDevice); serialDevice = NULL; } return 0; }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { short n, success; /* loop counters, flags, etc. */ unsigned char *init_seq = (unsigned char *)"\002\0330"; /* string to send to Braille to initialise: [ESC][0] */ unsigned char *init_ack = (unsigned char *)"\002\033V"; /* string to expect as acknowledgement: [ESC][V]... */ unsigned char c; TimePeriod period; if (!isSerialDevice(&device)) { unsupportedDevice(device); return 0; } brlcols = -1; /* length of braille display (auto-detected) */ prevdata = rawdata = NULL; /* clear pointers */ /* No need to load translation tables, as these are now * defined in tables.h */ /* Now open the Braille display device for random access */ if (!(MB_serialDevice = serialOpenDevice(device))) goto failure; if (!serialRestartDevice(MB_serialDevice, BAUDRATE)) goto failure; if (!serialSetFlowControl(MB_serialDevice, SERIAL_FLOW_HARDWARE)) goto failure; /* MultiBraille initialisation procedure: * [ESC][V][Braillelength][Software Version][CR] * I guess, they mean firmware version with software version :*} * firmware version == [Software Version] / 10.0 */ success = 0; if (init_seq[0]) if (serialWriteData (MB_serialDevice, init_seq + 1, init_seq[0]) != init_seq[0]) goto failure; startTimePeriod (&period, ACK_TIMEOUT); /* initialise timeout testing */ n = 0; do { approximateDelay (20); if (serialReadData (MB_serialDevice, &c, 1, 0, 0) == 0) continue; if (n < init_ack[0] && c != init_ack[1 + n]) continue; if (n == init_ack[0]) { brlcols = c, success = 1; /* reading version-info */ /* firmware version == [Software Version] / 10.0 */ serialReadData (MB_serialDevice, &c, 1, 0, 0); logMessage (LOG_INFO, "MultiBraille: Version: %2.1f", c/10.0); /* read trailing [CR] */ serialReadData (MB_serialDevice, &c, 1, 0, 0); } n++; } while (!afterTimePeriod (&period, NULL) && n <= init_ack[0]); if (success && (brlcols != 25)) { if ((prevdata = malloc(brl->textColumns * brl->textRows))) { if ((rawdata = malloc(20 + (brl->textColumns * brl->textRows * 2)))) { brl->textColumns = brlcols; brl->textRows = BRLROWS; brl->statusColumns = 5; brl->statusRows = 1; { static const DotsTable dots = { 0X01, 0X02, 0X04, 0X80, 0X40, 0X20, 0X08, 0X10 }; makeOutputTable(dots); } return 1; } else { logMallocError(); } free(prevdata); } else { logMallocError(); } } failure: if (MB_serialDevice) { serialCloseDevice(MB_serialDevice); MB_serialDevice = NULL; } return 0; }
static int brl_construct(BrailleDisplay *brl, char **parameters, const char *device) { if(*parameters[PARM_DEVICE]) braille_config(BRL_DEVICE, parameters[PARM_DEVICE]); if(*parameters[PARM_DRIVER]) braille_config(BRL_DRIVER, parameters[PARM_DRIVER]); if(*parameters[PARM_TABLE]) braille_config(BRL_TABLE, parameters[PARM_TABLE]); if(braille_init()) { logMessage(LOG_INFO, "Libbraille Version: %s", braille_info(BRL_VERSION)); #ifdef BRL_PATH logMessage(LOG_DEBUG, "Libbraille Installation Directory: %s", braille_info(BRL_PATH)); #endif /* BRL_PATH */ #ifdef BRL_PATHCONF logMessage(LOG_DEBUG, "Libbraille Configuration Directory: %s", braille_info(BRL_PATHCONF)); #endif /* BRL_PATHCONF */ #ifdef BRL_PATHTBL logMessage(LOG_DEBUG, "Libbraille Tables Directory: %s", braille_info(BRL_PATHTBL)); #endif /* BRL_PATHTBL */ #ifdef BRL_PATHDRV logMessage(LOG_DEBUG, "Libbraille Drivers Directory: %s", braille_info(BRL_PATHDRV)); #endif /* BRL_PATHDRV */ logMessage(LOG_INFO, "Libbraille Table: %s", braille_info(BRL_TABLE)); logMessage(LOG_INFO, "Libbraille Driver: %s", braille_info(BRL_DRIVER)); logMessage(LOG_INFO, "Libbraille Device: %s", braille_info(BRL_DEVICE)); logMessage(LOG_INFO, "Display Type: %s", braille_info(BRL_TERMINAL)); logMessage(LOG_INFO, "Display Size: %d", braille_size()); brl->textColumns = braille_size(); /* initialise size of display */ brl->textRows = 1; { static const DotsTable dots = { BRAILLE(1, 0, 0, 0, 0, 0, 0, 0), BRAILLE(0, 1, 0, 0, 0, 0, 0, 0), BRAILLE(0, 0, 1, 0, 0, 0, 0, 0), BRAILLE(0, 0, 0, 1, 0, 0, 0, 0), BRAILLE(0, 0, 0, 0, 1, 0, 0, 0), BRAILLE(0, 0, 0, 0, 0, 1, 0, 0), BRAILLE(0, 0, 0, 0, 0, 0, 1, 0), BRAILLE(0, 0, 0, 0, 0, 0, 0, 1) }; makeOutputTable(dots); makeInputTable(); } braille_timeout(100); return 1; } else { logMessage(LOG_DEBUG, "Libbraille initialization erorr: %s", braille_geterror()); } return 0; }