subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Trackunit Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr/modem/pipe.h>
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
#define PIPE_EVENT_OPENED_BIT BIT(0)
|
|
|
|
#define PIPE_EVENT_CLOSED_BIT BIT(1)
|
|
|
|
#define PIPE_EVENT_RECEIVE_READY_BIT BIT(2)
|
|
|
|
#define PIPE_EVENT_TRANSMIT_IDLE_BIT BIT(3)
|
|
|
|
|
|
|
|
static void pipe_set_callback(struct modem_pipe *pipe,
|
|
|
|
modem_pipe_api_callback callback,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
K_SPINLOCK(&pipe->spinlock) {
|
|
|
|
pipe->callback = callback;
|
|
|
|
pipe->user_data = user_data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_call_callback(struct modem_pipe *pipe, enum modem_pipe_event event)
|
|
|
|
{
|
|
|
|
K_SPINLOCK(&pipe->spinlock) {
|
|
|
|
if (pipe->callback != NULL) {
|
|
|
|
pipe->callback(pipe, event, pipe->user_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t pipe_test_events(struct modem_pipe *pipe, uint32_t events)
|
|
|
|
{
|
|
|
|
return k_event_test(&pipe->event, events);
|
|
|
|
}
|
|
|
|
|
2024-06-10 23:51:15 +08:00
|
|
|
static uint32_t pipe_await_events(struct modem_pipe *pipe,
|
|
|
|
uint32_t events,
|
|
|
|
k_timeout_t timeout)
|
2024-06-10 19:15:25 +08:00
|
|
|
{
|
2024-06-10 23:51:15 +08:00
|
|
|
return k_event_wait(&pipe->event, events, false, timeout);
|
2024-06-10 19:15:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_post_events(struct modem_pipe *pipe, uint32_t events)
|
|
|
|
{
|
|
|
|
k_event_post(&pipe->event, events);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_clear_events(struct modem_pipe *pipe, uint32_t events)
|
|
|
|
{
|
|
|
|
k_event_clear(&pipe->event, events);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_set_events(struct modem_pipe *pipe, uint32_t events)
|
|
|
|
{
|
|
|
|
k_event_set(&pipe->event, events);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pipe_call_open(struct modem_pipe *pipe)
|
|
|
|
{
|
|
|
|
return pipe->api->open(pipe->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pipe_call_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size)
|
|
|
|
{
|
|
|
|
return pipe->api->transmit(pipe->data, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pipe_call_receive(struct modem_pipe *pipe, uint8_t *buf, size_t size)
|
|
|
|
{
|
|
|
|
return pipe->api->receive(pipe->data, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pipe_call_close(struct modem_pipe *pipe)
|
|
|
|
{
|
|
|
|
return pipe->api->close(pipe->data);
|
|
|
|
}
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
|
2024-06-29 02:11:04 +08:00
|
|
|
void modem_pipe_init(struct modem_pipe *pipe, void *data, const struct modem_pipe_api *api)
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
{
|
|
|
|
__ASSERT_NO_MSG(pipe != NULL);
|
|
|
|
__ASSERT_NO_MSG(data != NULL);
|
|
|
|
__ASSERT_NO_MSG(api != NULL);
|
|
|
|
|
|
|
|
pipe->data = data;
|
|
|
|
pipe->api = api;
|
|
|
|
pipe->callback = NULL;
|
|
|
|
pipe->user_data = NULL;
|
2024-06-10 19:15:25 +08:00
|
|
|
k_event_init(&pipe->event);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
2024-06-10 23:51:15 +08:00
|
|
|
int modem_pipe_open(struct modem_pipe *pipe, k_timeout_t timeout)
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
if (pipe_test_events(pipe, PIPE_EVENT_OPENED_BIT)) {
|
2023-09-29 17:35:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
ret = pipe_call_open(pipe);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-06-10 23:51:15 +08:00
|
|
|
if (!pipe_await_events(pipe, PIPE_EVENT_OPENED_BIT, timeout)) {
|
2024-06-10 19:15:25 +08:00
|
|
|
return -EAGAIN;
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
return 0;
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int modem_pipe_open_async(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
if (pipe_test_events(pipe, PIPE_EVENT_OPENED_BIT)) {
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_OPENED);
|
2023-09-29 17:35:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
return pipe_call_open(pipe);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void modem_pipe_attach(struct modem_pipe *pipe, modem_pipe_api_callback callback, void *user_data)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_set_callback(pipe, callback, user_data);
|
2023-09-14 02:03:27 +08:00
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
if (pipe_test_events(pipe, PIPE_EVENT_RECEIVE_READY_BIT)) {
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_RECEIVE_READY);
|
2023-09-14 02:03:27 +08:00
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
if (pipe_test_events(pipe, PIPE_EVENT_TRANSMIT_IDLE_BIT)) {
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_TRANSMIT_IDLE);
|
2023-11-22 13:59:44 +08:00
|
|
|
}
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int modem_pipe_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
if (!pipe_test_events(pipe, PIPE_EVENT_OPENED_BIT)) {
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_clear_events(pipe, PIPE_EVENT_TRANSMIT_IDLE_BIT);
|
|
|
|
return pipe_call_transmit(pipe, buf, size);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int modem_pipe_receive(struct modem_pipe *pipe, uint8_t *buf, size_t size)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
if (!pipe_test_events(pipe, PIPE_EVENT_OPENED_BIT)) {
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_clear_events(pipe, PIPE_EVENT_RECEIVE_READY_BIT);
|
|
|
|
return pipe_call_receive(pipe, buf, size);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void modem_pipe_release(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_set_callback(pipe, NULL, NULL);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
2024-06-10 23:51:15 +08:00
|
|
|
int modem_pipe_close(struct modem_pipe *pipe, k_timeout_t timeout)
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
if (pipe_test_events(pipe, PIPE_EVENT_CLOSED_BIT)) {
|
2023-09-29 17:35:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
ret = pipe_call_close(pipe);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-06-10 23:51:15 +08:00
|
|
|
if (!pipe_await_events(pipe, PIPE_EVENT_CLOSED_BIT, timeout)) {
|
2024-06-10 19:15:25 +08:00
|
|
|
return -EAGAIN;
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
return 0;
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int modem_pipe_close_async(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
if (pipe_test_events(pipe, PIPE_EVENT_CLOSED_BIT)) {
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_CLOSED);
|
2023-09-29 17:35:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-06-10 19:15:25 +08:00
|
|
|
return pipe_call_close(pipe);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void modem_pipe_notify_opened(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_set_events(pipe, PIPE_EVENT_OPENED_BIT | PIPE_EVENT_TRANSMIT_IDLE_BIT);
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_OPENED);
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_TRANSMIT_IDLE);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void modem_pipe_notify_closed(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_set_events(pipe, PIPE_EVENT_TRANSMIT_IDLE_BIT | PIPE_EVENT_CLOSED_BIT);
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_CLOSED);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void modem_pipe_notify_receive_ready(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_post_events(pipe, PIPE_EVENT_RECEIVE_READY_BIT);
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_RECEIVE_READY);
|
subsys/modem: Add modem modules
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>
2023-04-10 23:58:39 +08:00
|
|
|
}
|
2023-11-22 13:59:44 +08:00
|
|
|
|
|
|
|
void modem_pipe_notify_transmit_idle(struct modem_pipe *pipe)
|
|
|
|
{
|
2024-06-10 19:15:25 +08:00
|
|
|
pipe_post_events(pipe, PIPE_EVENT_TRANSMIT_IDLE_BIT);
|
|
|
|
pipe_call_callback(pipe, MODEM_PIPE_EVENT_TRANSMIT_IDLE);
|
2023-11-22 13:59:44 +08:00
|
|
|
}
|