[aravis] gvcp: avoid 0 for packet_count, as it is an error value.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] gvcp: avoid 0 for packet_count, as it is an error value.
- Date: Mon, 4 Jul 2011 14:47:55 +0000 (UTC)
commit 2e16eb6c2c25bd886c92a42328b3269517ef6d25
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Jul 4 16:45:43 2011 +0200
gvcp: avoid 0 for packet_count, as it is an error value.
This commit should really fix the lost of connection after a period
of time.
docs/reference/aravis/aravis-sections.txt | 1 +
src/arvgvcp.h | 9 +++++++++
src/arvgvdevice.c | 14 +++++++++-----
src/arvgvstream.c | 6 ++++--
4 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index b6afe16..4b5dbb6 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -802,6 +802,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
<SUBSECTION Private>
ARV_GVBS_CONTROL_CHANNEL_PRIVILEGE_CONTROL
ARV_GVBS_CONTROL_CHANNEL_PRIVILEGE_EXCLUSIVE
diff --git a/src/arvgvcp.h b/src/arvgvcp.h
index b195437..1467cb8 100644
--- a/src/arvgvcp.h
+++ b/src/arvgvcp.h
@@ -313,6 +313,15 @@ arv_gvcp_packet_get_write_register_cmd_infos (const ArvGvcpPacket *packet, guint
*value = g_ntohl (*((guint32 *) ((char *) packet + sizeof (ArvGvcpPacket) + sizeof (guint32))));
}
+static inline guint16
+arv_gvcp_next_packet_count (guint16 packet_count)
+{
+ /* packet_count == 0 is an error value */
+ if (packet_count == 0xffff)
+ return 1;
+ return packet_count++;
+}
+
G_END_DECLS
#endif
diff --git a/src/arvgvdevice.c b/src/arvgvdevice.c
index 96a6066..495b299 100644
--- a/src/arvgvdevice.c
+++ b/src/arvgvdevice.c
@@ -93,7 +93,8 @@ _read_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *b
0, &packet_size);
do {
- arv_gvcp_packet_set_packet_count (packet, ++io_data->packet_count);
+ io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
+ arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -157,7 +158,8 @@ _write_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *
memcpy (arv_gvcp_packet_get_write_memory_cmd_data (packet), buffer, size);
do {
- arv_gvcp_packet_set_packet_count (packet, ++io_data->packet_count);
+ io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
+ arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -215,7 +217,8 @@ _read_register (ArvGvDeviceIOData *io_data, guint32 address, guint32 *value_plac
packet = arv_gvcp_packet_new_read_register_cmd (address, 0, &packet_size);
do {
- arv_gvcp_packet_set_packet_count (packet, ++io_data->packet_count);
+ io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
+ arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -277,7 +280,8 @@ _write_register (ArvGvDeviceIOData *io_data, guint32 address, guint32 value)
packet = arv_gvcp_packet_new_write_register_cmd (address, value, io_data->packet_count, &packet_size);
do {
- arv_gvcp_packet_set_packet_count (packet, ++io_data->packet_count);
+ io_data->packet_count = arv_gvcp_next_packet_count (io_data->packet_count);
+ arv_gvcp_packet_set_packet_count (packet, io_data->packet_count);
arv_gvcp_packet_debug (packet, ARV_DEBUG_LEVEL_LOG);
@@ -688,7 +692,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 = 0;
+ io_data->packet_count = 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/arvgvstream.c b/src/arvgvstream.c
index 0965a8b..007af54 100644
--- a/src/arvgvstream.c
+++ b/src/arvgvstream.c
@@ -134,8 +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);
+
packet = arv_gvcp_packet_new_packet_resend_cmd (frame_id, first_block, last_block,
- thread_data->packet_count++, &packet_size);
+ thread_data->packet_count, &packet_size);
arv_log_stream_thread ("[GvStream::send_packet_request] frame_id = %u (%d - %d)",
frame_id, first_block, last_block);
@@ -734,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 = 1;
+ thread_data->packet_count = 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]