-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bring echo functionality on slm #18823
base: main
Are you sure you want to change the base?
Conversation
Thank you for your contribution! Note: This comment is automatically posted and updated by the Contribs GitHub Action. |
@@ -700,6 +700,10 @@ void slm_at_receive(const uint8_t *buf, size_t len) | |||
break; | |||
} | |||
|
|||
#if defined(CONFIG_SLM_UART_ECHO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SLM can handle multiple commands coming in a single UART buffer. And this loop is run once for each command. This printing would need to be moved out from the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it's out from the loop.
@@ -700,6 +700,10 @@ void slm_at_receive(const uint8_t *buf, size_t len) | |||
break; | |||
} | |||
|
|||
#if defined(CONFIG_SLM_UART_ECHO) | |||
slm_at_send(buf, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will print the data as well and should likely call slm_at_send_indicate without indicate and tracing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it directly calls at_backend.send
@@ -68,6 +68,12 @@ config SLM_UART_TX_BUF_SIZE | |||
help | |||
Amount of UART traffic waiting to be sent (TX), that can be held. If the buffers are full, will send synchronously. | |||
|
|||
config SLM_UART_ECHO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this deal with backspace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it clears the line before putting buffer on it.
if (get_slm_mode() == SLM_AT_COMMAND_MODE && at_backend.send) { | ||
const uint8_t clear_line_cmd[] = "\33[2K\r"; /* VT100 Clear line escape sequence */ | ||
at_backend.send(clear_line_cmd, sizeof(clear_line_cmd)); | ||
at_backend.send(slm_at_buf, at_cmd_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work with multi-line inputs such as certificates with AT%CMNG commands. Only the last line is echoed for the terminal. Similarly, if the certificate is larger than UART buffers, the received parts will be repeated multiple times.
I also had problems with other multi-line inputs such as:
at#xsend="test
test"
The output buffer keeps on getting printed for every character on the second row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am starting to think that this might be something that is quite hard to get to work correctly for all inputs (and terminals?). The local echo should handle this on terminals, so I don't fully understand the need for this. I am currently leaning on not approving this change to our main, even if it seems to work with most inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed multi-line input problem with my last push.
I implemented this to not only for terminal usage but also if someone writes an application to talk with modem through uart and expects echo on the first response line for the parser function etc. Because Modem Shell (mosh) has it by default true.
First, I created a ticket on Nordic DevZone: https://devzone.nordicsemi.com/f/nordic-q-a/116126/serial-lte-modem-doesn-t-show-what-i-typed
And then I realized there is no such an option for this. That's the why I wanted to implement my own. And I implemented with by default false. Therefore, it won't affect the other people who use SLM.
By the way, I already arranged my parser. I don't need this change. Even I need it I can patch it. So, I don't need this PR to be merged personally. It may be helpful for other people in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good that you got this to work in your parser. That is the way want to encourage our users to solve this issue. As for the integrations, ones that we currently have do not except echoes of commands. This need has not been risen during the time that I have worked with this component. I think that it may be more difficult to implement the parsing of responses if the original commands are echoed back.
If such need arises in future, this PR can be revisited.
For future reference, PR has the before mentioned issues:
-
Multi-line inputs keep repeating previous rows:
at#xsend="test
test" -
Messages that are larger than the size of the UART buffers will be repeated multiple times.
There are sure to be other issues as well, but this will likely work well enough for some use-cases.
Modem Shell has already echo functionality on at_cmd_mode. Let's bring this functionality to Serial LTE Modem as well with by default false.