Skip to content

Commit

Permalink
arv: add arv_get_device_manufacturer_info API
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelP committed Dec 15, 2021
1 parent 08dc0ba commit e60c25a
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 49 deletions.
2 changes: 2 additions & 0 deletions docs/reference/aravis/aravis-sections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ arv_get_device_physical_id
arv_get_device_model
arv_get_device_serial_nbr
arv_get_device_vendor
arv_get_device_manufacturer_info
arv_get_device_address
arv_get_device_protocol
arv_open_device
Expand All @@ -298,6 +299,7 @@ arv_interface_get_device_model
arv_interface_get_device_physical_id
arv_interface_get_device_serial_nbr
arv_interface_get_device_vendor
arv_interface_get_device_manufacturer_info
arv_interface_get_device_protocol
arv_interface_get_n_devices
arv_interface_open_device
Expand Down
1 change: 1 addition & 0 deletions src/arvfakecamera.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ arv_fake_camera_new_full (const char *serial_number, const char *genicam_filenam

strcpy (((char *) memory) + ARV_GVBS_MANUFACTURER_NAME_OFFSET, "Aravis");
strcpy (((char *) memory) + ARV_GVBS_MODEL_NAME_OFFSET, "Fake");
strcpy (((char *) memory) + ARV_GVBS_MANUFACTURER_INFO_OFFSET, "none");
strcpy (((char *) memory) + ARV_GVBS_DEVICE_VERSION_OFFSET, ARAVIS_VERSION);
strcpy (((char *) memory) + ARV_GVBS_SERIAL_NUMBER_OFFSET, serial_number);

Expand Down
14 changes: 8 additions & 6 deletions src/arvfakeinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
#include <arvdebug.h>
#include <arvmisc.h>

#define ARV_FAKE_DEVICE_ID "Fake_1"
#define ARV_FAKE_PHYSICAL_ID "Fake_1"
#define ARV_FAKE_ADDRESS "0.0.0.0"
#define ARV_FAKE_VENDOR "Aravis"
#define ARV_FAKE_MODEL "Fake"
#define ARV_FAKE_SERIAL "1"
#define ARV_FAKE_DEVICE_ID "Fake_1"
#define ARV_FAKE_PHYSICAL_ID "Fake_1"
#define ARV_FAKE_ADDRESS "0.0.0.0"
#define ARV_FAKE_VENDOR "Aravis"
#define ARV_FAKE_MANUFACTURER_INFO "none"
#define ARV_FAKE_MODEL "Fake"
#define ARV_FAKE_SERIAL "1"

struct _ArvFakeInterface {
ArvInterface interface;
Expand All @@ -62,6 +63,7 @@ arv_fake_interface_update_device_list (ArvInterface *interface, GArray *device_i
ids->physical = g_strdup (ARV_FAKE_PHYSICAL_ID);
ids->address = g_strdup (ARV_FAKE_ADDRESS);
ids->vendor = g_strdup (ARV_FAKE_VENDOR);
ids->manufacturer_info = g_strdup (ARV_FAKE_MANUFACTURER_INFO);
ids->model = g_strdup (ARV_FAKE_MODEL);
ids->serial_nbr = g_strdup (ARV_FAKE_SERIAL);

Expand Down
4 changes: 2 additions & 2 deletions src/arvgvcpprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ G_BEGIN_DECLS
#define ARV_GVBS_DEVICE_VERSION_OFFSET 0x00000088
#define ARV_GVBS_DEVICE_VERSION_SIZE 32

#define ARV_GVBS_MANUFACTURER_INFORMATIONS_OFFSET 0x000000a8
#define ARV_GVBS_MANUFACTURER_INFORMATIONS_SIZE 48
#define ARV_GVBS_MANUFACTURER_INFO_OFFSET 0x000000a8
#define ARV_GVBS_MANUFACTURER_INFO_SIZE 48

#define ARV_GVBS_SERIAL_NUMBER_OFFSET 0x000000d8
#define ARV_GVBS_SERIAL_NUMBER_SIZE 16
Expand Down
31 changes: 18 additions & 13 deletions src/arvgvinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ typedef struct {
char *vendor_serial;
char *vendor_alias_serial;
char *vendor;
char *manufacturer_info;
char *model;
char *serial;
char *mac;
Expand Down Expand Up @@ -247,19 +248,21 @@ arv_gv_interface_device_infos_new (GInetAddress *interface_address,

infos->vendor = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_MANUFACTURER_NAME_OFFSET],
ARV_GVBS_MANUFACTURER_NAME_SIZE);
infos->model = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_MODEL_NAME_OFFSET],
ARV_GVBS_MODEL_NAME_SIZE);
infos->serial = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_SERIAL_NUMBER_OFFSET],
ARV_GVBS_SERIAL_NUMBER_SIZE);
infos->user_id = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_USER_DEFINED_NAME_OFFSET],
ARV_GVBS_USER_DEFINED_NAME_SIZE);
infos->mac = g_strdup_printf ("%02x:%02x:%02x:%02x:%02x:%02x",
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 2],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 3],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 4],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 5],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 6],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 7]);
infos->manufacturer_info = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_MANUFACTURER_INFO_OFFSET],
ARV_GVBS_MANUFACTURER_INFO_SIZE);
infos->model = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_MODEL_NAME_OFFSET],
ARV_GVBS_MODEL_NAME_SIZE);
infos->serial = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_SERIAL_NUMBER_OFFSET],
ARV_GVBS_SERIAL_NUMBER_SIZE);
infos->user_id = g_strndup ((char *) &infos->discovery_data[ARV_GVBS_USER_DEFINED_NAME_OFFSET],
ARV_GVBS_USER_DEFINED_NAME_SIZE);
infos->mac = g_strdup_printf ("%02x:%02x:%02x:%02x:%02x:%02x",
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 2],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 3],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 4],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 5],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 6],
infos->discovery_data[ARV_GVBS_DEVICE_MAC_ADDRESS_HIGH_OFFSET + 7]);

