ports: rename 'MMSerialPort' to 'MMPortSerial'

This commit is contained in:
Aleksander Morgado
2013-11-20 15:28:34 +01:00
parent c9e2b46b21
commit 9cde02111b
22 changed files with 306 additions and 304 deletions

View File

@@ -1378,7 +1378,7 @@ setup_ports (MMBroadbandModem *self)
return; return;
g_object_set (primary, g_object_set (primary,
MM_SERIAL_PORT_SEND_DELAY, (guint64) 0, MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
MM_AT_SERIAL_PORT_SEND_LF, TRUE, MM_AT_SERIAL_PORT_SEND_LF, TRUE,
MM_AT_SERIAL_PORT_INIT_SEQUENCE, primary_init_sequence, MM_AT_SERIAL_PORT_INIT_SEQUENCE, primary_init_sequence,
NULL); NULL);

View File

@@ -640,7 +640,7 @@ connect_cancelled_cb (GCancellable *cancellable,
} }
static void static void
forced_close_cb (MMSerialPort *port, forced_close_cb (MMPortSerial *port,
MMBroadbandBearerIcera *self) MMBroadbandBearerIcera *self)
{ {
/* Just treat the forced close event as any other unsolicited message */ /* Just treat the forced close event as any other unsolicited message */

View File

@@ -343,7 +343,7 @@ setup_ports (MMBroadbandModem *self)
return; return;
g_object_set (G_OBJECT (primary), g_object_set (G_OBJECT (primary),
MM_SERIAL_PORT_BAUD, 9600, MM_PORT_SERIAL_BAUD, 9600,
MM_AT_SERIAL_PORT_INIT_SEQUENCE, primary_init_sequence, MM_AT_SERIAL_PORT_INIT_SEQUENCE, primary_init_sequence,
NULL); NULL);
} }

View File

