/* Given a Topfield protocol packet, this function will calculate the required * CRC and send the packet out over a bulk pipe. */ ssize_t send_tf_packet(int fd, struct tf_packet *packet) { unsigned int pl = get_u16(&packet->length); ssize_t byte_count = (pl + 1) & ~1; trace(3, fprintf(stderr, "%s\n", __func__)); put_u16(&packet->crc, get_crc(packet)); print_packet(packet, "OUT>"); swap_out_packet(packet); return usb_bulk_write(fd, 0x01, (__u8 *) packet, byte_count, TF_PROTOCOL_TIMEOUT); }
/* Given a Topfield protocol packet, this function will calculate the required * CRC and send the packet out over a bulk pipe. */ int send_tf_packet(libusb_device_handle* fd, struct tf_packet *packet) { unsigned int pl = get_u16(&packet->length); size_t byte_count = (pl + 1) & ~1; put_u16(&packet->crc, get_crc(packet)); if (verbose>2) print_packet(packet, "OUT>"); swap_out_packet(packet); if (fd==0) return -1; return usb_bulk_write(fd, 0x01, (__u8 *) packet, byte_count, default_timeout()); }