ESP-AT and linux kernel communication

reofit77
Posts: 2
Joined: Tue Jun 21, 2022 11:40 am

ESP-AT and linux kernel communication

Postby reofit77 » Tue Jun 21, 2022 12:00 pm

Hello

I'm trying for send at-commands from linux kernel and reading the response over uart, but when I read from the device after writing to it, I get some random characters which may change depending on the execution. These characters are different from the expected response.
When I use the Arduino monitor, I can send at-commands and get the response as expected.
Also, when I have already used the Arduino monitor atleast once, I get the expected response with "busy p...". So I taught the problem was because I did not set the configuration for the tty device, but when I set the tty configurations, the linux kernel freezes.

This is my code below with some of the configurations I have tried to set.

Code: Untitled.c Select all

 char response_buf[64];

struct file *esp_device_file = filp_open(esp_device, O_RDWR | O_NONBLOCK, 0);
struct tty_struct *tty = (struct tty_struct *) esp_device_file->private_data;

// struct ktermios n_termios;
// down_read(&tty->termios_rwsem);
// n_termios = tty->termios;
// up_read(&tty->termios_rwsem);
// tty_termios_encode_baud_rate(&n_termios, B115200, B115200);
// tty_set_termios(tty, &n_termios);

// tty_encode_baud_rate(tty, B115200, B115200);
// speed_t baud = tty_get_baud_rate(tty);

// tty_write_message(tty, rawtp_command);
tty->ops->write(tty, rawtp_command, sizeof(rawtp_command));

if(kernel_write(esp_device_file, rawtp_command, sizeof(rawtp_command), 0) > 0)
{
printk(KERN_INFO "***** Writing done successfully *****");
kernel_read(esp_device_file, response_buf, sizeof(response_buf), 0);

printk(KERN_INFO "***** Reading done successfully *****");

}

printk(KERN_INFO "***** File closed successfully *****");
Any response is welcomed.
Thanks.

Sun
Espressif staff
Espressif staff
Posts: 336
Joined: Thu Dec 30, 2021 9:52 am

Re: ESP-AT and linux kernel communication

Postby Sun » Wed Jun 22, 2022 3:42 am

Hi,

I'm guessing this may be due to different UART level pull-ups and pull-downs for different MCUs. Maybe you can check from here?

Who is online

Users browsing this forum: No registered users and 1 guest