static void spk_write (const unsigned char *address, unsigned int count) { serialWriteData(CB_serialDevice, address, count); spk_written += count; }
static void spk_mute (SpeechSynthesizer *spk) { unsigned char *mute_seq = (unsigned char *)MUTE_SEQ; serialWriteData (MB_serialDevice, mute_seq+1, mute_seq[0]); }
static int writeSerialBytes (const unsigned char *buffer, int length, unsigned int *delay) { int count = serialWriteData(serialDevice, buffer, length); if (delay && (count != -1)) *delay += (length * 1000 / charactersPerSecond) + 1; return count; }
static int writeSerialBytes (const unsigned char *buffer, int length) { return serialWriteData(serialDevice, buffer, length); }
static int writeSerialBytes (const unsigned char *buffer, size_t size) { return serialWriteData(serialDevice, buffer, size); }
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; 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; hasTimedOut (0); /* 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 (!hasTimedOut (ACK_TIMEOUT) && 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; }