int eloWaitAck(int fd) { unsigned char packet[ELO_PACKET_SIZE]; int i, nb_errors; if (eloWaitReply(ELO_ACK, packet, fd)) { for (i = 0, nb_errors = 0; i < 4; i++) { if (packet[2 + i] != '0') { nb_errors++; } } if (nb_errors != 0) { #ifdef DEBUG_MOUSE fprintf(stderr, "Elographics acknowledge packet reports %d errors\n", nb_errors); #endif } return 1; } else { return 0; } }
/* eloSendQuery -- */ int eloSendQuery(unsigned char *request, unsigned char* reply, int fd) { int ok; if (eloSendPacket(request, fd)) { ok = eloWaitReply(toupper(request[1]), reply, fd); if (ok) { ok = eloWaitAck(fd); } return ok; } else { return 0; } }