how to turn off echo on USB serial port


Holger Schurig
 

Hi,

I use a CDC_ACM serial port with Zephyr (from git), and using IRQ driven. Here is my ISR:

static void usb_serial_irq(const struct device *usb_dev, void *user_data)
{
    while (uart_irq_update(usb_dev) && uart_irq_is_pending(usb_dev)) {
        if (uart_irq_rx_ready(usb_dev)) {
            usb_rx_buf_len = uart_fifo_read(usb_dev, usb_rx_buf, sizeof(usb_rx_buf));
            // we disable the interrupt here and send an event
            // main.c will receive the event, parses what we received, and turn
            // on the receive interrupts again.
            uart_irq_rx_disable(usb_dev);
            LOG_HEXDUMP_ERR(&usb_rx_buf, usb_rx_buf_len, "USB RX");
            event_send(USB_INCOMING_DATA);
        }

        if (uart_irq_tx_ready(usb_dev)) {
            uint8_t buffer[64];
            int rb_len;
            int send_len;

            rb_len = ring_buf_get(&usb_tx_ring, buffer, sizeof(buffer));
            if (!rb_len) {
                uart_irq_tx_disable(usb_dev);
                continue;
            }

            send_len = uart_fifo_fill(usb_dev, buffer, rb_len);
            if (send_len < rb_len) {
                LOG_ERR("dropped tx %d byte", rb_len - send_len);
            }
        }
    }
}

I can receive nicely with this.

However, when I sent characters this way:

int usb_serial_putc(char c)
{
    if (!usb_dev)
        return 0;
    int count = 0;
    while (ring_buf_space_get(&usb_tx_ring) < 1) {
        if (++count > 500)
            return -1;
        k_sleep(K_MSEC(2));
    }
    ring_buf_put(&usb_tx_ring, &c, 1);
    uart_irq_tx_enable(usb_dev);
    return 0;
}

I will *ALSO* receive them, as the LOG_HEXDUMP_ERR in the ISR showed me.

My applicaton is currently compiled for POSIX native (real hardware isn't ready yet). In Linux, I use "usbip attach -r localhost -b 1-1". And even a "cat </dev/ttyACM0" makes my ISR receive sent data ... despite the fact that cat cannot send at all. This also doesn't happen with normal USB dongles, so it must be some behavior of Zephyr.

How can I prevent the reception of the data that I sent by myself?