[aravis] control: provide direct device register access, with R[address] syntax.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] control: provide direct device register access, with R[address] syntax.
- Date: Tue, 21 Jun 2011 06:54:56 +0000 (UTC)
commit bc5cdaaa16e98fc75b63f75071d266872ea6a09c
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Tue Jun 21 08:54:24 2011 +0200
control: provide direct device register access, with R[address] syntax.
src/arvcontrol.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/src/arvcontrol.c b/src/arvcontrol.c
index c4c30d4..c5157f2 100644
--- a/src/arvcontrol.c
+++ b/src/arvcontrol.c
@@ -1,5 +1,6 @@
#include <arv.h>
#include <stdlib.h>
+#include <string.h>
#include <stdio.h>
static char *arv_option_device_name = NULL;
@@ -83,7 +84,10 @@ main (int argc, char **argv)
g_option_context_set_description (context,
"For example the setting of the Width and Height features, followed by"
" the read of the Gain, is done with this command: 'arv-control-"
- ARAVIS_API_VERSION " Width=128 Height=128 Gain'.");
+ ARAVIS_API_VERSION " Width=128 Height=128 Gain'.\n"
+ "Direct access to device registers is provided using a R[address] syntax"
+ " in place of a feature name, like: 'arv-control-" ARAVIS_API_VERSION
+ " R[0x10000] R[0x10004]=10'" );
g_option_context_add_main_entries (context, arv_option_entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
@@ -117,7 +121,24 @@ main (int argc, char **argv)
tokens = g_strsplit (argv[i], "=", 2);
feature = arv_device_get_feature (device, tokens[0]);
if (!ARV_IS_GC_NODE (feature))
- printf ("Feature '%s' not found\n", tokens[0]);
+ if (g_strrstr (tokens[0], "R[") == tokens[0]) {
+ guint32 value;
+ guint32 address;
+
+ address = g_ascii_strtoll(&tokens[0][2], NULL, 0);
+
+ if (tokens[1] != NULL) {
+ arv_device_write_register (device,
+ address,
+ g_ascii_strtoll (tokens[1], NULL, 0));
+ }
+
+ arv_device_read_register (device, address, &value);
+
+ printf ("R[0x%08x] = 0x%08x\n",
+ address, value);
+ } else
+ printf ("Feature '%s' not found\n", tokens[0]);
else {
if (ARV_IS_GC_COMMAND (feature)) {
arv_gc_command_execute (ARV_GC_COMMAND (feature));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]