/* Some devices return a zero length string as the serial identifier.
* Use the MAC address as the serial number in this case */
Expand Down Expand Up @@ -309,6 +312,7 @@ arv_gv_interface_device_infos_unref (ArvGvInterfaceDeviceInfos *infos)
g_free (infos->vendor_serial);
g_free (infos->vendor_alias_serial);
g_free (infos->vendor);
g_free (infos->manufacturer_info);
g_free (infos->model);
g_free (infos->serial);
g_free (infos->mac);
Expand Down Expand Up @@ -502,6 +506,7 @@ arv_gv_interface_update_device_list (ArvInterface *interface, GArray *device_ids
ids->physical = g_strdup (infos->mac);
ids->address = g_inet_address_to_string (device_address);
ids->vendor = g_strdup (infos->vendor);
ids->manufacturer_info = g_strdup (infos->manufacturer_info);
ids->model = g_strdup (infos->model);
ids->serial_nbr = g_strdup (infos->serial);

Expand Down
30 changes: 30 additions & 0 deletions src/arvinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ arv_interface_clear_device_ids (ArvInterface *interface)
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i)->physical);
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i)->address);
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i)->vendor);
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i)->manufacturer_info);
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i)->model);
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i)->serial_nbr);
g_free (g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, i));
Expand Down Expand Up @@ -232,6 +233,35 @@ arv_interface_get_device_vendor (ArvInterface *interface, unsigned int index)
return g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, index)->vendor;
}

/**
* arv_interface_get_device_manufacturer_info:
* @interface: a #ArvInterface
* @index: device index
*
* Queries the device manufacturer info.
*
* Prior to this call the arv_interface_update_device_list()
* function must be called.
*
* Returns: (transfer none): the device manufacturer info, NULL on error
*
* Since: 0.8.20
*/

