//****************************************************************************** /// \brief Get debug message as byte array /// \param mxt Maxtouch Device /// \param buf Pointer to buffer /// \param buflen Length of buffer /// \param count number of bytes read /// \return #mxt_rc int dmesg_get_msg_bytes(struct mxt_device *mxt, unsigned char *buf, size_t buflen, int *count) { unsigned int bufidx = 0; int offset; char *message; message = dmesg_get_msg_string(mxt); if (!message) return MXT_ERROR_NO_MESSAGE; /* Check message begins with prefix */ if (strncmp(MSG_PREFIX, message, strlen(MSG_PREFIX))) { *count = 0; return MXT_SUCCESS; } message += strlen(MSG_PREFIX); while (1 == sscanf(message, "%hhx%n", buf + bufidx, &offset)) { message += offset; bufidx++; if (bufidx >= buflen) break; } *count = bufidx; return MXT_SUCCESS; }
//****************************************************************************** /// \brief Get T5 message as string /// \return Message string (null for no message) char *mxt_get_msg_string(struct mxt_device *mxt) { char *msg_string = NULL; switch (mxt->conn->type) { case E_SYSFS: if (sysfs_has_debug_v2(mxt)) msg_string = sysfs_get_msg_string_v2(mxt); else msg_string = dmesg_get_msg_string(mxt); break; #ifdef HAVE_LIBUSB case E_USB: #endif /* HAVE_LIBUSB */ case E_I2C_DEV: case E_HIDRAW: msg_string = t44_get_msg_string(mxt); break; default: mxt_err(mxt->ctx, "Device type not supported"); break; } if (msg_string) mxt_dbg(mxt->ctx, "%s", msg_string); return msg_string; }