@@ -1209,7 +1209,9 @@ setup_ports (MMBroadbandModem *_self)
* command mode. F5521gw R2A07 resets port properties like echo when * command mode. F5521gw R2A07 resets port properties like echo when
* flashed, leading to confusion. bgo #650740 * flashed, leading to confusion. bgo #650740
*/ */
g_object_set (G_OBJECT (ports[i]), MM_SERIAL_PORT_FLASH_OK, FALSE, NULL); g_object_set (G_OBJECT (ports[i]),
MM_PORT_SERIAL_FLASH_OK, FALSE,
NULL);
mm_at_serial_port_add_unsolicited_msg_handler ( mm_at_serial_port_add_unsolicited_msg_handler (
ports[i], ports[i],

View File

@@ -462,7 +462,7 @@ connect_cancelled_cb (GCancellable *cancellable,
} }
static void static void
forced_close_cb (MMSerialPort *port, forced_close_cb (MMPortSerial *port,
MMBroadbandBearerHso *self) MMBroadbandBearerHso *self)
{ {
/* Just treat the forced close event as any other unsolicited message */ /* Just treat the forced close event as any other unsolicited message */

View File

@@ -474,7 +474,7 @@ gps_disabled_ready (MMBaseModem *self,
/* Even if we get an error here, we try to close the GPS port */ /* Even if we get an error here, we try to close the GPS port */
gps_port = mm_base_modem_peek_port_gps (self); gps_port = mm_base_modem_peek_port_gps (self);
if (gps_port) if (gps_port)
mm_serial_port_close (MM_SERIAL_PORT (gps_port)); mm_port_serial_close (MM_PORT_SERIAL (gps_port));
g_simple_async_result_complete (simple); g_simple_async_result_complete (simple);
g_object_unref (simple); g_object_unref (simple);
@@ -567,7 +567,7 @@ gps_enabled_ready (MMBaseModem *self,
gps_port = mm_base_modem_peek_port_gps (self); gps_port = mm_base_modem_peek_port_gps (self);
if (!gps_port || if (!gps_port ||
!mm_serial_port_open (MM_SERIAL_PORT (gps_port), &error)) { !mm_port_serial_open (MM_PORT_SERIAL (gps_port), &error)) {
if (error) if (error)
g_simple_async_result_take_error (ctx->result, error); g_simple_async_result_take_error (ctx->result, error);
else else
@@ -698,7 +698,7 @@ setup_ports (MMBroadbandModem *self)
NULL, NULL, NULL); NULL, NULL, NULL);
g_object_set (mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), g_object_set (mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
MM_SERIAL_PORT_SEND_DELAY, (guint64) 0, MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
/* built-in echo removal conflicts with unsolicited _OWANCALL /* built-in echo removal conflicts with unsolicited _OWANCALL
* messages, which are not <CR><LF> prefixed. */ * messages, which are not <CR><LF> prefixed. */
MM_AT_SERIAL_PORT_REMOVE_ECHO, FALSE, MM_AT_SERIAL_PORT_REMOVE_ECHO, FALSE,

View File

@@ -53,7 +53,7 @@ setup_ports (MMBroadbandModem *self)
continue; continue;
g_object_set (ports[i], g_object_set (ports[i],
MM_SERIAL_PORT_SEND_DELAY, (guint64) 0, MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
NULL); NULL);
} }
} }

View File

@@ -86,8 +86,8 @@ nodist_libserial_la_SOURCES = \
libserial_la_SOURCES = \ libserial_la_SOURCES = \
mm-port.c \ mm-port.c \
mm-port.h \ mm-port.h \
mm-serial-port.c \ mm-port-serial.c \
mm-serial-port.h \ mm-port-serial.h \
mm-at-serial-port.c \ mm-at-serial-port.c \
mm-at-serial-port.h \ mm-at-serial-port.h \
mm-qcdm-serial-port.c \ mm-qcdm-serial-port.c \

View File

@@ -24,7 +24,7 @@
#include "mm-at-serial-port.h" #include "mm-at-serial-port.h"
#include "mm-log.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)) #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 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); MMAtSerialPort *self = MM_AT_SERIAL_PORT (port);
MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self); MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self);
@@ -152,7 +152,7 @@ parse_response (MMSerialPort *port, GByteArray *response, GError **error)
} }
static gsize static gsize
handle_response (MMSerialPort *port, handle_response (MMPortSerial *port,
GByteArray *response, GByteArray *response,
GError *error, GError *error,
GCallback callback, GCallback callback,
@@ -264,7 +264,7 @@ remove_eval_cb (const GMatchInfo *match_info,
} }
static void static void
parse_unsolicited (MMSerialPort *port, GByteArray *response) parse_unsolicited (MMPortSerial *port, GByteArray *response)
{ {
MMAtSerialPort *self = MM_AT_SERIAL_PORT (port); MMAtSerialPort *self = MM_AT_SERIAL_PORT (port);
MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self); 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); buf = at_command_to_byte_array (command, is_raw, priv->send_lf);
g_return_if_fail (buf != NULL); 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, buf,
TRUE, TRUE,
timeout_seconds, 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); buf = at_command_to_byte_array (command, is_raw, priv->send_lf);
g_return_if_fail (buf != NULL); 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, buf,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
@@ -407,7 +407,7 @@ mm_at_serial_port_queue_command_cached (MMAtSerialPort *self,
} }
static void 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; static GString *debug = NULL;
const char *s; const char *s;
@@ -485,7 +485,7 @@ mm_at_serial_port_run_init_sequence (MMAtSerialPort *self)
} }
static void static void
config (MMSerialPort *self) config (MMPortSerial *self)
{ {
MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self); MMAtSerialPortPrivate *priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self);
@@ -600,7 +600,7 @@ static void
mm_at_serial_port_class_init (MMAtSerialPortClass *klass) mm_at_serial_port_class_init (MMAtSerialPortClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); 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->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
port_class->parse_unsolicited = parse_unsolicited; serial_class->parse_unsolicited = parse_unsolicited;
port_class->parse_response = parse_response; serial_class->parse_response = parse_response;
port_class->handle_response = handle_response; serial_class->handle_response = handle_response;
port_class->debug_log = debug_log; serial_class->debug_log = debug_log;
port_class->config = config; serial_class->config = config;
g_object_class_install_property g_object_class_install_property
(object_class, PROP_REMOVE_ECHO, (object_class, PROP_REMOVE_ECHO,

View File

@@ -20,7 +20,7 @@
#include <glib.h> #include <glib.h>
#include <glib-object.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_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)) #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" #define MM_AT_SERIAL_PORT_SEND_LF "send-lf"
struct _MMAtSerialPort { struct _MMAtSerialPort {
MMSerialPort parent; MMPortSerial parent;
}; };
struct _MMAtSerialPortClass { struct _MMAtSerialPortClass {
MMSerialPortClass parent; MMPortSerialClass parent;
}; };
GType mm_at_serial_port_get_type (void); GType mm_at_serial_port_get_type (void);

View File

@@ -60,7 +60,7 @@ abort_async_if_port_unusable (MMBaseModem *self,
g_object_set (port, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE, NULL); g_object_set (port, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE, NULL);
/* Ensure we have a port open during the sequence */ /* 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_simple_async_report_error_in_idle (
G_OBJECT (self), G_OBJECT (self),
callback, callback,
@@ -107,7 +107,7 @@ typedef struct {
static void static void
at_sequence_context_free (AtSequenceContext *ctx) 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->port);
g_object_unref (ctx->self); g_object_unref (ctx->self);
@@ -442,7 +442,7 @@ typedef struct {
static void static void
at_command_context_free (AtCommandContext *ctx) 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) if (ctx->cancelled_id)
g_cancellable_disconnect (ctx->modem_cancellable, g_cancellable_disconnect (ctx->modem_cancellable,

View File

@@ -138,7 +138,7 @@ mm_base_modem_owns_port (MMBaseModem *self,
} }
static void static void
serial_port_timed_out_cb (MMSerialPort *port, serial_port_timed_out_cb (MMPortSerial *port,
guint n_consecutive_timeouts, guint n_consecutive_timeouts,
gpointer user_data) gpointer user_data)
{ {

View File

@@ -111,7 +111,7 @@ detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
g_object_unref (ctx->secondary); g_object_unref (ctx->secondary);
if (ctx->data) { if (ctx->data) {
if (ctx->close_data_on_exit) 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->data);
} }
g_object_unref (ctx->self); g_object_unref (ctx->self);
@@ -206,7 +206,7 @@ common_get_at_data_port (MMBaseModem *modem,
g_assert (MM_IS_AT_SERIAL_PORT (data)); 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."); g_prefix_error (error, "Couldn't connect: cannot keep data port open.");
return NULL; return NULL;
} }
@@ -516,7 +516,7 @@ extended_error_ready (MMBaseModem *modem,
const gchar *result; const gchar *result;
/* Close the dialling port as we got an error */ /* 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 cancelled, complete */
if (dial_3gpp_context_complete_and_free_if_cancelled (ctx)) if (dial_3gpp_context_complete_and_free_if_cancelled (ctx))
@@ -1326,13 +1326,13 @@ detailed_disconnect_context_new (MMBroadbandBearer *self,
/* CDMA disconnect */ /* CDMA disconnect */
static void static void
data_flash_cdma_ready (MMSerialPort *data, data_flash_cdma_ready (MMPortSerial *data,
GError *error, GError *error,
DetailedDisconnectContext *ctx) DetailedDisconnectContext *ctx)
{ {
/* We kept the serial port open during connection, now we close that open /* We kept the serial port open during connection, now we close that open
* count */ * count */
mm_serial_port_close (data); mm_port_serial_close (data);
/* Port is disconnected; update the state */ /* Port is disconnected; update the state */
mm_port_set_connected (MM_PORT (data), FALSE); mm_port_set_connected (MM_PORT (data), FALSE);
@@ -1361,7 +1361,7 @@ data_flash_cdma_ready (MMSerialPort *data,
} }
static void static void
data_reopen_cdma_ready (MMSerialPort *data, data_reopen_cdma_ready (MMPortSerial *data,
GError *error, GError *error,
DetailedDisconnectContext *ctx) DetailedDisconnectContext *ctx)
{ {
@@ -1374,7 +1374,7 @@ data_reopen_cdma_ready (MMSerialPort *data,
/* Just flash the data port */ /* Just flash the data port */
mm_dbg ("Flashing data port (%s)...", mm_port_get_device (MM_PORT (ctx->data))); 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, 1000,
TRUE, TRUE,
(MMSerialFlashFn)data_flash_cdma_ready, (MMSerialFlashFn)data_flash_cdma_ready,
@@ -1395,7 +1395,7 @@ disconnect_cdma (MMBroadbandBearer *self,
g_assert (primary != NULL); g_assert (primary != NULL);
/* Generic CDMA plays only with SERIAL data ports */ /* 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, ctx = detailed_disconnect_context_new (self,
modem, modem,
@@ -1407,7 +1407,7 @@ disconnect_cdma (MMBroadbandBearer *self,
/* Fully reopen the port before flashing */ /* Fully reopen the port before flashing */
mm_dbg ("Reopening data port (%s)...", mm_port_get_device (MM_PORT (ctx->data))); 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, 1000,
(MMSerialReopenFn)data_reopen_cdma_ready, (MMSerialReopenFn)data_reopen_cdma_ready,
ctx); ctx);
@@ -1436,13 +1436,13 @@ cgact_data_ready (MMBaseModem *modem,
} }
static void static void
data_flash_3gpp_ready (MMSerialPort *data, data_flash_3gpp_ready (MMPortSerial *data,
GError *error, GError *error,
DetailedDisconnectContext *ctx) DetailedDisconnectContext *ctx)
{ {
/* We kept the serial port open during connection, now we close that open /* We kept the serial port open during connection, now we close that open
* count */ * count */
mm_serial_port_close (data); mm_port_serial_close (data);
/* Port is disconnected; update the state */ /* Port is disconnected; update the state */
mm_port_set_connected (MM_PORT (data), FALSE); mm_port_set_connected (MM_PORT (data), FALSE);
@@ -1489,7 +1489,7 @@ data_flash_3gpp_ready (MMSerialPort *data,
} }
static void static void
data_reopen_3gpp_ready (MMSerialPort *data, data_reopen_3gpp_ready (MMPortSerial *data,
GError *error, GError *error,
DetailedDisconnectContext *ctx) DetailedDisconnectContext *ctx)
{ {
@@ -1502,7 +1502,7 @@ data_reopen_3gpp_ready (MMSerialPort *data,
/* Just flash the data port */ /* Just flash the data port */
mm_dbg ("Flashing data port (%s)...", mm_port_get_device (MM_PORT (ctx->data))); 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, 1000,
TRUE, TRUE,
(MMSerialFlashFn)data_flash_3gpp_ready, (MMSerialFlashFn)data_flash_3gpp_ready,
@@ -1514,7 +1514,7 @@ data_reopen_3gpp (DetailedDisconnectContext *ctx)
{ {
/* Fully reopen the port before flashing */ /* Fully reopen the port before flashing */
mm_dbg ("Reopening data port (%s)...", mm_port_get_device (MM_PORT (ctx->data))); 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, 1000,
(MMSerialReopenFn)data_reopen_3gpp_ready, (MMSerialReopenFn)data_reopen_3gpp_ready,
ctx); ctx);
@@ -1553,7 +1553,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
g_assert (primary != NULL); g_assert (primary != NULL);
/* Generic 3GPP plays only with SERIAL data ports */ /* 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, ctx = detailed_disconnect_context_new (self,
modem, modem,
@@ -1824,7 +1824,7 @@ init_async_context_free (InitAsyncContext *ctx,
{ {
if (ctx->port) { if (ctx->port) {
if (close_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->port);
} }
g_object_unref (ctx->self); g_object_unref (ctx->self);
@@ -1984,7 +1984,7 @@ initable_init_async (GAsyncInitable *initable,
return; 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_take_error (ctx->result, error);
g_simple_async_result_complete_in_idle (ctx->result); g_simple_async_result_complete_in_idle (ctx->result);
init_async_context_free (ctx, FALSE); init_async_context_free (ctx, FALSE);

View File

@@ -329,7 +329,7 @@ load_capabilities_context_complete_and_free (LoadCapabilitiesContext *ctx)
{ {
g_simple_async_result_complete (ctx->result); g_simple_async_result_complete (ctx->result);
if (ctx->qcdm_port) { 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->qcdm_port);
} }
g_object_unref (ctx->result); 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)); ctx->qcdm_port = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (ctx->self));
g_assert (ctx->qcdm_port); 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", mm_dbg ("Failed to open QCDM port for NV ModePref request: %s",
error->message); error->message);
g_error_free (error); 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->result);
g_object_unref (ctx->self); g_object_unref (ctx->self);
if (ctx->qcdm) { 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_object_unref (ctx->qcdm);
} }
g_free (ctx); g_free (ctx);
@@ -1148,7 +1148,7 @@ modem_load_own_numbers (MMIfaceModem *self,
modem_load_own_numbers); modem_load_own_numbers);
ctx->qcdm = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (self)); ctx->qcdm = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (self));
if (ctx->qcdm) { 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); ctx->qcdm = g_object_ref (ctx->qcdm);
} else { } else {
mm_dbg ("Couldn't open QCDM port: (%d) %s", mm_dbg ("Couldn't open QCDM port: (%d) %s",
@@ -1697,7 +1697,7 @@ modem_load_supported_ip_families (MMIfaceModem *self,
typedef struct { typedef struct {
MMBroadbandModem *self; MMBroadbandModem *self;
GSimpleAsyncResult *result; GSimpleAsyncResult *result;
MMSerialPort *port; MMPortSerial *port;
} SignalQualityContext; } SignalQualityContext;
static void static void
@@ -1986,7 +1986,7 @@ modem_load_signal_quality (MMIfaceModem *self,
modem_load_signal_quality); modem_load_signal_quality);
/* Check whether we can get a non-connected AT port */ /* 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 (ctx->port) {
if (MM_BROADBAND_MODEM (self)->priv->modem_cind_supported && if (MM_BROADBAND_MODEM (self)->priv->modem_cind_supported &&
CIND_INDICATOR_IS_VALID (MM_BROADBAND_MODEM (self)->priv->modem_cind_indicator_signal_quality)) 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 */ /* 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) { if (ctx->port) {
g_error_free (error); g_error_free (error);
signal_quality_qcdm (ctx); signal_quality_qcdm (ctx);
@@ -7599,17 +7599,17 @@ ports_context_unref (PortsContext *ctx)
if (g_atomic_int_dec_and_test (&ctx->ref_count)) { if (g_atomic_int_dec_and_test (&ctx->ref_count)) {
if (ctx->primary) { if (ctx->primary) {
if (ctx->primary_open) 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); g_object_unref (ctx->primary);
} }
if (ctx->secondary) { if (ctx->secondary) {
if (ctx->secondary_open) 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); g_object_unref (ctx->secondary);
} }
if (ctx->qcdm) { if (ctx->qcdm) {
if (ctx->qcdm_open) 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_object_unref (ctx->qcdm);
} }
g_free (ctx); g_free (ctx);
@@ -7679,7 +7679,7 @@ open_ports_initialization (MMBroadbandModem *self,
* We do keep the primary port open during the whole initialization * We do keep the primary port open during the whole initialization
* sequence. Note that this port is not really passed to the interfaces, * sequence. Note that this port is not really passed to the interfaces,
* they will get the primary port themselves. */ * 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: "); g_prefix_error (error, "Couldn't open primary port: ");
return FALSE; return FALSE;
} }
@@ -7846,7 +7846,7 @@ enabling_modem_init_ready (MMBroadbandModem *self,
} }
static void static void
enabling_flash_done (MMSerialPort *port, enabling_flash_done (MMPortSerial *port,
GError *error, GError *error,
EnablingStartedContext *ctx) EnablingStartedContext *ctx)
{ {
@@ -7895,7 +7895,7 @@ open_ports_enabling (MMBroadbandModem *self,
NULL); 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: "); g_prefix_error (error, "Couldn't open primary port: ");
return FALSE; return FALSE;
} }
@@ -7910,7 +7910,7 @@ open_ports_enabling (MMBroadbandModem *self,
g_object_set (ctx->secondary, g_object_set (ctx->secondary,
MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE,
NULL); 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: "); g_prefix_error (error, "Couldn't open secondary port: ");
return FALSE; return FALSE;
} }
@@ -7920,7 +7920,7 @@ open_ports_enabling (MMBroadbandModem *self,
/* Open qcdm (optional) */ /* Open qcdm (optional) */
ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self)); ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
if (ctx->qcdm) { 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: "); g_prefix_error (error, "Couldn't open QCDM port: ");
return FALSE; return FALSE;
} }
@@ -7971,7 +7971,7 @@ enabling_started (MMBroadbandModem *self,
/* Ports were correctly opened, now flash the primary port */ /* Ports were correctly opened, now flash the primary port */
mm_dbg ("Flashing primary AT port before enabling..."); 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, 100,
FALSE, FALSE,
(MMSerialFlashFn)enabling_flash_done, (MMSerialFlashFn)enabling_flash_done,

View File

@@ -21,7 +21,7 @@
#include "mm-gps-serial-port.h" #include "mm-gps-serial-port.h"
#include "mm-log.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 { struct _MMGpsSerialPortPrivate {
/* Trace handler data */ /* Trace handler data */
@@ -69,7 +69,7 @@ remove_eval_cb (const GMatchInfo *match_info,
} }
static gboolean static gboolean
parse_response (MMSerialPort *port, parse_response (MMPortSerial *port,
GByteArray *response, GByteArray *response,
GError **error) GError **error)
{ {
@@ -132,7 +132,7 @@ parse_response (MMSerialPort *port,
/*****************************************************************************/ /*****************************************************************************/
static void 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; static GString *debug = NULL;
const char *s; const char *s;
@@ -206,13 +206,13 @@ static void
mm_gps_serial_port_class_init (MMGpsSerialPortClass *klass) mm_gps_serial_port_class_init (MMGpsSerialPortClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); g_type_class_add_private (object_class, sizeof (MMGpsSerialPortPrivate));
/* Virtual methods */ /* Virtual methods */
object_class->finalize = finalize; object_class->finalize = finalize;
port_class->parse_response = parse_response; serial_class->parse_response = parse_response;
port_class->debug_log = debug_log; serial_class->debug_log = debug_log;
} }

View File

@@ -19,7 +19,7 @@
#include <glib.h> #include <glib.h>
#include <glib-object.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_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)) #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); gpointer user_data);
struct _MMGpsSerialPort { struct _MMGpsSerialPort {
MMSerialPort parent; MMPortSerial parent;
MMGpsSerialPortPrivate *priv; MMGpsSerialPortPrivate *priv;
}; };
struct _MMGpsSerialPortClass { struct _MMGpsSerialPortClass {
MMSerialPortClass parent; MMPortSerialClass parent;
}; };
GType mm_gps_serial_port_get_type (void); GType mm_gps_serial_port_get_type (void);

View File

@@ -27,7 +27,7 @@
#include "mm-port-probe.h" #include "mm-port-probe.h"
#include "mm-log.h" #include "mm-log.h"
#include "mm-at-serial-port.h" #include "mm-at-serial-port.h"
#include "mm-serial-port.h" #include "mm-port-serial.h"
#include "mm-serial-parsers.h" #include "mm-serial-parsers.h"
#include "mm-port-probe-at.h" #include "mm-port-probe-at.h"
#include "libqcdm/src/commands.h" #include "libqcdm/src/commands.h"
@@ -82,7 +82,7 @@ typedef struct {
/* ---- Serial probing specific context ---- */ /* ---- Serial probing specific context ---- */
guint buffer_full_id; guint buffer_full_id;
MMSerialPort *serial; MMPortSerial *serial;
/* ---- AT probing specific context ---- */ /* ---- 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_warn_if_fail (MM_IS_AT_SERIAL_PORT (task->serial));
g_signal_handler_disconnect (task->serial, task->buffer_full_id); g_signal_handler_disconnect (task->serial, task->buffer_full_id);
} }
if (mm_serial_port_is_open (task->serial)) if (mm_port_serial_is_open (task->serial))
mm_serial_port_close (task->serial); mm_port_serial_close (task->serial);
g_object_unref (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); g_signal_handler_disconnect (task->serial, task->buffer_full_id);
task->buffer_full_id = 0; task->buffer_full_id = 0;
} }
mm_serial_port_close (task->serial); mm_port_serial_close (task->serial);
g_object_unref (task->serial); g_object_unref (task->serial);
} }
/* Open the QCDM port */ /* 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) { if (!task->serial) {
port_probe_run_task_complete ( port_probe_run_task_complete (
task, task,
@@ -684,7 +684,7 @@ serial_probe_qcdm (MMPortProbe *self)
} }
/* Try to open the port */ /* 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 ( port_probe_run_task_complete (
task, task,
FALSE, FALSE,
@@ -1077,7 +1077,7 @@ serial_probe_schedule (MMPortProbe *self)
} }
static void static void
serial_flash_done (MMSerialPort *port, serial_flash_done (MMPortSerial *port,
GError *error, GError *error,
MMPortProbe *self) MMPortProbe *self)
{ {
@@ -1086,7 +1086,7 @@ serial_flash_done (MMSerialPort *port,
} }
static void static void
serial_buffer_full (MMSerialPort *serial, serial_buffer_full (MMPortSerial *serial,
GByteArray *buffer, GByteArray *buffer,
MMPortProbe *self) MMPortProbe *self)
{ {
@@ -1136,7 +1136,7 @@ serial_open_at (MMPortProbe *self)
if (!task->serial) { if (!task->serial) {
gpointer parser; 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) { if (!task->serial) {
port_probe_run_task_complete ( port_probe_run_task_complete (
task, task,
@@ -1150,10 +1150,10 @@ serial_open_at (MMPortProbe *self)
} }
g_object_set (task->serial, 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_REMOVE_ECHO, task->at_remove_echo,
MM_AT_SERIAL_PORT_SEND_LF, task->at_send_lf, MM_AT_SERIAL_PORT_SEND_LF, task->at_send_lf,
MM_SERIAL_PORT_SPEW_CONTROL, TRUE,
NULL); NULL);
parser = mm_serial_parser_v1_new (); parser = mm_serial_parser_v1_new ();
@@ -1167,7 +1167,7 @@ serial_open_at (MMPortProbe *self)
} }
/* Try to open the port */ /* 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 */ /* Abort if maximum number of open tries reached */
if (++task->at_open_tries > 4) { if (++task->at_open_tries > 4) {
/* took too long to open the port; give up */ /* took too long to open the port; give up */
@@ -1208,7 +1208,7 @@ serial_open_at (MMPortProbe *self)
G_CALLBACK (serial_buffer_full), G_CALLBACK (serial_buffer_full),
self); self);
mm_serial_port_flash (MM_SERIAL_PORT (task->serial), mm_port_serial_flash (MM_PORT_SERIAL (task->serial),
100, 100,
TRUE, TRUE,
(MMSerialFlashFn)serial_flash_done, (MMSerialFlashFn)serial_flash_done,

View File

@@ -31,13 +31,13 @@
#include <ModemManager.h> #include <ModemManager.h>
#include <mm-errors-types.h> #include <mm-errors-types.h>
#include "mm-serial-port.h" #include "mm-port-serial.h"
#include "mm-log.h" #include "mm-log.h"
static gboolean mm_serial_port_queue_process (gpointer data); static gboolean mm_port_serial_queue_process (gpointer data);
static void mm_serial_port_close_force (MMSerialPort *self); 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 { enum {
PROP_0, PROP_0,
@@ -66,7 +66,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
#define SERIAL_BUF_SIZE 2048 #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 { typedef struct {
guint32 open_count; guint32 open_count;
@@ -100,7 +100,7 @@ typedef struct {
guint flash_id; guint flash_id;
guint reopen_id; guint reopen_id;
guint connected_id; guint connected_id;
} MMSerialPortPrivate; } MMPortSerialPrivate;
typedef struct { typedef struct {
GByteArray *command; GByteArray *command;
@@ -178,9 +178,9 @@ baud_to_string (int baud)
} }
void 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; struct termios stbuf;
int err; int err;
@@ -333,9 +333,9 @@ parse_stopbits (guint i)
} }
static gboolean 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; struct termios stbuf, other;
int speed; int speed;
int bits; int bits;
@@ -420,20 +420,20 @@ real_config_fd (MMSerialPort *self, int fd, GError **error)
} }
static void 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); g_return_if_fail (len > 0);
if (MM_SERIAL_PORT_GET_CLASS (self)->debug_log) if (MM_PORT_SERIAL_GET_CLASS (self)->debug_log)
MM_SERIAL_PORT_GET_CLASS (self)->debug_log (self, prefix, buf, len); MM_PORT_SERIAL_GET_CLASS (self)->debug_log (self, prefix, buf, len);
} }
static gboolean static gboolean
mm_serial_port_process_command (MMSerialPort *self, mm_port_serial_process_command (MMPortSerial *self,
MMQueueData *info, MMQueueData *info,
GError **error) GError **error)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
const guint8 *p; const guint8 *p;
int status, expected_status, send_len; int status, expected_status, send_len;
@@ -497,14 +497,14 @@ mm_serial_port_process_command (MMSerialPort *self,
} }
static void static void
mm_serial_port_set_cached_reply (MMSerialPort *self, mm_port_serial_set_cached_reply (MMPortSerial *self,
const GByteArray *command, const GByteArray *command,
const GByteArray *response) 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 (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); g_return_if_fail (command != NULL);
if (response) { 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_byte_array_append (rsp_copy, response->data, response->len);
g_hash_table_insert (priv->reply_cache, cmd_copy, rsp_copy); g_hash_table_insert (priv->reply_cache, cmd_copy, rsp_copy);
} else } 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 * 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 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) { if (priv->timeout_id) {
/* A command is already in progress */ /* A command is already in progress */
@@ -540,13 +540,13 @@ mm_serial_port_schedule_queue_process (MMSerialPort *self, guint timeout_ms)
} }
if (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 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 static gsize
real_handle_response (MMSerialPort *self, real_handle_response (MMPortSerial *self,
GByteArray *response, GByteArray *response,
GError *error, GError *error,
GCallback callback, GCallback callback,
@@ -559,9 +559,9 @@ real_handle_response (MMSerialPort *self,
} }
static void 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; MMQueueData *info;
gsize consumed = priv->response->len; 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); info = (MMQueueData *) g_queue_pop_head (priv->queue);
if (info) { if (info) {
if (info->cached && !error) 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) { if (info->callback) {
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);
consumed = MM_SERIAL_PORT_GET_CLASS (self)->handle_response (self, consumed = MM_PORT_SERIAL_GET_CLASS (self)->handle_response (self,
priv->response, priv->response,
error, error,
info->callback, info->callback,
@@ -604,14 +604,14 @@ mm_serial_port_got_response (MMSerialPort *self, GError *error)
if (consumed) if (consumed)
g_byte_array_remove_range (priv->response, 0, consumed); g_byte_array_remove_range (priv->response, 0, consumed);
if (!g_queue_is_empty (priv->queue)) 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 static gboolean
mm_serial_port_timed_out (gpointer data) mm_port_serial_timed_out (gpointer data)
{ {
MMSerialPort *self = MM_SERIAL_PORT (data); MMPortSerial *self = MM_PORT_SERIAL (data);
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
GError *error; GError *error;
priv->timeout_id = 0; 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 /* 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 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. */ 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 /* Emit a timed out signal, used by upper layers to identify a disconnected
* serial port */ * serial port */
@@ -636,10 +636,10 @@ mm_serial_port_timed_out (gpointer data)
} }
static void static void
serial_port_response_wait_cancelled (GCancellable *cancellable, port_serial_response_wait_cancelled (GCancellable *cancellable,
MMSerialPort *self) MMPortSerial *self)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
GError *error; GError *error;
/* We don't want to call disconnect () while in the signal handler */ /* 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 /* 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 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. */ 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 static gboolean
mm_serial_port_queue_process (gpointer data) mm_port_serial_queue_process (gpointer data)
{ {
MMSerialPort *self = MM_SERIAL_PORT (data); MMPortSerial *self = MM_PORT_SERIAL (data);
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
MMQueueData *info; MMQueueData *info;
GError *error = NULL; GError *error = NULL;
@@ -670,7 +670,7 @@ mm_serial_port_queue_process (gpointer data)
return FALSE; return FALSE;
if (info->cached) { 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) { if (cached) {
/* Ensure the response array is fully empty before setting the /* 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); 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; return FALSE;
} }
} }
if (mm_serial_port_process_command (self, info, &error)) { if (mm_port_serial_process_command (self, info, &error)) {
if (info->done) { if (info->done) {
/* setup the cancellable so that we can stop waiting for a response */ /* setup the cancellable so that we can stop waiting for a response */
if (info->cancellable) { if (info->cancellable) {
priv->cancellable = g_object_ref (info->cancellable); priv->cancellable = g_object_ref (info->cancellable);
priv->cancellable_id = (g_cancellable_connect ( priv->cancellable_id = (g_cancellable_connect (
info->cancellable, info->cancellable,
(GCallback) serial_port_response_wait_cancelled, (GCallback) port_serial_response_wait_cancelled,
self, self,
NULL)); NULL));
if (!priv->cancellable_id) { if (!priv->cancellable_id) {
error = g_error_new (MM_CORE_ERROR, error = g_error_new (MM_CORE_ERROR,
MM_CORE_ERROR_CANCELLED, MM_CORE_ERROR_CANCELLED,
"Won't wait for the reply"); "Won't wait for the reply");
mm_serial_port_got_response (self, error); mm_port_serial_got_response (self, error);
return FALSE; return FALSE;
} }
} }
/* If the command is finished being sent, schedule the timeout */ /* If the command is finished being sent, schedule the timeout */
priv->timeout_id = g_timeout_add_seconds (info->timeout, priv->timeout_id = g_timeout_add_seconds (info->timeout,
mm_serial_port_timed_out, mm_port_serial_timed_out,
self); self);
} else { } else {
/* Schedule the next byte of the command to be sent */ /* 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 } else
mm_serial_port_got_response (self, error); mm_port_serial_got_response (self, error);
return FALSE; return FALSE;
} }
static gboolean static gboolean
parse_response (MMSerialPort *self, parse_response (MMPortSerial *self,
GByteArray *response, GByteArray *response,
GError **error) GError **error)
{ {
if (MM_SERIAL_PORT_GET_CLASS (self)->parse_unsolicited) if (MM_PORT_SERIAL_GET_CLASS (self)->parse_unsolicited)
MM_SERIAL_PORT_GET_CLASS (self)->parse_unsolicited (self, response); MM_PORT_SERIAL_GET_CLASS (self)->parse_unsolicited (self, response);
g_return_val_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->parse_response, FALSE); g_return_val_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->parse_response, FALSE);
return MM_SERIAL_PORT_GET_CLASS (self)->parse_response (self, response, error); return MM_PORT_SERIAL_GET_CLASS (self)->parse_response (self, response, error);
} }
static gboolean static gboolean
@@ -739,8 +739,8 @@ data_available (GIOChannel *source,
GIOCondition condition, GIOCondition condition,
gpointer data) gpointer data)
{ {
MMSerialPort *self = MM_SERIAL_PORT (data); MMPortSerial *self = MM_PORT_SERIAL (data);
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
char buf[SERIAL_BUF_SIZE + 1]; char buf[SERIAL_BUF_SIZE + 1];
gsize bytes_read; gsize bytes_read;
GIOStatus status; GIOStatus status;
@@ -753,7 +753,7 @@ data_available (GIOChannel *source,
if (priv->response->len) if (priv->response->len)
g_byte_array_remove_range (priv->response, 0, 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; return FALSE;
} }
@@ -800,7 +800,7 @@ data_available (GIOChannel *source,
if (parse_response (self, priv->response, &err)) { if (parse_response (self, priv->response, &err)) {
/* Reset number of consecutive timeouts only here */ /* Reset number of consecutive timeouts only here */
priv->n_consecutive_timeouts = 0; 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) } while ( (bytes_read == SERIAL_BUF_SIZE || status == G_IO_STATUS_AGAIN)
&& (priv->watch_id > 0)); && (priv->watch_id > 0));
@@ -809,9 +809,9 @@ data_available (GIOChannel *source,
} }
static void 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 (priv->watch_id) {
if (enable) if (enable)
@@ -830,9 +830,9 @@ data_watch_enable (MMSerialPort *self, gboolean enable)
} }
static void 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; gboolean connected;
if (priv->fd < 0) if (priv->fd < 0)
@@ -861,18 +861,18 @@ port_connected (MMSerialPort *self, GParamSpec *pspec, gpointer user_data)
} }
gboolean gboolean
mm_serial_port_open (MMSerialPort *self, GError **error) mm_port_serial_open (MMPortSerial *self, GError **error)
{ {
MMSerialPortPrivate *priv; MMPortSerialPrivate *priv;
char *devfile; char *devfile;
const char *device; const char *device;
struct serial_struct sinfo = { 0 }; struct serial_struct sinfo = { 0 };
GTimeVal tv_start, tv_end; GTimeVal tv_start, tv_end;
int errno_save = 0; 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)); device = mm_port_get_device (MM_PORT (self));
if (priv->forced_close) { if (priv->forced_close) {
@@ -943,8 +943,8 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
goto error; goto error;
} }
g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->config_fd); g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->config_fd);
if (!MM_SERIAL_PORT_GET_CLASS (self)->config_fd (self, priv->fd, error)) { if (!MM_PORT_SERIAL_GET_CLASS (self)->config_fd (self, priv->fd, error)) {
mm_dbg ("(%s) failed to configure serial device", device); mm_dbg ("(%s) failed to configure serial device", device);
goto error; goto error;
} }
@@ -978,8 +978,8 @@ success:
mm_dbg ("(%s) device open count is %d (open)", device, priv->open_count); mm_dbg ("(%s) device open count is %d (open)", device, priv->open_count);
/* Run additional port config if just opened */ /* Run additional port config if just opened */
if (priv->open_count == 1 && MM_SERIAL_PORT_GET_CLASS (self)->config) if (priv->open_count == 1 && MM_PORT_SERIAL_GET_CLASS (self)->config)
MM_SERIAL_PORT_GET_CLASS (self)->config (self); MM_PORT_SERIAL_GET_CLASS (self)->config (self);
return TRUE; return TRUE;
@@ -991,24 +991,24 @@ error:
} }
gboolean 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 (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 void
mm_serial_port_close (MMSerialPort *self) mm_port_serial_close (MMPortSerial *self)
{ {
MMSerialPortPrivate *priv; MMPortSerialPrivate *priv;
const char *device; const char *device;
int i; 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. /* If we forced closing the port, open_count will be 0 already.
* Just return without issuing any warning */ * Just return without issuing any warning */
@@ -1031,7 +1031,7 @@ mm_serial_port_close (MMSerialPort *self)
priv->connected_id = 0; priv->connected_id = 0;
} }
mm_serial_port_flash_cancel (self); mm_port_serial_flash_cancel (self);
if (priv->fd >= 0) { if (priv->fd >= 0) {
GTimeVal tv_start, tv_end; GTimeVal tv_start, tv_end;
@@ -1089,14 +1089,14 @@ mm_serial_port_close (MMSerialPort *self)
GError *error; GError *error;
GByteArray *response; 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, error = g_error_new_literal (MM_SERIAL_ERROR,
MM_SERIAL_ERROR_SEND_FAILED, MM_SERIAL_ERROR_SEND_FAILED,
"Serial port is now closed"); "Serial port is now closed");
response = g_byte_array_sized_new (1); response = g_byte_array_sized_new (1);
g_byte_array_append (response, (const guint8 *) "\0", 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, response,
error, error,
item->callback, item->callback,
@@ -1132,14 +1132,14 @@ mm_serial_port_close (MMSerialPort *self)
} }
static void 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 (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 already forced to close, return */
if (priv->forced_close) if (priv->forced_close)
@@ -1153,7 +1153,7 @@ mm_serial_port_close_force (MMSerialPort *self)
/* Force the port to close */ /* Force the port to close */
priv->open_count = 1; 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 /* Mark as having forced the close, so that we don't warn about incorrect
* open counts */ * open counts */
@@ -1164,7 +1164,7 @@ mm_serial_port_close_force (MMSerialPort *self)
} }
static void static void
internal_queue_command (MMSerialPort *self, internal_queue_command (MMPortSerial *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
gboolean cached, gboolean cached,
@@ -1173,10 +1173,10 @@ internal_queue_command (MMSerialPort *self,
MMSerialResponseFn callback, MMSerialResponseFn callback,
gpointer user_data) gpointer user_data)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
MMQueueData *info; 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); g_return_if_fail (command != NULL);
if (priv->open_count == 0) { 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 */ /* Clear the cached value for this command if not asking for cached value */
if (!cached) 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); g_queue_push_tail (priv->queue, info);
if (g_queue_get_length (priv->queue) == 1) 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 void
mm_serial_port_queue_command (MMSerialPort *self, mm_port_serial_queue_command (MMPortSerial *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
@@ -1232,7 +1232,7 @@ mm_serial_port_queue_command (MMSerialPort *self,
} }
void void
mm_serial_port_queue_command_cached (MMSerialPort *self, mm_port_serial_queue_command_cached (MMPortSerial *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
@@ -1244,20 +1244,20 @@ mm_serial_port_queue_command_cached (MMSerialPort *self,
} }
typedef struct { typedef struct {
MMSerialPort *port; MMPortSerial *port;
guint initial_open_count; guint initial_open_count;
MMSerialReopenFn callback; MMSerialReopenFn callback;
gpointer user_data; gpointer user_data;
} ReopenInfo; } ReopenInfo;
static void 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) { if (priv->reopen_id > 0) {
g_source_remove (priv->reopen_id); g_source_remove (priv->reopen_id);
@@ -1269,14 +1269,14 @@ static gboolean
reopen_do (gpointer data) reopen_do (gpointer data)
{ {
ReopenInfo *info = (ReopenInfo *) 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; GError *error = NULL;
guint i; guint i;
priv->reopen_id = 0; priv->reopen_id = 0;
for (i = 0; i < info->initial_open_count; i++) { 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); g_prefix_error (&error, "Couldn't reopen port (%u): ", i);
break; break;
} }
@@ -1290,17 +1290,17 @@ reopen_do (gpointer data)
} }
gboolean gboolean
mm_serial_port_reopen (MMSerialPort *self, mm_port_serial_reopen (MMPortSerial *self,
guint32 reopen_time, guint32 reopen_time,
MMSerialReopenFn callback, MMSerialReopenFn callback,
gpointer user_data) gpointer user_data)
{ {
ReopenInfo *info; ReopenInfo *info;
MMSerialPortPrivate *priv; MMPortSerialPrivate *priv;
guint i; guint i;
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);
if (priv->forced_close) { if (priv->forced_close) {
GError *error; GError *error;
@@ -1329,7 +1329,7 @@ mm_serial_port_reopen (MMSerialPort *self,
info->callback = callback; info->callback = callback;
info->user_data = user_data; 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; info->initial_open_count = priv->open_count;
mm_dbg ("(%s) reopening port (%u)", mm_dbg ("(%s) reopening port (%u)",
@@ -1337,7 +1337,7 @@ mm_serial_port_reopen (MMSerialPort *self,
info->initial_open_count); info->initial_open_count);
for (i = 0; i < info->initial_open_count; i++) for (i = 0; i < info->initial_open_count; i++)
mm_serial_port_close (self); mm_port_serial_close (self);
if (reopen_time > 0) if (reopen_time > 0)
priv->reopen_id = g_timeout_add (reopen_time, reopen_do, info); priv->reopen_id = g_timeout_add (reopen_time, reopen_do, info);
@@ -1348,12 +1348,12 @@ mm_serial_port_reopen (MMSerialPort *self,
} }
static gboolean static gboolean
get_speed (MMSerialPort *self, speed_t *speed, GError **error) get_speed (MMPortSerial *self, speed_t *speed, GError **error)
{ {
struct termios options; struct termios options;
memset (&options, 0, sizeof (struct termios)); 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, g_set_error (error,
MM_CORE_ERROR, MM_CORE_ERROR,
MM_CORE_ERROR_FAILED, MM_CORE_ERROR_FAILED,
@@ -1367,14 +1367,14 @@ get_speed (MMSerialPort *self, speed_t *speed, GError **error)
} }
static gboolean 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; struct termios options;
int fd, count = 4; int fd, count = 4;
gboolean success = FALSE; 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)); memset (&options, 0, sizeof (struct termios));
if (tcgetattr (fd, &options) != 0) { if (tcgetattr (fd, &options) != 0) {
@@ -1427,7 +1427,7 @@ set_speed (MMSerialPort *self, speed_t speed, GError **error)
} }
typedef struct { typedef struct {
MMSerialPort *port; MMPortSerial *port;
speed_t current_speed; speed_t current_speed;
MMSerialFlashFn callback; MMSerialFlashFn callback;
gpointer user_data; gpointer user_data;
@@ -1437,7 +1437,7 @@ static gboolean
flash_do (gpointer data) flash_do (gpointer data)
{ {
FlashInfo *info = (FlashInfo *) 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; GError *error = NULL;
priv->flash_id = 0; priv->flash_id = 0;
@@ -1460,23 +1460,23 @@ flash_do (gpointer data)
} }
gboolean gboolean
mm_serial_port_flash (MMSerialPort *self, mm_port_serial_flash (MMPortSerial *self,
guint32 flash_time, guint32 flash_time,
gboolean ignore_errors, gboolean ignore_errors,
MMSerialFlashFn callback, MMSerialFlashFn callback,
gpointer user_data) gpointer user_data)
{ {
FlashInfo *info = NULL; FlashInfo *info = NULL;
MMSerialPortPrivate *priv; MMPortSerialPrivate *priv;
GError *error = NULL; GError *error = NULL;
gboolean success; 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); 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, error = g_error_new_literal (MM_SERIAL_ERROR,
MM_SERIAL_ERROR_NOT_OPEN, MM_SERIAL_ERROR_NOT_OPEN,
"The serial port is not open."); "The serial port is not open.");
@@ -1522,13 +1522,13 @@ error:
} }
void 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) { if (priv->flash_id > 0) {
g_source_remove (priv->flash_id); g_source_remove (priv->flash_id);
@@ -1537,19 +1537,19 @@ mm_serial_port_flash_cancel (MMSerialPort *self)
} }
gboolean 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 * MMPortSerial *
mm_serial_port_new (const char *name, MMPortType ptype) 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_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY, MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY,
MM_PORT_TYPE, ptype, MM_PORT_TYPE, ptype,
@@ -1599,9 +1599,9 @@ ba_free (gpointer v)
} }
static void 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); 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, set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec) const GValue *value, GParamSpec *pspec)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (object);
switch (prop_id) { switch (prop_id) {
case PROP_FD: case PROP_FD:
@@ -1660,7 +1660,7 @@ static void
get_property (GObject *object, guint prop_id, get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (object);
switch (prop_id) { switch (prop_id) {
case PROP_FD: case PROP_FD:
@@ -1699,40 +1699,40 @@ get_property (GObject *object, guint prop_id,
static void static void
dispose (GObject *object) dispose (GObject *object)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (object);
if (priv->timeout_id) { if (priv->timeout_id) {
g_source_remove (priv->timeout_id); g_source_remove (priv->timeout_id);
priv->timeout_id = 0; 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)); port_serial_reopen_cancel (MM_PORT_SERIAL (object));
mm_serial_port_flash_cancel (MM_SERIAL_PORT (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 static void
finalize (GObject *object) finalize (GObject *object)
{ {
MMSerialPort *self = MM_SERIAL_PORT (object); MMPortSerial *self = MM_PORT_SERIAL (object);
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMPortSerialPrivate *priv = MM_PORT_SERIAL_GET_PRIVATE (self);
g_hash_table_destroy (priv->reply_cache); g_hash_table_destroy (priv->reply_cache);
g_byte_array_free (priv->response, TRUE); g_byte_array_free (priv->response, TRUE);
g_queue_free (priv->queue); 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 static void
mm_serial_port_class_init (MMSerialPortClass *klass) mm_port_serial_class_init (MMPortSerialClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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 */ /* Virtual methods */
object_class->set_property = set_property; object_class->set_property = set_property;
@@ -1746,7 +1746,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
/* Properties */ /* Properties */
g_object_class_install_property g_object_class_install_property
(object_class, PROP_FD, (object_class, PROP_FD,
g_param_spec_int (MM_SERIAL_PORT_FD, g_param_spec_int (MM_PORT_SERIAL_FD,
"File descriptor", "File descriptor",
"File descriptor", "File descriptor",
-1, G_MAXINT, -1, -1, G_MAXINT, -1,
@@ -1754,7 +1754,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_BAUD, (object_class, PROP_BAUD,
g_param_spec_uint (MM_SERIAL_PORT_BAUD, g_param_spec_uint (MM_PORT_SERIAL_BAUD,
"Baud", "Baud",
"Baud rate", "Baud rate",
0, G_MAXUINT, 57600, 0, G_MAXUINT, 57600,
@@ -1762,7 +1762,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_BITS, (object_class, PROP_BITS,
g_param_spec_uint (MM_SERIAL_PORT_BITS, g_param_spec_uint (MM_PORT_SERIAL_BITS,
"Bits", "Bits",
"Bits", "Bits",
5, 8, 8, 5, 8, 8,
@@ -1770,7 +1770,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_PARITY, (object_class, PROP_PARITY,
g_param_spec_char (MM_SERIAL_PORT_PARITY, g_param_spec_char (MM_PORT_SERIAL_PARITY,
"Parity", "Parity",
"Parity", "Parity",
'E', 'o', 'n', 'E', 'o', 'n',
@@ -1778,7 +1778,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_STOPBITS, (object_class, PROP_STOPBITS,
g_param_spec_uint (MM_SERIAL_PORT_STOPBITS, g_param_spec_uint (MM_PORT_SERIAL_STOPBITS,
"Stopbits", "Stopbits",
"Stopbits", "Stopbits",
1, 2, 1, 1, 2, 1,
@@ -1786,7 +1786,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_SEND_DELAY, (object_class, PROP_SEND_DELAY,
g_param_spec_uint64 (MM_SERIAL_PORT_SEND_DELAY, g_param_spec_uint64 (MM_PORT_SERIAL_SEND_DELAY,
"SendDelay", "SendDelay",
"Send delay for each byte in microseconds", "Send delay for each byte in microseconds",
0, G_MAXUINT64, 0, 0, G_MAXUINT64, 0,
@@ -1794,7 +1794,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_SPEW_CONTROL, (object_class, PROP_SPEW_CONTROL,
g_param_spec_boolean (MM_SERIAL_PORT_SPEW_CONTROL, g_param_spec_boolean (MM_PORT_SERIAL_SPEW_CONTROL,
"SpewControl", "SpewControl",
"Spew control", "Spew control",
FALSE, FALSE,
@@ -1802,7 +1802,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_RTS_CTS, (object_class, PROP_RTS_CTS,
g_param_spec_boolean (MM_SERIAL_PORT_RTS_CTS, g_param_spec_boolean (MM_PORT_SERIAL_RTS_CTS,
"RTSCTS", "RTSCTS",
"Enable RTS/CTS flow control", "Enable RTS/CTS flow control",
FALSE, FALSE,
@@ -1810,7 +1810,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_object_class_install_property g_object_class_install_property
(object_class, PROP_FLASH_OK, (object_class, PROP_FLASH_OK,
g_param_spec_boolean (MM_SERIAL_PORT_FLASH_OK, g_param_spec_boolean (MM_PORT_SERIAL_FLASH_OK,
"FlashOk", "FlashOk",
"Flashing the port (0 baud for a short period) " "Flashing the port (0 baud for a short period) "
"is allowed.", "is allowed.",
@@ -1822,7 +1822,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_signal_new ("buffer-full", g_signal_new ("buffer-full",
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MMSerialPortClass, buffer_full), G_STRUCT_OFFSET (MMPortSerialClass, buffer_full),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_generic, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, G_TYPE_POINTER); G_TYPE_NONE, 1, G_TYPE_POINTER);
@@ -1831,7 +1831,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_signal_new ("timed-out", g_signal_new ("timed-out",
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MMSerialPortClass, timed_out), G_STRUCT_OFFSET (MMPortSerialClass, timed_out),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_generic, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, G_TYPE_UINT); G_TYPE_NONE, 1, G_TYPE_UINT);
@@ -1840,7 +1840,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
g_signal_new ("forced-close", g_signal_new ("forced-close",
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MMSerialPortClass, forced_close), G_STRUCT_OFFSET (MMPortSerialClass, forced_close),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_generic, g_cclosure_marshal_generic,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);

View File

@@ -14,8 +14,8 @@
* Copyright (C) 2009 - 2010 Red Hat, Inc. * Copyright (C) 2009 - 2010 Red Hat, Inc.
*/ */
#ifndef MM_SERIAL_PORT_H #ifndef MM_PORT_SERIAL_H
#define MM_SERIAL_PORT_H #define MM_PORT_SERIAL_H
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
@@ -23,52 +23,52 @@
#include "mm-port.h" #include "mm-port.h"
#define MM_TYPE_SERIAL_PORT (mm_serial_port_get_type ()) #define MM_TYPE_PORT_SERIAL (mm_port_serial_get_type ())
#define MM_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SERIAL_PORT, MMSerialPort)) #define MM_PORT_SERIAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PORT_SERIAL, MMPortSerial))
#define MM_SERIAL_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SERIAL_PORT, MMSerialPortClass)) #define MM_PORT_SERIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PORT_SERIAL, MMPortSerialClass))
#define MM_IS_SERIAL_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SERIAL_PORT)) #define MM_IS_PORT_SERIAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PORT_SERIAL))
#define MM_IS_SERIAL_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SERIAL_PORT)) #define MM_IS_PORT_SERIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PORT_SERIAL))
#define MM_SERIAL_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SERIAL_PORT, MMSerialPortClass)) #define MM_PORT_SERIAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PORT_SERIAL, MMPortSerialClass))
#define MM_SERIAL_PORT_BAUD "baud" #define MM_PORT_SERIAL_BAUD "baud"
#define MM_SERIAL_PORT_BITS "bits" #define MM_PORT_SERIAL_BITS "bits"
#define MM_SERIAL_PORT_PARITY "parity" #define MM_PORT_SERIAL_PARITY "parity"
#define MM_SERIAL_PORT_STOPBITS "stopbits" #define MM_PORT_SERIAL_STOPBITS "stopbits"
#define MM_SERIAL_PORT_SEND_DELAY "send-delay" #define MM_PORT_SERIAL_SEND_DELAY "send-delay"
#define MM_SERIAL_PORT_RTS_CTS "rts-cts" #define MM_PORT_SERIAL_RTS_CTS "rts-cts"
#define MM_SERIAL_PORT_FD "fd" /* Construct-only */ #define MM_PORT_SERIAL_FD "fd" /* Construct-only */
#define MM_SERIAL_PORT_SPEW_CONTROL "spew-control" /* Construct-only */ #define MM_PORT_SERIAL_SPEW_CONTROL "spew-control" /* Construct-only */
#define MM_SERIAL_PORT_FLASH_OK "flash-ok" /* Construct-only */ #define MM_PORT_SERIAL_FLASH_OK "flash-ok" /* Construct-only */
typedef struct _MMSerialPort MMSerialPort; typedef struct _MMPortSerial MMPortSerial;
typedef struct _MMSerialPortClass MMSerialPortClass; typedef struct _MMPortSerialClass MMPortSerialClass;
typedef void (*MMSerialReopenFn) (MMSerialPort *port, typedef void (*MMSerialReopenFn) (MMPortSerial *port,
GError *error, GError *error,
gpointer user_data); gpointer user_data);
typedef void (*MMSerialFlashFn) (MMSerialPort *port, typedef void (*MMSerialFlashFn) (MMPortSerial *port,
GError *error, GError *error,
gpointer user_data); gpointer user_data);
typedef void (*MMSerialResponseFn) (MMSerialPort *port, typedef void (*MMSerialResponseFn) (MMPortSerial *port,
GByteArray *response, GByteArray *response,
GError *error, GError *error,
gpointer user_data); gpointer user_data);
struct _MMSerialPort { struct _MMPortSerial {
MMPort parent; MMPort parent;
}; };
struct _MMSerialPortClass { struct _MMPortSerialClass {
MMPortClass parent; MMPortClass parent;
/* Called for subclasses to parse unsolicited responses. If any recognized /* Called for subclasses to parse unsolicited responses. If any recognized
* unsolicited response is found, it should be removed from the 'response' * unsolicited response is found, it should be removed from the 'response'
* byte array before returning. * 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 /* 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 * 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 * the device's reply (whether success *or* error), and should return TRUE
* when the device's response has been recognized and parsed. * when the device's response has been recognized and parsed.
*/ */
gboolean (*parse_response) (MMSerialPort *self, gboolean (*parse_response) (MMPortSerial *self,
GByteArray *response, GByteArray *response,
GError **error); GError **error);
@@ -85,7 +85,7 @@ struct _MMSerialPortClass {
* it's callback to be handled. Returns the # of bytes of the response * it's callback to be handled. Returns the # of bytes of the response
* consumed. * consumed.
*/ */
gsize (*handle_response) (MMSerialPort *self, gsize (*handle_response) (MMPortSerial *self,
GByteArray *response, GByteArray *response,
GError *error, GError *error,
GCallback callback, GCallback callback,
@@ -94,54 +94,54 @@ struct _MMSerialPortClass {
/* Called to configure the serial port fd after it's opened. On error, should /* Called to configure the serial port fd after it's opened. On error, should
* return FALSE and set 'error' as appropriate. * 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, /* Called to configure the serial port after it's opened. Errors, if any,
* should get ignored. */ * 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 *prefix,
const char *buf, const char *buf,
gsize len); gsize len);
/* Signals */ /* Signals */
void (*buffer_full) (MMSerialPort *port, const GByteArray *buffer); void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
void (*timed_out) (MMSerialPort *port, guint n_consecutive_replies); void (*timed_out) (MMPortSerial *port, guint n_consecutive_replies);
void (*forced_close) (MMSerialPort *port); 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 /* Keep in mind that port open/close is refcounted, so ensure that
* open/close calls are properly balanced. * 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); 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, guint32 reopen_time,
MMSerialReopenFn callback, MMSerialReopenFn callback,
gpointer user_data); gpointer user_data);
gboolean mm_serial_port_flash (MMSerialPort *self, gboolean mm_port_serial_flash (MMPortSerial *self,
guint32 flash_time, guint32 flash_time,
gboolean ignore_errors, gboolean ignore_errors,
MMSerialFlashFn callback, MMSerialFlashFn callback,
gpointer user_data); 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, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
@@ -149,7 +149,7 @@ void mm_serial_port_queue_command (MMSerialPort *self,
MMSerialResponseFn callback, MMSerialResponseFn callback,
gpointer user_data); gpointer user_data);
void mm_serial_port_queue_command_cached (MMSerialPort *self, void mm_port_serial_queue_command_cached (MMPortSerial *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
@@ -157,4 +157,4 @@ void mm_serial_port_queue_command_cached (MMSerialPort *self,
MMSerialResponseFn callback, MMSerialResponseFn callback,
gpointer user_data); gpointer user_data);
#endif /* MM_SERIAL_PORT_H */ #endif /* MM_PORT_SERIAL_H */

View File

@@ -28,7 +28,7 @@
#include "libqcdm/src/errors.h" #include "libqcdm/src/errors.h"
#include "mm-log.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)) #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 static gboolean
parse_response (MMSerialPort *port, GByteArray *response, GError **error) parse_response (MMPortSerial *port, GByteArray *response, GError **error)
{ {
return find_qcdm_start (response, NULL); return find_qcdm_start (response, NULL);
} }
static gsize static gsize
handle_response (MMSerialPort *port, handle_response (MMPortSerial *port,
GByteArray *response, GByteArray *response,
GError *error, GError *error,
GCallback callback, GCallback callback,
@@ -157,7 +157,7 @@ mm_qcdm_serial_port_queue_command (MMQcdmSerialPort *self,
g_return_if_fail (command != NULL); g_return_if_fail (command != NULL);
/* 'command' is expected to be already CRC-ed and escaped */ /* '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, command,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
@@ -179,7 +179,7 @@ mm_qcdm_serial_port_queue_command_cached (MMQcdmSerialPort *self,
g_return_if_fail (command != NULL); g_return_if_fail (command != NULL);
/* 'command' is expected to be already CRC-ed and escaped */ /* '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, command,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
@@ -189,7 +189,7 @@ mm_qcdm_serial_port_queue_command_cached (MMQcdmSerialPort *self,
} }
static void 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; static GString *debug = NULL;
const char *s = buf; const char *s = buf;
@@ -209,7 +209,7 @@ debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
/*****************************************************************************/ /*****************************************************************************/
static gboolean static gboolean
config_fd (MMSerialPort *port, int fd, GError **error) config_fd (MMPortSerial *port, int fd, GError **error)
{ {
int err; int err;
@@ -231,7 +231,7 @@ mm_qcdm_serial_port_new (const char *name)
MM_PORT_DEVICE, name, MM_PORT_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY, MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY,
MM_PORT_TYPE, MM_PORT_TYPE_QCDM, MM_PORT_TYPE, MM_PORT_TYPE_QCDM,
MM_SERIAL_PORT_SEND_DELAY, (guint64) 0, MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
NULL)); NULL));
} }
@@ -246,8 +246,8 @@ mm_qcdm_serial_port_new_fd (int fd)
MM_PORT_DEVICE, name, MM_PORT_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY, MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY,
MM_PORT_TYPE, MM_PORT_TYPE_QCDM, MM_PORT_TYPE, MM_PORT_TYPE_QCDM,
MM_SERIAL_PORT_FD, fd, MM_PORT_SERIAL_FD, fd,
MM_SERIAL_PORT_SEND_DELAY, (guint64) 0, MM_PORT_SERIAL_SEND_DELAY, (guint64) 0,
NULL)); NULL));
g_free (name); g_free (name);
return port; return port;
@@ -268,7 +268,7 @@ static void
mm_qcdm_serial_port_class_init (MMQcdmSerialPortClass *klass) mm_qcdm_serial_port_class_init (MMQcdmSerialPortClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); g_type_class_add_private (object_class, sizeof (MMQcdmSerialPortPrivate));

View File

@@ -20,7 +20,7 @@
#include <glib.h> #include <glib.h>
#include <glib-object.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_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)) #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); gpointer user_data);
struct _MMQcdmSerialPort { struct _MMQcdmSerialPort {
MMSerialPort parent; MMPortSerial parent;
}; };
struct _MMQcdmSerialPortClass { struct _MMQcdmSerialPortClass {
MMSerialPortClass parent; MMPortSerialClass parent;
}; };
GType mm_qcdm_serial_port_get_type (void); GType mm_qcdm_serial_port_get_type (void);

View File

@@ -220,14 +220,14 @@ qcdm_test_child (int fd, VerInfoCb cb)
port = mm_qcdm_serial_port_new_fd (fd); port = mm_qcdm_serial_port_new_fd (fd);
g_assert (port); 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_no_error (error);
g_assert (success); g_assert (success);
qcdm_request_verinfo (port, cb, loop); qcdm_request_verinfo (port, cb, loop);
g_main_loop_run (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); g_object_unref (port);
} }