const char *
arv_interface_get_device_manufacturer_info (ArvInterface *interface, unsigned int index)
{
ArvInterfacePrivate *priv = arv_interface_get_instance_private (interface);

g_return_val_if_fail (ARV_IS_INTERFACE (interface), 0);
g_return_val_if_fail (priv->device_ids != NULL, 0);

if (index >= priv->device_ids->len)
return NULL;

return g_array_index (priv->device_ids, ArvInterfaceDeviceIds *, index)->manufacturer_info;
}

/**
* arv_interface_get_device_model:
* @interface: a #ArvInterface
Expand Down
22 changes: 12 additions & 10 deletions src/arvinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ struct _ArvInterfaceClass {
const char * protocol;
};

ARV_API void arv_interface_update_device_list (ArvInterface *interface);
ARV_API unsigned int arv_interface_get_n_devices (ArvInterface *interface);
ARV_API const char * arv_interface_get_device_id (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_physical_id (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_address (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_vendor (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_model (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_serial_nbr (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_protocol (ArvInterface *interface, unsigned int index);
ARV_API ArvDevice * arv_interface_open_device (ArvInterface *interface, const char *device_id, GError **error);
ARV_API void arv_interface_update_device_list (ArvInterface *interface);
ARV_API unsigned int arv_interface_get_n_devices (ArvInterface *interface);
ARV_API const char * arv_interface_get_device_id (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_physical_id (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_address (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_vendor (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_manufacturer_info (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_model (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_serial_nbr (ArvInterface *interface, unsigned int index);
ARV_API const char * arv_interface_get_device_protocol (ArvInterface *interface, unsigned int index);
ARV_API ArvDevice * arv_interface_open_device (ArvInterface *interface, const char *device_id,
GError **error);

G_END_DECLS

Expand Down
1 change: 1 addition & 0 deletions src/arvinterfaceprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef struct {
char *physical;
char *address;
char *vendor;
char *manufacturer_info;
char *model;
char *serial_nbr;
} ArvInterfaceDeviceIds;
Expand Down
20 changes: 20 additions & 0 deletions src/arvsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,26 @@ arv_get_device_vendor (unsigned int index)
return arv_get_info (index, arv_interface_get_device_vendor);
}

/**
* arv_get_device_manufacturer_info:
* @index: device index
*
* Queries the device manufacturer info.
*
* Prior to this call the arv_update_device_list()
* function must be called.
*
* Returns: (transfer none): the device manufacturer info, NULL on error
*
* Since: 0.8.20
*/

const char *
arv_get_device_manufacturer_info (unsigned int index)
{
return arv_get_info (index, arv_interface_get_device_manufacturer_info);
}

/**
* arv_get_device_model:
* @index: device index
Expand Down
37 changes: 19 additions & 18 deletions src/arvsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@

G_BEGIN_DECLS

ARV_API unsigned int arv_get_n_interfaces (void);
ARV_API const char * arv_get_interface_id (unsigned int index);
ARV_API void arv_enable_interface (const char *interface_id);
ARV_API void arv_disable_interface (const char *interface_id);

ARV_API void arv_update_device_list (void);
ARV_API unsigned int arv_get_n_devices (void);
ARV_API const char * arv_get_device_id (unsigned int index);
ARV_API const char * arv_get_device_physical_id (unsigned int index);
ARV_API const char * arv_get_device_address (unsigned int index);
ARV_API const char * arv_get_device_vendor (unsigned int index);
ARV_API const char * arv_get_device_model (unsigned int index);
ARV_API const char * arv_get_device_serial_nbr (unsigned int index);
ARV_API const char * arv_get_device_protocol (unsigned int index);

ARV_API ArvDevice * arv_open_device (const char *device_id, GError **error);

ARV_API void arv_shutdown (void);
ARV_API unsigned int arv_get_n_interfaces (void);
ARV_API const char * arv_get_interface_id (unsigned int index);
ARV_API void arv_enable_interface (const char *interface_id);
ARV_API void arv_disable_interface (const char *interface_id);

ARV_API void arv_update_device_list (void);
ARV_API unsigned int arv_get_n_devices (void);
ARV_API const char * arv_get_device_id (unsigned int index);
ARV_API const char * arv_get_device_physical_id (unsigned int index);
ARV_API const char * arv_get_device_address (unsigned int index);
ARV_API const char * arv_get_device_vendor (unsigned int index);
ARV_API const char * arv_get_device_manufacturer_info (unsigned int index);
ARV_API const char * arv_get_device_model (unsigned int index);
ARV_API const char * arv_get_device_serial_nbr (unsigned int index);
ARV_API const char * arv_get_device_protocol (unsigned int index);

ARV_API ArvDevice * arv_open_device (const char *device_id, GError **error);

ARV_API void arv_shutdown (void);

G_END_DECLS

Expand Down
1 change: 1 addition & 0 deletions src/arvuvinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ _usb_device_to_device_ids (ArvUvInterface *uv_interface, libusb_device *device)
device_ids->physical = g_strdup (device_infos->guid);
device_ids->address = g_strdup ("USB3"); /* FIXME */
device_ids->vendor = g_strdup (device_infos->manufacturer);
device_ids->manufacturer_info = g_strdup ("none");
device_ids->model = g_strdup (device_infos->product);
device_ids->serial_nbr = g_strdup (device_infos->serial_nbr);

