Synopsis

#define             NTD_PROTOCOL_ERROR
struct              NtdProtocol;
struct              NtdProtocolClass;
enum                NtdProtocolError;
gboolean            ntd_protocol_clear_error            (NtdProtocol *protocol);
GType               ntd_protocol_convert_type           (NtdProtocol *protocol,
                                                         NtdSourceType type);
GQuark              ntd_protocol_error_quark            (void);
NtdDevice *         ntd_protocol_get_device             (NtdProtocol *protocol);
GError *            ntd_protocol_get_error              (NtdProtocol *protocol);
gchar *             ntd_protocol_get_error_message      (NtdProtocolError error_code);
gboolean            ntd_protocol_in_error               (NtdProtocol *protocol);
void                ntd_protocol_multi_read             (NtdProtocol *protocol,
                                                         GPtrArray *addresses,
                                                         GPtrArray *dst_values);
void                ntd_protocol_multi_write            (NtdProtocol *protocol,
                                                         GPtrArray *addresses,
                                                         GPtrArray *src_values);
void                ntd_protocol_read                   (NtdProtocol *protocol,
                                                         const NtdAddress *address,
                                                         GValue *dst);
void                ntd_protocol_read_with_data         (NtdProtocol *protocol,
                                                         NtdSourceType type,
                                                         const gchar *id,
                                                         GValue *dst);
void                ntd_protocol_set_device             (NtdProtocol *protocol,
                                                         NtdDevice *device);
void                ntd_protocol_set_error              (NtdProtocol *protocol,
                                                         NtdProtocolError error_code,
                                                         const gchar *format,
                                                         ...);
void                ntd_protocol_set_errorv             (NtdProtocol *protocol,
                                                         NtdProtocolError error_code,
                                                         const gchar *format,
                                                         va_list args);
void                ntd_protocol_write                  (NtdProtocol *protocol,
                                                         const NtdAddress *address,
                                                         const GValue *src);
void                ntd_protocol_write_with_data        (NtdProtocol *protocol,
                                                         NtdSourceType type,
                                                         const gchar *id,
                                                         const GValue *src);

Object Hierarchy

  GObject
   +----NtdProtocol
         +----NtdNardiNE
         +----NtdSimulator
  GEnum
   +----NtdProtocolError

Properties

  "device"                   NtdDevice*            : Read / Write

Signals

  "on-error"                                       : Run Last
  "read"                                           : Run Last
  "write"                                          : Run Last

Description

Details

NTD_PROTOCOL_ERROR

#define NTD_PROTOCOL_ERROR             ntd_protocol_error_quark()

struct NtdProtocol

struct NtdProtocol;

struct NtdProtocolClass

struct NtdProtocolClass {
    GObjectClass parent_class;

    /* Virtual Table */

    GType         (* convert_type)                (NtdSourceType  type);

    void          (* read)                        (NtdProtocol*      protocol,
            const NtdAddress* address,
            GValue*           dst);
    void          (* multi_read)                  (NtdProtocol*      protocol,
            GPtrArray*        addresses,
            GPtrArray*        dst_values);
    void          (* write)                       (NtdProtocol*      protocol,
            const NtdAddress* address,
            const GValue*     src);
    void          (* multi_write)                 (NtdProtocol*      protocol,
            GPtrArray*        addresses,
            GPtrArray*        src_values);

    /* Signals */

    void          (* read_done)                   (NtdProtocol*      protocol);
    void          (* write_done)                  (NtdProtocol*      protocol);
    void          (* on_error)                    (NtdProtocol*      protocol);
};

enum NtdProtocolError

typedef enum {
    NTD_PROTOCOL_ERROR_DEVICE,
    NTD_PROTOCOL_ERROR_TIMEDOUT,
    NTD_PROTOCOL_ERROR_BADCRC,
    NTD_PROTOCOL_ERROR_NOIMPL,
    NTD_PROTOCOL_ERROR_FAILED
} NtdProtocolError;

ntd_protocol_clear_error ()

gboolean            ntd_protocol_clear_error            (NtdProtocol *protocol);

Resets the protocol internal error.

protocol :

an NtdProtocol derived object.

Returns :

TRUE if there was an internal error, FALSE otherwise.

ntd_protocol_convert_type ()

GType               ntd_protocol_convert_type           (NtdProtocol *protocol,
                                                         NtdSourceType type);

Converts the specified NtdSourceType type to a GType type.

protocol :

an NtdProtocol derived protocol.

type :

the source type to convert.

Returns :

the GType associated to type in this protocol protocol or G_TYPE_NONE if this type is not managed.

ntd_protocol_error_quark ()

GQuark              ntd_protocol_error_quark            (void);

ntd_protocol_get_device ()

NtdDevice *         ntd_protocol_get_device             (NtdProtocol *protocol);

Gets the link device used by this protocol.

protocol :

an NtdProtocol derived protocol.

Returns :

the link device of protocol or NULL on errors.

ntd_protocol_get_error ()

GError *            ntd_protocol_get_error              (NtdProtocol *protocol);

ntd_protocol_get_error_message ()

gchar *             ntd_protocol_get_error_message      (NtdProtocolError error_code);

Gets the description of the specified protocol error. If the error_code is invalid, this function returns NULL.

error_code :

the NtdProtocolError error code to convert.

Returns :

a newly allocated string containig the error message. This string must be freed when no longer used.

ntd_protocol_in_error ()

gboolean            ntd_protocol_in_error               (NtdProtocol *protocol);

Checks the presence of internal errors.

