mirror of git://git.sysmocom.de/ofono
gatchat: Fix marker handling within HDLC support
This commit is contained in:
parent
4dc66b9cb0
commit
e266a5e220
|
@ -89,15 +89,15 @@ static inline void hdlc_record(GAtHDLC *hdlc, gboolean in,
|
||||||
unsigned char id;
|
unsigned char id;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_at_util_debug_hexdump(in, data, length,
|
g_at_util_debug_hexdump(in, data, length,
|
||||||
hdlc->debugf, hdlc->debug_data);
|
hdlc->debugf, hdlc->debug_data);
|
||||||
|
|
||||||
if (hdlc->record_fd < 0)
|
if (hdlc->record_fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
ts = htonl(now.tv_sec & 0xffffffff);
|
ts = htonl(now.tv_sec & 0xffffffff);
|
||||||
|
|
||||||
|
@ -562,12 +562,19 @@ gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned char *data, gsize size)
|
||||||
|
|
||||||
if (hdlc->start_frame_marker == TRUE) {
|
if (hdlc->start_frame_marker == TRUE) {
|
||||||
/* Protocol requires 0x7e as start marker */
|
/* Protocol requires 0x7e as start marker */
|
||||||
|
if (pos + 1 > avail)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
*buf++ = HDLC_FLAG;
|
*buf++ = HDLC_FLAG;
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
|
if (pos == wrap)
|
||||||
|
buf = ring_buffer_write_ptr(write_buffer, pos);
|
||||||
} else if (hdlc->wakeup_sent == FALSE) {
|
} else if (hdlc->wakeup_sent == FALSE) {
|
||||||
/* Write an initial 0x7e as wakeup character */
|
/* Write an initial 0x7e as wakeup character */
|
||||||
*buf++ = HDLC_FLAG;
|
*buf++ = HDLC_FLAG;
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
hdlc->wakeup_sent = TRUE;
|
hdlc->wakeup_sent = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue