diff options
author | Dan Williams <dcbw@redhat.com> | 2010-10-14 00:09:22 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-10-14 00:09:22 -0500 |
commit | 9956b06a4467a784f16a60b6fcfd5130e09591e6 (patch) | |
tree | 9889deca93852b39c6ec4c2d7cb98f2a3b1a40d9 | |
parent | ad4e2fc65608d4f7d0bf829e5e618e4eb6f4ba01 (diff) |
core: add helper to create QCDM serial ports from a file descriptor
Aids in unit testing
-rw-r--r-- | src/mm-qcdm-serial-port.c | 17 | ||||
-rw-r--r-- | src/mm-qcdm-serial-port.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mm-qcdm-serial-port.c b/src/mm-qcdm-serial-port.c index 1ce27e79..72463fbf 100644 --- a/src/mm-qcdm-serial-port.c +++ b/src/mm-qcdm-serial-port.c @@ -196,6 +196,23 @@ mm_qcdm_serial_port_new (const char *name, MMPortType ptype) NULL)); } +MMQcdmSerialPort * +mm_qcdm_serial_port_new_fd (int fd, MMPortType ptype) +{ + MMQcdmSerialPort *port; + char *name; + + name = g_strdup_printf ("port%d", fd); + port = MM_QCDM_SERIAL_PORT (g_object_new (MM_TYPE_QCDM_SERIAL_PORT, + MM_PORT_DEVICE, name, + MM_PORT_SUBSYS, MM_PORT_SUBSYS_TTY, + MM_PORT_TYPE, ptype, + MM_SERIAL_PORT_FD, fd, + NULL)); + g_free (name); + return port; +} + static void mm_qcdm_serial_port_init (MMQcdmSerialPort *self) { diff --git a/src/mm-qcdm-serial-port.h b/src/mm-qcdm-serial-port.h index e70e124b..2786ee81 100644 --- a/src/mm-qcdm-serial-port.h +++ b/src/mm-qcdm-serial-port.h @@ -50,6 +50,8 @@ GType mm_qcdm_serial_port_get_type (void); MMQcdmSerialPort *mm_qcdm_serial_port_new (const char *name, MMPortType ptype); +MMQcdmSerialPort *mm_qcdm_serial_port_new_fd (int fd, MMPortType ptype); + void mm_qcdm_serial_port_queue_command (MMQcdmSerialPort *self, GByteArray *command, guint32 timeout_seconds, |