aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2023-06-29 12:29:57 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2023-06-29 12:47:28 +0900
commit186e28f1e57343e04a26dc1b5abd8d11b3340fdb (patch)
treeaf57c0cde44dd6b56ee13bc4e21d1c3835dc8d6b
parent0384aa29695cbd28cb84ab767f90324ed6574f6f (diff)
downloadlibhinawa-186e28f1e57343e04a26dc1b5abd8d11b3340fdb.tar.gz
fw_req: add method to send asynchronous transaction and receive time stamp
This commit adds a variation of method to send asynchronous transaction and receive time stamp. The caller can receive two time stamps of the isochronous cycle; at which the packet was sent for the request subaction of transaction, and at which the packet arrived for the response subaction. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_req.c53
-rw-r--r--src/fw_req.h5
-rw-r--r--src/hinawa.map2
-rwxr-xr-xtests/fw-req1
4 files changed, 61 insertions, 0 deletions
diff --git a/src/fw_req.c b/src/fw_req.c
index 1abdb0d..86f601a 100644
--- a/src/fw_req.c
+++ b/src/fw_req.c
@@ -447,6 +447,59 @@ void hinawa_fw_req_transaction_sync(HinawaFwReq *self, HinawaFwNode *node,
}
/**
+ * hinawa_fw_req_transaction_with_tstamp_sync:
+ * @self: A [class@FwReq].
+ * @node: A [class@FwNode].
+ * @tcode: A transaction code of [enum@FwTcode].
+ * @addr: A destination address of target device
+ * @length: The range of address in byte unit.
+ * @frame: (array length=frame_size)(inout): An array with elements for byte data. Callers should
+ * give it for buffer with enough space against the request since this library performs no
+ * reallocation. Due to the reason, the value of this argument should point to the pointer
+ * to the array and immutable. The content of array is mutable for read and lock
+ * transaction.
+ * @frame_size: The size of array in byte unit. The value of this argument should point to the
+ * numeric number and mutable for read and lock transaction.
+ * @tstamp: (array fixed-size=2)(inout): The array with two elements for time stamps. The first
+ * element is for the isochronous cycle at which the request was sent. The second element
+ * is for the isochronous cycle at which the response arrived.
+ * @timeout_ms: The timeout to wait for response subaction of the transaction since request
+ * subaction is initiated, in milliseconds.
+ * @error: A [struct@GLib.Error]. Error can be generated with two domains; Hinawa.FwNodeError and
+ * Hinawa.FwReqError.
+ *
+ * Execute request subaction of transaction to the given node according to given code, then wait
+ * for response subaction within the given timeout. The [property@FwReq:timeout] property of
+ * instance is ignored.
+ *
+ * Each value of @tstamp is unsigned 16 bit integer including higher 3 bits for three low order bits
+ * of second field and the rest 13 bits for cycle field in the format of IEEE 1394 CYCLE_TIMER register.
+ *
+ * If the version of kernel ABI for Linux FireWire subsystem is less than 6, each element of @tstamp
+ * has invalid value (=G_MAXUINT).
+ *
+ * Returns: TRUE if the overall operation finishes successfully, otherwise FALSE.
+ * Since: 2.6
+ */
+gboolean hinawa_fw_req_transaction_with_tstamp_sync(HinawaFwReq *self, HinawaFwNode *node,
+ HinawaFwTcode tcode, guint64 addr, gsize length,
+ guint8 **frame, gsize *frame_size, guint **tstamp,
+ guint timeout_ms, GError **error)
+{
+ struct waiter w;
+ gboolean result;
+
+ result = transaction_sync(self, node, tcode, addr, length, frame, frame_size, timeout_ms,
+ &w, error);
+ if (*error == NULL) {
+ (*tstamp)[0] = w.request_tstamp;
+ (*tstamp)[1] = w.response_tstamp;
+ }
+
+ return result;
+}
+
+/**
* hinawa_fw_req_transaction:
* @self: A [class@FwReq].
* @node: A [class@FwNode].
diff --git a/src/fw_req.h b/src/fw_req.h
index 25e89c8..b4a0db9 100644
--- a/src/fw_req.h
+++ b/src/fw_req.h
@@ -63,6 +63,11 @@ void hinawa_fw_req_transaction_sync(HinawaFwReq *self, HinawaFwNode *node,
guint8 *const *frame, gsize *frame_size, guint timeout_ms,
GError **error);
+gboolean hinawa_fw_req_transaction_with_tstamp_sync(HinawaFwReq *self, HinawaFwNode *node,
+ HinawaFwTcode tcode, guint64 addr, gsize length,
+ guint8 **frame, gsize *frame_size, guint **tstamp,
+ guint timeout_ms, GError **error);
+
void hinawa_fw_req_transaction(HinawaFwReq *self, HinawaFwNode *node,
HinawaFwTcode tcode, guint64 addr, gsize length,
guint8 *const *frame, gsize *frame_size,
diff --git a/src/hinawa.map b/src/hinawa.map
index 6b2fe5a..aae19c5 100644
--- a/src/hinawa.map
+++ b/src/hinawa.map
@@ -171,4 +171,6 @@ HINAWA_2_6_0 {
"hinawa_cycle_time_parse_tstamp";
"hinawa_fw_node_read_cycle_time";
+
+ "hinawa_fw_req_transaction_with_tstamp_sync";
} HINAWA_2_5_0;
diff --git a/tests/fw-req b/tests/fw-req
index 2301f18..341ca1b 100755
--- a/tests/fw-req
+++ b/tests/fw-req
@@ -18,6 +18,7 @@ methods = (
'transaction',
'transaction_async',
'transaction_sync',
+ 'transaction_with_tstamp_sync',
)
vmethods = (
'do_responded',