//****************************************************************************** /// \brief Get T5 message as byte array /// \param mxt Maxtouch Device /// \param buf Pointer to buffer /// \param buflen Length of buffer /// \param count length of message in bytes /// \return #mxt_rc int mxt_get_msg_bytes(struct mxt_device *mxt, unsigned char *buf, size_t buflen, int *count) { int ret; switch (mxt->conn->type) { case E_SYSFS: if (sysfs_has_debug_v2(mxt)) ret = sysfs_get_msg_bytes_v2(mxt, buf, buflen, count); else ret = dmesg_get_msg_bytes(mxt, buf, buflen, count); break; #ifdef HAVE_LIBUSB case E_USB: #endif /* HAVE_LIBUSB */ case E_I2C_DEV: case E_HIDRAW: ret = t44_get_msg_bytes(mxt, buf, buflen, count); break; default: mxt_err(mxt->ctx, "Device type not supported"); ret = MXT_ERROR_NOT_SUPPORTED; break; } if (ret == MXT_SUCCESS) mxt_log_buffer(mxt->ctx, LOG_DEBUG, MSG_PREFIX, buf, *count); return ret; }
//****************************************************************************** /// \brief Get next MSG as a string /// \return String or NULL for error char *t44_get_msg_string(struct mxt_device *mxt) { int ret, i; int size; size_t length; unsigned char databuf[20]; ret = t44_get_msg_bytes(mxt, &databuf[0], sizeof(databuf), &size); if (ret) return NULL; length = snprintf(msg_string, sizeof(msg_string), MSG_PREFIX); for (i = 0; i < size; i++) { length += snprintf(msg_string + length, sizeof(msg_string) - length, "%02X ", databuf[i]); } return &msg_string[0]; }
//****************************************************************************** /// \brief Discard all messages /// \return #mxt_rc int t44_msg_reset(struct mxt_device *mxt) { int count, i, ret, size; unsigned char databuf[20]; ret = t44_get_msg_count(mxt, &count); if (ret) { mxt_verb(mxt->ctx, "rc = %d", ret); return ret; } for (i = 0; i < count; i++) { ret = t44_get_msg_bytes(mxt, &databuf[0], sizeof(databuf), &size); if (ret) { mxt_verb(mxt->ctx, "rc = %d", ret); return ret; } } return MXT_SUCCESS; }