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.
  1.  char response_buf[64];
  2.  
  3.     struct file *esp_device_file = filp_open(esp_device, O_RDWR | O_NONBLOCK, 0);
  4.     struct tty_struct *tty = (struct tty_struct *) esp_device_file->private_data;
  5.  
  6.     // struct ktermios n_termios;
  7.     // down_read(&tty->termios_rwsem);
  8.     // n_termios = tty->termios;
  9.     // up_read(&tty->termios_rwsem);
  10.     // tty_termios_encode_baud_rate(&n_termios, B115200, B115200);
  11.     // tty_set_termios(tty, &n_termios);
  12.  
  13.     // tty_encode_baud_rate(tty, B115200, B115200);
  14.     // speed_t baud = tty_get_baud_rate(tty);
  15.  
  16.     // tty_write_message(tty, rawtp_command);
  17.     tty->ops->write(tty, rawtp_command, sizeof(rawtp_command));
  18.  
  19.     if(kernel_write(esp_device_file, rawtp_command, sizeof(rawtp_command), 0) > 0)
  20.     {
  21.         printk(KERN_INFO "***** Writing done successfully *****");
  22.         kernel_read(esp_device_file, response_buf, sizeof(response_buf), 0);
  23.  
  24.         printk(KERN_INFO "***** Reading done successfully *****");
  25.  
  26.     }
  27.  
  28.     printk(KERN_INFO "***** File closed successfully *****");
Any response is welcomed.
Thanks.

ESP_Sun
Posts: 326
Joined: Thu Dec 30, 2021 9:52 am

Re: ESP-AT and linux kernel communication

Postby ESP_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 8 guests