You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/12/20 10:02:00 UTC
[nuttx] branch master updated (4fa163ade7 -> 2dbfd8e798)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 4fa163ade7 s32k3xx:EDMA fix git count
new eb102a668f sim/uart: check if txbuffer is not full before uart write
new 2dbfd8e798 sim_uart: fix printf error when use irq mode
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/sim/src/sim/posix/sim_hostuart.c | 17 +++++++-
arch/sim/src/sim/sim_internal.h | 3 +-
arch/sim/src/sim/sim_uart.c | 79 +++++++++++++++++++++--------------
arch/sim/src/sim/win/sim_hostuart.c | 13 +++++-
4 files changed, 75 insertions(+), 37 deletions(-)
[nuttx] 02/02: sim_uart: fix printf error when use irq mode
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2dbfd8e79857ed0f01faeb211aee95d78ae6a1dc
Author: ligd <li...@xiaomi.com>
AuthorDate: Fri Dec 16 23:36:00 2022 +0800
sim_uart: fix printf error when use irq mode
Signed-off-by: ligd <li...@xiaomi.com>
---
arch/sim/src/sim/sim_uart.c | 62 ++++++++++++++++++++++++++++++---------------
1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/arch/sim/src/sim/sim_uart.c b/arch/sim/src/sim/sim_uart.c
index 12554cc9da..3965b45a2a 100644
--- a/arch/sim/src/sim/sim_uart.c
+++ b/arch/sim/src/sim/sim_uart.c
@@ -41,10 +41,16 @@
#endif
#define TTY_RECVSEND(port) \
- if (g_tty##port##_priv.fd > 0) \
+ if (g_##port##_priv.fd >= 0) \
{ \
- uart_recvchars(&g_tty##port##_dev); \
- uart_xmitchars(&g_tty##port##_dev); \
+ if (g_##port##_priv.rxint) \
+ { \
+ uart_recvchars(&g_##port##_dev); \
+ } \
+ if (g_##port##_priv.txint) \
+ { \
+ uart_xmitchars(&g_##port##_dev); \
+ } \
} \
/****************************************************************************
@@ -59,7 +65,15 @@ struct tty_priv_s
/* The file descriptor. It is returned by open */
- int fd;
+ int fd;
+
+ /* TX interrupt enable or not */
+
+ bool txint;
+
+ /* RX interrupt enable or not */
+
+ bool rxint;
};
/****************************************************************************
@@ -130,10 +144,17 @@ static char g_tty3_txbuf[CONFIG_SIM_UART_BUFFER_SIZE];
#endif
#ifdef USE_DEVCONSOLE
+static struct tty_priv_s g_console_priv =
+{
+ .path = "console",
+ .fd = 0,
+};
+
static struct uart_dev_s g_console_dev =
{
.isconsole = true,
.ops = &g_tty_ops,
+ .priv = &g_console_priv,
.xmit =
{
.size = CONFIG_SIM_UART_BUFFER_SIZE,
@@ -344,12 +365,10 @@ static int tty_ioctl(struct file *filep, int cmd, unsigned long arg)
switch (cmd)
{
case TCGETS:
- return host_uart_getcflag(dev->isconsole ? 0 : priv->fd,
- &termiosp->c_cflag);
+ return host_uart_getcflag(priv->fd, &termiosp->c_cflag);
case TCSETS:
- return host_uart_setcflag(dev->isconsole ? 0 : priv->fd,
- termiosp->c_cflag);
+ return host_uart_setcflag(priv->fd, termiosp->c_cflag);
}
#endif
@@ -371,7 +390,7 @@ static int tty_receive(struct uart_dev_s *dev, uint32_t *status)
struct tty_priv_s *priv = dev->priv;
*status = 0;
- return host_uart_getc(dev->isconsole ? 0 : priv->fd);
+ return host_uart_getc(priv->fd);
}
/****************************************************************************
@@ -384,6 +403,9 @@ static int tty_receive(struct uart_dev_s *dev, uint32_t *status)
static void tty_rxint(struct uart_dev_s *dev, bool enable)
{
+ struct tty_priv_s *priv = dev->priv;
+
+ priv->rxint = enable;
}
/****************************************************************************
@@ -398,7 +420,7 @@ static bool tty_rxavailable(struct uart_dev_s *dev)
{
struct tty_priv_s *priv = dev->priv;
- return host_uart_checkin(dev->isconsole ? 0 : priv->fd);
+ return host_uart_checkin(priv->fd);
}
/****************************************************************************
@@ -448,10 +470,9 @@ static void tty_send(struct uart_dev_s *dev, int ch)
static void tty_txint(struct uart_dev_s *dev, bool enable)
{
- if (enable)
- {
- uart_xmitchars(dev);
- }
+ struct tty_priv_s *priv = dev->priv;
+
+ priv->txint = enable;
}
/****************************************************************************
@@ -466,7 +487,7 @@ static bool tty_txready(struct uart_dev_s *dev)
{
struct tty_priv_s *priv = dev->priv;
- return host_uart_checkout(dev->isconsole ? 0 : priv->fd);
+ return host_uart_checkout(dev->isconsole ? 1 : priv->fd);
}
/****************************************************************************
@@ -527,24 +548,23 @@ void sim_uartinit(void)
void sim_uartloop(void)
{
#ifdef USE_DEVCONSOLE
- uart_recvchars(&g_console_dev);
- uart_xmitchars(&g_console_dev);
+ TTY_RECVSEND(console)
#endif
#ifdef CONFIG_SIM_UART0_NAME
- TTY_RECVSEND(0)
+ TTY_RECVSEND(tty0)
#endif
#ifdef CONFIG_SIM_UART1_NAME
- TTY_RECVSEND(1)
+ TTY_RECVSEND(tty1)
#endif
#ifdef CONFIG_SIM_UART2_NAME
- TTY_RECVSEND(2)
+ TTY_RECVSEND(tty2)
#endif
#ifdef CONFIG_SIM_UART3_NAME
- TTY_RECVSEND(3)
+ TTY_RECVSEND(tty3)
#endif
}
[nuttx] 01/02: sim/uart: check if txbuffer is not full before uart write
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit eb102a668f50f043e72bc11ebbd610c7cb62984e
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Fri Dec 9 22:10:39 2022 +0800
sim/uart: check if txbuffer is not full before uart write
Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
Signed-off-by: ligd <li...@xiaomi.com>
---
arch/sim/src/sim/posix/sim_hostuart.c | 17 +++++++++++++--
arch/sim/src/sim/sim_internal.h | 3 ++-
arch/sim/src/sim/sim_uart.c | 39 +++++++++++++++--------------------
arch/sim/src/sim/win/sim_hostuart.c | 13 ++++++++++--
4 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/arch/sim/src/sim/posix/sim_hostuart.c b/arch/sim/src/sim/posix/sim_hostuart.c
index 683b8bd9a9..b464301f75 100644
--- a/arch/sim/src/sim/posix/sim_hostuart.c
+++ b/arch/sim/src/sim/posix/sim_hostuart.c
@@ -199,10 +199,10 @@ int host_uart_setcflag(int fd, unsigned int cflag)
}
/****************************************************************************
- * Name: host_uart_checkc
+ * Name: host_uart_checkin
****************************************************************************/
-bool host_uart_checkc(int fd)
+bool host_uart_checkin(int fd)
{
struct pollfd pfd;
@@ -210,3 +210,16 @@ bool host_uart_checkc(int fd)
pfd.events = POLLIN;
return poll(&pfd, 1, 0) == 1;
}
+
+/****************************************************************************
+ * Name: host_uart_checkout
+ ****************************************************************************/
+
+bool host_uart_checkout(int fd)
+{
+ struct pollfd pfd;
+
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
+ return poll(&pfd, 1, 0) == 1;
+}
diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h
index 455488ebb1..2dc5267f3b 100644
--- a/arch/sim/src/sim/sim_internal.h
+++ b/arch/sim/src/sim/sim_internal.h
@@ -195,7 +195,8 @@ int host_uart_open(const char *pathname);
void host_uart_close(int fd);
int host_uart_putc(int fd, int ch);
int host_uart_getc(int fd);
-bool host_uart_checkc(int fd);
+bool host_uart_checkin(int fd);
+bool host_uart_checkout(int fd);
int host_uart_setcflag(int fd, unsigned int cflag);
int host_uart_getcflag(int fd, unsigned int *cflag);
diff --git a/arch/sim/src/sim/sim_uart.c b/arch/sim/src/sim/sim_uart.c
index 6a2086538e..12554cc9da 100644
--- a/arch/sim/src/sim/sim_uart.c
+++ b/arch/sim/src/sim/sim_uart.c
@@ -40,6 +40,13 @@
#define CONFIG_SIM_UART_BUFFER_SIZE 256
#endif
+#define TTY_RECVSEND(port) \
+ if (g_tty##port##_priv.fd > 0) \
+ { \
+ uart_recvchars(&g_tty##port##_dev); \
+ uart_xmitchars(&g_tty##port##_dev); \
+ } \
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -391,7 +398,7 @@ static bool tty_rxavailable(struct uart_dev_s *dev)
{
struct tty_priv_s *priv = dev->priv;
- return host_uart_checkc(dev->isconsole ? 0 : priv->fd);
+ return host_uart_checkin(dev->isconsole ? 0 : priv->fd);
}
/****************************************************************************
@@ -457,7 +464,9 @@ static void tty_txint(struct uart_dev_s *dev, bool enable)
static bool tty_txready(struct uart_dev_s *dev)
{
- return true;
+ struct tty_priv_s *priv = dev->priv;
+
+ return host_uart_checkout(dev->isconsole ? 0 : priv->fd);
}
/****************************************************************************
@@ -518,38 +527,24 @@ void sim_uartinit(void)
void sim_uartloop(void)
{
#ifdef USE_DEVCONSOLE
- if (host_uart_checkc(0))
- {
- uart_recvchars(&g_console_dev);
- }
+ uart_recvchars(&g_console_dev);
+ uart_xmitchars(&g_console_dev);
#endif
#ifdef CONFIG_SIM_UART0_NAME
- if (g_tty0_priv.fd > 0 && host_uart_checkc(g_tty0_priv.fd))
- {
- uart_recvchars(&g_tty0_dev);
- }
+ TTY_RECVSEND(0)
#endif
#ifdef CONFIG_SIM_UART1_NAME
- if (g_tty1_priv.fd > 0 && host_uart_checkc(g_tty1_priv.fd))
- {
- uart_recvchars(&g_tty1_dev);
- }
+ TTY_RECVSEND(1)
#endif
#ifdef CONFIG_SIM_UART2_NAME
- if (g_tty2_priv.fd > 0 && host_uart_checkc(g_tty2_priv.fd))
- {
- uart_recvchars(&g_tty2_dev);
- }
+ TTY_RECVSEND(2)
#endif
#ifdef CONFIG_SIM_UART3_NAME
- if (g_tty3_priv.fd > 0 && host_uart_checkc(g_tty3_priv.fd))
- {
- uart_recvchars(&g_tty3_dev);
- }
+ TTY_RECVSEND(3)
#endif
}
diff --git a/arch/sim/src/sim/win/sim_hostuart.c b/arch/sim/src/sim/win/sim_hostuart.c
index 014bf8400b..693018f2d4 100644
--- a/arch/sim/src/sim/win/sim_hostuart.c
+++ b/arch/sim/src/sim/win/sim_hostuart.c
@@ -126,10 +126,10 @@ int host_uart_setcflag(int fd, unsigned int cflag)
}
/****************************************************************************
- * Name: host_uart_checkc
+ * Name: host_uart_checkin
****************************************************************************/
-bool host_uart_checkc(int fd)
+bool host_uart_checkin(int fd)
{
DWORD size;
@@ -140,3 +140,12 @@ bool host_uart_checkc(int fd)
return false;
}
+
+/****************************************************************************
+ * Name: host_uart_checkout
+ ****************************************************************************/
+
+bool host_uart_checkout(int fd)
+{
+ return true;
+}