diff --git a/src/arvcamera.c b/src/arvcamera.c index 508d459cd..6786c1865 100644 --- a/src/arvcamera.c +++ b/src/arvcamera.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -2816,6 +2817,69 @@ arv_camera_get_float_increment (ArvCamera *camera, const char *feature, GError * return arv_device_get_float_feature_increment (priv->device, feature, error); } +/** + * arv_camera_set_register: + * @camera: a #ArvCamera + * @feature: feature name + * @value: new feature value + * @error: a #GError placeholder, %NULL to ignore + * + * Set a register feature value. + * + * Since: + */ + +void +arv_camera_set_register (ArvCamera *camera, const char *feature, guint64 length, void* value, GError **error) +{ + ArvCameraPrivate *priv = arv_camera_get_instance_private (camera); + + g_return_if_fail (ARV_IS_CAMERA (camera)); + + arv_device_set_register_feature_value (priv->device, feature, length, value, error); +} + +/** + * arv_camera_get_register: + * @camera: a #ArvCamera + * @feature: feature name + * @value: (out): the register feature value + * @error: a #GError placeholder, %NULL to ignore + * + * Since: + */ + +void +arv_camera_get_register (ArvCamera *camera, const char *feature,guint64 length, void* value, GError **error) +{ + ArvCameraPrivate *priv = arv_camera_get_instance_private (camera); + + g_return_val_if_fail (ARV_IS_CAMERA (camera), 0.0); + + return arv_device_get_register_feature_value (priv->device, feature, length, value, error); +} + +/** + * arv_camera_get_register_length: + * @camera: a #ArvCamera + * @feature: feature name + * @error: a #GError placeholder, %NULL to ignore + * + * Returns: the length of register value. + * + * Since: + */ + +guint64 +arv_camera_get_register_length (ArvCamera *camera, const char *feature, GError **error) +{ + ArvCameraPrivate *priv = arv_camera_get_instance_private (camera); + + g_return_val_if_fail (ARV_IS_CAMERA (camera), 0.0); + + return arv_device_get_register_feature_length (priv->device, feature, error); +} + /** * arv_camera_dup_available_enumerations: * @camera: a #ArvCamera diff --git a/src/arvcamera.h b/src/arvcamera.h index bc5f28e86..7dd2b374a 100644 --- a/src/arvcamera.h +++ b/src/arvcamera.h @@ -196,6 +196,10 @@ ARV_API double arv_camera_get_float (ArvCamera *camera, const char *feature, ARV_API void arv_camera_get_float_bounds (ArvCamera *camera, const char *feature, double *min, double *max, GError **error); ARV_API double arv_camera_get_float_increment (ArvCamera *camera, const char *feature, GError **error); +ARV_API void arv_camera_set_register (ArvCamera *camera, const char *feature, guint64 length, void* value, GError **error); +ARV_API void arv_camera_get_register (ArvCamera *camera, const char *feature, guint64 length, void* value, GError **error); +ARV_API guint64 arv_camera_get_register_length (ArvCamera *camera, const char *feature, GError **error); + ARV_API gint64 * arv_camera_dup_available_enumerations (ArvCamera *camera, const char *feature, guint *n_values, GError **error); ARV_API const char ** arv_camera_dup_available_enumerations_as_strings (ArvCamera *camera, const char *feature, diff --git a/src/arvchunkparser.c b/src/arvchunkparser.c index fd604af11..b522f4e2d 100644 --- a/src/arvchunkparser.c +++ b/src/arvchunkparser.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/src/arvdevice.c b/src/arvdevice.c index 93606b094..b08c4469d 100644 --- a/src/arvdevice.c +++ b/src/arvdevice.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -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. + * + * 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; +} + /** * arv_device_dup_available_enumeration_feature_values: * @device: an #ArvDevice diff --git a/src/arvdevice.h b/src/arvdevice.h index a13fcbbd7..72e7fa75e 100644 --- a/src/arvdevice.h +++ b/src/arvdevice.h @@ -133,6 +133,10 @@ ARV_API void arv_device_set_float_feature_value (ArvDevice *device, const char ARV_API double arv_device_get_float_feature_value (ArvDevice *device, const char *feature, GError **error); ARV_API void arv_device_get_float_feature_bounds (ArvDevice *device, const char *feature, double *min, double *max, GError **error); ARV_API double arv_device_get_float_feature_increment (ArvDevice *device, const char *feature, GError **error); + +ARV_API void arv_device_set_register_feature_value (ArvDevice *device, const char *feature, guint64 length, void* value, GError **error); +ARV_API void arv_device_get_register_feature_value (ArvDevice *device, const char *feature, guint64 length, void* value, GError **error); +ARV_API guint64 arv_device_get_register_feature_length (ArvDevice *device, const char *feature, GError **error); ARV_API gint64 * arv_device_dup_available_enumeration_feature_values (ArvDevice *device, const char *feature, guint *n_values, GError **error); diff --git a/src/arvgcenumeration.c b/src/arvgcenumeration.c index 454da2bd7..7a26f6625 100644 --- a/src/arvgcenumeration.c +++ b/src/arvgcenumeration.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/arvgcfeaturenode.c b/src/arvgcfeaturenode.c index 9bb3c7e65..3580bd526 100644 --- a/src/arvgcfeaturenode.c +++ b/src/arvgcfeaturenode.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/src/arvgcpropertynode.c b/src/arvgcpropertynode.c index 684ba7c68..d6a82ac2c 100644 --- a/src/arvgcpropertynode.c +++ b/src/arvgcpropertynode.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/src/arvgcstringnode.c b/src/arvgcstringnode.c index fcdb8a9f0..c923bd9f7 100644 --- a/src/arvgcstringnode.c +++ b/src/arvgcstringnode.c @@ -26,6 +26,7 @@ */ #include +#include #include #include #include diff --git a/src/arvtool.c b/src/arvtool.c index f6026cd94..9d7a2c208 100644 --- a/src/arvtool.c +++ b/src/arvtool.c @@ -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)); + } + } + printf("\n"); + free(buffer); + }else { const char *value = arv_gc_feature_node_get_value_as_string (ARV_GC_FEATURE_NODE (feature), &error);