forked from Imagelibrary/rtems
Converted from using a message queue for the raw input queue to using a
ring buffer in conjunction with a counting semaphore.
This commit is contained in:
@@ -23,18 +23,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <ringbuf.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The size of the cooked buffer
|
* The size of the cooked buffer
|
||||||
*/
|
*/
|
||||||
#define CBUFSIZE 256
|
#define CBUFSIZE 256
|
||||||
|
|
||||||
/*
|
|
||||||
* The size of the raw input message queue
|
|
||||||
*/
|
|
||||||
#define RAW_MESSAGE_QUEUE_COUNT 10
|
|
||||||
#define RAW_MESSAGE_QUEUE_SIZE 16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables associated with each termios instance.
|
* Variables associated with each termios instance.
|
||||||
* One structure for each hardware I/O device.
|
* One structure for each hardware I/O device.
|
||||||
@@ -85,10 +80,9 @@ struct rtems_termios_tty {
|
|||||||
/*
|
/*
|
||||||
* Raw character buffer
|
* Raw character buffer
|
||||||
*/
|
*/
|
||||||
rtems_id rawInputQueue;
|
rtems_id rawInputSem;
|
||||||
char rawBuf[RAW_MESSAGE_QUEUE_SIZE];
|
Ring_buffer_t rawInputBuffer;
|
||||||
int rawBufCount;
|
|
||||||
int rawBufIndex;
|
|
||||||
rtems_unsigned32 rawMessageOptions;
|
rtems_unsigned32 rawMessageOptions;
|
||||||
rtems_interval rawMessageTimeout;
|
rtems_interval rawMessageTimeout;
|
||||||
rtems_interval rawMessageFirstTimeout;
|
rtems_interval rawMessageFirstTimeout;
|
||||||
@@ -97,7 +91,7 @@ struct rtems_termios_tty {
|
|||||||
* Callbacks to device-specific routines
|
* Callbacks to device-specific routines
|
||||||
*/
|
*/
|
||||||
int (*lastClose)(int major, int minor, void *arg);
|
int (*lastClose)(int major, int minor, void *arg);
|
||||||
int (*read)(int minor, char *buf /*, int len */);
|
int (*read)(int minor, char *buf );
|
||||||
int (*write)(int minor, char *buf, int len);
|
int (*write)(int minor, char *buf, int len);
|
||||||
};
|
};
|
||||||
static struct rtems_termios_tty *ttyHead, *ttyTail;
|
static struct rtems_termios_tty *ttyHead, *ttyTail;
|
||||||
@@ -194,15 +188,14 @@ rtems_termios_open (
|
|||||||
tty->write = deviceWrite;
|
tty->write = deviceWrite;
|
||||||
tty->lastClose = deviceLastClose;
|
tty->lastClose = deviceLastClose;
|
||||||
if ((tty->read = deviceRead) == NULL) {
|
if ((tty->read = deviceRead) == NULL) {
|
||||||
sc = rtems_message_queue_create (
|
sc = rtems_semaphore_create (
|
||||||
rtems_build_name ('T', 'R', 'i', c),
|
rtems_build_name ('T', 'R', 'r', c),
|
||||||
RAW_MESSAGE_QUEUE_COUNT,
|
0,
|
||||||
RAW_MESSAGE_QUEUE_SIZE,
|
RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO | RTEMS_LOCAL,
|
||||||
RTEMS_FIFO | RTEMS_LOCAL,
|
RTEMS_NO_PRIORITY,
|
||||||
&tty->rawInputQueue);
|
&tty->rawInputSem);
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
rtems_fatal_error_occurred (sc);
|
rtems_fatal_error_occurred (sc);
|
||||||
tty->rawBufCount = tty->rawBufIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -275,7 +268,7 @@ rtems_termios_close (void *arg)
|
|||||||
rtems_semaphore_delete (tty->isem);
|
rtems_semaphore_delete (tty->isem);
|
||||||
rtems_semaphore_delete (tty->osem);
|
rtems_semaphore_delete (tty->osem);
|
||||||
if (tty->read == NULL)
|
if (tty->read == NULL)
|
||||||
rtems_message_queue_delete (tty->rawInputQueue);
|
rtems_semaphore_delete (tty->rawInputSem);
|
||||||
free (tty);
|
free (tty);
|
||||||
}
|
}
|
||||||
rtems_semaphore_release (ttyMutex);
|
rtems_semaphore_release (ttyMutex);
|
||||||
@@ -668,14 +661,23 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
|||||||
{
|
{
|
||||||
rtems_interval timeout = tty->rawMessageFirstTimeout;
|
rtems_interval timeout = tty->rawMessageFirstTimeout;
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_unsigned32 msgSize;
|
rtems_unsigned8 c;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read characters from raw queue
|
||||||
|
*/
|
||||||
|
sc = rtems_semaphore_obtain (tty->rawInputSem,
|
||||||
|
tty->rawMessageOptions,
|
||||||
|
timeout);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
break;
|
||||||
|
Ring_buffer_Remove_character( &tty->rawInputBuffer, c );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process characters read from raw queue
|
* Process characters read from raw queue
|
||||||
*/
|
*/
|
||||||
while (tty->rawBufIndex < tty->rawBufCount) {
|
|
||||||
unsigned char c = tty->rawBuf[tty->rawBufIndex++];
|
|
||||||
if (tty->termios.c_lflag & ICANON) {
|
if (tty->termios.c_lflag & ICANON) {
|
||||||
if (siproc (c, tty))
|
if (siproc (c, tty))
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
@@ -685,21 +687,7 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
|||||||
if (tty->ccount >= tty->termios.c_cc[VMIN])
|
if (tty->ccount >= tty->termios.c_cc[VMIN])
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read characters from raw queue
|
|
||||||
*/
|
|
||||||
msgSize = RAW_MESSAGE_QUEUE_SIZE;
|
|
||||||
sc = rtems_message_queue_receive (tty->rawInputQueue,
|
|
||||||
tty->rawBuf,
|
|
||||||
&msgSize,
|
|
||||||
tty->rawMessageOptions,
|
|
||||||
timeout);
|
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
|
||||||
break;
|
|
||||||
tty->rawBufIndex = 0;
|
|
||||||
tty->rawBufCount = msgSize;
|
|
||||||
timeout = tty->rawMessageTimeout;
|
timeout = tty->rawMessageTimeout;
|
||||||
}
|
}
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
@@ -744,17 +732,15 @@ void
|
|||||||
rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len)
|
rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len)
|
||||||
{
|
{
|
||||||
struct rtems_termios_tty *tty = ttyp;
|
struct rtems_termios_tty *tty = ttyp;
|
||||||
int ncopy;
|
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
if (len < RAW_MESSAGE_QUEUE_SIZE)
|
if (Ring_buffer_Is_full(&tty->rawInputBuffer))
|
||||||
ncopy = len;
|
|
||||||
else
|
|
||||||
ncopy = RAW_MESSAGE_QUEUE_SIZE;
|
|
||||||
if (rtems_message_queue_send (tty->rawInputQueue, buf, ncopy) != RTEMS_SUCCESSFUL)
|
|
||||||
break;
|
break;
|
||||||
len -= ncopy;
|
Ring_buffer_Add_character(&tty->rawInputBuffer, *buf);
|
||||||
buf += ncopy;
|
if (rtems_semaphore_release(tty->rawInputSem) != RTEMS_SUCCESSFUL)
|
||||||
|
break;
|
||||||
|
len -= 1;
|
||||||
|
buf += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <ringbuf.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The size of the cooked buffer
|
* The size of the cooked buffer
|
||||||
*/
|
*/
|
||||||
#define CBUFSIZE 256
|
#define CBUFSIZE 256
|
||||||
|
|
||||||
/*
|
|
||||||
* The size of the raw input message queue
|
|
||||||
*/
|
|
||||||
#define RAW_MESSAGE_QUEUE_COUNT 10
|
|
||||||
#define RAW_MESSAGE_QUEUE_SIZE 16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables associated with each termios instance.
|
* Variables associated with each termios instance.
|
||||||
* One structure for each hardware I/O device.
|
* One structure for each hardware I/O device.
|
||||||
@@ -85,10 +80,9 @@ struct rtems_termios_tty {
|
|||||||
/*
|
/*
|
||||||
* Raw character buffer
|
* Raw character buffer
|
||||||
*/
|
*/
|
||||||
rtems_id rawInputQueue;
|
rtems_id rawInputSem;
|
||||||
char rawBuf[RAW_MESSAGE_QUEUE_SIZE];
|
Ring_buffer_t rawInputBuffer;
|
||||||
int rawBufCount;
|
|
||||||
int rawBufIndex;
|
|
||||||
rtems_unsigned32 rawMessageOptions;
|
rtems_unsigned32 rawMessageOptions;
|
||||||
rtems_interval rawMessageTimeout;
|
rtems_interval rawMessageTimeout;
|
||||||
rtems_interval rawMessageFirstTimeout;
|
rtems_interval rawMessageFirstTimeout;
|
||||||
@@ -97,7 +91,7 @@ struct rtems_termios_tty {
|
|||||||
* Callbacks to device-specific routines
|
* Callbacks to device-specific routines
|
||||||
*/
|
*/
|
||||||
int (*lastClose)(int major, int minor, void *arg);
|
int (*lastClose)(int major, int minor, void *arg);
|
||||||
int (*read)(int minor, char *buf /*, int len */);
|
int (*read)(int minor, char *buf );
|
||||||
int (*write)(int minor, char *buf, int len);
|
int (*write)(int minor, char *buf, int len);
|
||||||
};
|
};
|
||||||
static struct rtems_termios_tty *ttyHead, *ttyTail;
|
static struct rtems_termios_tty *ttyHead, *ttyTail;
|
||||||
@@ -194,15 +188,14 @@ rtems_termios_open (
|
|||||||
tty->write = deviceWrite;
|
tty->write = deviceWrite;
|
||||||
tty->lastClose = deviceLastClose;
|
tty->lastClose = deviceLastClose;
|
||||||
if ((tty->read = deviceRead) == NULL) {
|
if ((tty->read = deviceRead) == NULL) {
|
||||||
sc = rtems_message_queue_create (
|
sc = rtems_semaphore_create (
|
||||||
rtems_build_name ('T', 'R', 'i', c),
|
rtems_build_name ('T', 'R', 'r', c),
|
||||||
RAW_MESSAGE_QUEUE_COUNT,
|
0,
|
||||||
RAW_MESSAGE_QUEUE_SIZE,
|
RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO | RTEMS_LOCAL,
|
||||||
RTEMS_FIFO | RTEMS_LOCAL,
|
RTEMS_NO_PRIORITY,
|
||||||
&tty->rawInputQueue);
|
&tty->rawInputSem);
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
rtems_fatal_error_occurred (sc);
|
rtems_fatal_error_occurred (sc);
|
||||||
tty->rawBufCount = tty->rawBufIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -275,7 +268,7 @@ rtems_termios_close (void *arg)
|
|||||||
rtems_semaphore_delete (tty->isem);
|
rtems_semaphore_delete (tty->isem);
|
||||||
rtems_semaphore_delete (tty->osem);
|
rtems_semaphore_delete (tty->osem);
|
||||||
if (tty->read == NULL)
|
if (tty->read == NULL)
|
||||||
rtems_message_queue_delete (tty->rawInputQueue);
|
rtems_semaphore_delete (tty->rawInputSem);
|
||||||
free (tty);
|
free (tty);
|
||||||
}
|
}
|
||||||
rtems_semaphore_release (ttyMutex);
|
rtems_semaphore_release (ttyMutex);
|
||||||
@@ -668,14 +661,23 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
|||||||
{
|
{
|
||||||
rtems_interval timeout = tty->rawMessageFirstTimeout;
|
rtems_interval timeout = tty->rawMessageFirstTimeout;
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_unsigned32 msgSize;
|
rtems_unsigned8 c;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read characters from raw queue
|
||||||
|
*/
|
||||||
|
sc = rtems_semaphore_obtain (tty->rawInputSem,
|
||||||
|
tty->rawMessageOptions,
|
||||||
|
timeout);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
break;
|
||||||
|
Ring_buffer_Remove_character( &tty->rawInputBuffer, c );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process characters read from raw queue
|
* Process characters read from raw queue
|
||||||
*/
|
*/
|
||||||
while (tty->rawBufIndex < tty->rawBufCount) {
|
|
||||||
unsigned char c = tty->rawBuf[tty->rawBufIndex++];
|
|
||||||
if (tty->termios.c_lflag & ICANON) {
|
if (tty->termios.c_lflag & ICANON) {
|
||||||
if (siproc (c, tty))
|
if (siproc (c, tty))
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
@@ -685,21 +687,7 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
|||||||
if (tty->ccount >= tty->termios.c_cc[VMIN])
|
if (tty->ccount >= tty->termios.c_cc[VMIN])
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read characters from raw queue
|
|
||||||
*/
|
|
||||||
msgSize = RAW_MESSAGE_QUEUE_SIZE;
|
|
||||||
sc = rtems_message_queue_receive (tty->rawInputQueue,
|
|
||||||
tty->rawBuf,
|
|
||||||
&msgSize,
|
|
||||||
tty->rawMessageOptions,
|
|
||||||
timeout);
|
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
|
||||||
break;
|
|
||||||
tty->rawBufIndex = 0;
|
|
||||||
tty->rawBufCount = msgSize;
|
|
||||||
timeout = tty->rawMessageTimeout;
|
timeout = tty->rawMessageTimeout;
|
||||||
}
|
}
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
@@ -744,17 +732,15 @@ void
|
|||||||
rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len)
|
rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len)
|
||||||
{
|
{
|
||||||
struct rtems_termios_tty *tty = ttyp;
|
struct rtems_termios_tty *tty = ttyp;
|
||||||
int ncopy;
|
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
if (len < RAW_MESSAGE_QUEUE_SIZE)
|
if (Ring_buffer_Is_full(&tty->rawInputBuffer))
|
||||||
ncopy = len;
|
|
||||||
else
|
|
||||||
ncopy = RAW_MESSAGE_QUEUE_SIZE;
|
|
||||||
if (rtems_message_queue_send (tty->rawInputQueue, buf, ncopy) != RTEMS_SUCCESSFUL)
|
|
||||||
break;
|
break;
|
||||||
len -= ncopy;
|
Ring_buffer_Add_character(&tty->rawInputBuffer, *buf);
|
||||||
buf += ncopy;
|
if (rtems_semaphore_release(tty->rawInputSem) != RTEMS_SUCCESSFUL)
|
||||||
|
break;
|
||||||
|
len -= 1;
|
||||||
|
buf += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <ringbuf.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The size of the cooked buffer
|
* The size of the cooked buffer
|
||||||
*/
|
*/
|
||||||
#define CBUFSIZE 256
|
#define CBUFSIZE 256
|
||||||
|
|
||||||
/*
|
|
||||||
* The size of the raw input message queue
|
|
||||||
*/
|
|
||||||
#define RAW_MESSAGE_QUEUE_COUNT 10
|
|
||||||
#define RAW_MESSAGE_QUEUE_SIZE 16
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables associated with each termios instance.
|
* Variables associated with each termios instance.
|
||||||
* One structure for each hardware I/O device.
|
* One structure for each hardware I/O device.
|
||||||
@@ -85,10 +80,9 @@ struct rtems_termios_tty {
|
|||||||
/*
|
/*
|
||||||
* Raw character buffer
|
* Raw character buffer
|
||||||
*/
|
*/
|
||||||
rtems_id rawInputQueue;
|
rtems_id rawInputSem;
|
||||||
char rawBuf[RAW_MESSAGE_QUEUE_SIZE];
|
Ring_buffer_t rawInputBuffer;
|
||||||
int rawBufCount;
|
|
||||||
int rawBufIndex;
|
|
||||||
rtems_unsigned32 rawMessageOptions;
|
rtems_unsigned32 rawMessageOptions;
|
||||||
rtems_interval rawMessageTimeout;
|
rtems_interval rawMessageTimeout;
|
||||||
rtems_interval rawMessageFirstTimeout;
|
rtems_interval rawMessageFirstTimeout;
|
||||||
@@ -97,7 +91,7 @@ struct rtems_termios_tty {
|
|||||||
* Callbacks to device-specific routines
|
* Callbacks to device-specific routines
|
||||||
*/
|
*/
|
||||||
int (*lastClose)(int major, int minor, void *arg);
|
int (*lastClose)(int major, int minor, void *arg);
|
||||||
int (*read)(int minor, char *buf /*, int len */);
|
int (*read)(int minor, char *buf );
|
||||||
int (*write)(int minor, char *buf, int len);
|
int (*write)(int minor, char *buf, int len);
|
||||||
};
|
};
|
||||||
static struct rtems_termios_tty *ttyHead, *ttyTail;
|
static struct rtems_termios_tty *ttyHead, *ttyTail;
|
||||||
@@ -194,15 +188,14 @@ rtems_termios_open (
|
|||||||
tty->write = deviceWrite;
|
tty->write = deviceWrite;
|
||||||
tty->lastClose = deviceLastClose;
|
tty->lastClose = deviceLastClose;
|
||||||
if ((tty->read = deviceRead) == NULL) {
|
if ((tty->read = deviceRead) == NULL) {
|
||||||
sc = rtems_message_queue_create (
|
sc = rtems_semaphore_create (
|
||||||
rtems_build_name ('T', 'R', 'i', c),
|
rtems_build_name ('T', 'R', 'r', c),
|
||||||
RAW_MESSAGE_QUEUE_COUNT,
|
0,
|
||||||
RAW_MESSAGE_QUEUE_SIZE,
|
RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO | RTEMS_LOCAL,
|
||||||
RTEMS_FIFO | RTEMS_LOCAL,
|
RTEMS_NO_PRIORITY,
|
||||||
&tty->rawInputQueue);
|
&tty->rawInputSem);
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
rtems_fatal_error_occurred (sc);
|
rtems_fatal_error_occurred (sc);
|
||||||
tty->rawBufCount = tty->rawBufIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -275,7 +268,7 @@ rtems_termios_close (void *arg)
|
|||||||
rtems_semaphore_delete (tty->isem);
|
rtems_semaphore_delete (tty->isem);
|
||||||
rtems_semaphore_delete (tty->osem);
|
rtems_semaphore_delete (tty->osem);
|
||||||
if (tty->read == NULL)
|
if (tty->read == NULL)
|
||||||
rtems_message_queue_delete (tty->rawInputQueue);
|
rtems_semaphore_delete (tty->rawInputSem);
|
||||||
free (tty);
|
free (tty);
|
||||||
}
|
}
|
||||||
rtems_semaphore_release (ttyMutex);
|
rtems_semaphore_release (ttyMutex);
|
||||||
@@ -668,14 +661,23 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
|||||||
{
|
{
|
||||||
rtems_interval timeout = tty->rawMessageFirstTimeout;
|
rtems_interval timeout = tty->rawMessageFirstTimeout;
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_unsigned32 msgSize;
|
rtems_unsigned8 c;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read characters from raw queue
|
||||||
|
*/
|
||||||
|
sc = rtems_semaphore_obtain (tty->rawInputSem,
|
||||||
|
tty->rawMessageOptions,
|
||||||
|
timeout);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
break;
|
||||||
|
Ring_buffer_Remove_character( &tty->rawInputBuffer, c );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process characters read from raw queue
|
* Process characters read from raw queue
|
||||||
*/
|
*/
|
||||||
while (tty->rawBufIndex < tty->rawBufCount) {
|
|
||||||
unsigned char c = tty->rawBuf[tty->rawBufIndex++];
|
|
||||||
if (tty->termios.c_lflag & ICANON) {
|
if (tty->termios.c_lflag & ICANON) {
|
||||||
if (siproc (c, tty))
|
if (siproc (c, tty))
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
@@ -685,21 +687,7 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
|||||||
if (tty->ccount >= tty->termios.c_cc[VMIN])
|
if (tty->ccount >= tty->termios.c_cc[VMIN])
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read characters from raw queue
|
|
||||||
*/
|
|
||||||
msgSize = RAW_MESSAGE_QUEUE_SIZE;
|
|
||||||
sc = rtems_message_queue_receive (tty->rawInputQueue,
|
|
||||||
tty->rawBuf,
|
|
||||||
&msgSize,
|
|
||||||
tty->rawMessageOptions,
|
|
||||||
timeout);
|
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
|
||||||
break;
|
|
||||||
tty->rawBufIndex = 0;
|
|
||||||
tty->rawBufCount = msgSize;
|
|
||||||
timeout = tty->rawMessageTimeout;
|
timeout = tty->rawMessageTimeout;
|
||||||
}
|
}
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
@@ -744,17 +732,15 @@ void
|
|||||||
rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len)
|
rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len)
|
||||||
{
|
{
|
||||||
struct rtems_termios_tty *tty = ttyp;
|
struct rtems_termios_tty *tty = ttyp;
|
||||||
int ncopy;
|
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
if (len < RAW_MESSAGE_QUEUE_SIZE)
|
if (Ring_buffer_Is_full(&tty->rawInputBuffer))
|
||||||
ncopy = len;
|
|
||||||
else
|
|
||||||
ncopy = RAW_MESSAGE_QUEUE_SIZE;
|
|
||||||
if (rtems_message_queue_send (tty->rawInputQueue, buf, ncopy) != RTEMS_SUCCESSFUL)
|
|
||||||
break;
|
break;
|
||||||
len -= ncopy;
|
Ring_buffer_Add_character(&tty->rawInputBuffer, *buf);
|
||||||
buf += ncopy;
|
if (rtems_semaphore_release(tty->rawInputSem) != RTEMS_SUCCESSFUL)
|
||||||
|
break;
|
||||||
|
len -= 1;
|
||||||
|
buf += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user