[aravis] documentation: more work on GVCP and GVSP packet documentation.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] documentation: more work on GVCP and GVSP packet documentation.
- Date: Mon, 25 Jul 2011 16:03:45 +0000 (UTC)
commit 1559e3fff3314b628ab2f1ccb6f5adf36a783bb5
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Jul 25 18:03:15 2011 +0200
documentation: more work on GVCP and GVSP packet documentation.
docs/reference/aravis/aravis-gv.xml | 249 ++++++++++++++++++++++++++++-
docs/reference/aravis/aravis-sections.txt | 17 ++-
src/arvcamera.c | 4 +-
src/arvdebug.c | 16 ++-
src/arvfakegvcamera.c | 12 +-
src/arvgvcp.c | 89 +++++++----
src/arvgvcp.h | 61 +++++---
src/arvgvdevice.c | 48 +++---
src/arvgvinterface.c | 2 +-
src/arvgvsp.h | 68 +++++++-
src/arvgvstream.c | 8 +-
11 files changed, 464 insertions(+), 110 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-gv.xml b/docs/reference/aravis/aravis-gv.xml
index e8fbf5c..6d0261f 100644
--- a/docs/reference/aravis/aravis-gv.xml
+++ b/docs/reference/aravis/aravis-gv.xml
@@ -19,20 +19,259 @@
</para>
<para>
- A GVCP packet is composed by a 64 bit headers, followed by a data byte array.
+ The <link linkend="aravis-ArvGvcp">ArvGvcp</link> API offers a set of function for handling of GVCP packets.
</para>
+ <para>
+ The content of a GVCP packet is composed by a 64 bit headers, followed or not by a data byte array, depending on the GVCP packet type. Multibyte values are in big endian encoding.
+ </para>
+
+ <table frame='all'><title>GVCP packet</title>
+ <tgroup cols='8' align='left' colsep='1' rowsep='1'>
+ <colspec colname='B0'/>
+ <colspec colname='B1'/>
+ <colspec colname='B2'/>
+ <colspec colname='B3'/>
+ <colspec colname='B4'/>
+ <colspec colname='B5'/>
+ <colspec colname='B6'/>
+ <colspec colname='B7'/>
+ <thead>
+ <row>
+ <entry align="left">0</entry>
+ <entry align="right">15</entry>
+ <entry align="left">16</entry>
+ <entry align="right">31</entry>
+ <entry align="left">32</entry>
+ <entry align="right">47</entry>
+ <entry align="left">48</entry>
+ <entry align="right">63</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry namest="B0" nameend="B1">#ArvGvcpPacketType</entry>
+ <entry namest="B2" nameend="B3">#ArvGvcpCommand</entry>
+ <entry namest="B4" nameend="B5">Data size</entry>
+ <entry namest="B6" nameend="B7">Packet id</entry>
+ </row>
+ <row>
+ <entry namest="B0" nameend="B7" align='center'>Optional data</entry>
+ </row>
+ <row>
+ <entry namest="B0" nameend="B7" align='center'>...</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <sect2>
+ <title>Discovery</title>
+
+ <para>
+ A device discovery mechanism is implemented using a discovery GVCP packet, broadcasted by the client to the GVCP port. Each available device responds to this discovery packet with an acknowledge packet, containing a description of the device (device name, model name, manufacturer name, MAC Address...).
+ </para>
+
+ <para>
+ In the discovery command packet, data size is set to 0 and packet id is equal to 0xffff.
+ </para>
+
+ <table frame='all'><title>Discovery acknowledge packet</title>
+
+ <tgroup cols='5' align='left' colsep='1' rowsep='1'>
+ <colspec colname='Address'/>
+ <colspec colname='B0'/>
+ <colspec colname='B1'/>
+ <colspec colname='B2'/>
+ <colspec colname='B3'/>
+ <thead>
+ <row>
+ <entry align="left">Address</entry>
+ <entry align="left">0</entry>
+ <entry align="right">15</entry>
+ <entry align="left">16</entry>
+ <entry align="right">31</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry namest="B0" nameend="B1">0x0000</entry>
+ <entry namest="B2" nameend="B3">0x0003</entry>
+ </row>
+ <row>
+ <entry namest="B0" nameend="B1">0x00f8</entry>
+ <entry namest="B2" nameend="B3">0xffff</entry>
+ </row>
+ <row>
+ <entry>0x0000</entry>
+ <entry namest="B0" nameend="B1">Version major</entry>
+ <entry namest="B2" nameend="B3">Version minor</entry>
+ </row>
+ <row>
+ <entry>0x0004</entry>
+ <entry namest="B0" nameend="B1">Endianness</entry>
+ <entry namest="B2" nameend="B3">Character set</entry>
+ </row>
+ <row>
+ <entry>0x0008</entry>
+ <entry namest="B0" nameend="B3">MAC address high</entry>
+ </row>
+ <row>
+ <entry>0x000c</entry>
+ <entry namest="B0" nameend="B3">MAC address low</entry>
+ </row>
+ <row>
+ <entry>0x0010</entry>
+ <entry namest="B0" nameend="B3">Supported IP configuration</entry>
+ </row>
+ <row>
+ <entry>0x0014</entry>
+ <entry namest="B0" nameend="B3">Current IP configuration</entry>
+ </row>
+ <row>
+ <entry>0x0018</entry>
+ <entry morerows="2" namest="B0" nameend="B3"></entry>
+ </row>
+ <row><entry>0x001c</entry></row>
+ <row><entry>0x0020</entry></row>
+ <row>
+ <entry>0x0024</entry>
+ <entry namest="B0" nameend="B3">
+ Current IP address
+ </entry>
+ </row>
+ <row>
+ <entry>0x0028</entry>
+ <entry morerows="2" namest="B0" nameend="B3"></entry>
+ </row>
+ <row><entry>0x002c</entry></row>
+ <row><entry>0x0030</entry></row>
+ <row>
+ <entry>0x0034</entry>
+ <entry morerows="0" namest="B0" nameend="B3">
+ Current subnet mask
+ </entry>
+ </row>
+ <row>
+ <entry>0x0038</entry>
+ <entry morerows="2" namest="B0" nameend="B3"></entry>
+ </row>
+ <row><entry>0x003c</entry></row>
+ <row><entry>0x0040</entry></row>
+ <row>
+ <entry>0x0044</entry>
+ <entry namest="B0" nameend="B3">
+ Current gateway
+ </entry>
+ </row>
+ <row>
+ <entry>0x0048</entry>
+ <entry morerows="7" namest="B0" nameend="B3">
+ Manufacturer name
+ </entry>
+ </row>
+ <row><entry>0x004c</entry></row>
+ <row><entry>0x0050</entry></row>
+ <row><entry>0x0054</entry></row>
+ <row><entry>0x0058</entry></row>
+ <row><entry>0x005c</entry></row>
+ <row><entry>0x0060</entry></row>
+ <row><entry>0x0064</entry></row>
+ <row>
+ <entry>0x0068</entry>
+ <entry morerows="7" namest="B0" nameend="B3">
+ Model name
+ </entry>
+ </row>
+ <row><entry>0x006c</entry></row>
+ <row><entry>0x0070</entry></row>
+ <row><entry>0x0074</entry></row>
+ <row><entry>0x0078</entry></row>
+ <row><entry>0x007c</entry></row>
+ <row><entry>0x0080</entry></row>
+ <row><entry>0x0084</entry></row>
+ <row>
+ <entry>0x0088</entry>
+ <entry morerows="7" namest="B0" nameend="B3">
+ Device version
+ </entry>
+ </row>
+ <row><entry>0x008c</entry></row>
+ <row><entry>0x0090</entry></row>
+ <row><entry>0x0094</entry></row>
+ <row><entry>0x0098</entry></row>
+ <row><entry>0x009c</entry></row>
+ <row><entry>0x00a0</entry></row>
+ <row><entry>0x00a4</entry></row>
+ <row>
+ <entry>0x00a8</entry>
+ <entry morerows="11" namest="B0" nameend="B3">
+ Manufacturer informations
+ </entry>
+ </row>
+ <row><entry>0x00ac</entry></row>
+ <row><entry>0x00b0</entry></row>
+ <row><entry>0x00b4</entry></row>
+ <row><entry>0x00b8</entry></row>
+ <row><entry>0x00bc</entry></row>
+ <row><entry>0x00c0</entry></row>
+ <row><entry>0x00c0</entry></row>
+ <row><entry>0x00c4</entry></row>
+ <row><entry>0x00cc</entry></row>
+ <row><entry>0x00d0</entry></row>
+ <row><entry>0x00d4</entry></row>
+ <row>
+ <entry>0x00d8</entry>
+ <entry morerows="7" namest="B0" nameend="B3">
+ User defined name
+ </entry>
+ </row>
+ <row><entry>0x00dc</entry></row>
+ <row><entry>0x00e0</entry></row>
+ <row><entry>0x00e4</entry></row>
+ <row><entry>0x00e8</entry></row>
+ <row><entry>0x00ec</entry></row>
+ <row><entry>0x00f0</entry></row>
+ <row><entry>0x00f4</entry></row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect2>
+ <sect2>
+ <title>Read and write register</title>
+
+ <para>
+ These packets are used for the read and write of 32 bit registers, accessed using 32 bit adresses. For the read command, a list of addresses is sent ot the client, which returns a list of 32 bit values. For the write command, a list of address/value pairs is sent to the client, which returns a list of 32 bit values.
+ </para>
+ <para>
+ Address and data are encoded in the packet as big endian values.
+ </para>
+ </sect2>
+ <sect2>
+ <title>Read and write memory</title>
+ <para>
+ Write memory packet data area consists in a 32 bit address, followed by the data to write. Client returns an acknowledge packet with the target address.
+ </para>
+ <para>
+ For read memory command, an address/size pair is sent to the device, which returns the content of the given memory area.
+ </para>
+ </sect2>
+
</chapter>
<chapter id="aravis-gvsp">
<title>GVSP packets</title>
- </chapter>
- <chapter id="aravis-gvcp-discovery">
- <title>Device discovery mechanism</title>
+ <para>
+ GVSP packets are sent by the device for the video stream transmission. Depending on the device, it is possible to have more than one stream simultaneously, each directed to a different client port. Stream is splitted in frames. For each frame, identified by a frame id, three different packets are used: a leader packet, one or more data packets, and a trailer packet. Each packet in a frame is identified by a packet id, starting from 0.
+ </para>
+
+ <para>
+ The <link linkend="aravis-ArvGvsp">ArvGvsp</link> API offers a set of function for handling of GVSP packets. Structure of a GVSP is described in #ArvGvspPacket structure documentation. Content of leader and trailer packets in #ArvGvspDataLeader and #ArvGvspDataTrailer.
+ </para>
<para>
- A device discovery mechanism is implemented using a discovery GVCP packet, broadcasted by the client to the GVCP port. Each available device responds to this discovery packet with an acknowledge packet, containing a description of the device (device name, model name, manufacturer name, MAC Address...).
+ In the video stream reception code, client must take care to check if all frame packets are present, and ask for packet resend for missing ones, using a GVCP packet resend command.
</para>
</chapter>
</part>
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index 7531ff8..17e6919 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -779,6 +779,7 @@ arv_pixel_format_from_gst_caps
<SECTION>
<FILE>arvgvcp</FILE>
<TITLE>ArvGvcp</TITLE>
+ARV_GVCP_PORT
ArvGvcpPacketType
ArvGvcpCommand
ArvGvcpHeader
@@ -786,7 +787,7 @@ ArvGvcpPacket
arv_gvcp_packet_free
arv_gvcp_packet_get_packet_type
arv_gvcp_packet_get_command
-arv_gvcp_packet_get_packet_count
+arv_gvcp_packet_get_packet_id
arv_gvcp_packet_get_read_memory_ack_data
arv_gvcp_packet_get_read_memory_ack_size
arv_gvcp_packet_get_read_memory_cmd_infos
@@ -796,7 +797,7 @@ arv_gvcp_packet_get_write_memory_ack_size
arv_gvcp_packet_get_write_memory_cmd_data
arv_gvcp_packet_get_write_memory_cmd_infos
arv_gvcp_packet_get_write_register_cmd_infos
-arv_gvcp_packet_set_packet_count
+arv_gvcp_packet_set_packet_id
arv_gvcp_packet_new_read_memory_cmd
arv_gvcp_packet_new_read_memory_ack
arv_gvcp_packet_new_write_memory_cmd
@@ -810,7 +811,7 @@ arv_gvcp_packet_new_discovery_ack
arv_gvcp_packet_new_packet_resend_cmd
arv_gvcp_packet_to_string
arv_gvcp_packet_debug
-arv_gvcp_next_packet_count
+arv_gvcp_next_packet_id
<SUBSECTION Private>
ARV_GVBS_CONTROL_CHANNEL_PRIVILEGE_CONTROL
ARV_GVBS_CONTROL_CHANNEL_PRIVILEGE_EXCLUSIVE
@@ -897,7 +898,6 @@ ARV_GVBS_MODEL_NAME_SIZE
ARV_GVBS_SERIAL_NUMBER_SIZE
ARV_GVBS_USER_DEFINED_NAME_SIZE
ARV_GVBS_XML_URL_SIZE
-ARV_GVCP_PORT
ARV_GVCP_DATA_SIZE_MAX
g_ntohl
g_ntohs
@@ -958,6 +958,12 @@ arv_warning_stream_thread
<SECTION>
<FILE>arvgvsp</FILE>
<TITLE>ArvGvsp</TITLE>
+ArvGvspPacketType
+ArvGvspContentType
+ArvGvspDataLeader
+ArvGvspDataTrailer
+ArvGvspHeader
+ArvGvspPacket
arv_gvsp_packet_to_string
arv_gvsp_packet_get_data_size
arv_gvsp_packet_get_frame_id
@@ -975,9 +981,6 @@ arv_gvsp_packet_new_data_block
arv_gvsp_packet_new_data_leader
arv_gvsp_packet_new_data_trailer
<SUBSECTION Private>
-ArvGvspPacket
-ArvGvspPacketType
-ArvGvspContentType
ARV_GVSP_PACKET_INFOS_ID_MASK
ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_MASK
ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_POS
diff --git a/src/arvcamera.c b/src/arvcamera.c
index 858efba..7b66a88 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -503,7 +503,7 @@ arv_camera_get_frame_rate (ArvCamera *camera)
* underlying device object.
*
* Source can also be "Software". In this case, an acquisition is triggered
- * by a call to @arv_camera_software_trigger.
+ * by a call to arv_camera_software_trigger().
*/
void
@@ -535,7 +535,7 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
* @camera: a #ArvCamera
*
* Sends a software trigger command to @camera. The camera must be previously
- * configured to use a software trigger, using @arv_camera_set_trigger.
+ * configured to use a software trigger, using @arv_camera_set_trigger().
*/
void
diff --git a/src/arvdebug.c b/src/arvdebug.c
index 6ecb464..fb39cf0 100644
--- a/src/arvdebug.c
+++ b/src/arvdebug.c
@@ -200,10 +200,22 @@ arv_log (ArvDebugCategory *category, const char *format, ...)
va_end (args);
}
+/**
+ * arv_debug_enable:
+ * @category_selection: debug category configuration string
+ *
+ * Configures the debug output using a configuration string consisting of a comma separated list of debug categories or category/debug level pair. This function overwrites the configuration done by ARV_DEBUG environment variable.
+ * For example, enabling debug level 3 of the gvcp category and default debug level of category genicam is done using:
+ *
+ * <informalexample><programlisting>
+ * arv_debug_enable ("gvcp:3,genicam");
+ * </programlisting></informalexample>
+ */
+
void
-arv_debug_enable (const char *categories)
+arv_debug_enable (const char *category_selection)
{
- arv_debug_initialize (categories);
+ arv_debug_initialize (category_selection);
}
void
diff --git a/src/arvfakegvcamera.c b/src/arvfakegvcamera.c
index a2a0555..61312b6 100644
--- a/src/arvfakegvcamera.c
+++ b/src/arvfakegvcamera.c
@@ -335,7 +335,7 @@ handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
size_t ack_packet_size;
guint32 block_address;
guint32 block_size;
- guint32 packet_count;
+ guint16 packet_id;
guint32 register_address;
guint32 register_value;
gboolean write_access;
@@ -365,7 +365,7 @@ handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
- packet_count = arv_gvcp_packet_get_packet_count (packet);
+ packet_id = arv_gvcp_packet_get_packet_id (packet);
switch (g_ntohs (packet->header.command)) {
case ARV_GVCP_COMMAND_DISCOVERY_CMD:
@@ -379,7 +379,7 @@ handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
arv_debug_device ("[FakeGvCamera::handle_control_packet] Read memory command %d (%d)",
block_address, block_size);
ack_packet = arv_gvcp_packet_new_read_memory_ack (block_address, block_size,
- packet_count, &ack_packet_size);
+ packet_id, &ack_packet_size);
arv_fake_camera_read_memory (gv_camera->camera, block_address, block_size,
arv_gvcp_packet_get_read_memory_ack_data (ack_packet));
break;
@@ -392,7 +392,7 @@ handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
block_address, block_size);
arv_fake_camera_write_memory (gv_camera->camera, block_address, block_size,
arv_gvcp_packet_get_write_memory_cmd_data (packet));
- ack_packet = arv_gvcp_packet_new_write_memory_ack (block_address, packet_count,
+ ack_packet = arv_gvcp_packet_new_write_memory_ack (block_address, packet_id,
&ack_packet_size);
break;
case ARV_GVCP_COMMAND_READ_REGISTER_CMD:
@@ -400,7 +400,7 @@ handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
arv_fake_camera_read_register (gv_camera->camera, register_address, ®ister_value);
arv_debug_device ("[FakeGvCamera::handle_control_packet] Read register command %d -> %d",
register_address, register_value);
- ack_packet = arv_gvcp_packet_new_read_register_ack (register_value, packet_count,
+ ack_packet = arv_gvcp_packet_new_read_register_ack (register_value, packet_id,
&ack_packet_size);
if (register_address == ARV_GVBS_CONTROL_CHANNEL_PRIVILEGE_OFFSET)
@@ -415,7 +415,7 @@ handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
arv_fake_camera_write_register (gv_camera->camera, register_address, register_value);
arv_debug_device ("[FakeGvCamera::handle_control_packet] Write register command %d -> %d",
register_address, register_value);
- ack_packet = arv_gvcp_packet_new_write_register_ack (register_value, packet_count,
+ ack_packet = arv_gvcp_packet_new_write_register_ack (register_value, packet_id,
&ack_packet_size);
break;
default:
diff --git a/src/arvgvcp.c b/src/arvgvcp.c
index 2d0d90d..5a479a0 100644
--- a/src/arvgvcp.c
+++ b/src/arvgvcp.c
@@ -40,7 +40,7 @@ arv_gvcp_packet_free (ArvGvcpPacket *packet)
* arv_gvcp_packet_new_read_memory_cmd: (skip)
* @address: read address
* @size: read size, in bytes
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -48,7 +48,7 @@ arv_gvcp_packet_free (ArvGvcpPacket *packet)
*/
ArvGvcpPacket *
-arv_gvcp_packet_new_read_memory_cmd (guint32 address, guint32 size, guint16 packet_count, size_t *packet_size)
+arv_gvcp_packet_new_read_memory_cmd (guint32 address, guint32 size, guint16 packet_id, size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -63,7 +63,7 @@ arv_gvcp_packet_new_read_memory_cmd (guint32 address, guint32 size, guint16 pack
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_CMD);
packet->header.command = g_htons (ARV_GVCP_COMMAND_READ_MEMORY_CMD);
packet->header.size = g_htons (2 * sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
memcpy (&packet->data[sizeof(guint32)], &n_size, sizeof (guint32));
@@ -75,7 +75,7 @@ arv_gvcp_packet_new_read_memory_cmd (guint32 address, guint32 size, guint16 pack
* arv_gvcp_packet_new_read_memory_ack: (skip)
* @address: read address
* @size: read size, in bytes
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -83,7 +83,7 @@ arv_gvcp_packet_new_read_memory_cmd (guint32 address, guint32 size, guint16 pack
*/
ArvGvcpPacket *
-arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 packet_count, size_t *packet_size)
+arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 packet_id, size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -97,7 +97,7 @@ arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 pack
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_ACK);
packet->header.command = g_htons (ARV_GVCP_COMMAND_READ_MEMORY_ACK);
packet->header.size = g_htons (sizeof (guint32) + size);
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
@@ -108,7 +108,7 @@ arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 pack
* arv_gvcp_packet_new_write_memory_cmd: (skip)
* @address: write address
* @size: write size, in bytes
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -116,7 +116,7 @@ arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 pack
*/
ArvGvcpPacket *
-arv_gvcp_packet_new_write_memory_cmd (guint32 address, guint32 size, guint16 packet_count, size_t *packet_size)
+arv_gvcp_packet_new_write_memory_cmd (guint32 address, guint32 size, guint16 packet_id, size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -130,7 +130,7 @@ arv_gvcp_packet_new_write_memory_cmd (guint32 address, guint32 size, guint16 pac
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_CMD);
packet->header.command = g_htons (ARV_GVCP_COMMAND_WRITE_MEMORY_CMD);
packet->header.size = g_htons (sizeof (guint32) + size);
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
@@ -140,7 +140,7 @@ arv_gvcp_packet_new_write_memory_cmd (guint32 address, guint32 size, guint16 pac
/**
* arv_gvcp_packet_new_write_memory_ack: (skip)
* @address: write address
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -149,7 +149,8 @@ arv_gvcp_packet_new_write_memory_cmd (guint32 address, guint32 size, guint16 pac
ArvGvcpPacket *
arv_gvcp_packet_new_write_memory_ack (guint32 address,
- guint16 packet_count, size_t *packet_size)
+ guint16 packet_id,
+ size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -163,7 +164,7 @@ arv_gvcp_packet_new_write_memory_ack (guint32 address,
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_ACK);
packet->header.command = g_htons (ARV_GVCP_COMMAND_WRITE_MEMORY_ACK);
packet->header.size = g_htons (sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
@@ -173,7 +174,7 @@ arv_gvcp_packet_new_write_memory_ack (guint32 address,
/**
* arv_gvcp_packet_new_read_register_cmd: (skip)
* @address: write address
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -181,7 +182,9 @@ arv_gvcp_packet_new_write_memory_ack (guint32 address,
*/
ArvGvcpPacket *
-arv_gvcp_packet_new_read_register_cmd (guint32 address, guint16 packet_count, size_t *packet_size)
+arv_gvcp_packet_new_read_register_cmd (guint32 address,
+ guint16 packet_id,
+ size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -195,7 +198,7 @@ arv_gvcp_packet_new_read_register_cmd (guint32 address, guint16 packet_count, si
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_CMD);
packet->header.command = g_htons (ARV_GVCP_COMMAND_READ_REGISTER_CMD);
packet->header.size = g_htons (sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
@@ -205,7 +208,7 @@ arv_gvcp_packet_new_read_register_cmd (guint32 address, guint16 packet_count, si
/**
* arv_gvcp_packet_new_read_register_ack: (skip)
* @value: read value
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -214,7 +217,8 @@ arv_gvcp_packet_new_read_register_cmd (guint32 address, guint16 packet_count, si
ArvGvcpPacket *
arv_gvcp_packet_new_read_register_ack (guint32 value,
- guint16 packet_count, size_t *packet_size)
+ guint16 packet_id,
+ size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_value = g_htonl (value);
@@ -228,7 +232,7 @@ arv_gvcp_packet_new_read_register_ack (guint32 value,
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_ACK);
packet->header.command = g_htons (ARV_GVCP_COMMAND_READ_REGISTER_ACK);
packet->header.size = g_htons (sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_value, sizeof (guint32));
@@ -239,7 +243,7 @@ arv_gvcp_packet_new_read_register_ack (guint32 value,
* arv_gvcp_packet_new_write_register_cmd: (skip)
* @address: write address
* @value: value to write
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -247,8 +251,10 @@ arv_gvcp_packet_new_read_register_ack (guint32 value,
*/
ArvGvcpPacket *
-arv_gvcp_packet_new_write_register_cmd (guint32 address, guint32 value,
- guint16 packet_count, size_t *packet_size)
+arv_gvcp_packet_new_write_register_cmd (guint32 address,
+ guint32 value,
+ guint16 packet_id,
+ size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -263,7 +269,7 @@ arv_gvcp_packet_new_write_register_cmd (guint32 address, guint32 value,
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_CMD);
packet->header.command = g_htons (ARV_GVCP_COMMAND_WRITE_REGISTER_CMD);
packet->header.size = g_htons (2 * sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
memcpy (&packet->data[sizeof (guint32)], &n_value, sizeof (guint32));
@@ -274,7 +280,7 @@ arv_gvcp_packet_new_write_register_cmd (guint32 address, guint32 value,
/**
* arv_gvcp_packet_new_write_register_ack: (skip)
* @address: write address
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
* Return value: (transfer full): a new #ArvGvcpPacket
*
@@ -283,7 +289,8 @@ arv_gvcp_packet_new_write_register_cmd (guint32 address, guint32 value,
ArvGvcpPacket *
arv_gvcp_packet_new_write_register_ack (guint32 address,
- guint16 packet_count, size_t *packet_size)
+ guint16 packet_id,
+ size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 n_address = g_htonl (address);
@@ -297,7 +304,7 @@ arv_gvcp_packet_new_write_register_ack (guint32 address,
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_ACK);
packet->header.command = g_htons (ARV_GVCP_COMMAND_WRITE_REGISTER_ACK);
packet->header.size = g_htons (sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
memcpy (&packet->data, &n_address, sizeof (guint32));
@@ -326,7 +333,7 @@ arv_gvcp_packet_new_discovery_cmd (size_t *packet_size)
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_CMD);
packet->header.command = g_htons (ARV_GVCP_COMMAND_DISCOVERY_CMD);
packet->header.size = g_htons (0x0000);
- packet->header.count = g_htons (0xffff);
+ packet->header.id = g_htons (0xffff);
return packet;
}
@@ -353,7 +360,7 @@ arv_gvcp_packet_new_discovery_ack (size_t *packet_size)
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_ACK);
packet->header.command = g_htons (ARV_GVCP_COMMAND_DISCOVERY_ACK);
packet->header.size = g_htons (ARV_GVBS_DISCOVERY_DATA_SIZE);
- packet->header.count = g_htons (0xffff);
+ packet->header.id = g_htons (0xffff);
return packet;
}
@@ -363,17 +370,18 @@ arv_gvcp_packet_new_discovery_ack (size_t *packet_size)
* @frame_id: frame id
* @first_block: first missing packet
* @last_block: last missing packet
- * @packet_count: current packet count
+ * @packet_id: packet id
* @packet_size: (out): packet size, in bytes
- * Return value: (transfer full): a new #ArvGvcpPacket
*
* Create a gvcp packet for a packet resend command.
+ *
+ * Return value: (transfer full): a new #ArvGvcpPacket
*/
ArvGvcpPacket *
arv_gvcp_packet_new_packet_resend_cmd (guint32 frame_id,
guint32 first_block, guint32 last_block,
- guint16 packet_count, size_t *packet_size)
+ guint16 packet_id, size_t *packet_size)
{
ArvGvcpPacket *packet;
guint32 *data;
@@ -387,7 +395,7 @@ arv_gvcp_packet_new_packet_resend_cmd (guint32 frame_id,
packet->header.packet_type = g_htons (ARV_GVCP_PACKET_TYPE_RESEND);
packet->header.command = g_htons (ARV_GVCP_COMMAND_PACKET_RESEND_CMD);
packet->header.size = g_htons (3 * sizeof (guint32));
- packet->header.count = g_htons (packet_count);
+ packet->header.id = g_htons (packet_id);
data = (guint32 *) &packet->data;
@@ -429,6 +437,15 @@ arv_gvcp_command_to_string (ArvGvcpCommand value)
return arv_enum_to_string (ARV_TYPE_GVCP_COMMAND, value);
}
+/**
+ * arv_gvcp_packet_to_string:
+ * @packet: a #ArvGvcpPacket
+ *
+ * Converts @packet into a human readable string.
+ *
+ * return value: (transfer full): A newly allocated string.
+ */
+
char *
arv_gvcp_packet_to_string (const ArvGvcpPacket *packet)
{
@@ -447,7 +464,7 @@ arv_gvcp_packet_to_string (const ArvGvcpPacket *packet)
g_string_append_printf (string, "command = %s\n",
arv_gvcp_command_to_string (g_ntohs (packet->header.command)));
g_string_append_printf (string, "size = %d\n", g_ntohs (packet->header.size));
- g_string_append_printf (string, "count = %d\n", g_ntohs (packet->header.count));
+ g_string_append_printf (string, "id = %d\n", g_ntohs (packet->header.id));
data = (char *) &packet->data;
@@ -534,6 +551,14 @@ arv_gvcp_packet_to_string (const ArvGvcpPacket *packet)
return c_string;
}
+/**
+ * arv_gvcp_packet_debug:
+ * @packet: a #ArvGvcpPacket
+ * @level: debug level
+ *
+ * Dumps the content of @packet if level is lower or equal to the current debug level for the gvcp debug category. See arv_debug_enable().
+ */
+
void
arv_gvcp_packet_debug (const ArvGvcpPacket *packet, ArvDebugLevel level)
{
diff --git a/src/arvgvcp.h b/src/arvgvcp.h
index 623a183..873805c 100644
--- a/src/arvgvcp.h
+++ b/src/arvgvcp.h
@@ -28,6 +28,11 @@
G_BEGIN_DECLS
+/**
+ * ARV_GVCP_PORT:
+ *
+ * Standard device listening port for GVCP packets
+ */
#define ARV_GVCP_PORT 3956
#define ARV_GVBS_VERSION_OFFSET 0x00000000
@@ -192,23 +197,23 @@ typedef enum {
ARV_GVCP_COMMAND_WRITE_MEMORY_ACK = 0x0087
} ArvGvcpCommand;
+#define ARAVIS_PACKED_STRUCTURE __attribute__((__packed__))
+
/**
* ArvGvcpHeader:
* @packet_type: a #ArvGvcpPacketType identifier
* @command: a #ArvGvcpCommand identifier
* @size: data size
- * @count: packet identifier
+ * @id: packet identifier
*
* GVCP packet header structure.
*/
-#define ARAVIS_PACKED_STRUCTURE __attribute__((__packed__))
-
typedef struct ARAVIS_PACKED_STRUCTURE {
guint16 packet_type;
guint16 command;
guint16 size;
- guint16 count;
+ guint16 id;
} ArvGvcpHeader;
#undef ARAVIS_PACKED_STRUCTURE
@@ -228,29 +233,36 @@ typedef struct {
void arv_gvcp_packet_free (ArvGvcpPacket *packet);
ArvGvcpPacket * arv_gvcp_packet_new_read_memory_cmd (guint32 address, guint32 size,
- guint16 packet_count, size_t *packet_size);
-ArvGvcpPacket * arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 packet_count,
+ guint16 packet_id, size_t *packet_size);
+ArvGvcpPacket * arv_gvcp_packet_new_read_memory_ack (guint32 address, guint32 size, guint16 packet_id,
size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_write_memory_cmd (guint32 address, guint32 size,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_write_memory_ack (guint32 address,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_read_register_cmd (guint32 address,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_read_register_ack (guint32 value,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_write_register_cmd (guint32 address, guint32 value,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_write_register_ack (guint32 address,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_discovery_cmd (size_t *size);
ArvGvcpPacket * arv_gvcp_packet_new_discovery_ack (size_t *packet_size);
ArvGvcpPacket * arv_gvcp_packet_new_packet_resend_cmd (guint32 frame_id,
guint32 first_block, guint32 last_block,
- guint16 packet_count, size_t *packet_size);
+ guint16 packet_id, size_t *packet_size);
char * arv_gvcp_packet_to_string (const ArvGvcpPacket *packet);
void arv_gvcp_packet_debug (const ArvGvcpPacket *packet, ArvDebugLevel level);
+/**
+ * arv_gvcp_packet_get_packet_type:
+ * @packet: a #ArvGvcpPacket
+ *
+ * Return value: The #ArvGvcpPacketType code of @packet.
+ */
+
static inline ArvGvcpPacketType
arv_gvcp_packet_get_packet_type (ArvGvcpPacket *packet)
{
@@ -260,6 +272,13 @@ arv_gvcp_packet_get_packet_type (ArvGvcpPacket *packet)
return (ArvGvcpPacketType) g_ntohs (packet->header.packet_type);
}
+/**
+ * arv_gvcp_packet_get_command:
+ * @packet: a #ArvGvcpPacket
+ *
+ * Return value: The #ArvGvcpCommand code of @packet.
+ */
+
static inline ArvGvcpCommand
arv_gvcp_packet_get_command (ArvGvcpPacket *packet)
{
@@ -270,19 +289,19 @@ arv_gvcp_packet_get_command (ArvGvcpPacket *packet)
}
static inline void
-arv_gvcp_packet_set_packet_count (ArvGvcpPacket *packet, guint16 count)
+arv_gvcp_packet_set_packet_id (ArvGvcpPacket *packet, guint16 id)
{
if (packet != NULL)
- packet->header.count = g_htons (count);
+ packet->header.id = g_htons (id);
}
static inline guint16
-arv_gvcp_packet_get_packet_count (ArvGvcpPacket *packet)
+arv_gvcp_packet_get_packet_id (ArvGvcpPacket *packet)
{
if (packet == NULL)
return 0;
- return g_ntohs (packet->header.count);
+ return g_ntohs (packet->header.id);
}
static inline void
@@ -362,12 +381,12 @@ arv_gvcp_packet_get_write_register_cmd_infos (const ArvGvcpPacket *packet, guint
}
static inline guint16
-arv_gvcp_next_packet_count (guint16 packet_count)
+arv_gvcp_next_packet_id (guint16 packet_id)
{
- /* packet_count == 0 is an error value */
- if (packet_count == 0xffff)
+ /* packet_id == 0 is an error value */
+ if (packet_id == 0xffff)
return 1;
- return packet_count + 1;
+ return packet_id + 1;
}
G_END_DECLS
diff --git a/src/arvgvdevice.c b/src/arvgvdevice.c
index f5248f2..d112db7 100644
--- a/src/arvgvdevice.c
+++ b/src/arvgvdevice.c
@@ -42,7 +42,7 @@ static GRegex *arv_gv_device_url_regex = NULL;
typedef struct {
GMutex *mutex;
- guint16 packet_count;
+ guint16 packet_id;
GSocket *socket;
GSocketAddress *interface_address;
@@ -92,8 +92,8 @@ _read_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *b
0, &packet_size);
do {
- io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
- arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
+ io_data->packet_id = arv_gvcp_next_packet_id (io_data->packet_id);
+ arv_gvcp_packet_set_packet_id (packet, io_data->packet_id);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -108,17 +108,17 @@ _read_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *b
ArvGvcpPacket *ack_packet = io_data->buffer;
ArvGvcpPacketType packet_type;
ArvGvcpCommand command;
- guint16 packet_count;
+ guint16 packet_id;
arv_gvcp_packet_debug (ack_packet, ARV_DEBUG_LEVEL_LOG);
packet_type = arv_gvcp_packet_get_packet_type (ack_packet);
command = arv_gvcp_packet_get_command (ack_packet);
- packet_count = arv_gvcp_packet_get_packet_count (ack_packet);
+ packet_id = arv_gvcp_packet_get_packet_id (ack_packet);
if (packet_type == ARV_GVCP_PACKET_TYPE_ACK &&
command == ARV_GVCP_COMMAND_READ_MEMORY_ACK &&
- packet_count == io_data->packet_count) {
+ packet_id == io_data->packet_id) {
memcpy (buffer, arv_gvcp_packet_get_read_memory_ack_data (ack_packet), size);
success = TRUE;
} else
@@ -156,8 +156,8 @@ _write_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *
memcpy (arv_gvcp_packet_get_write_memory_cmd_data (packet), buffer, size);
do {
- io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
- arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
+ io_data->packet_id = arv_gvcp_next_packet_id (io_data->packet_id);
+ arv_gvcp_packet_set_packet_id (packet, io_data->packet_id);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -172,17 +172,17 @@ _write_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *
ArvGvcpPacket *ack_packet = io_data->buffer;
ArvGvcpPacketType packet_type;
ArvGvcpCommand command;
- guint16 packet_count;
+ guint16 packet_id;
arv_gvcp_packet_debug (ack_packet, ARV_DEBUG_LEVEL_LOG);
packet_type = arv_gvcp_packet_get_packet_type (ack_packet);
command = arv_gvcp_packet_get_command (ack_packet);
- packet_count = arv_gvcp_packet_get_packet_count (ack_packet);
+ packet_id = arv_gvcp_packet_get_packet_id (ack_packet);
if (packet_type == ARV_GVCP_PACKET_TYPE_ACK &&
command == ARV_GVCP_COMMAND_WRITE_MEMORY_ACK &&
- packet_count == io_data->packet_count)
+ packet_id == io_data->packet_id)
success = TRUE;
else
arv_gvcp_packet_debug (ack_packet, ARV_DEBUG_LEVEL_WARNING);
@@ -214,8 +214,8 @@ _read_register (ArvGvDeviceIOData *io_data, guint32 address, guint32 *value_plac
packet = arv_gvcp_packet_new_read_register_cmd (address, 0, &packet_size);
do {
- io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
- arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
+ io_data->packet_id = arv_gvcp_next_packet_id (io_data->packet_id);
+ arv_gvcp_packet_set_packet_id (packet, io_data->packet_id);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -230,17 +230,17 @@ _read_register (ArvGvDeviceIOData *io_data, guint32 address, guint32 *value_plac
ArvGvcpPacket *ack_packet = io_data->buffer;
ArvGvcpPacketType packet_type;
ArvGvcpCommand command;
- guint16 packet_count;
+ guint16 packet_id;
arv_gvcp_packet_debug (ack_packet, ARV_DEBUG_LEVEL_LOG);
packet_type = arv_gvcp_packet_get_packet_type (ack_packet);
command = arv_gvcp_packet_get_command (ack_packet);
- packet_count = arv_gvcp_packet_get_packet_count (ack_packet);
+ packet_id = arv_gvcp_packet_get_packet_id (ack_packet);
if (packet_type == ARV_GVCP_PACKET_TYPE_ACK &&
command == ARV_GVCP_COMMAND_READ_REGISTER_ACK &&
- packet_count == io_data->packet_count) {
+ packet_id == io_data->packet_id) {
*value_placeholder = arv_gvcp_packet_get_read_register_ack_value (ack_packet);
success = TRUE;
} else
@@ -273,11 +273,11 @@ _write_register (ArvGvDeviceIOData *io_data, guint32 address, guint32 value)
g_mutex_lock (io_data->mutex);
- packet = arv_gvcp_packet_new_write_register_cmd (address, value, io_data->packet_count, &packet_size);
+ packet = arv_gvcp_packet_new_write_register_cmd (address, value, io_data->packet_id, &packet_size);
do {
- io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
- arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
+ io_data->packet_id = arv_gvcp_next_packet_id (io_data->packet_id);
+ arv_gvcp_packet_set_packet_id (packet, io_data->packet_id);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -291,19 +291,19 @@ _write_register (ArvGvDeviceIOData *io_data, guint32 address, guint32 value)
ArvGvcpPacket *ack_packet = io_data->buffer;
ArvGvcpPacketType packet_type;
ArvGvcpCommand command;
- guint16 packet_count;
+ guint16 packet_id;
arv_gvcp_packet_debug (ack_packet, ARV_DEBUG_LEVEL_LOG);
packet_type = arv_gvcp_packet_get_packet_type (ack_packet);
command = arv_gvcp_packet_get_command (ack_packet);
- packet_count = arv_gvcp_packet_get_packet_count (ack_packet);
+ packet_id = arv_gvcp_packet_get_packet_id (ack_packet);
- arv_log_gvcp ("%d, %d, %d", packet_type, command, packet_count);
+ arv_log_gvcp ("%d, %d, %d", packet_type, command, packet_id);
if (packet_type == ARV_GVCP_PACKET_TYPE_ACK &&
command == ARV_GVCP_COMMAND_WRITE_REGISTER_ACK &&
- packet_count == io_data->packet_count)
+ packet_id == io_data->packet_id)
success = TRUE;
else
arv_gvcp_packet_debug (ack_packet, ARV_DEBUG_LEVEL_WARNING);
@@ -713,7 +713,7 @@ arv_gv_device_new (GInetAddress *interface_address, GInetAddress *device_address
io_data = g_new0 (ArvGvDeviceIOData, 1);
io_data->mutex = g_mutex_new ();
- io_data->packet_count = 65300; /* Start near the end of the circular counter */
+ io_data->packet_id = 65300; /* Start near the end of the circular counter */
io_data->interface_address = g_inet_socket_address_new (interface_address, 0);
io_data->device_address = g_inet_socket_address_new (device_address, ARV_GVCP_PORT);
diff --git a/src/arvgvinterface.c b/src/arvgvinterface.c
index ac4d4bf..e1607a7 100644
--- a/src/arvgvinterface.c
+++ b/src/arvgvinterface.c
@@ -249,7 +249,7 @@ arv_gv_interface_receive_hello_packet (ArvGvInterface *gv_interface)
ArvGvcpPacket *packet = (ArvGvcpPacket *) buffer;
if (g_ntohs (packet->header.command) == ARV_GVCP_COMMAND_DISCOVERY_ACK &&
- g_ntohs (packet->header.count) == 0xffff) {
+ g_ntohs (packet->header.id) == 0xffff) {
ArvGvInterfaceDeviceInfos *device_infos;
GInetAddress *interface_address;
char *address_string;
diff --git a/src/arvgvsp.h b/src/arvgvsp.h
index 5627acd..063f327 100644
--- a/src/arvgvsp.h
+++ b/src/arvgvsp.h
@@ -34,24 +34,62 @@ G_BEGIN_DECLS
#define ARV_GVSP_PACKET_PROTOCOL_OVERHEAD (20 + 8 + 8) /* IP + UDP + GVSP headers */
+/**
+ * ArvGvspPacketType:
+ * @ARV_GVSP_PACKET_TYPE_OK: valid packet
+ * @ARV_GVSP_PACKET_TYPE_ERROR: error packet, indicating invalid resend request
+ */
+
typedef enum {
ARV_GVSP_PACKET_TYPE_OK = 0x0000,
ARV_GVSP_PACKET_TYPE_ERROR = 0x800c
} ArvGvspPacketType;
+/**
+ * ArvGvspContentType:
+ * @ARV_GVSP_CONTENT_TYPE_DATA_LEADER: leader packet
+ * @ARV_GVSP_CONTENT_TYPE_DATA_TRAILER: trailer packet
+ * @ARV_GVSP_CONTENT_TYPE_DATA_BLOCK: data packet
+ */
+
typedef enum {
ARV_GVSP_CONTENT_TYPE_DATA_LEADER = 0x01,
ARV_GVSP_CONTENT_TYPE_DATA_TRAILER = 0x02,
ARV_GVSP_CONTENT_TYPE_DATA_BLOCK = 0x03
} ArvGvspContentType;
-typedef struct {
+#define ARAVIS_PACKED_STRUCTURE __attribute__((__packed__))
+
+/**
+ * ArvGvspHeader:
+ * @packet_type: a #ArvGvspPacketType identifier
+ * @frame_id: frame identifier
+ * @packet_infos: #ArvGvspContentType and packet identifier in a 32 bit value
+ *
+ * GVSP packet header structure.
+ */
+
+typedef struct ARAVIS_PACKED_STRUCTURE {
guint16 packet_type;
guint16 frame_id;
guint32 packet_infos;
-} __attribute__((__packed__)) ArvGvspHeader;
+} ArvGvspHeader;
+
+/**
+ * ArvGvspDataLeader:
+ * @data0: unused
+ * @timestamp_high: most significant bits of frame timestamp
+ * @timestamp_low: least significant bits of frame timestamp_low
+ * @pixel_format: a #ArvPixelFormat identifier
+ * @width: frame width, in pixels
+ * @height: frame height, in pixels
+ * @x_offset: frame x offset, in pixels
+ * @y_offset: frame y offset, in pixels
+ *
+ * GVSP data leader packet data area.
+ */
-typedef struct {
+typedef struct ARAVIS_PACKED_STRUCTURE {
guint32 data0;
guint32 timestamp_high;
guint32 timestamp_low;
@@ -60,12 +98,30 @@ typedef struct {
guint32 height;
guint32 x_offset;
guint32 y_offset;
-} __attribute__((__packed__)) ArvGvspDataLeader;
+} ArvGvspDataLeader;
-typedef struct {
+/**
+ * ArvGvspDataTrailer:
+ * @data0: unused
+ * @data1: unused
+ *
+ * GVSP data trailer packet data area.
+ */
+
+typedef struct ARAVIS_PACKED_STRUCTURE {
guint32 data0;
guint32 data1;
-} __attribute__((__packed__)) ArvGvspDataTrailer;
+} ArvGvspDataTrailer;
+
+#undef ARAVIS_PACKED_STRUCTURE
+
+/**
+ * ArvGvspPacket:
+ * @header: common GVSP packet header
+ * @data: data byte array
+ *
+ * GVSP packet structure.
+ */
typedef struct {
ArvGvspHeader header;
diff --git a/src/arvgvstream.c b/src/arvgvstream.c
index 007af54..a66e511 100644
--- a/src/arvgvstream.c
+++ b/src/arvgvstream.c
@@ -93,7 +93,7 @@ typedef struct {
gboolean cancel;
- guint16 packet_count;
+ guint16 packet_id;
GSList *frames;
guint32 last_frame_id;
@@ -134,10 +134,10 @@ _send_packet_request (ArvGvStreamThreadData *thread_data,
ArvGvcpPacket *packet;
size_t packet_size;
- thread_data->packet_count = arv_gvcp_next_packet_count (thread_data->packet_count);
+ thread_data->packet_id = arv_gvcp_next_packet_id (thread_data->packet_id);
packet = arv_gvcp_packet_new_packet_resend_cmd (frame_id, first_block, last_block,
- thread_data->packet_count, &packet_size);
+ thread_data->packet_id, &packet_size);
arv_log_stream_thread ("[GvStream::send_packet_request] frame_id = %u (%d - %d)",
frame_id, first_block, last_block);
@@ -736,7 +736,7 @@ arv_gv_stream_new (GInetAddress *device_address, guint16 port,
thread_data->data_size = packet_size - ARV_GVSP_PACKET_PROTOCOL_OVERHEAD;
thread_data->cancel = FALSE;
- thread_data->packet_count = 65300;
+ thread_data->packet_id = 65300;
thread_data->last_frame_id = 0;
thread_data->n_completed_buffers = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]