fu-io-channel: fwupd Reference Manual

## fu-io-channel fu-io-channel |

## Functions

FuIOChannel * | fu_io_channel_unix_new ()
FuIOChannel * | fu_io_channel_new_file ()
gint | fu_io_channel_unix_get_fd ()
gboolean | fu_io_channel_shutdown ()
gboolean | fu_io_channel_write_raw ()
gboolean | fu_io_channel_read_raw ()
gboolean | fu_io_channel_write_bytes ()
gboolean | fu_io_channel_write_byte_array ()
GBytes * | fu_io_channel_read_bytes ()
GByteArray * | fu_io_channel_read_byte_array ()

## Types and Values

#define | FU_TYPE_IO_CHANNEL
enum | FuIOChannelFlags
| FuIOChannel

## Description

## Functions

### fu_io_channel_unix_new ()

    FuIOChannel *
    fu_io_channel_unix_new (gint fd);

Creates a new object to write and read from.

#### Parameters

fd | file descriptor |

#### Returns

a FuIOChannel

Since: 1.2.2

### fu_io_channel_new_file ()

    FuIOChannel *
    fu_io_channel_new_file (const gchar *filename,
                            GError **error);

Creates a new object to write and read from.

#### Parameters

filename | device file |
error | optional return location for an error. | [nullable]

#### Returns

a FuIOChannel

Since: 1.2.2

### fu_io_channel_unix_get_fd ()

    gint
    fu_io_channel_unix_get_fd (FuIOChannel *self);

Gets the file descriptor for the device.

#### Parameters

self | a FuIOChannel |

#### Returns

fd, or -1 for not open.

Since: 1.2.2

### fu_io_channel_shutdown ()

    gboolean
    fu_io_channel_shutdown (FuIOChannel *self,
                            GError **error);

Closes the file descriptor for the device.

#### Parameters

self | a FuIOChannel |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` if all the FD was closed.

Since: 1.2.2

### fu_io_channel_write_raw ()

    gboolean
    fu_io_channel_write_raw (FuIOChannel *self,
                             const guint8 *data,
                             gsize datasz,
                             guint timeout_ms,
                             FuIOChannelFlags flags,
                             GError **error);

Writes bytes to the TTY, that will fail if exceeding `timeout_ms` .

#### Parameters

self | a FuIOChannel |
data | buffer to write |
datasz | size of `data` |
timeout_ms | timeout in ms |
flags | channel flags, e.g. `FU_IO_CHANNEL_FLAG_SINGLE_SHOT` |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` if all the bytes was written

Since: 1.2.2

### fu_io_channel_read_raw ()

    gboolean
    fu_io_channel_read_raw (FuIOChannel *self,
                            guint8 *buf,
                            gsize bufsz,
                            gsize *bytes_read,
                            guint timeout_ms,
                            FuIOChannelFlags flags,
                            GError **error);

Reads bytes from the TTY, that will fail if exceeding `timeout_ms` .

#### Parameters

self | a FuIOChannel |
buf | optional buffer. | [nullable]
bufsz | size of `buf` |
bytes_read | data written to `buf` . | [out][nullable]
timeout_ms | timeout in ms |
flags | channel flags, e.g. `FU_IO_CHANNEL_FLAG_SINGLE_SHOT` |
error | optional return location for an error. | [nullable]

#### Returns

a GBytes, or `NULL` for error

Since: 1.2.2

### fu_io_channel_write_bytes ()

    gboolean
    fu_io_channel_write_bytes (FuIOChannel *self,
                               GBytes *bytes,
                               guint timeout_ms,
                               FuIOChannelFlags flags,
                               GError **error);

Writes bytes to the TTY, that will fail if exceeding `timeout_ms` .

#### Parameters

self | a FuIOChannel |
bytes | buffer to write |
timeout_ms | timeout in ms |
flags | channel flags, e.g. `FU_IO_CHANNEL_FLAG_SINGLE_SHOT` |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` if all the bytes was written

Since: 1.2.2

### fu_io_channel_write_byte_array ()

    gboolean
    fu_io_channel_write_byte_array (FuIOChannel *self,
                                    GByteArray *buf,
                                    guint timeout_ms,
                                    FuIOChannelFlags flags,
                                    GError **error);

Writes bytes to the TTY, that will fail if exceeding `timeout_ms` .

#### Parameters

self | a FuIOChannel |
buf | buffer to write |
timeout_ms | timeout in ms |
flags | channel flags, e.g. `FU_IO_CHANNEL_FLAG_SINGLE_SHOT` |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` if all the bytes was written

Since: 1.3.2

### fu_io_channel_read_bytes ()

    GBytes *
    fu_io_channel_read_bytes (FuIOChannel *self,
                              gssize max_size,
                              guint timeout_ms,
                              FuIOChannelFlags flags,
                              GError **error);

Reads bytes from the TTY, that will fail if exceeding `timeout_ms` .

#### Parameters

self | a FuIOChannel |
max_size | maximum size of the returned blob, or -1 for no limit |
timeout_ms | timeout in ms |
flags | channel flags, e.g. `FU_IO_CHANNEL_FLAG_SINGLE_SHOT` |
error | optional return location for an error. | [nullable]

#### Returns

a GBytes, or `NULL` for error

Since: 1.2.2

### fu_io_channel_read_byte_array ()

    GByteArray *
    fu_io_channel_read_byte_array (FuIOChannel *self,
                                   gssize max_size,
                                   guint timeout_ms,
                                   FuIOChannelFlags flags,
                                   GError **error);

Reads bytes from the TTY, that will fail if exceeding `timeout_ms` .

#### Parameters

self | a FuIOChannel |
max_size | maximum size of the returned blob, or -1 for no limit |
timeout_ms | timeout in ms |
flags | channel flags, e.g. `FU_IO_CHANNEL_FLAG_SINGLE_SHOT` |
error | optional return location for an error. | [nullable]

#### Returns

a GByteArray, or `NULL` for error.

[transfer full]

Since: 1.3.2

## Types and Values

### FU_TYPE_IO_CHANNEL

    #define FU_TYPE_IO_CHANNEL (fu_io_channel_get_type())

### enum FuIOChannelFlags

The flags used when reading data from the TTY.

#### Members

FU_IO_CHANNEL_FLAG_NONE | No flags are set |
FU_IO_CHANNEL_FLAG_SINGLE_SHOT | Only one read or write is expected |
FU_IO_CHANNEL_FLAG_FLUSH_INPUT | Flush pending input before writing |
FU_IO_CHANNEL_FLAG_USE_BLOCKING_IO | Block waiting for the TTY |

### FuIOChannel

    typedef struct _FuIOChannel FuIOChannel;

A bidirectional IO channel which can be read from and written to.