core: add helper to create QCDM serial ports from a file descriptor

Aids in unit testing
This commit is contained in:
Dan Williams
2010-10-14 00:09:22 -05:00
parent ad4e2fc656
commit 9956b06a44
2 changed files with 19 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -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,