-
-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added get/set register node value #833
Changes from all commits
4dc7779
f0e0262
960ca45
8678c1f
43c5305
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
#include <arvgcfeaturenode.h> | ||
#include <arvgcboolean.h> | ||
#include <arvgcenumeration.h> | ||
#include <arvgcregister.h> | ||
#include <arvgcstring.h> | ||
#include <arvstream.h> | ||
#include <arvdebug.h> | ||
|
@@ -798,6 +799,72 @@ arv_device_get_float_feature_increment (ArvDevice *device, const char *feature, | |
return G_MINDOUBLE; | ||
} | ||
|
||
/** | ||
* arv_device_set_register_feature_value: | ||
* @device: a #ArvDevice | ||
* @feature: feature name | ||
* @value: new feature value | ||
* @error: a #GError placeholder | ||
* | ||
* Set the register feature value. | ||
* | ||
* Since: | ||
*/ | ||
|
||
void | ||
arv_device_set_register_feature_value (ArvDevice *device, const char *feature, guint64 length, void* value, GError **error) | ||
{ | ||
ArvGcNode *node; | ||
|
||
node = _get_feature (device, ARV_TYPE_GC_REGISTER, feature, error); | ||
if (node != NULL) | ||
arv_gc_register_set (ARV_GC_REGISTER (node), value, length, error); | ||
} | ||
|
||
/** | ||
* arv_device_get_register_feature_value: | ||
* @device: a #ArvDevice | ||
* @feature: feature name | ||
* @value: (out): the register feature value | ||
* @error: a #GError placeholder | ||
* | ||
* Retrive the register feature value. | ||
* | ||
* Since: | ||
*/ | ||
|
||
void | ||
arv_device_get_register_feature_value (ArvDevice *device, const char *feature, guint64 length, void* value, GError **error) | ||
{ | ||
ArvGcNode *node; | ||
|
||
node = _get_feature (device, ARV_TYPE_GC_REGISTER, feature, error); | ||
if (node != NULL) | ||
arv_gc_register_get (ARV_GC_REGISTER (node), value, length, error); | ||
} | ||
|
||
/** | ||
* arv_device_get_register_feature_length: | ||
* @device: a #ArvDevice | ||
* @feature: feature name | ||
* @error: a #GError placeholder | ||
* | ||
* Returns: the length of register value, 0 if not available | ||
* | ||
* Since: | ||
*/ | ||
|
||
guint64 | ||
arv_device_get_register_feature_length (ArvDevice *device, const char *feature, GError **error) | ||
{ | ||
ArvGcNode *node; | ||
node = _get_feature (device, ARV_TYPE_GC_REGISTER, feature, error); | ||
if (node != NULL) | ||
return arv_gc_register_get_length(ARV_GC_REGISTER (node), error); | ||
|
||
return 0; | ||
} | ||
|
||
Comment on lines
+836
to
+867
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark here about the API simplification. In arvDevice, the get_register function should take care to check the buffer length value is lower than the maximum size (2^16), and return an error otherwise. |
||
/** | ||
* arv_device_dup_available_enumeration_feature_values: | ||
* @device: an #ArvDevice | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,12 @@ arv_tool_show_feature (ArvGcFeatureNode *node, ArvToolListMode list_mode, int le | |
value = g_strdup_printf ("%s", | ||
arv_gc_boolean_get_value (ARV_GC_BOOLEAN (node), | ||
&error) ? "true" : "false"); | ||
} else if (ARV_IS_GC_REGISTER (node)) { | ||
void* buffer; | ||
guint64 length = arv_gc_register_get_length(ARV_GC_REGISTER (node), &error); | ||
arv_gc_register_get (ARV_GC_REGISTER (node), buffer, length, &error); | ||
|
||
value = g_strdup_printf ("%" G_GUINT64_FORMAT, (char *)buffer ? length : 0); | ||
} | ||
} | ||
|
||
|
@@ -364,7 +370,28 @@ arv_tool_control (int argc, char **argv, ArvDevice *device) | |
|
||
if (error == NULL) | ||
printf ("%s = %s\n", tokens[0], value ? "true" : "false"); | ||
} else { | ||
} else if (ARV_IS_GC_REGISTER (feature)) { | ||
unsigned char* buffer; | ||
|
||
guint64 length = arv_gc_register_get_length(ARV_GC_REGISTER (feature), &error); | ||
if (error == NULL) | ||
printf ("Length of %s = %"G_GUINT64_FORMAT"\n", tokens[0], length); | ||
|
||
buffer = (unsigned char*) malloc(length); | ||
arv_gc_register_get (ARV_GC_REGISTER (feature), (void*)buffer, length, &error); | ||
|
||
if (error == NULL){ | ||
printf("Content of %s =", tokens[0]); | ||
for( int i = 0; i < length; i++){ | ||
if ( i%8 == 0){ | ||
printf("\n\t"); | ||
} | ||
printf("0x%02x ", *((buffer)+i)); | ||
Comment on lines
+383
to
+389
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use arv_g_string_append_hex_dump here. Please format the output as:
|
||
} | ||
} | ||
printf("\n"); | ||
free(buffer); | ||
}else { | ||
const char *value = arv_gc_feature_node_get_value_as_string | ||
(ARV_GC_FEATURE_NODE (feature), &error); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simplify the API here, and make get_register allocate a buffer and return the buffer length, and suppress get_register_length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And rename get_register to dup_register, which makes clear the data must be freed after use.