![]() |
![]() |
![]() |
ntdisp reference manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
struct NtdDevice; struct NtdDeviceClass; void ntd_device_set_error (NtdDevice *device
,NtdSystemError error_code
,const gchar *format
,...
); void ntd_device_set_errorv (NtdDevice *device
,NtdSystemError error_code
,const gchar *format
,va_list args
); gboolean ntd_device_set_error_from_system (NtdDevice *device
,const gchar *format
,...
); GError * ntd_device_get_error (NtdDevice *device
); gboolean ntd_device_clear_error (NtdDevice *device
); gboolean ntd_device_in_error (NtdDevice *device
); void ntd_device_set_file (NtdDevice *device
,const gchar *file
); const gchar * ntd_device_get_file (NtdDevice *device
); void ntd_device_open (NtdDevice *device
); void ntd_device_close (NtdDevice *device
); gboolean ntd_device_is_opened (NtdDevice *device
); void ntd_device_flush (NtdDevice *device
,gboolean input
,gboolean output
); gpointer ntd_device_read (NtdDevice *device
,gsize nbytes
); gpointer ntd_device_read_until (NtdDevice *device
,gchar eol
); gboolean ntd_device_write (NtdDevice *device
,gsize nbytes
,gconstpointer buffer
); gboolean ntd_device_printf (NtdDevice *device
,const gchar *format
,...
); gboolean ntd_device_vprintf (NtdDevice *device
,const gchar *format
,va_list var_args
);
"close" :No Recursion
"error-set" :No Recursion
"flush" :No Recursion
"open" :No Recursion
"read" :No Recursion
"write" :No Recursion
void ntd_device_set_error (NtdDevice *device
,NtdSystemError error_code
,const gchar *format
,...
);
Sets the device internal error to the specified error code. Optionally, any custom message can be appended to the standard message.
At the end, an "error-set" signal will be emitted.
|
an NtdDevice based instance |
|
an NtdSystemError error code |
|
printf-style format string |
|
parameters for format string |
void ntd_device_set_errorv (NtdDevice *device
,NtdSystemError error_code
,const gchar *format
,va_list args
);
Wrapper to ntd_device_set_error()
with va_list argument.
|
an NtdDevice based instance |
|
the NtdSystemError error code to use |
|
printf-style format string |
|
parameters for format string |
gboolean ntd_device_set_error_from_system (NtdDevice *device
,const gchar *format
,...
);
Checks the system for any error and eventually sets the device internal error.
If the device internal error is yet set, the function returns TRUE
immediately.
If no system errors are pending, nothing is done and FALSE
is returned.
If a system error is present, the device internal error is set accordling
to the system error and a ntd_system_clear_error()
call is performed to
reset the system error. Any custom message can be optionally appended to
the standard message.
At the end, an "error-set" signal will be emitted.
GError * ntd_device_get_error (NtdDevice *device
);
Gets the device internal error. This function is basically called when
catching the errors on a device. Be sure to call ntd_device_clear_error()
to reset the internal error after the treatment.
gboolean ntd_device_clear_error (NtdDevice *device
);
Resets the device internal error.
gboolean ntd_device_in_error (NtdDevice *device
);
Checks the presence of internal errors.
void ntd_device_set_file (NtdDevice *device
,const gchar *file
);
Sets the file name of the device bound to device
.
On posix system, file
is usually a file inside the
"/dev/" path.
|
an NtdDevice based instance |
|
the file name |
const gchar * ntd_device_get_file (NtdDevice *device
);
Retrieves the file name bound to device
.
void ntd_device_open (NtdDevice *device
);
Starts the communication over device
. If device
is in error,
no operation is performed.
|
an NtdDevice based instance |
void ntd_device_close (NtdDevice *device
);
Terminates the communication on device
.
The device is automatically closed whenever the object is destroyed.
|
an NtdDevice based instance |
gboolean ntd_device_is_opened (NtdDevice *device
);
Checks if device
is yet opened. This does not mean device
is really opened, but that a previous call to ntd_device_open()
has been performed.
void ntd_device_flush (NtdDevice *device
,gboolean input
,gboolean output
);
Flushes the input queue (if input
is TRUE
) and/or the output
queue (if output
is TRUE
) on device
.
|
an NtdDevice based instance |
|
whether to flush the input queue |
|
whether to flush the output queue |
gpointer ntd_device_read (NtdDevice *device
,gsize nbytes
);
Reads nbytes
bytes of data from device
and returns
the result as a newly allocated buffer. If an unexpected
condition is encountered before all the nbytes
are read
(such as a communication timeout), the data is freed
and NULL
is returned.
If an unexpected condition is encountered, such as a
communication timeout, the buffer is freed and NULL
is
returned. Use another function if partial data are expected.
gpointer ntd_device_read_until (NtdDevice *device
,gchar eol
);
Reads I/O data from device
until the specified eol
terminating
character is found. Whatever has been read, including the EOL
character, is returned.
The returned buffer could possibly embed NUL bytes and must be
freed with g_free()
when no longer needed.
If an unexpected condition is encountered, such as a
communication timeout, the buffer is freed and NULL
is
returned. Use another function if partial data are expected.
gboolean ntd_device_write (NtdDevice *device
,gsize nbytes
,gconstpointer buffer
);
Writes nbytes
bytes of data from buffer
to device
.
gboolean ntd_device_printf (NtdDevice *device
,const gchar *format
,...
);
Provides a convenient way to send complex formatted data
throught device
by using a printf style approach.
format
and @... are passed directly to g_vasprintf()
so
check the GLib manual for further details.
gboolean ntd_device_vprintf (NtdDevice *device
,const gchar *format
,va_list var_args
);
A variadic version of ntd_device_printf()
.
"file"
property"file" gchar* : Read / Write
Device file bound to this device.
Default value: NULL
"close"
signalvoid user_function (NtdDevice *device,
gpointer user_data) : No Recursion
Emitted whenever device
is closed.
|
an NtdDevice based instance |
|
user data set when the signal handler was connected. |
"error-set"
signalvoid user_function (NtdDevice *device,
gpointer user_data) : No Recursion
Emitted whenever an I/O call fails.
|
an NtdDevice based instance |
|
user data set when the signal handler was connected. |
"flush"
signalvoid user_function (NtdDevice *device,
gboolean input,
gboolean output,
gpointer user_data) : No Recursion
Emitted whenever device
must be flushed. One of input
or output
must be TRUE
otherwise the internal error will be set.
|
an NtdDevice based instance |
|
whether to flush the input queue |
|
whether to flush the output queue |
|
user data set when the signal handler was connected. |
"open"
signalvoid user_function (NtdDevice *device,
gpointer user_data) : No Recursion
Emitted whenever device
is opened. On success, the internal is-opened
state is set to TRUE
. If yet set, that is if device
has been opened
before, no actions are taken.
|
an NtdDevice based instance |
|
user data set when the signal handler was connected. |
"read"
signalguint user_function (NtdDevice *device,
guint nbytes,
gpointer buffer,
gpointer user_data) : No Recursion
Emitted whenever a read operation, that is a call to the raw_read virtual method, is performed.
|
an NtdDevice based instance |
|
number of bytes read |
|
pointer to the destination memory |
|
user data set when the signal handler was connected. |
Returns : |
the number of bytes effectively read. |
"write"
signalguint user_function (NtdDevice *device,
guint nbytes,
gpointer buffer,
gpointer user_data) : No Recursion
Emitted whenever a write operation, that is a call to the raw_write virtual method, is performed.
|
an NtdDevice based instance |
|
number of bytes written |
|
pointer to the source memory |
|
user data set when the signal handler was connected. |
Returns : |
the number of bytes effectively written. |