Skip to content

Commit

Permalink
added get/set register node value
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixstars-momoko committed Oct 31, 2023
1 parent 73a4ec4 commit 4dc7779
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 1 deletion.
64 changes: 64 additions & 0 deletions src/arvcamera.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <arvgcfloat.h>
#include <arvgcenumeration.h>
#include <arvgcenumentry.h>
#include <arvgcregister.h>
#include <arvgcstring.h>
#include <arvbuffer.h>
#include <arvgc.h>
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/arvcamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/arvchunkparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <arvbuffer.h>
#include <arvgcinteger.h>
#include <arvgcfloat.h>
#include <arvgcregister.h>
#include <arvgcstring.h>
#include <arvgcboolean.h>
#include <arvdebugprivate.h>
Expand Down
67 changes: 67 additions & 0 deletions src/arvdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/arvdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/arvgcenumeration.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <arvgcenumentry.h>
#include <arvgcinteger.h>
#include <arvgcselector.h>
#include <arvgcregister.h>
#include <arvgcstring.h>
#include <arvgcfeaturenodeprivate.h>
#include <arvgc.h>
Expand Down
1 change: 1 addition & 0 deletions src/arvgcfeaturenode.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <arvgcboolean.h>
#include <arvgcinteger.h>
#include <arvgcfloat.h>
#include <arvgcregister.h>
#include <arvgcstring.h>
#include <arvgcenumeration.h>
#include <arvgcenums.h>
Expand Down
1 change: 1 addition & 0 deletions src/arvgcpropertynode.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <arvgcinteger.h>
#include <arvgcfloat.h>
#include <arvgcboolean.h>
#include <arvgcregister.h>
#include <arvgcstring.h>
#include <arvgc.h>
#include <arvdomtext.h>
Expand Down
1 change: 1 addition & 0 deletions src/arvgcstringnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <arvgcstringnode.h>
#include <arvgcregister.h>
#include <arvgcstring.h>
#include <arvgcinteger.h>
#include <arvgcvalueindexednode.h>
Expand Down
29 changes: 28 additions & 1 deletion src/arvtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 4dc7779

Please sign in to comment.