ArvChunkParser * arv_chunk_parser_new (const char *xml, gsize size) { ArvChunkParser *chunk_parser; ArvGc *genicam; genicam = arv_gc_new (NULL, xml, size); g_return_val_if_fail (ARV_IS_GC (genicam), NULL); chunk_parser = g_object_new (ARV_TYPE_CHUNK_PARSER, "genicam", genicam, NULL); g_object_unref (genicam); return chunk_parser; }
ArvDevice * arv_fake_device_new (const char *serial_number) { ArvFakeDevice *fake_device; g_return_val_if_fail (serial_number != NULL, NULL); fake_device = g_object_new (ARV_TYPE_FAKE_DEVICE, NULL); fake_device->priv->camera = arv_fake_camera_new (serial_number); fake_device->priv->genicam_xml = arv_get_fake_camera_genicam_xml (&fake_device->priv->genicam_xml_size); fake_device->priv->genicam = arv_gc_new (ARV_DEVICE (fake_device), fake_device->priv->genicam_xml, fake_device->priv->genicam_xml_size); return ARV_DEVICE (fake_device); }
static void arv_gv_device_load_genicam (ArvGvDevice *gv_device) { const char *genicam; size_t size; genicam = arv_gv_device_get_genicam_xml (ARV_DEVICE (gv_device), &size); if (genicam != NULL) { gv_device->priv->genicam = arv_gc_new (ARV_DEVICE (gv_device), genicam, size); arv_gc_set_default_node_data (gv_device->priv->genicam, "GevSCPSPacketSize", "<Integer Name=\"GevSCPSPacketSize\">" "<Visibility>Expert</Visibility>" "<pIsLocked>TLParamsLocked</pIsLocked>" "<pValue>GevSCPSPacketSizeReg</pValue>" "</Integer>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "GevSCPSPacketSizeReg", "<MaskedIntReg Name=\"GevSCPSPacketSizeReg\">" "<Address>0xd04</Address>" "<Length>4</Length>" "<AccessMode>RW</AccessMode>" "<pPort>Device</pPort>" "<LSB>31</LSB>" "<MSB>16</MSB>" "<Sign>Unsigned</Sign>" "<Endianess>BigEndian</Endianess>" "</MaskedIntReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "TLParamsLocked", "<Integer Name=\"TLParamsLocked\">" "<Visibility>Invisible</Visibility>" "<Value>0</Value>" "<Min>0</Min>" "<Max>1</Max>" "</Integer>"); } }
static void _bootstrap (ArvUvDevice *uv_device) { ArvDevice *device = ARV_DEVICE (uv_device); guint64 offset; guint32 response_time; guint64 manifest_table_address; guint64 device_capability; guint32 max_cmd_transfer; guint32 max_ack_transfer; guint32 u3vcp_capability; guint64 sirm_offset; guint32 si_info; guint32 si_control; guint64 si_req_payload_size; guint32 si_req_leader_size; guint32 si_req_trailer_size; guint32 si_max_leader_size; guint32 si_payload_size; guint32 si_payload_count; guint32 si_transfer1_size; guint32 si_transfer2_size; guint32 si_max_trailer_size; guint64 manifest_n_entries; ArvUvcpManifestEntry entry; ArvUvcpManifestSchemaType schema_type; GString *string; void *data; char manufacturer[64]; arv_debug_device ("Get genicam"); arv_device_read_memory(device, ARV_ABRM_MANUFACTURER_NAME, 64, &manufacturer, NULL); manufacturer[63] = 0; arv_debug_device ("MANUFACTURER_NAME = '%s'", manufacturer); arv_device_read_memory (device, ARV_ABRM_SBRM_ADDRESS, sizeof (guint64), &offset, NULL); arv_device_read_memory (device, ARV_ABRM_MAX_DEVICE_RESPONSE_TIME, sizeof (guint32), &response_time, NULL); arv_device_read_memory (device, ARV_ABRM_DEVICE_CAPABILITY, sizeof (guint64), &device_capability, NULL); arv_device_read_memory (device, ARV_ABRM_MANIFEST_TABLE_ADDRESS, sizeof (guint64), &manifest_table_address, NULL); arv_debug_device ("MAX_DEVICE_RESPONSE_TIME = 0x%08x", response_time); arv_debug_device ("DEVICE_CAPABILITY = 0x%016lx", device_capability); arv_debug_device ("SRBM_ADDRESS = 0x%016lx", offset); arv_debug_device ("MANIFEST_TABLE_ADDRESS = 0x%016lx", manifest_table_address); uv_device->priv->timeout_ms = MAX (ARV_UVCP_DEFAULT_RESPONSE_TIME_MS, response_time); arv_device_read_memory (device, offset + ARV_SBRM_U3VCP_CAPABILITY, sizeof (guint32), &u3vcp_capability, NULL); arv_device_read_memory (device, offset + ARV_SBRM_MAX_CMD_TRANSFER, sizeof (guint32), &max_cmd_transfer, NULL); arv_device_read_memory (device, offset + ARV_SBRM_MAX_ACK_TRANSFER, sizeof (guint32), &max_ack_transfer, NULL); arv_device_read_memory (device, offset + ARV_SBRM_SIRM_ADDRESS, sizeof (guint64), &sirm_offset, NULL); arv_debug_device ("U3VCP_CAPABILITY = 0x%08x", u3vcp_capability); arv_debug_device ("MAX_CMD_TRANSFER = 0x%08x", max_cmd_transfer); arv_debug_device ("MAX_ACK_TRANSFER = 0x%08x", max_ack_transfer); arv_debug_device ("SIRM_OFFSET = 0x%016lx", sirm_offset); uv_device->priv->cmd_packet_size_max = MIN (uv_device->priv->cmd_packet_size_max, max_cmd_transfer); uv_device->priv->ack_packet_size_max = MIN (uv_device->priv->ack_packet_size_max, max_ack_transfer); arv_device_read_memory (device, sirm_offset + ARV_SI_INFO, sizeof (si_info), &si_info, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_CONTROL, sizeof (si_control), &si_control, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_PAYLOAD_SIZE, sizeof (si_req_payload_size), &si_req_payload_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_LEADER_SIZE, sizeof (si_req_leader_size), &si_req_leader_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_TRAILER_SIZE, sizeof (si_req_trailer_size), &si_req_trailer_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_MAX_LEADER_SIZE, sizeof (si_max_leader_size), &si_max_leader_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_PAYLOAD_SIZE, sizeof (si_payload_size), &si_payload_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_PAYLOAD_COUNT, sizeof (si_payload_count), &si_payload_count, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_TRANSFER1_SIZE, sizeof (si_transfer1_size), &si_transfer1_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_TRANSFER2_SIZE, sizeof (si_transfer2_size), &si_transfer2_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_MAX_TRAILER_SIZE, sizeof (si_max_trailer_size), &si_max_trailer_size, NULL); arv_debug_device ("SI_INFO = 0x%08x", si_info); arv_debug_device ("SI_CONTROL = 0x%08x", si_control); arv_debug_device ("SI_REQ_PAYLOAD_SIZE = 0x%016lx", si_req_payload_size); arv_debug_device ("SI_REQ_LEADER_SIZE = 0x%08x", si_req_leader_size); arv_debug_device ("SI_REQ_TRAILER_SIZE = 0x%08x", si_req_trailer_size); arv_debug_device ("SI_MAX_LEADER_SIZE = 0x%08x", si_max_leader_size); arv_debug_device ("SI_PAYLOAD_SIZE = 0x%08x", si_payload_size); arv_debug_device ("SI_PAYLOAD_COUNT = 0x%08x", si_payload_count); arv_debug_device ("SI_TRANSFER1_SIZE = 0x%08x", si_transfer1_size); arv_debug_device ("SI_TRANSFER2_SIZE = 0x%08x", si_transfer2_size); arv_debug_device ("SI_MAX_TRAILER_SIZE = 0x%08x", si_max_trailer_size); arv_device_read_memory (device, manifest_table_address, sizeof (guint64), &manifest_n_entries, NULL); arv_device_read_memory (device, manifest_table_address + 0x08, sizeof (entry), &entry, NULL); arv_debug_device ("MANIFEST_N_ENTRIES = 0x%016lx", manifest_n_entries); string = g_string_new (""); arv_g_string_append_hex_dump (string, &entry, sizeof (entry)); arv_debug_device ("MANIFEST ENTRY\n%s", string->str); g_string_free (string, TRUE); arv_debug_device ("genicam address = 0x%016lx", entry.address); arv_debug_device ("genicam size = 0x%016lx", entry.size); data = g_malloc0 (entry.size); arv_device_read_memory (device, entry.address, entry.size, data, NULL); #if 0 string = g_string_new (""); arv_g_string_append_hex_dump (string, data, entry.size); arv_debug_device ("GENICAM\n%s", string->str); g_string_free (string, TRUE); #endif schema_type = arv_uvcp_manifest_entry_get_schema_type (&entry); switch (schema_type) { case ARV_UVCP_SCHEMA_ZIP: { ArvZip *zip; const GSList *zip_files; zip = arv_zip_new (data, entry.size); zip_files = arv_zip_get_file_list (zip); if (zip_files != NULL) { const char *zip_filename; zip_filename = arv_zip_file_get_name (zip_files->data); uv_device->priv->genicam_xml = arv_zip_get_file (zip, zip_filename, &uv_device->priv->genicam_xml_size); arv_debug_device ("zip file = %s", zip_filename); #if 0 string = g_string_new (""); arv_g_string_append_hex_dump (string, uv_device->priv->genicam_xml, uv_device->priv->genicam_xml_size); arv_debug_device ("GENICAM\n%s", string->str); g_string_free (string, TRUE); #endif uv_device->priv->genicam = arv_gc_new (ARV_DEVICE (uv_device), uv_device->priv->genicam_xml, uv_device->priv->genicam_xml_size); } arv_zip_free (zip); g_free (data); } break; case ARV_UVCP_SCHEMA_RAW: { uv_device->priv->genicam_xml = data; uv_device->priv->genicam_xml_size = entry.size; uv_device->priv->genicam = arv_gc_new (ARV_DEVICE (uv_device), uv_device->priv->genicam_xml, uv_device->priv->genicam_xml_size); } break; default: arv_warning_device ("Unknown USB3Vision manifest schema type (%d)", schema_type); } #if 0 arv_debug_device("GENICAM\n:%s", uv_device->priv->genicam_xml); #endif }
int main (int argc, char **argv) { ArvGc *genicam; char *xml; size_t size; GOptionContext *context; GError *error = NULL; int i; arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); if (arv_option_filenames == NULL) { g_print ("Missing input filename.\n"); return EXIT_FAILURE; } for (i = 0; arv_option_filenames[i] != NULL; i++) { g_file_get_contents (arv_option_filenames[i], &xml, &size, NULL); if (xml != NULL) { ArvGcNode *node; g_print ("Loading '%s'.\n", arv_option_filenames[i]); genicam = arv_gc_new (NULL, xml, size); node = arv_gc_get_node (genicam, "RegAcquisitionCommand"); if (node != NULL) { g_print ("RegAcquisitionCommand address = 0x%Lx - length = 0x%Lx\n", (unsigned long long) arv_gc_register_get_address (ARV_GC_REGISTER (node), NULL), (unsigned long long) arv_gc_register_get_length (ARV_GC_REGISTER (node), NULL)); } node = arv_gc_get_node (genicam, "IntWidthIncrement"); if (node != NULL) { g_print ("IntWidthIncrement value = %Ld\n", (long long) arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL)); } node = arv_gc_get_node (genicam, "WhitebalValueMin"); if (node != NULL) { g_print ("WhitebalValueMin value = %g\n", arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL)); } g_free (xml); g_object_unref (genicam); } else g_print ("File '%s' not found.\n", arv_option_filenames[i]); } return EXIT_SUCCESS; }
static void arv_gv_device_load_genicam (ArvGvDevice *gv_device) { const char *genicam; size_t size; genicam = arv_gv_device_get_genicam_xml (ARV_DEVICE (gv_device), &size); if (genicam != NULL) { gv_device->priv->genicam = arv_gc_new (ARV_DEVICE (gv_device), genicam, size); arv_gc_set_default_node_data (gv_device->priv->genicam, "DeviceVendorName", "<StringReg Name=\"DeviceVendorName\">" "<DisplayName>Vendor Name</DisplayName>" "<Address>0x48</Address>" "<Length>32</Length>" "<AccessMode>RO</AccessMode>" "<pPort>Device</pPort>" "</StringReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "DeviceModelName", "<StringReg Name=\"DeviceModelName\">" "<DisplayName>Model Name</DisplayName>" "<Address>0x68</Address>" "<Length>32</Length>" "<AccessMode>RO</AccessMode>" "<pPort>Device</pPort>" "</StringReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "DeviceVersion", "<StringReg Name=\"DeviceVersion\">" "<DisplayName>Device Version</DisplayName>" "<Address>0x88</Address>" "<Length>32</Length>" "<AccessMode>RO</AccessMode>" "<pPort>Device</pPort>" "</StringReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "DeviceManufacturerInfo", "<StringReg Name=\"DeviceManufacturerInfo\">" "<DisplayName>Manufacturer Info</DisplayName>" "<Address>0xa8</Address>" "<Length>48</Length>" "<AccessMode>RO</AccessMode>" "<pPort>Device</pPort>" "</StringReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "DeviceID", "<StringReg Name=\"DeviceID\">" "<DisplayName>Device ID</DisplayName>" "<Address>0xd8</Address>" "<Length>16</Length>" "<AccessMode>RO</AccessMode>" "<pPort>Device</pPort>" "</StringReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "GevSCPSPacketSize", "<Integer Name=\"GevSCPSPacketSize\">" "<Visibility>Expert</Visibility>" "<pIsLocked>TLParamsLocked</pIsLocked>" "<pValue>GevSCPSPacketSizeReg</pValue>" "</Integer>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "GevSCPSPacketSizeReg", "<MaskedIntReg Name=\"GevSCPSPacketSizeReg\">" "<Address>0xd04</Address>" "<Length>4</Length>" "<AccessMode>RW</AccessMode>" "<pPort>Device</pPort>" "<LSB>31</LSB>" "<MSB>16</MSB>" "<Sign>Unsigned</Sign>" "<Endianess>BigEndian</Endianess>" "</MaskedIntReg>"); arv_gc_set_default_node_data (gv_device->priv->genicam, "TLParamsLocked", "<Integer Name=\"TLParamsLocked\">" "<Visibility>Invisible</Visibility>" "<Value>0</Value>" "<Min>0</Min>" "<Max>1</Max>" "</Integer>"); } }