Use a char pointer for the poll command which is a string literal. Which
eliminates the "necessity" to strip the NUL terminator from an array
after its construction. The strlen() for literals also gets resolved at
compile time. Which means that execution cost remains identical.
Rename the variable to lower case, it's not a preprocessor symbol.
#define TC_POLL_PERIOD_MS 100
#define TC_TIMEOUT_MS 1000
#define TC_POLL_PERIOD_MS 100
#define TC_TIMEOUT_MS 1000
-static const char POLL_CMD[] = "getva";
+static const char *poll_cmd = "getva";
#define MAGIC_PAC1 0x31636170UL
#define MAGIC_PAC2 0x32636170UL
#define MAGIC_PAC1 0x31636170UL
#define MAGIC_PAC2 0x32636170UL
int len;
uint8_t poll_pkt[TC_POLL_LEN];
int len;
uint8_t poll_pkt[TC_POLL_LEN];
- if (serial_write_blocking(serial, &POLL_CMD, sizeof(POLL_CMD) - 1,
+ if (serial_write_blocking(serial, poll_cmd, strlen(poll_cmd),
SERIAL_WRITE_TIMEOUT_MS) < 0) {
sr_err("Unable to send probe request.");
return SR_ERR;
SERIAL_WRITE_TIMEOUT_MS) < 0) {
sr_err("Unable to send probe request.");
return SR_ERR;
struct dev_context *devc = sdi->priv;
struct sr_serial_dev_inst *serial = sdi->conn;
struct dev_context *devc = sdi->priv;
struct sr_serial_dev_inst *serial = sdi->conn;
- if (serial_write_blocking(serial, &POLL_CMD, sizeof(POLL_CMD) - 1,
+ if (serial_write_blocking(serial, poll_cmd, strlen(poll_cmd),
SERIAL_WRITE_TIMEOUT_MS) < 0) {
sr_err("Unable to send poll request.");
return SR_ERR;
SERIAL_WRITE_TIMEOUT_MS) < 0) {
sr_err("Unable to send poll request.");
return SR_ERR;