Expand Down
22 changes: 22 additions & 0 deletions tests/fake.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#include <glib.h>
#include <arv.h>

static void
discovery_test (void)
{
int n_devices;
int i;

n_devices = arv_get_n_devices ();

for (i = 0; i < n_devices; i++) {
if (g_strcmp0 (arv_get_device_vendor (i), "Aravis") == 0 &&
g_strcmp0 (arv_get_device_model (i), "Fake") == 0 &&
g_strcmp0 (arv_get_device_serial_nbr (i), "1") == 0 &&
g_strcmp0 (arv_get_device_manufacturer_info (i), "none") == 0 &&
g_strcmp0 (arv_get_device_id (i), "Fake_1") == 0 &&
g_strcmp0 (arv_get_device_physical_id (i), "Fake_1") == 0)
return;
}

g_assert_not_reached ();
}

static void
trigger_registers_test (void)
{
Expand Down Expand Up @@ -676,6 +697,7 @@ main (int argc, char *argv[])

arv_update_device_list ();

g_test_add_func ("/fake/discovery-test", discovery_test);
g_test_add_func ("/fake/trigger-registers", trigger_registers_test);
g_test_add_func ("/fake/registers", registers_test);
g_test_add_func ("/fake/fake-device", fake_device_test);
Expand Down
24 changes: 24 additions & 0 deletions tests/fakegv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@

static ArvCamera *camera = NULL;

static void
discovery_test (void)
{
int n_devices;
int i;

n_devices = arv_get_n_devices ();

for (i = 0; i < n_devices; i++) {
if (g_strcmp0 (arv_get_device_vendor (i), "Aravis") == 0 &&
g_strcmp0 (arv_get_device_model (i), "Fake") == 0 &&
g_strcmp0 (arv_get_device_serial_nbr (i), "GVTest") == 0 &&
g_strcmp0 (arv_get_device_manufacturer_info (i), "none") == 0 &&
g_strcmp0 (arv_get_device_id (i), "Aravis-Fake-GVTest") == 0 &&
g_strcmp0 (arv_get_device_physical_id (i), "00:00:00:00:00:00") == 0)
return;
}

g_assert_not_reached ();
}

static void
register_test (void)
{
Expand Down Expand Up @@ -234,6 +255,9 @@ main (int argc, char *argv[])
camera = arv_camera_new ("Aravis-GVTest", NULL);
g_assert (ARV_IS_CAMERA (camera));

arv_update_device_list ();

g_test_add_func ("/fakegv/discovery", discovery_test);
g_test_add_func ("/fakegv/device_registers", register_test);
g_test_add_func ("/fakegv/acquisition", acquisition_test);
g_test_add_func ("/fakegv/stream", stream_test);
Expand Down

0 comments on commit e60c25a

Please sign in to comment.