Commit 88f97efd authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Ignore `get bit 31`, used as event_char for FTDI USB/serial adaptors

parent fab36bc5
...@@ -91,7 +91,7 @@ struct moberg_status serial2002_read(int f, long timeout, ...@@ -91,7 +91,7 @@ struct moberg_status serial2002_read(int f, long timeout,
value->index = 0; value->index = 0;
value->value = 0; value->value = 0;
length = 0; length = 0;
while (1) { while (value->kind == is_invalid) {
unsigned char data; unsigned char data;
struct moberg_status result = tty_read(f, timeout, &data); struct moberg_status result = tty_read(f, timeout, &data);
if (! OK(result)) { if (! OK(result)) {
...@@ -106,6 +106,7 @@ struct moberg_status serial2002_read(int f, long timeout, ...@@ -106,6 +106,7 @@ struct moberg_status serial2002_read(int f, long timeout,
return MOBERG_ERRNO(EFBIG); return MOBERG_ERRNO(EFBIG);
break; break;
} else { } else {
value->index = data & 0x1f;
if (length == 1) { if (length == 1) {
switch ((data >> 5) & 0x03) { switch ((data >> 5) & 0x03) {
case 0:{ case 0:{
...@@ -116,13 +117,25 @@ struct moberg_status serial2002_read(int f, long timeout, ...@@ -116,13 +117,25 @@ struct moberg_status serial2002_read(int f, long timeout,
value->value = 1; value->value = 1;
value->kind = is_digital; value->kind = is_digital;
} break; } break;
case 2:{
if (data == 0x5f) {
/* Ignore FTDI USB/serial event character (get bit 31) */
value->kind = is_invalid;
value->index = 0;
value->value = 0;
length = 0;
} else {
return MOBERG_ERRNO(EINVAL);
}
} break;
case 3:{
return MOBERG_ERRNO(EINVAL);
} break;
} }
} else { } else {
value->value = (value->value << 2) | ((data & 0x60) >> 5); value->value = (value->value << 2) | ((data & 0x60) >> 5);
value->kind = is_channel; value->kind = is_channel;
} }
value->index = data & 0x1f;
break;
} }
} }
return MOBERG_OK; return MOBERG_OK;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment