Page 1 of 1

how can i use USB-SERIAL port communicate with PC?

Posted: Sun Jan 16, 2022 2:01 am
by wanzhilin88
hello!
i want communicate with PC by using esp32-c3's USB-SERIAL-JTAG port as usual uart,
but,i don't known how to initialize it,don't know which API can send data to the usb-serial port or receive data from it.
would you tell me the details?

there are some functions in ESP-IDF 4.4:
static void usb_serial_jtag_write_and_flush(const uint8_t *buf, uint32_t wr_len)
static void usb_serial_jtag_isr_handler_default(void *arg)
esp_err_t usb_serial_jtag_driver_install(usb_serial_jtag_driver_config_t *usb_serial_jtag_config)
int usb_serial_jtag_read_bytes(void* buf, uint32_t length, TickType_t ticks_to_wait)
int usb_serial_jtag_write_bytes(const void* src, size_t size, TickType_t ticks_to_wait)

these functions are interface of usb-serial-jtag port?how to use it? where to find examples about?

Re: how can i use USB-SERIAL port communicate with PC?

Posted: Sun Jan 16, 2022 11:34 am
by ESP_Sprite
The most trivial use case is to use menuconfig to configure the USB-serial-JTAG as your standard input/output. You can then use the standard Unix functions (printf, getc, ...) to use it.

Re: how can i use USB-SERIAL port communicate with PC?

Posted: Mon Jan 17, 2022 12:38 am
by wanzhilin88
good,thanks very much.

Re: how can i use USB-SERIAL port communicate with PC?

Posted: Sat Jan 22, 2022 4:20 am
by wangshuoran
ESP_Sprite wrote:
Sun Jan 16, 2022 11:34 am
The most trivial use case is to use menuconfig to configure the USB-serial-JTAG as your standard input/output. You can then use the standard Unix functions (printf, getc, ...) to use it.
If my upper computer send datas to esp32-c3, what function or API let esp32-c3 capture these data?

Re: how can i use USB-SERIAL port communicate with PC?

Posted: Wed Jan 26, 2022 7:54 am
by wanzhilin88
in my example, i try to use the function:usb_serial_jtag_write_bytes() to get data from PC
but this function work not good.
sometimes it can get data form PC,sometimes can not.

Re: how can i use USB-SERIAL port communicate with PC?

Posted: Wed Jan 26, 2022 7:56 am
by wanzhilin88
sorry, i mean usb_serial_jtag_read_bytes()

Re: how can i use USB-SERIAL port communicate with PC?

Posted: Sun Feb 13, 2022 1:55 am
by wangshuoran
thank you. If you use scanf or gets maybe easy to realize function.