Those helpers allow to define some typical kinds of chat matches and
scripts with more ease/less boilerplate.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
A Kconfig item is added and the buffer
is embedded into the modem_cmux struct.
The default value is increased from 16 to 64 bytes in
an effort to reduce the number of modem_pipe_receive() calls.
CONFIG_MODEM_CHAT_LOG_BUFFER is renamed
to CONFIG_MODEM_CHAT_LOG_BUFFER_SIZE for consistency.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Refactors modem chat module to use TRANSMIT_IDLE event instead
of polling when transmitting, cleaning up the transmit handler
by combining duplicate code and using an internal state instead
of multiple iterators to track send state.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
Remove receive and transmit timeouts which are no
longer useful as the RECEIVE_READY and
TRANSMIT_IDLE events will be used to efficiently
manage timeouts between transmit/receive calls.
Then update the the in-tree drivers using the
modem_chat module to omit the process timeout
parameter.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
This PR makes the modem_chat wait until a chat script chat
request has been sent before accepting responses to said
request.
This helps ensure that an unsolicitet response is not mistaken
for a response to a request, which is especially problematic
if the chat script chat is using an any match.
For example, start chat script sending AT+CGMI, expecting the
modem name as a response followed by OK
> start script, waiting for response immediately
> start sending "AT+CGMI"
> receive "+CEREG 1,0" while sending
> script accepts "+CEREG 1,0" as the response to "AT+CGMI"
> "AT+CGMI" sent
> receive "QUECTEL BG95"
> receive "OK"
script handler got "+CEREG 1,0" instead of "QUECTEL BG95"
After this PR:
> start script
> start sending AT+CGMI
> receive "+CEREG 1,0" while sending
> "AT+CGMI" sent
> start waiting for response
> receive "QUECTEL BG95"
> script accepts "QUECTEL BG95" as response to "AT+CGMI"
> receive "OK"
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The chat module contains an array of three lists of matches,
one of which are static, two of which are contained within the
currently running script. The current match, which is an
object stored in one of the three lists, is stored in its own
pointer in the chat module context.
A memory error occurs when the script is stopped, while the
chat module is using one of the matches stored withing the
script. This commit clears the match pointer when the script
is stopped if the match is stored within the script.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
This commit optimizes the performance of the script chats by
storing the size of requests with the chat script chat, negating
the need to use strlen() within the modem_chat module every time
a chat script chat request is sent.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit adds one new feature, modem_chat_run_script(),
which synchronously runs a script.
The existing function modem_chat_script_run() is async,
and doesn't follow the naming convention created for the
other modem modules, specifically, all functions are sync,
unless appended with _async.
To preserve backwards compatibility, the existing function
modem_chat_script_run() will remain until deprecated. It
simply calls modem_chat_run_script_async().
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit adds support for partial matches for the modem_chat
module. A match is a combination of an expected response to a
request along with delimiters to use and a handler for the
parsed response.
The usual behavior of the modem_chat script is to continue to
the next step when any expected response is received. The partial
flag indicates that the script should not proceed to the next
step if the response matches the match. This is useful for
commands which respond with an unspecified number of lines,
followed by an "OK". This flag allows the script to essentially
run in a "while" loop until OK is received.
Along with this addition, a more scalable macro for initializing
the modem_chat match struct, MODEM_CHAT_MATCH_INITIALIZER().
Without this macro, we will need 4 different macros to initialize
the 4 variants of a chat_match, and 8 when the next feature is
added...
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This PR adds the following modem modules to the subsys/modem
folder:
- chat: Light implementation of the Linux chat program, used to
send and receive text based commands statically created
scripts.
- cmux: Implementation of the CMUX protocol
- pipe: Thread-safe async data-in/data-out binding layer between
modem modules.
- ppp: Implementation of the PPP protocol, binding the Zephyr PPP
L2 stack with the data-in/data-out pipe.
These modules use the abstract pipes to communicate between each
other. To bind them with the hardware, the following backends
are provided:
- TTY: modem pipe <-> POSIX TTY file
- UART: modem pipe <-> UART, async and ISR APIs supported
The backends are used to abstract away the physical layer, UART,
TTY, IPC, I2C, SPI etc, to a modem modules friendly pipe.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>