aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2013-11-20 15:28:34 +0100
committerAleksander Morgado <aleksander@aleksander.es>2014-02-13 13:39:51 +0100
commit9cde02111b3c0eb2ef487c021bcb0950d7cb5f92 (patch)
tree201e54e024b09eb8d54ad38de6f35e984512c598 /src
parentc9e2b46b2124afcf710736900ba1848711126a83 (diff)
ports: rename 'MMSerialPort' to 'MMPortSerial'
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/mm-at-serial-port.c28
-rw-r--r--src/mm-at-serial-port.h6
-rw-r--r--src/mm-base-modem-at.c6
-rw-r--r--src/mm-base-modem.c2
-rw-r--r--src/mm-broadband-bearer.c34
-rw-r--r--src/mm-broadband-modem.c32
-rw-r--r--src/mm-gps-serial-port.c12
-rw-r--r--src/mm-gps-serial-port.h6
-rw-r--r--src/mm-port-probe.c28
-rw-r--r--src/mm-port-serial.c (renamed from src/mm-serial-port.c)310
-rw-r--r--src/mm-port-serial.h (renamed from src/mm-serial-port.h)96
-rw-r--r--src/mm-qcdm-serial-port.c22
-rw-r--r--src/mm-qcdm-serial-port.h6
-rw-r--r--src/tests/test-qcdm-serial-port.c4
15 files changed, 298 insertions, 298 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2051472d..b5f3bd8a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -86,8 +86,8 @@ nodist_libserial_la_SOURCES = \
libserial_la_SOURCES = \
mm-port.c \
mm-port.h \
- mm-serial-port.c \
- mm-serial-port.h \
+ mm-port-serial.c \
+ mm-port-serial.h \
mm-at-serial-port.c \
mm-at-serial-port.h \
mm-qcdm-serial-port.c \
diff --git a/src/mm-at-serial-port.c b/src/mm-at-serial-port.c
index 1c8e3552..6c4fac3b 100644
--- a/src/mm-at-serial-port.c
+++ b/src/mm-at-serial-port.c
@@ -24,7 +24,7 @@
#include "mm-at-serial-port.h"
#include "mm-log.h"
-G_DEFINE_TYPE (MMAtSerialPort, mm_at_serial_port, MM_TYPE_SERIAL_PORT)
+G_DEFINE_TYPE (MMAtSerialPort, mm_at_serial_port, MM_TYPE_PORT_SERIAL)
#define MM_AT_SERIAL_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_AT_SERIAL_PORT, MMAtSerialPortPrivate))
@@ -121,7 +121,7 @@ mm_at_serial_port_remove_echo (GByteArray *response)
}
static gboolean
-parse_response (MMSerialPort *port, GByteArray *response, GError **error)
+parse_response (MMPortSerial *port, GByteArray *response, GError **error)
{
MMAtSerialPort *self = MM_AT_SERIAL_PORT (port);
MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self);
@@ -152,7 +152,7 @@ parse_response (MMSerialPort *port, GByteArray *response, GError **error)
}
static gsize
-handle_response (MMSerialPort *port,
+handle_response (MMPortSerial *port,
GByteArray *response,
GError *error,
GCallback callback,
@@ -264,7 +264,7 @@ remove_eval_cb (const GMatchInfo *match_info,
}
static void
-parse_unsolicited (MMSerialPort *port, GByteArray *response)
+parse_unsolicited (MMPortSerial *port, GByteArray *response)
{
MMAtSerialPort *self = MM_AT_SERIAL_PORT (port);
MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self);
@@ -369,7 +369,7 @@ mm_at_serial_port_queue_command (MMAtSerialPort *self,
buf = at_command_to_byte_array (command, is_raw, priv->send_lf);
g_return_if_fail (buf != NULL);
- mm_serial_port_queue_command (MM_SERIAL_PORT (self),
+ mm_port_serial_queue_command (MM_PORT_SERIAL (self),
buf,
TRUE,
timeout_seconds,
@@ -397,7 +397,7 @@ mm_at_serial_port_queue_command_cached (MMAtSerialPort *self,
buf = at_command_to_byte_array (command, is_raw, priv->send_lf);
g_return_if_fail (buf != NULL);
- mm_serial_port_queue_command_cached (MM_SERIAL_PORT (self),
+ mm_port_serial_queue_command_cached (MM_PORT_SERIAL (self),
buf,
TRUE,
timeout_seconds,
@@ -407,7 +407,7 @@ mm_at_serial_port_queue_command_cached (MMAtSerialPort *self,
}
static void
-debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
+debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
{
static GString *debug = NULL;
const char *s;
@@ -485,7 +485,7 @@ mm_at_serial_port_run_init_sequence (MMAtSerialPort *self)
}
static void
-config (MMSerialPort *self)
+config (MMPortSerial *self)
{
MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self);
@@ -600,7 +600,7 @@ static void
mm_at_serial_port_class_init (MMAtSerialPortClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- MMSerialPortClass *port_class = MM_SERIAL_PORT_CLASS (klass);
+ MMPortSerialClass *serial_class = MM_PORT_SERIAL_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMAtSerialPortPrivate));
@@ -609,11 +609,11 @@ mm_at_serial_port_class_init (MMAtSerialPortClass *klass)
object_class->get_property = get_property;
object_class->finalize = finalize;
- port_class->parse_unsolicited = parse_unsolicited;
- port_class->parse_response = parse_response;
- port_class->handle_response = handle_response;
- port_class->debug_log = debug_log;
- port_class->config = config;
+ serial_class->parse_unsolicited = parse_unsolicited;
+ serial_class->parse_response = parse_response;
+ serial_class->handle_response = handle_response;
+ serial_class->debug_log = debug_log;
+ serial_class->config = config;
g_object_class_install_property
(object_class, PROP_REMOVE_ECHO,
diff --git a/src/mm-at-serial-port.h b/src/mm-at-serial-port.h
index cdd3b9cb..334bacd8 100644
--- a/src/mm-at-serial-port.h
+++ b/src/mm-at-serial-port.h
@@ -20,7 +20,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "mm-serial-port.h"
+#include "mm-port-serial.h"
#define MM_TYPE_AT_SERIAL_PORT (mm_at_serial_port_get_type ())
#define MM_AT_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_AT_SERIAL_PORT, MMAtSerialPort))
@@ -72,11 +72,11 @@ typedef void (*MMAtSerialResponseFn) (MMAtSerialPort *port,
#define MM_AT_SERIAL_PORT_SEND_LF "send-lf"
struct _MMAtSerialPort {
- MMSerialPort parent;
+ MMPortSerial parent;
};
struct _MMAtSerialPortClass {
- MMSerialPortClass parent;
+ MMPortSerialClass parent;
};
GType mm_at_serial_port_get_type (void);
diff --git a/src/mm-base-modem-at.c b/src/mm-base-modem-at.c
index e25bdf33..ce15e83d 100644
--- a/src/mm-base-modem-at.c
+++ b/src/mm-base-modem-at.c
@@ -60,7 +60,7 @@ abort_async_if_port_unusable (MMBaseModem *self,
g_object_set (port, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE, NULL);
/* Ensure we have a port open during the sequence */
- if (!mm_serial_port_open (MM_SERIAL_PORT (port), &error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (port), &error)) {
g_simple_async_report_error_in_idle (
G_OBJECT (self),
callback,
@@ -107,7 +107,7 @@ typedef struct {
static void
at_sequence_context_free (AtSequenceContext *ctx)
{
- mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->port));
g_object_unref (ctx->port);
g_object_unref (ctx->self);
@@ -442,7 +442,7 @@ typedef struct {
static void
at_command_context_free (AtCommandContext *ctx)
{
- mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->port));
if (ctx->cancelled_id)
g_cancellable_disconnect (ctx->modem_cancellable,
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index f6f448fa..bd09c43d 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -138,7 +138,7 @@ mm_base_modem_owns_port (MMBaseModem *self,
}
static void
-serial_port_timed_out_cb (MMSerialPort *port,
+serial_port_timed_out_cb (MMPortSerial *port,
guint n_consecutive_timeouts,
gpointer user_data)
{
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 33b4ca73..c25e4032 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -111,7 +111,7 @@ detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
g_object_unref (ctx->secondary);
if (ctx->data) {
if (ctx->close_data_on_exit)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->data));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->data));
g_object_unref (ctx->data);
}
g_object_unref (ctx->self);
@@ -206,7 +206,7 @@ common_get_at_data_port (MMBaseModem *modem,
g_assert (MM_IS_AT_SERIAL_PORT (data));
- if (!mm_serial_port_open (MM_SERIAL_PORT (data), error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (data), error)) {
g_prefix_error (error, "Couldn't connect: cannot keep data port open.");
return NULL;
}
@@ -516,7 +516,7 @@ extended_error_ready (MMBaseModem *modem,
const gchar *result;
/* Close the dialling port as we got an error */
- mm_serial_port_close (MM_SERIAL_PORT (ctx->dial_port));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->dial_port));
/* If cancelled, complete */
if (dial_3gpp_context_complete_and_free_if_cancelled (ctx))
@@ -1326,13 +1326,13 @@ detailed_disconnect_context_new (MMBroadbandBearer *self,
/* CDMA disconnect */
static void
-data_flash_cdma_ready (MMSerialPort *data,
+data_flash_cdma_ready (MMPortSerial *data,
GError *error,
DetailedDisconnectContext *ctx)
{
/* We kept the serial port open during connection, now we close that open
* count */
- mm_serial_port_close (data);
+ mm_port_serial_close (data);
/* Port is disconnected; update the state */
mm_port_set_connected (MM_PORT (data), FALSE);
@@ -1361,7 +1361,7 @@ data_flash_cdma_ready (MMSerialPort *data,
}
static void
-data_reopen_cdma_ready (MMSerialPort *data,
+data_reopen_cdma_ready (MMPortSerial *data,
GError *error,
DetailedDisconnectContext *ctx)
{
@@ -1374,7 +1374,7 @@ data_reopen_cdma_ready (MMSerialPort *data,
/* Just flash the data port */
mm_dbg ("Flashing data port (%s)...", mm_port_get_device (MM_PORT (ctx->data)));
- mm_serial_port_flash (MM_SERIAL_PORT (ctx->data),
+ mm_port_serial_flash (MM_PORT_SERIAL (ctx->data),
1000,
TRUE,
(MMSerialFlashFn)data_flash_cdma_ready,
@@ -1395,7 +1395,7 @@ disconnect_cdma (MMBroadbandBearer *self,
g_assert (primary != NULL);
/* Generic CDMA plays only with SERIAL data ports */
- g_assert (MM_IS_SERIAL_PORT (data));
+ g_assert (MM_IS_PORT_SERIAL (data));
ctx = detailed_disconnect_context_new (self,
modem,
@@ -1407,7 +1407,7 @@ disconnect_cdma (MMBroadbandBearer *self,
/* Fully reopen the port before flashing */
mm_dbg ("Reopening data port (%s)...", mm_port_get_device (MM_PORT (ctx->data)));
- mm_serial_port_reopen (MM_SERIAL_PORT (ctx->data),
+ mm_port_serial_reopen (MM_PORT_SERIAL (ctx->data),
1000,
(MMSerialReopenFn)data_reopen_cdma_ready,
ctx);
@@ -1436,13 +1436,13 @@ cgact_data_ready (MMBaseModem *modem,
}
static void
-data_flash_3gpp_ready (MMSerialPort *data,
+data_flash_3gpp_ready (MMPortSerial *data,
GError *error,
DetailedDisconnectContext *ctx)
{
/* We kept the serial port open during connection, now we close that open
* count */
- mm_serial_port_close (data);
+ mm_port_serial_close (data);
/* Port is disconnected; update the state */
mm_port_set_connected (MM_PORT (data), FALSE);
@@ -1489,7 +1489,7 @@ data_flash_3gpp_ready (MMSerialPort *data,
}
static void
-data_reopen_3gpp_ready (MMSerialPort *data,
+data_reopen_3gpp_ready (MMPortSerial *data,
GError *error,
DetailedDisconnectContext *ctx)
{
@@ -1502,7 +1502,7 @@ data_reopen_3gpp_ready (MMSerialPort *data,
/* Just flash the data port */
mm_dbg ("Flashing data port (%s)...", mm_port_get_device (MM_PORT (ctx->data)));
- mm_serial_port_flash (MM_SERIAL_PORT (ctx->data),
+ mm_port_serial_flash (MM_PORT_SERIAL (ctx->data),
1000,
TRUE,
(MMSerialFlashFn)data_flash_3gpp_ready,
@@ -1514,7 +1514,7 @@ data_reopen_3gpp (DetailedDisconnectContext *ctx)
{
/* Fully reopen the port before flashing */
mm_dbg ("Reopening data port (%s)...", mm_port_get_device (MM_PORT (ctx->data)));
- mm_serial_port_reopen (MM_SERIAL_PORT (ctx->data),
+ mm_port_serial_reopen (MM_PORT_SERIAL (ctx->data),
1000,
(MMSerialReopenFn)data_reopen_3gpp_ready,
ctx);
@@ -1553,7 +1553,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
g_assert (primary != NULL);
/* Generic 3GPP plays only with SERIAL data ports */
- g_assert (MM_IS_SERIAL_PORT (data));
+ g_assert (MM_IS_PORT_SERIAL (data));
ctx = detailed_disconnect_context_new (self,
modem,
@@ -1824,7 +1824,7 @@ init_async_context_free (InitAsyncContext *ctx,
{
if (ctx->port) {
if (close_port)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->port));
g_object_unref (ctx->port);
}
g_object_unref (ctx->self);
@@ -1984,7 +1984,7 @@ initable_init_async (GAsyncInitable *initable,
return;
}
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->port), &error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->port), &error)) {
g_simple_async_result_take_error (ctx->result, error);
g_simple_async_result_complete_in_idle (ctx->result);
init_async_context_free (ctx, FALSE);
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 8e111c99..efd8a153 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -329,7 +329,7 @@ load_capabilities_context_complete_and_free (LoadCapabilitiesContext *ctx)
{
g_simple_async_result_complete (ctx->result);
if (ctx->qcdm_port) {
- mm_serial_port_close (MM_SERIAL_PORT (ctx->qcdm_port));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->qcdm_port));
g_object_unref (ctx->qcdm_port);
}
g_object_unref (ctx->result);
@@ -662,7 +662,7 @@ load_current_capabilities_qcdm (LoadCapabilitiesContext *ctx)
ctx->qcdm_port = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (ctx->self));
g_assert (ctx->qcdm_port);
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->qcdm_port), &error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->qcdm_port), &error)) {
mm_dbg ("Failed to open QCDM port for NV ModePref request: %s",
error->message);
g_error_free (error);
@@ -1007,7 +1007,7 @@ own_numbers_context_complete_and_free (OwnNumbersContext *ctx)
g_object_unref (ctx->result);
g_object_unref (ctx->self);
if (ctx->qcdm) {
- mm_serial_port_close (MM_SERIAL_PORT (ctx->qcdm));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->qcdm));
g_object_unref (ctx->qcdm);
}
g_free (ctx);
@@ -1148,7 +1148,7 @@ modem_load_own_numbers (MMIfaceModem *self,
modem_load_own_numbers);
ctx->qcdm = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (self));
if (ctx->qcdm) {
- if (mm_serial_port_open (MM_SERIAL_PORT (ctx->qcdm), &error)) {
+ if (mm_port_serial_open (MM_PORT_SERIAL (ctx->qcdm), &error)) {
ctx->qcdm = g_object_ref (ctx->qcdm);
} else {
mm_dbg ("Couldn't open QCDM port: (%d) %s",
@@ -1697,7 +1697,7 @@ modem_load_supported_ip_families (MMIfaceModem *self,
typedef struct {
MMBroadbandModem *self;
GSimpleAsyncResult *result;
- MMSerialPort *port;
+ MMPortSerial *port;
} SignalQualityContext;
static void
@@ -1986,7 +1986,7 @@ modem_load_signal_quality (MMIfaceModem *self,
modem_load_signal_quality);
/* Check whether we can get a non-connected AT port */
- ctx->port = (MMSerialPort *)mm_base_modem_get_best_at_port (MM_BASE_MODEM (self), &error);
+ ctx->port = (MMPortSerial *)mm_base_modem_get_best_at_port (MM_BASE_MODEM (self), &error);
if (ctx->port) {
if (MM_BROADBAND_MODEM (self)->priv->modem_cind_supported &&
CIND_INDICATOR_IS_VALID (MM_BROADBAND_MODEM (self)->priv->modem_cind_indicator_signal_quality))
@@ -1997,7 +1997,7 @@ modem_load_signal_quality (MMIfaceModem *self,
}
/* If no best AT port available (all connected), try with QCDM ports */
- ctx->port = (MMSerialPort *)mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
+ ctx->port = (MMPortSerial *)mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
if (ctx->port) {
g_error_free (error);
signal_quality_qcdm (ctx);
@@ -7599,17 +7599,17 @@ ports_context_unref (PortsContext *ctx)
if (g_atomic_int_dec_and_test (&ctx->ref_count)) {
if (ctx->primary) {
if (ctx->primary_open)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->primary));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->primary));
g_object_unref (ctx->primary);
}
if (ctx->secondary) {
if (ctx->secondary_open)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->secondary));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->secondary));
g_object_unref (ctx->secondary);
}
if (ctx->qcdm) {
if (ctx->qcdm_open)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->qcdm));
+ mm_port_serial_close (MM_PORT_SERIAL (ctx->qcdm));
g_object_unref (ctx->qcdm);
}
g_free (ctx);
@@ -7679,7 +7679,7 @@ open_ports_initialization (MMBroadbandModem *self,
* We do keep the primary port open during the whole initialization
* sequence. Note that this port is not really passed to the interfaces,
* they will get the primary port themselves. */
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->primary), error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->primary), error)) {
g_prefix_error (error, "Couldn't open primary port: ");
return FALSE;
}
@@ -7846,7 +7846,7 @@ enabling_modem_init_ready (MMBroadbandModem *self,
}
static void
-enabling_flash_done (MMSerialPort *port,
+enabling_flash_done (MMPortSerial *port,
GError *error,
EnablingStartedContext *ctx)
{
@@ -7895,7 +7895,7 @@ open_ports_enabling (MMBroadbandModem *self,
NULL);
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->primary), error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->primary), error)) {
g_prefix_error (error, "Couldn't open primary port: ");
return FALSE;
}
@@ -7910,7 +7910,7 @@ open_ports_enabling (MMBroadbandModem *self,
g_object_set (ctx->secondary,
MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE,
NULL);
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->secondary), error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->secondary), error)) {
g_prefix_error (error, "Couldn't open secondary port: ");
return FALSE;
}
@@ -7920,7 +7920,7 @@ open_ports_enabling (MMBroadbandModem *self,
/* Open qcdm (optional) */
ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
if (ctx->qcdm) {
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->qcdm), error)) {
+ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->qcdm), error)) {
g_prefix_error (error, "Couldn't open QCDM port: ");
return FALSE;
}
@@ -7971,7 +7971,7 @@ enabling_started (MMBroadbandModem *self,
/* Ports were correctly opened, now flash the primary port */
mm_dbg ("Flashing primary AT port before enabling...");
- mm_serial_port_flash (MM_SERIAL_PORT (ctx->ports->primary),
+ mm_port_serial_flash (MM_PORT_SERIAL (ctx->ports->primary),
100,
FALSE,
(MMSerialFlashFn)enabling_flash_done,
diff --git a/src/mm-gps-serial-port.c b/src/mm-gps-serial-port.c
index cfd653c4..53ace56a 100644
--- a/src/mm-gps-serial-port.c
+++ b/src/mm-gps-serial-port.c
@@ -21,7 +21,7 @@
#include "mm-gps-serial-port.h"
#include "mm-log.h"
-G_DEFINE_TYPE (MMGpsSerialPort, mm_gps_serial_port, MM_TYPE_SERIAL_PORT)
+G_DEFINE_TYPE (MMGpsSerialPort, mm_gps_serial_port, MM_TYPE_PORT_SERIAL)
struct _MMGpsSerialPortPrivate {
/* Trace handler data */
@@ -69,7 +69,7 @@ remove_eval_cb (const GMatchInfo *match_info,
}
static gboolean
-parse_response (MMSerialPort *port,
+parse_response (MMPortSerial *port,
GByteArray *response,
GError **error)
{
@@ -132,7 +132,7 @@ parse_response (MMSerialPort *port,
/*****************************************************************************/
static void
-debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
+debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
{
static GString *debug = NULL;
const char *s;
@@ -206,13 +206,13 @@ static void
mm_gps_serial_port_class_init (MMGpsSerialPortClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- MMSerialPortClass *port_class = MM_SERIAL_PORT_CLASS (klass);
+ MMPortSerialClass *serial_class = MM_PORT_SERIAL_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMGpsSerialPortPrivate));
/* Virtual methods */
object_class->finalize = finalize;
- port_class->parse_response = parse_response;
- port_class->debug_log = debug_log;
+ serial_class->parse_response = parse_response;
+ serial_class->debug_log = debug_log;
}
diff --git a/src/mm-gps-serial-port.h b/src/mm-gps-serial-port.h
index 5a7c23b1..b2ad6078 100644
--- a/src/mm-gps-serial-port.h
+++ b/src/mm-gps-serial-port.h
@@ -19,7 +19,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "mm-serial-port.h"
+#include "mm-port-serial.h"
#define MM_TYPE_GPS_SERIAL_PORT (mm_gps_serial_port_get_type ())
#define MM_GPS_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_GPS_SERIAL_PORT, MMGpsSerialPort))
@@ -37,12 +37,12 @@ typedef void (*MMGpsSerialTraceFn) (MMGpsSerialPort *port,
gpointer user_data);
struct _MMGpsSerialPort {
- MMSerialPort parent;
+ MMPortSerial parent;
MMGpsSerialPortPrivate *priv;
};
struct _MMGpsSerialPortClass {
- MMSerialPortClass parent;
+ MMPortSerialClass parent;
};
GType mm_gps_serial_port_get_type (void);
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index 4c64f2a9..3400bf12 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -27,7 +27,7 @@
#include "mm-port-probe.h"
#include "mm-log.h"
#include "mm-at-serial-port.h"
-#include "mm-serial-port.h"
+#include "mm-port-serial.h"
#include "mm-serial-parsers.h"
#include "mm-port-probe-at.h"
#include "libqcdm/src/commands.h"
@@ -82,7 +82,7 @@ typedef struct {
/* ---- Serial probing specific context ---- */
guint buffer_full_id;
- MMSerialPort *serial;
+ MMPortSerial *serial;
/* ---- AT probing specific context ---- */
@@ -332,8 +332,8 @@ port_probe_run_task_free (PortProbeRunTask *task)
g_warn_if_fail (MM_IS_AT_SERIAL_PORT (task->serial));
g_signal_handler_disconnect (task->serial, task->buffer_full_id);
}
- if (mm_serial_port_is_open (task->serial))
- mm_serial_port_close (task->serial);
+ if (mm_port_serial_is_open (task->serial))
+ mm_port_serial_close (task->serial);
g_object_unref (task->serial);
}
@@ -665,12 +665,12 @@ serial_probe_qcdm (MMPortProbe *self)
g_signal_handler_disconnect (task->serial, task->buffer_full_id);
task->buffer_full_id = 0;
}
- mm_serial_port_close (task->serial);
+ mm_port_serial_close (task->serial);
g_object_unref (task->serial);
}
/* Open the QCDM port */
- task->serial = MM_SERIAL_PORT (mm_qcdm_serial_port_new (g_udev_device_get_name (self->priv->port)));
+ task->serial = MM_PORT_SERIAL (mm_qcdm_serial_port_new (g_udev_device_get_name (self->priv->port)));
if (!task->serial) {
port_probe_run_task_complete (
task,
@@ -684,7 +684,7 @@ serial_probe_qcdm (MMPortProbe *self)
}
/* Try to open the port */
- if (!mm_serial_port_open (task->serial, &error)) {
+ if (!mm_port_serial_open (task->serial, &error)) {
port_probe_run_task_complete (
task,
FALSE,
@@ -1077,7 +1077,7 @@ serial_probe_schedule (MMPortProbe *self)
}
static void
-serial_flash_done (MMSerialPort *port,
+serial_flash_done (MMPortSerial *port,
GError *error,
MMPortProbe *self)
{
@@ -1086,7 +1086,7 @@ serial_flash_done (MMSerialPort *port,
}
static void
-serial_buffer_full (MMSerialPort *serial,
+serial_buffer_full (MMPortSerial *serial,
GByteArray *buffer,
MMPortProbe *self)
{
@@ -1136,7 +1136,7 @@ serial_open_at (MMPortProbe *self)
if (!task->serial) {
gpointer parser;
- task->serial = MM_SERIAL_PORT (mm_at_serial_port_new (g_udev_device_get_name (self->priv->port)));
+ task->serial = MM_PORT_SERIAL (mm_at_serial_port_new (g_udev_device_get_name (self->priv->port)));
if (!task->serial) {
port_probe_run_task_complete (
task,
@@ -1150,10 +1150,10 @@ serial_open_at (MMPortProbe *self)
}
g_object_set (task->serial,
- MM_SERIAL_PORT_SEND_DELAY, task->at_send_delay,
+ MM_PORT_SERIAL_SPEW_CONTROL, TRUE,
+ MM_PORT_SERIAL_SEND_DELAY, task->at_send_delay,
MM_AT_SERIAL_PORT_REMOVE_ECHO, task->at_remove_echo,
MM_AT_SERIAL_PORT_SEND_LF, task->at_send_lf,
- MM_SERIAL_PORT_SPEW_CONTROL, TRUE,
NULL);
parser = mm_serial_parser_v1_new ();
@@ -1167,7 +1167,7 @@ serial_open_at (MMPortProbe *self)
}
/* Try to open the port */
- if (!mm_serial_port_open (task->serial, &error)) {
+ if (!mm_port_serial_open (task->serial, &error)) {
/* Abort if maximum number of open tries reached */
if (++task->at_open_tries > 4) {
/* took too long to open the port; give up */
@@ -1208,7 +1208,7 @@ serial_open_at (MMPortProbe *self)
G_CALLBACK (serial_buffer_full),
self);
- mm_serial_port_flash (MM_SERIAL_PORT (task->serial),
+ mm_port_serial_flash (MM_PORT_SERIAL (task->serial),
100,
TRUE,
(MMSerialFlashFn)serial_flash_done,
diff --git a/src/mm-serial-port.c b/src/mm-port-serial.c
index cc4fc461..44d47990 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-port-serial.c
@@ -31,13 +31,13 @@
#include <ModemManager.h>
#include <mm-errors-types.h>
-#include "mm-serial-port.h"
+#include "mm-port-serial.h"
#include "mm-log.h"
-static gboolean mm_serial_port_queue_process (gpointer data);
-static void mm_serial_port_close_force (MMSerialPort *self);
+static gboolean mm_port_serial_queue_process (gpointer data);
+static void mm_port_serial_close_force (MMPortSerial *self);
-G_DEFINE_TYPE (MMSerialPort, mm_serial_port, MM_TYPE_PORT)
+G_DEFINE_TYPE (MMPortSerial, mm_port_serial, MM_TYPE_PORT)
enum {
PROP_0,
@@ -66,7 +66,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
#define SERIAL_BUF_SIZE 2048
-#define MM_SERIAL_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_SERIAL_PORT, MMSerialPortPrivate))
+#define MM_PORT_SERIAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_PORT_SERIAL, MMPortSerialPrivate))
typedef struct {
guint32 open_count;
@@ -100,7 +100,7 @@ typedef struct {
guint flash_id;
guint reopen_id;
guint connected_id;
-} MMSerialPortPrivate;
+} MMPortSerialPrivate;
typedef struct {
GByteArray *command;
@@ -178,9 +178,9 @@ baud_to_string (int baud)
}
void
-mm_serial_port_print_config (MMSerialPort *port, const char *detail)
+mm_port_serial_print_config (MMPortSerial *port, const char *detail)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (port);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (port);
struct termios stbuf;
int err;
@@ -333,9 +333,9 @@ parse_stopbits (guint i)
}
static gboolean
-real_config_fd (MMSerialPort *self, int fd, GError **error)
+real_config_fd (MMPortSerial *self, int fd, GError **error)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
struct termios stbuf, other;
int speed;
int bits;
@@ -420,20 +420,20 @@ real_config_fd (MMSerialPort *self, int fd, GError **error)
}
static void
-serial_debug (MMSerialPort *self, const char *prefix, const char *buf, gsize len)
+serial_debug (MMPortSerial *self, const char *prefix, const char *buf, gsize len)
{
g_return_if_fail (len > 0);
- if (MM_SERIAL_PORT_GET_CLASS (self)->debug_log)
- MM_SERIAL_PORT_GET_CLASS (self)->debug_log (self, prefix, buf, len);
+ if (MM_PORT_SERIAL_GET_CLASS (self)->debug_log)
+ MM_PORT_SERIAL_GET_CLASS (self)->debug_log (self, prefix, buf, len);
}
static gboolean
-mm_serial_port_process_command (MMSerialPort *self,
+mm_port_serial_process_command (MMPortSerial *self,
MMQueueData *info,
GError **error)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
const guint8 *p;
int status, expected_status, send_len;
@@ -497,14 +497,14 @@ mm_serial_port_process_command (MMSerialPort *self,
}
static void
-mm_serial_port_set_cached_reply (MMSerialPort *self,
+mm_port_serial_set_cached_reply (MMPortSerial *self,
const GByteArray *command,
const GByteArray *response)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
g_return_if_fail (self != NULL);
- g_return_if_fail (MM_IS_SERIAL_PORT (self));
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
g_return_if_fail (command != NULL);
if (response) {
@@ -515,19 +515,19 @@ mm_serial_port_set_cached_reply (MMSerialPort *self,
g_byte_array_append (rsp_copy, response->data, response->len);
g_hash_table_insert (priv->reply_cache, cmd_copy, rsp_copy);
} else
- g_hash_table_remove (MM_SERIAL_PORT_GET_PRIVATE (self)->reply_cache, command);
+ g_hash_table_remove (MM_PORT_SERIAL_GET_PRIVATE (self)->reply_cache, command);
}
static const GByteArray *
-mm_serial_port_get_cached_reply (MMSerialPort *self, GByteArray *command)
+mm_port_serial_get_cached_reply (MMPortSerial *self, GByteArray *command)
{
- return (const GByteArray *) g_hash_table_lookup (MM_SERIAL_PORT_GET_PRIVATE (self)->reply_cache, command);
+ return (const GByteArray *) g_hash_table_lookup (MM_PORT_SERIAL_GET_PRIVATE (self)->reply_cache, command);
}
static void
-mm_serial_port_schedule_queue_process (MMSerialPort *self, guint timeout_ms)
+mm_port_serial_schedule_queue_process (MMPortSerial *self, guint timeout_ms)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
if (priv->timeout_id) {
/* A command is already in progress */
@@ -540,13 +540,13 @@ mm_serial_port_schedule_queue_process (MMSerialPort *self, guint timeout_ms)
}
if (timeout_ms)
- priv->queue_id = g_timeout_add (timeout_ms, mm_serial_port_queue_process, self);
+ priv->queue_id = g_timeout_add (timeout_ms, mm_port_serial_queue_process, self);
else
- priv->queue_id = g_idle_add (mm_serial_port_queue_process, self);
+ priv->queue_id = g_idle_add (mm_port_serial_queue_process, self);
}
static gsize
-real_handle_response (MMSerialPort *self,
+real_handle_response (MMPortSerial *self,
GByteArray *response,
GError *error,
GCallback callback,
@@ -559,9 +559,9 @@ real_handle_response (MMSerialPort *self,
}
static void
-mm_serial_port_got_response (MMSerialPort *self, GError *error)
+mm_port_serial_got_response (MMPortSerial *self, GError *error)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
MMQueueData *info;
gsize consumed = priv->response->len;
@@ -582,11 +582,11 @@ mm_serial_port_got_response (MMSerialPort *self, GError *error)
info = (MMQueueData *) g_queue_pop_head (priv->queue);
if (info) {
if (info->cached && !error)
- mm_serial_port_set_cached_reply (self, info->command, priv->response);
+ mm_port_serial_set_cached_reply (self, info->command, priv->response);
if (info->callback) {
- g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->handle_response != NULL);
- consumed = MM_SERIAL_PORT_GET_CLASS (self)->handle_response (self,
+ g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->handle_response != NULL);
+ consumed = MM_PORT_SERIAL_GET_CLASS (self)->handle_response (self,
priv->response,
error,
info->callback,
@@ -604,14 +604,14 @@ mm_serial_port_got_response (MMSerialPort *self, GError *error)
if (consumed)
g_byte_array_remove_range (priv->response, 0, consumed);
if (!g_queue_is_empty (priv->queue))
- mm_serial_port_schedule_queue_process (self, 0);
+ mm_port_serial_schedule_queue_process (self, 0);
}
static gboolean
-mm_serial_port_timed_out (gpointer data)
+mm_port_serial_timed_out (gpointer data)
{
- MMSerialPort *self = MM_SERIAL_PORT (data);
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerial *self = MM_PORT_SERIAL (data);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
GError *error;
priv->timeout_id = 0;
@@ -626,7 +626,7 @@ mm_serial_port_timed_out (gpointer data)
/* FIXME: This is not completely correct - if the response finally arrives and there's
some other command waiting for response right now, the other command will
get the output of the timed out command. Not sure what to do here. */
- mm_serial_port_got_response (self, error);
+ mm_port_serial_got_response (self, error);
/* Emit a timed out signal, used by upper layers to identify a disconnected
* serial port */
@@ -636,10 +636,10 @@ mm_serial_port_timed_out (gpointer data)
}
static void
-serial_port_response_wait_cancelled (GCancellable *cancellable,
- MMSerialPort *self)
+port_serial_response_wait_cancelled (GCancellable *cancellable,
+ MMPortSerial *self)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
GError *error;
/* We don't want to call disconnect () while in the signal handler */
@@ -652,14 +652,14 @@ serial_port_response_wait_cancelled (GCancellable *cancellable,
/* FIXME: This is not completely correct - if the response finally arrives and there's
some other command waiting for response right now, the other command will
get the output of the cancelled command. Not sure what to do here. */
- mm_serial_port_got_response (self, error);
+ mm_port_serial_got_response (self, error);
}
static gboolean
-mm_serial_port_queue_process (gpointer data)
+mm_port_serial_queue_process (gpointer data)
{
- MMSerialPort *self = MM_SERIAL_PORT (data);
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerial *self = MM_PORT_SERIAL (data);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
MMQueueData *info;
GError *error = NULL;
@@ -670,7 +670,7 @@ mm_serial_port_queue_process (gpointer data)
return FALSE;
if (info->cached) {
- const GByteArray *cached = mm_serial_port_get_cached_reply (self, info->command);
+ const GByteArray *cached = mm_port_serial_get_cached_reply (self, info->command);
if (cached) {
/* Ensure the response array is fully empty before setting the
@@ -684,54 +684,54 @@ mm_serial_port_queue_process (gpointer data)
}
g_byte_array_append (priv->response, cached->data, cached->len);
- mm_serial_port_got_response (self, NULL);
+ mm_port_serial_got_response (self, NULL);
return FALSE;
}
}
- if (mm_serial_port_process_command (self, info, &error)) {
+ if (mm_port_serial_process_command (self, info, &error)) {
if (info->done) {
/* setup the cancellable so that we can stop waiting for a response */
if (info->cancellable) {
priv->cancellable = g_object_ref (info->cancellable);
priv->cancellable_id = (g_cancellable_connect (
info->cancellable,
- (GCallback) serial_port_response_wait_cancelled,
+ (GCallback) port_serial_response_wait_cancelled,
self,
NULL));
if (!priv->cancellable_id) {
error = g_error_new (MM_CORE_ERROR,
MM_CORE_ERROR_CANCELLED,
"Won't wait for the reply");
- mm_serial_port_got_response (self, error);
+ mm_port_serial_got_response (self, error);
return FALSE;
}
}
/* If the command is finished being sent, schedule the timeout */
priv->timeout_id = g_timeout_add_seconds (info->timeout,
- mm_serial_port_timed_out,
+ mm_port_serial_timed_out,
self);
} else {
/* Schedule the next byte of the command to be sent */
- mm_serial_port_schedule_queue_process (self, priv->send_delay / 1000);
+ mm_port_serial_schedule_queue_process (self, priv->send_delay / 1000);
}
} else
- mm_serial_port_got_response (self, error);
+ mm_port_serial_got_response (self, error);
return FALSE;
}
static gboolean
-parse_response (MMSerialPort *self,
+parse_response (MMPortSerial *self,
GByteArray *response,
GError **error)
{
- if (MM_SERIAL_PORT_GET_CLASS (self)->parse_unsolicited)
- MM_SERIAL_PORT_GET_CLASS (self)->parse_unsolicited (self, response);
+ if (MM_PORT_SERIAL_GET_CLASS (self)->parse_unsolicited)
+ MM_PORT_SERIAL_GET_CLASS (self)->parse_unsolicited (self, response);
- g_return_val_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->parse_response, FALSE);
- return MM_SERIAL_PORT_GET_CLASS (self)->parse_response (self, response, error);
+ g_return_val_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->parse_response, FALSE);
+ return MM_PORT_SERIAL_GET_CLASS (self)->parse_response (self, response, error);
}
static gboolean
@@ -739,8 +739,8 @@ data_available (GIOChannel *source,
GIOCondition condition,
gpointer data)
{
- MMSerialPort *self = MM_SERIAL_PORT (data);
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerial *self = MM_PORT_SERIAL (data);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
char buf[SERIAL_BUF_SIZE + 1];
gsize bytes_read;
GIOStatus status;
@@ -753,7 +753,7 @@ data_available (GIOChannel *source,
if (priv->response->len)
g_byte_array_remove_range (priv->response, 0, priv->response->len);
- mm_serial_port_close_force (self);
+ mm_port_serial_close_force (self);
return FALSE;
}
@@ -800,7 +800,7 @@ data_available (GIOChannel *source,
if (parse_response (self, priv->response, &err)) {
/* Reset number of consecutive timeouts only here */
priv->n_consecutive_timeouts = 0;
- mm_serial_port_got_response (self, err);
+ mm_port_serial_got_response (self, err);
}
} while ( (bytes_read == SERIAL_BUF_SIZE || status == G_IO_STATUS_AGAIN)
&& (priv->watch_id > 0));
@@ -809,9 +809,9 @@ data_available (GIOChannel *source,
}
static void
-data_watch_enable (MMSerialPort *self, gboolean enable)
+data_watch_enable (MMPortSerial *self, gboolean enable)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
if (priv->watch_id) {
if (enable)
@@ -830,9 +830,9 @@ data_watch_enable (MMSerialPort *self, gboolean enable)
}
static void
-port_connected (MMSerialPort *self, GParamSpec *pspec, gpointer user_data)
+port_connected (MMPortSerial *self, GParamSpec *pspec, gpointer user_data)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
gboolean connected;
if (priv->fd < 0)
@@ -861,18 +861,18 @@ port_connected (MMSerialPort *self, GParamSpec *pspec, gpointer user_data)
}
gboolean
-mm_serial_port_open (MMSerialPort *self, GError **error)
+mm_port_serial_open (MMPortSerial *self, GError **error)
{
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
char *devfile;
const char *device;
struct serial_struct sinfo = { 0 };
GTimeVal tv_start, tv_end;
int errno_save = 0;
- g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
+ g_return_val_if_fail (MM_IS_PORT_SERIAL (self), FALSE);
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
device = mm_port_get_device (MM_PORT (self));
if (priv->forced_close) {
@@ -943,8 +943,8 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
goto error;
}
- g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->config_fd);
- if (!MM_SERIAL_PORT_GET_CLASS (self)->config_fd (self, priv->fd, error)) {
+ g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->config_fd);
+ if (!MM_PORT_SERIAL_GET_CLASS (self)->config_fd (self, priv->fd, error)) {
mm_dbg ("(%s) failed to configure serial device", device);
goto error;
}
@@ -978,8 +978,8 @@ success:
mm_dbg ("(%s) device open count is %d (open)", device, priv->open_count);
/* Run additional port config if just opened */
- if (priv->open_count == 1 && MM_SERIAL_PORT_GET_CLASS (self)->config)
- MM_SERIAL_PORT_GET_CLASS (self)->config (self);
+ if (priv->open_count == 1 && MM_PORT_SERIAL_GET_CLASS (self)->config)
+ MM_PORT_SERIAL_GET_CLASS (self)->config (self);
return TRUE;
@@ -991,24 +991,24 @@ error:
}
gboolean
-mm_serial_port_is_open (MMSerialPort *self)
+mm_port_serial_is_open (MMPortSerial *self)
{
g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
+ g_return_val_if_fail (MM_IS_PORT_SERIAL (self), FALSE);
- return !!MM_SERIAL_PORT_GET_PRIVATE (self)->open_count;
+ return !!MM_PORT_SERIAL_GET_PRIVATE (self)->open_count;
}
void
-mm_serial_port_close (MMSerialPort *self)
+mm_port_serial_close (MMPortSerial *self)
{
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
const char *device;
int i;
- g_return_if_fail (MM_IS_SERIAL_PORT (self));
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
/* If we forced closing the port, open_count will be 0 already.
* Just return without issuing any warning */
@@ -1031,7 +1031,7 @@ mm_serial_port_close (MMSerialPort *self)
priv->connected_id = 0;
}
- mm_serial_port_flash_cancel (self);
+ mm_port_serial_flash_cancel (self);
if (priv->fd >= 0) {
GTimeVal tv_start, tv_end;
@@ -1089,14 +1089,14 @@ mm_serial_port_close (MMSerialPort *self)
GError *error;
GByteArray *response;
- g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->handle_response != NULL);
+ g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->handle_response != NULL);
error = g_error_new_literal (MM_SERIAL_ERROR,
MM_SERIAL_ERROR_SEND_FAILED,
"Serial port is now closed");
response = g_byte_array_sized_new (1);
g_byte_array_append (response, (const guint8 *) "\0", 1);
- MM_SERIAL_PORT_GET_CLASS (self)->handle_response (self,
+ MM_PORT_SERIAL_GET_CLASS (self)->handle_response (self,
response,
error,
item->callback,
@@ -1132,14 +1132,14 @@ mm_serial_port_close (MMSerialPort *self)
}
static void
-mm_serial_port_close_force (MMSerialPort *self)
+mm_port_serial_close_force (MMPortSerial *self)
{
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
g_return_if_fail (self != NULL);
- g_return_if_fail (MM_IS_SERIAL_PORT (self));
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
/* If already forced to close, return */
if (priv->forced_close)
@@ -1153,7 +1153,7 @@ mm_serial_port_close_force (MMSerialPort *self)
/* Force the port to close */
priv->open_count = 1;
- mm_serial_port_close (self);
+ mm_port_serial_close (self);
/* Mark as having forced the close, so that we don't warn about incorrect
* open counts */
@@ -1164,7 +1164,7 @@ mm_serial_port_close_force (MMSerialPort *self)
}
static void
-internal_queue_command (MMSerialPort *self,
+internal_queue_command (MMPortSerial *self,
GByteArray *command,
gboolean take_command,
gboolean cached,
@@ -1173,10 +1173,10 @@ internal_queue_command (MMSerialPort *self,
MMSerialResponseFn callback,
gpointer user_data)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
MMQueueData *info;
- g_return_if_fail (MM_IS_SERIAL_PORT (self));
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
g_return_if_fail (command != NULL);
if (priv->open_count == 0) {
@@ -1211,16 +1211,16 @@ internal_queue_command (MMSerialPort *self,
/* Clear the cached value for this command if not asking for cached value */
if (!cached)
- mm_serial_port_set_cached_reply (self, info->command, NULL);
+ mm_port_serial_set_cached_reply (self, info->command, NULL);
g_queue_push_tail (priv->queue, info);
if (g_queue_get_length (priv->queue) == 1)
- mm_serial_port_schedule_queue_process (self, 0);
+ mm_port_serial_schedule_queue_process (self, 0);
}
void
-mm_serial_port_queue_command (MMSerialPort *self,
+mm_port_serial_queue_command (MMPortSerial *self,
GByteArray *command,
gboolean take_command,
guint32 timeout_seconds,
@@ -1232,7 +1232,7 @@ mm_serial_port_queue_command (MMSerialPort *self,
}
void
-mm_serial_port_queue_command_cached (MMSerialPort *self,
+mm_port_serial_queue_command_cached (MMPortSerial *self,
GByteArray *command,
gboolean take_command,
guint32 timeout_seconds,
@@ -1244,20 +1244,20 @@ mm_serial_port_queue_command_cached (MMSerialPort *self,
}
typedef struct {
- MMSerialPort *port;
+ MMPortSerial *port;
guint initial_open_count;
MMSerialReopenFn callback;
gpointer user_data;
} ReopenInfo;
static void
-serial_port_reopen_cancel (MMSerialPort *self)
+port_serial_reopen_cancel (MMPortSerial *self)
{
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
- g_return_if_fail (MM_IS_SERIAL_PORT (self));
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
if (priv->reopen_id > 0) {
g_source_remove (priv->reopen_id);
@@ -1269,14 +1269,14 @@ static gboolean
reopen_do (gpointer data)
{
ReopenInfo *info = (ReopenInfo *) data;
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (info->port);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (info->port);
GError *error = NULL;
guint i;
priv->reopen_id = 0;
for (i = 0; i < info->initial_open_count; i++) {
- if (!mm_serial_port_open (info->port, &error)) {
+ if (!mm_port_serial_open (info->port, &error)) {
g_prefix_error (&error, "Couldn't reopen port (%u): ", i);
break;
}
@@ -1290,17 +1290,17 @@ reopen_do (gpointer data)
}
gboolean
-mm_serial_port_reopen (MMSerialPort *self,
+mm_port_serial_reopen (MMPortSerial *self,
guint32 reopen_time,
MMSerialReopenFn callback,
gpointer user_data)
{
ReopenInfo *info;
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
guint i;
- g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ g_return_val_if_fail (MM_IS_PORT_SERIAL (self), FALSE);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
if (priv->forced_close) {
GError *error;
@@ -1329,7 +1329,7 @@ mm_serial_port_reopen (MMSerialPort *self,
info->callback = callback;
info->user_data = user_data;
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
info->initial_open_count = priv->open_count;
mm_dbg ("(%s) reopening port (%u)",
@@ -1337,7 +1337,7 @@ mm_serial_port_reopen (MMSerialPort *self,
info->initial_open_count);
for (i = 0; i < info->initial_open_count; i++)
- mm_serial_port_close (self);
+ mm_port_serial_close (self);
if (reopen_time > 0)
priv->reopen_id = g_timeout_add (reopen_time, reopen_do, info);
@@ -1348,12 +1348,12 @@ mm_serial_port_reopen (MMSerialPort *self,
}
static gboolean
-get_speed (MMSerialPort *self, speed_t *speed, GError **error)
+get_speed (MMPortSerial *self, speed_t *speed, GError **error)
{
struct termios options;
memset (&options, 0, sizeof (struct termios));
- if (tcgetattr (MM_SERIAL_PORT_GET_PRIVATE (self)->fd, &options) != 0) {
+ if (tcgetattr (MM_PORT_SERIAL_GET_PRIVATE (self)->fd, &options) != 0) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
@@ -1367,14 +1367,14 @@ get_speed (MMSerialPort *self, speed_t *speed, GError **error)
}
static gboolean
-set_speed (MMSerialPort *self, speed_t speed, GError **error)
+set_speed (MMPortSerial *self, speed_t speed, GError **error)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
struct termios options;
int fd, count = 4;
gboolean success = FALSE;
- fd = MM_SERIAL_PORT_GET_PRIVATE (self)->fd;
+ fd = MM_PORT_SERIAL_GET_PRIVATE (self)->fd;
memset (&options, 0, sizeof (struct termios));
if (tcgetattr (fd, &options) != 0) {
@@ -1427,7 +1427,7 @@ set_speed (MMSerialPort *self, speed_t speed, GError **error)
}
typedef struct {
- MMSerialPort *port;
+ MMPortSerial *port;
speed_t current_speed;
MMSerialFlashFn callback;
gpointer user_data;
@@ -1437,7 +1437,7 @@ static gboolean
flash_do (gpointer data)
{
FlashInfo *info = (FlashInfo *) data;
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (info->port);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (info->port);
GError *error = NULL;
priv->flash_id = 0;
@@ -1460,23 +1460,23 @@ flash_do (gpointer data)
}
gboolean
-mm_serial_port_flash (MMSerialPort *self,
+mm_port_serial_flash (MMPortSerial *self,
guint32 flash_time,
gboolean ignore_errors,
MMSerialFlashFn callback,
gpointer user_data)
{
FlashInfo *info = NULL;
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
GError *error = NULL;
gboolean success;
- g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
+ g_return_val_if_fail (MM_IS_PORT_SERIAL (self), FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
- if (!mm_serial_port_is_open (self)) {
+ if (!mm_port_serial_is_open (self)) {
error = g_error_new_literal (MM_SERIAL_ERROR,
MM_SERIAL_ERROR_NOT_OPEN,
"The serial port is not open.");
@@ -1522,13 +1522,13 @@ error:
}
void
-mm_serial_port_flash_cancel (MMSerialPort *self)
+mm_port_serial_flash_cancel (MMPortSerial *self)
{
- MMSerialPortPrivate *priv;
+ MMPortSerialPrivate *priv;
- g_return_if_fail (MM_IS_SERIAL_PORT (self));
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
- priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ priv = MM_PORT_SERIAL_GET_PRIVATE (self);
if (priv->flash_id > 0) {
g_source_remove (priv->flash_id);
@@ -1537,19 +1537,19 @@ mm_serial_port_flash_cancel (MMSerialPort *self)
}
gboolean
-mm_serial_port_get_flash_ok (MMSerialPort *self)
+mm_port_serial_get_flash_ok (MMPortSerial *self)
{
- g_return_val_if_fail (MM_IS_SERIAL_PORT (self), TRUE);
+ g_return_val_if_fail (MM_IS_PORT_SERIAL (self), TRUE);
- return MM_SERIAL_PORT_GET_PRIVATE (self)->flash_ok;
+ return MM_PORT_SERIAL_GET_PRIVATE (self)->flash_ok;
}
/*****************************************************************************/
-MMSerialPort *
-mm_serial_port_new (const char *name, MMPortType ptype)
+MMPortSerial *
+mm_port_serial_new (const char *name, MMPortType ptype)
{
- return MM_SERIAL_PORT (g_object_new (MM_TYPE_SERIAL_PORT,
+ return MM_PORT_SERIAL (g_object_new (MM_TYPE_PORT_SERIAL,
MM_PORT_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY,
MM_PORT_TYPE, ptype,
@@ -1599,9 +1599,9 @@ ba_free (gpointer v)
}
static void
-mm_serial_port_init (MMSerialPort *self)
+mm_port_serial_init (MMPortSerial *self)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
priv->reply_cache = g_hash_table_new_full (ba_hash, ba_equal, ba_free, ba_free);
@@ -1620,7 +1620,7 @@ static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (object);
switch (prop_id) {
case PROP_FD:
@@ -1660,7 +1660,7 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (object);
switch (prop_id) {
case PROP_FD:
@@ -1699,40 +1699,40 @@ get_property (GObject *object, guint prop_id,
static void
dispose (GObject *object)
{
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (object);
if (priv->timeout_id) {
g_source_remove (priv->timeout_id);
priv->timeout_id = 0;
}
- mm_serial_port_close_force (MM_SERIAL_PORT (object));
+ mm_port_serial_close_force (MM_PORT_SERIAL (object));
- serial_port_reopen_cancel (MM_SERIAL_PORT (object));
- mm_serial_port_flash_cancel (MM_SERIAL_PORT (object));
+ port_serial_reopen_cancel (MM_PORT_SERIAL (object));
+ mm_port_serial_flash_cancel (MM_PORT_SERIAL (object));
- G_OBJECT_CLASS (mm_serial_port_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_port_serial_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
- MMSerialPort *self = MM_SERIAL_PORT (object);
- MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
+ MMPortSerial *self = MM_PORT_SERIAL (object);
+ MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
g_hash_table_destroy (priv->reply_cache);
g_byte_array_free (priv->response, TRUE);
g_queue_free (priv->queue);
- G_OBJECT_CLASS (mm_serial_port_parent_class)->finalize (object);
+ G_OBJECT_CLASS (mm_port_serial_parent_class)->finalize (object);
}
static void
-mm_serial_port_class_init (MMSerialPortClass *klass)
+mm_port_serial_class_init (MMPortSerialClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (object_class, sizeof (MMSerialPortPrivate));
+ g_type_class_add_private (object_class, sizeof (MMPortSerialPrivate));
/* Virtual methods */
object_class->set_property = set_property;
@@ -1746,7 +1746,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
/* Properties */
g_object_class_install_property
(object_class, PROP_FD,
- g_param_spec_int (MM_SERIAL_PORT_FD,
+ g_param_spec_int (MM_PORT_SERIAL_FD,
"File descriptor",
"File descriptor",
-1, G_MAXINT, -1,
@@ -1754,7 +1754,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_BAUD,
- g_param_spec_uint (MM_SERIAL_PORT_BAUD,
+ g_param_spec_uint (MM_PORT_SERIAL_BAUD,
"Baud",
"Baud rate",
0, G_MAXUINT, 57600,
@@ -1762,7 +1762,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_BITS,
- g_param_spec_uint (MM_SERIAL_PORT_BITS,
+ g_param_spec_uint (MM_PORT_SERIAL_BITS,
"Bits",
"Bits",
5, 8, 8,
@@ -1770,7 +1770,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_PARITY,
- g_param_spec_char (MM_SERIAL_PORT_PARITY,
+ g_param_spec_char (MM_PORT_SERIAL_PARITY,
"Parity",
"Parity",
'E', 'o', 'n',
@@ -1778,7 +1778,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_STOPBITS,
- g_param_spec_uint (MM_SERIAL_PORT_STOPBITS,
+ g_param_spec_uint (MM_PORT_SERIAL_STOPBITS,
"Stopbits",
"Stopbits",
1, 2, 1,
@@ -1786,7 +1786,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_SEND_DELAY,
- g_param_spec_uint64 (MM_SERIAL_PORT_SEND_DELAY,
+ g_param_spec_uint64 (MM_PORT_SERIAL_SEND_DELAY,
"SendDelay",
"Send delay for each byte in microseconds",
0, G_MAXUINT64, 0,
@@ -1794,7 +1794,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_SPEW_CONTROL,
- g_param_spec_boolean (MM_SERIAL_PORT_SPEW_CONTROL,
+ g_param_spec_boolean (MM_PORT_SERIAL_SPEW_CONTROL,
"SpewControl",
"Spew control",
FALSE,
@@ -1802,7 +1802,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_RTS_CTS,
- g_param_spec_boolean (MM_SERIAL_PORT_RTS_CTS,
+ g_param_spec_boolean (MM_PORT_SERIAL_RTS_CTS,
"RTSCTS",
"Enable RTS/CTS flow control",
FALSE,
@@ -1810,7 +1810,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property
(object_class, PROP_FLASH_OK,
- g_param_spec_boolean (MM_SERIAL_PORT_FLASH_OK,
+ g_param_spec_boolean (MM_PORT_SERIAL_FLASH_OK,
"FlashOk",
"Flashing the port (0 baud for a short period) "
"is allowed.",
@@ -1822,7 +1822,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_signal_new ("buffer-full",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (MMSerialPortClass, buffer_full),
+ G_STRUCT_OFFSET (MMPortSerialClass, buffer_full),
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 1, G_TYPE_POINTER);
@@ -1831,7 +1831,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_signal_new ("timed-out",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (MMSerialPortClass, timed_out),
+ G_STRUCT_OFFSET (MMPortSerialClass, timed_out),
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 1, G_TYPE_UINT);
@@ -1840,7 +1840,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_signal_new ("forced-close",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (MMSerialPortClass, forced_close),
+ G_STRUCT_OFFSET (MMPortSerialClass, forced_close),
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 0);
diff --git a/src/mm-serial-port.h b/src/mm-port-serial.h
index 73e55d9f..6b124723 100644
--- a/src/mm-serial-port.h
+++ b/src/mm-port-serial.h
@@ -14,8 +14,8 @@
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
-#ifndef MM_SERIAL_PORT_H
-#define MM_SERIAL_PORT_H
+#ifndef MM_PORT_SERIAL_H
+#define MM_PORT_SERIAL_H
#include <glib.h>
#include <glib-object.h>
@@ -23,52 +23,52 @@
#include "mm-port.h"
-#define MM_TYPE_SERIAL_PORT (mm_serial_port_get_type ())
-#define MM_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SERIAL_PORT, MMSerialPort))
-#define MM_SERIAL_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SERIAL_PORT, MMSerialPortClass))
-#define MM_IS_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SERIAL_PORT))
-#define MM_IS_SERIAL_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SERIAL_PORT))
-#define MM_SERIAL_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SERIAL_PORT, MMSerialPortClass))
-
-#define MM_SERIAL_PORT_BAUD "baud"
-#define MM_SERIAL_PORT_BITS "bits"
-#define MM_SERIAL_PORT_PARITY "parity"
-#define MM_SERIAL_PORT_STOPBITS "stopbits"
-#define MM_SERIAL_PORT_SEND_DELAY "send-delay"
-#define MM_SERIAL_PORT_RTS_CTS "rts-cts"
-#define MM_SERIAL_PORT_FD "fd" /* Construct-only */
-#define MM_SERIAL_PORT_SPEW_CONTROL "spew-control" /* Construct-only */
-#define MM_SERIAL_PORT_FLASH_OK "flash-ok" /* Construct-only */
-
-typedef struct _MMSerialPort MMSerialPort;
-typedef struct _MMSerialPortClass MMSerialPortClass;
-
-typedef void (*MMSerialReopenFn) (MMSerialPort *port,
+#define MM_TYPE_PORT_SERIAL (mm_port_serial_get_type ())
+#define MM_PORT_SERIAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PORT_SERIAL, MMPortSerial))
+#define MM_PORT_SERIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PORT_SERIAL, MMPortSerialClass))
+#define MM_IS_PORT_SERIAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PORT_SERIAL))
+#define MM_IS_PORT_SERIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PORT_SERIAL))
+#define MM_PORT_SERIAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PORT_SERIAL, MMPortSerialClass))
+
+#define MM_PORT_SERIAL_BAUD "baud"
+#define MM_PORT_SERIAL_BITS "bits"
+#define MM_PORT_SERIAL_PARITY "parity"
+#define MM_PORT_SERIAL_STOPBITS "stopbits"
+#define MM_PORT_SERIAL_SEND_DELAY "send-delay"
+#define MM_PORT_SERIAL_RTS_CTS "rts-cts"
+#define MM_PORT_SERIAL_FD "fd" /* Construct-only */
+#define MM_PORT_SERIAL_SPEW_CONTROL "spew-control" /* Construct-only */
+#define MM_PORT_SERIAL_FLASH_OK "flash-ok" /* Construct-only */
+
+typedef struct _MMPortSerial MMPortSerial;
+typedef struct _MMPortSerialClass MMPortSerialClass;
+
+typedef void (*MMSerialReopenFn) (MMPortSerial *port,
GError *error,
gpointer user_data);
-typedef void (*MMSerialFlashFn) (MMSerialPort *port,
+typedef void (*MMSerialFlashFn) (MMPortSerial *port,
GError *error,
gpointer user_data);
-typedef void (*MMSerialResponseFn) (MMSerialPort *port,
+typedef void (*MMSerialResponseFn) (MMPortSerial *port,
GByteArray *response,
GError *error,
gpointer user_data);
-struct _MMSerialPort {
+struct _MMPortSerial {
MMPort parent;
};
-struct _MMSerialPortClass {
+struct _MMPortSerialClass {
MMPortClass parent;
/* Called for subclasses to parse unsolicited responses. If any recognized
* unsolicited response is found, it should be removed from the 'response'
* byte array before returning.
*/
- void (*parse_unsolicited) (MMSerialPort *self, GByteArray *response);
+ void (*parse_unsolicited) (MMPortSerial *self, GByteArray *response);
/* Called to parse the device's response to a command or determine if the
* response was an error response. If the response indicates an error, an
@@ -77,7 +77,7 @@ struct _MMSerialPortClass {
* the device's reply (whether success *or* error), and should return TRUE
* when the device's response has been recognized and parsed.
*/
- gboolean (*parse_response) (MMSerialPort *self,
+ gboolean (*parse_response) (MMPortSerial *self,
GByteArray *response,
GError **error);
@@ -85,7 +85,7 @@ struct _MMSerialPortClass {
* it's callback to be handled. Returns the # of bytes of the response
* consumed.
*/
- gsize (*handle_response) (MMSerialPort *self,
+ gsize (*handle_response) (MMPortSerial *self,
GByteArray *response,
GError *error,
GCallback callback,
@@ -94,54 +94,54 @@ struct _MMSerialPortClass {
/* Called to configure the serial port fd after it's opened. On error, should
* return FALSE and set 'error' as appropriate.
*/
- gboolean (*config_fd) (MMSerialPort *self, int fd, GError **error);
+ gboolean (*config_fd) (MMPortSerial *self, int fd, GError **error);
/* Called to configure the serial port after it's opened. Errors, if any,
* should get ignored. */
- void (*config) (MMSerialPort *self);
+ void (*config) (MMPortSerial *self);
- void (*debug_log) (MMSerialPort *self,
+ void (*debug_log) (MMPortSerial *self,
const char *prefix,
const char *buf,
gsize len);
/* Signals */
- void (*buffer_full) (MMSerialPort *port, const GByteArray *buffer);
- void (*timed_out) (MMSerialPort *port, guint n_consecutive_replies);
- void (*forced_close) (MMSerialPort *port);
+ void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
+ void (*timed_out) (MMPortSerial *port, guint n_consecutive_replies);
+ void (*forced_close) (MMPortSerial *port);
};
-GType mm_serial_port_get_type (void);
+GType mm_port_serial_get_type (void);
-MMSerialPort *mm_serial_port_new (const char *name, MMPortType ptype);
+MMPortSerial *mm_port_serial_new (const char *name, MMPortType ptype);
/* Keep in mind that port open/close is refcounted, so ensure that
* open/close calls are properly balanced.
*/
-gboolean mm_serial_port_is_open (MMSerialPort *self);
+gboolean mm_port_serial_is_open (MMPortSerial *self);
-gboolean mm_serial_port_open (MMSerialPort *self,
+gboolean mm_port_serial_open (MMPortSerial *self,
GError **error);
-void mm_serial_port_close (MMSerialPort *self);
+void mm_port_serial_close (MMPortSerial *self);
-gboolean mm_serial_port_reopen (MMSerialPort *self,
+gboolean mm_port_serial_reopen (MMPortSerial *self,
guint32 reopen_time,
MMSerialReopenFn callback,
gpointer user_data);
-gboolean mm_serial_port_flash (MMSerialPort *self,
+gboolean mm_port_serial_flash (MMPortSerial *self,
guint32 flash_time,
gboolean ignore_errors,
MMSerialFlashFn callback,
gpointer user_data);
-void mm_serial_port_flash_cancel (MMSerialPort *self);
+void mm_port_serial_flash_cancel (MMPortSerial *self);
-gboolean mm_serial_port_get_flash_ok (MMSerialPort *self);
+gboolean mm_port_serial_get_flash_ok (MMPortSerial *self);
-void mm_serial_port_queue_command (MMSerialPort *self,
+void mm_port_serial_queue_command (MMPortSerial *self,
GByteArray *command,
gboolean take_command,
guint32 timeout_seconds,
@@ -149,7 +149,7 @@ void mm_serial_port_queue_command (MMSerialPort *self,
MMSerialResponseFn callback,
gpointer user_data);
-void mm_serial_port_queue_command_cached (MMSerialPort *self,
+void mm_port_serial_queue_command_cached (MMPortSerial *self,
GByteArray *command,
gboolean take_command,
guint32 timeout_seconds,
@@ -157,4 +157,4 @@ void mm_serial_port_queue_command_cached (MMSerialPort *self,
MMSerialResponseFn callback,
gpointer user_data);
-#endif /* MM_SERIAL_PORT_H */
+#endif /* MM_PORT_SERIAL_H */
diff --git a/src/mm-qcdm-serial-port.c b/src/mm-qcdm-serial-port.c
index 5df7d1e4..8eef7f17 100644
--- a/src/mm-qcdm-serial-port.c
+++ b/src/mm-qcdm-serial-port.c
@@ -28,7 +28,7 @@
#include "libqcdm/src/errors.h"
#include "mm-log.h"
-G_DEFINE_TYPE (MMQcdmSerialPort, mm_qcdm_serial_port, MM_TYPE_SERIAL_PORT)
+G_DEFINE_TYPE (MMQcdmSerialPort, mm_qcdm_serial_port, MM_TYPE_PORT_SERIAL)
#define MM_QCDM_SERIAL_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_QCDM_SERIAL_PORT, MMQcdmSerialPortPrivate))
@@ -67,13 +67,13 @@ find_qcdm_start (GByteArray *response, gsize *start)
}
static gboolean
-parse_response (MMSerialPort *port, GByteArray *response, GError **error)
+parse_response (MMPortSerial *port, GByteArray *response, GError **error)
{
return find_qcdm_start (response, NULL);
}
static gsize
-handle_response (MMSerialPort *port,
+handle_response (MMPortSerial *port,
GByteArray *response,
GError *error,
GCallback callback,
@@ -157,7 +157,7 @@ mm_qcdm_serial_port_queue_command (MMQcdmSerialPort *self,
g_return_if_fail (command != NULL);
/* 'command' is expected to be already CRC-ed and escaped */
- mm_serial_port_queue_command (MM_SERIAL_PORT (self),
+ mm_port_serial_queue_command (MM_PORT_SERIAL (self),
command,
TRUE,
timeout_seconds,
@@ -179,7 +179,7 @@ mm_qcdm_serial_port_queue_command_cached (MMQcdmSerialPort *self,
g_return_if_fail (command != NULL);
/* 'command' is expected to be already CRC-ed and escaped */
- mm_serial_port_queue_command_cached (MM_SERIAL_PORT (self),
+ mm_port_serial_queue_command_cached (MM_PORT_SERIAL (self),
command,
TRUE,
timeout_seconds,
@@ -189,7 +189,7 @@ mm_qcdm_serial_port_queue_command_cached (MMQcdmSerialPort *self,
}
static void
-debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
+debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
{
static GString *debug = NULL;
const char *s = buf;
@@ -209,7 +209,7 @@ debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
/*****************************************************************************/
static gboolean
-config_fd (MMSerialPort *port, int fd, GError **error)
+config_fd (MMPortSerial *port, int fd, GError **error)
{
int err;
@@ -231,7 +231,7 @@ mm_qcdm_serial_port_new (const char *name)
MM_PORT_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY,
MM_PORT_TYPE, MM_PORT_TYPE_QCDM,
- MM_SERIAL_PORT_SEND_DELAY, (guint64) 0,
+ MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
NULL));
}
@@ -246,8 +246,8 @@ mm_qcdm_serial_port_new_fd (int fd)
MM_PORT_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY,
MM_PORT_TYPE, MM_PORT_TYPE_QCDM,
- MM_SERIAL_PORT_FD, fd,
- MM_SERIAL_PORT_SEND_DELAY, (guint64) 0,
+ MM_PORT_SERIAL_FD, fd,
+ MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
NULL));
g_free (name);
return port;
@@ -268,7 +268,7 @@ static void
mm_qcdm_serial_port_class_init (MMQcdmSerialPortClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- MMSerialPortClass *port_class = MM_SERIAL_PORT_CLASS (klass);
+ MMPortSerialClass *port_class = MM_PORT_SERIAL_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMQcdmSerialPortPrivate));
diff --git a/src/mm-qcdm-serial-port.h b/src/mm-qcdm-serial-port.h
index b8e858bd..ad552e75 100644
--- a/src/mm-qcdm-serial-port.h
+++ b/src/mm-qcdm-serial-port.h
@@ -20,7 +20,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "mm-serial-port.h"
+#include "mm-port-serial.h"
#define MM_TYPE_QCDM_SERIAL_PORT (mm_qcdm_serial_port_get_type ())
#define MM_QCDM_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_QCDM_SERIAL_PORT, MMQcdmSerialPort))
@@ -38,11 +38,11 @@ typedef void (*MMQcdmSerialResponseFn) (MMQcdmSerialPort *port,
gpointer user_data);
struct _MMQcdmSerialPort {
- MMSerialPort parent;
+ MMPortSerial parent;
};
struct _MMQcdmSerialPortClass {
- MMSerialPortClass parent;
+ MMPortSerialClass parent;
};
GType mm_qcdm_serial_port_get_type (void);
diff --git a/src/tests/test-qcdm-serial-port.c b/src/tests/test-qcdm-serial-port.c
index 1875cb5d..5fa9719f 100644
--- a/src/tests/test-qcdm-serial-port.c
+++ b/src/tests/test-qcdm-serial-port.c
@@ -220,14 +220,14 @@ qcdm_test_child (int fd, VerInfoCb cb)
port = mm_qcdm_serial_port_new_fd (fd);
g_assert (port);
- success = mm_serial_port_open (MM_SERIAL_PORT (port), &error);
+ success = mm_port_serial_open (MM_PORT_SERIAL (port), &error);
g_assert_no_error (error);
g_assert (success);
qcdm_request_verinfo (port, cb, loop);
g_main_loop_run (loop);
- mm_serial_port_close (MM_SERIAL_PORT (port));
+ mm_port_serial_close (MM_PORT_SERIAL (port));
g_object_unref (port);
}