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)); if (connectResource(brl, device)) { unsigned char response[MAXIMUM_RESPONSE_SIZE]; if (probeBrailleDisplay(brl, PROBE_RETRY_LIMIT, NULL, PROBE_INPUT_TIMEOUT, writeIdentityRequest, readPacket, &response, sizeof(response), isIdentityResponse)) { setBrailleKeyTable(brl, &KEY_TABLE_DEFINITION(all)); MAKE_OUTPUT_TABLE(0X01, 0X04, 0X10, 0X02, 0X08, 0X20, 0X40, 0X80); brl->textColumns = MAXIMUM_CELL_COUNT; brl->data->forceRewrite = 1; return 1; } disconnectBrailleResource(brl, NULL); } free(brl->data); } else { logMallocError(); } return 0; }
static int getCellCount (BrailleDisplay *brl, unsigned int *count) { InputPacket response; if (probeBrailleDisplay(brl, 2, NULL, 1000, writeCellCountRequest, readBytes, &response, sizeof(response.bytes), isCellCountResponse)) { *count = response.data.data; return 1; } return brl->data->protocol->getDefaultCellCount(brl, count); }
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; }