link-mso19: improve endianess conversion, avoid mem access alignment issue

Prefer sigrok's endianess conversion helper over the inet htons()
routine which is harder to read (is "network order" little or big?).

Writing the conversion results in units of bytes also avoids misaligned
memory access. The header length is odd, each payload item got written
as an uint16_t item to an odd address.
This commit is contained in:
Gerhard Sittig 2018-02-21 18:04:29 +01:00 committed by Uwe Hermann
parent f7711ed56c
commit 411b2f6822
1 changed files with 2 additions and 2 deletions

View File

@ -48,8 +48,8 @@ SR_PRIV int mso_send_control_message(struct sr_serial_dev_inst *serial,
p += sizeof(mso_head);
for (i = 0; i < n; i++) {
*(uint16_t *) p = g_htons(payload[i]);
p += 2;
WB16(p, payload[i]);
p += sizeof(uint16_t);
}
memcpy(p, mso_foot, sizeof(mso_foot));