ESP-AT and linux kernel communication
Posted: 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.
Any response is welcomed.
Thanks.
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.
- 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 *****");
Thanks.