protocol :

an NtdProtocol derived object.

Returns :

TRUE if the protocol internal error is set, FALSE otherwise.

ntd_protocol_multi_read ()

void                ntd_protocol_multi_read             (NtdProtocol *protocol,
                                                         GPtrArray *addresses,
                                                         GPtrArray *dst_values);

Reads one or more signals at once. Notice that, for almost all protocols, reading more signals is not the same than perform multiple calls to ntd_protocol_read(). This is especially true on protocols relying on slow device links (such as serial or parallel communications), where the time difference between multiple read calls and a single multiple read is bigger.

This function is specifically used by the NtdMonitor object inside its thread function.

protocol :

an NtdProtocol derived protocol.

addresses :

a GPtrArray of pointers to the NtdAddress structures.

dst_values :

a GPtrArray of pointers to the destination GValues.

ntd_protocol_multi_write ()

void                ntd_protocol_multi_write            (NtdProtocol *protocol,
                                                         GPtrArray *addresses,
                                                         GPtrArray *src_values);

Writes one or more sources at once. As for ntd_protocol_multi_read(), usually writing more sources is not the same than perform multiple calls to ntd_protocol_write() (in performance terms).

protocol :

an NtdProtocol derived protocol.

addresses :

a GPtrArray of pointers to the NtdAddress structures.

src_values :

a GPtrArray of pointers to the destination GValues.

ntd_protocol_read ()

void                ntd_protocol_read                   (NtdProtocol *protocol,
                                                         const NtdAddress *address,
                                                         GValue *dst);

Reads an object using the protocol communication protocol and store the result in dst. The type of the value to read is specified inside the address structure.

If the protocol is in error, the command will exit immediately. To force a new session, you must call ntd_protocol_clear_error() before any other communication functions.

protocol :

an NtdProtocol derived protocol.

address :

pointer to an NtdAddress filled structure.

dst :

destination of the value.

ntd_protocol_read_with_data ()

void                ntd_protocol_read_with_data         (NtdProtocol *protocol,
                                                         NtdSourceType type,
                                                         const gchar *id,
                                                         GValue *dst);

Wrapper to ntd_protocol_read() function.

protocol :

an NtdProtocol derived protocol.

type :

type of the variable to read.

id :

identification string (source address) of the value to read.

dst :

destination of the value.

ntd_protocol_set_device ()

void                ntd_protocol_set_device             (NtdProtocol *protocol,
                                                         NtdDevice *device);

Defines the link device to use for this protocol. If any previous device was defined, it is removed before applying the new one.

You can pass NULL as device to leave unset the link device.

protocol :

an NtdProtocol derived protocol.

device :

an NtdDevice derived connection.

ntd_protocol_set_error ()

void                ntd_protocol_set_error              (NtdProtocol *protocol,
                                                         NtdProtocolError error_code,
                                                         const gchar *format,
                                                         ...);

Sets the protocol internal error to the specified error code. Optionally, any custom message can be appended to the standard message.

At the end, an "on-error" signal is emitted.

protocol :

an NtdProtocol derived object.

error_code :

the NtdProtocolError error code.

format :

printf-style format string.

... :

parameters for format string.

ntd_protocol_set_errorv ()

void                ntd_protocol_set_errorv             (NtdProtocol *protocol,
                                                         NtdProtocolError error_code,
                                                         const gchar *format,
                                                         va_list args);

Wrapper to ntd_protocol_set_error() with va_list argument.

protocol :

an NtdProtocol derived object.

error_code :

the NtdProtocolError error code to use.

format :

printf-style format string.

args :

parameters for format string.

ntd_protocol_write ()

void                ntd_protocol_write                  (NtdProtocol *protocol,
                                                         const NtdAddress *address,
                                                         const GValue *src);

Writes to an object using the protocol communication protocol. The type of the value to write must be specified inside the address structure.

If the protocol is in error, the command will exit immediately. To force a new session, you must call ntd_protocol_clear_error() before any other communication functions.

protocol :

an NtdProtocol derived protocol.

address :

pointer to an NtdAddress filled structure.

src :

source value.

ntd_protocol_write_with_data ()

void                ntd_protocol_write_with_data        (NtdProtocol *protocol,
                                                         NtdSourceType type,
                                                         const gchar *id,
                                                         const GValue *src);

Wrapper to ntd_protocol_write() function.

protocol :

an NtdProtocol derived protocol.

type :

type of the variable to write.

id :

identification string (source address) of the value to read.

src :

source value.

Property Details

The "device" property

  "device"                   NtdDevice*            : Read / Write

Link device used by the protocol.

Signal Details

The "on-error" signal

void                user_function                      (NtdProtocol *protocol,
                                                        gpointer     user_data)      : Run Last

The "on-error" signal is emitted whenever a protocol error is found. If there is an I/O error on the device binded to this protocol, also an NTD_PROTOCOL_ERROR_DEVICE error is emitted.

protocol :

an NtdProtocol derived object.

user_data :

user data set when the signal handler was connected.

The "read" signal

void                user_function                      (NtdProtocol *protocol,
                                                        gpointer     user_data)      : Run Last

The "read" signal is emitted when a requested reading operation is performed.

protocol :

an NtdProtocol derived object.

user_data :

user data set when the signal handler was connected.

The "write" signal

void                user_function                      (NtdProtocol *protocol,
                                                        gpointer     user_data)      : Run Last

The "write" signal is emitted when a writing operation is performed.

protocol :

an NtdProtocol derived object.

user_data :

user data set when the signal handler was connected.