[aravis] fake_camera: convert to big endian.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] fake_camera: convert to big endian.
- Date: Tue, 3 Apr 2012 08:22:33 +0000 (UTC)
commit 68427157b8f4aae15b881145e3c24f40dd5f34a2
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Apr 2 22:40:48 2012 +0200
fake_camera: convert to big endian.
src/arv-fake-camera.xml | 50 +++++++++++++++++++++++-----------------------
src/arvfakecamera.c | 29 +++++++++++++++++++++-----
tests/data/genicam.xml | 4 +-
3 files changed, 50 insertions(+), 33 deletions(-)
---
diff --git a/src/arv-fake-camera.xml b/src/arv-fake-camera.xml
index c96f5e8..30ea1e5 100644
--- a/src/arv-fake-camera.xml
+++ b/src/arv-fake-camera.xml
@@ -100,7 +100,7 @@
<AccessMode>RO</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="SensorWidth" NameSpace="Standard">
@@ -114,7 +114,7 @@
<AccessMode>RO</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="OffsetX" NameSpace="Standard">
@@ -131,7 +131,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="OffsetY" NameSpace="Standard">
@@ -148,7 +148,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="Width" NameSpace="Standard">
@@ -165,7 +165,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="Height" NameSpace="Standard">
@@ -182,7 +182,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="BinningHorizontal" NameSpace="Standard">
@@ -198,7 +198,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Integer Name="BinningVertical" NameSpace="Standard">
@@ -214,7 +214,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Enumeration Name="PixelFormat" NameSpace="Standard">
@@ -231,7 +231,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<!-- Acquisition control -->
@@ -261,7 +261,7 @@
<AccessMode>WO</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Enumeration Name="AcquisitionMode" NameSpace="Standard">
@@ -284,7 +284,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Converter Name="AcquisitionFrameRate" NameSpace="Standard">
@@ -300,7 +300,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Enumeration Name="TriggerSelector" NameSpace="Standard">
@@ -335,7 +335,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Enumeration Name="TriggerSource" NameSpace="Standard">
@@ -353,7 +353,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Enumeration Name="TriggerActivation" NameSpace="Standard">
@@ -371,7 +371,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Float Name="ExposureTimeAbs" NameSpace="Standard">
@@ -393,7 +393,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<!-- Analog control -->
@@ -416,7 +416,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<Enumeration Name="GainAuto" NameSpace="Standard">
@@ -439,7 +439,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<!-- Transport layer control -->
@@ -466,7 +466,7 @@
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<StructReg Comment="TestStructReg">
@@ -474,22 +474,22 @@
<Length>4</Length>
<AccessMode>RW</AccessMode>
<pPort>Device</pPort>
- <Endianess>LittleEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
<StructEntry Name="StructEntry_0_15" NameSpace="Custom">
- <LSB>0</LSB>
- <MSB>15</MSB>
+ <LSB>31</LSB>
+ <MSB>16</MSB>
<Sign>Unsigned</Sign>
</StructEntry>
<StructEntry Name="StructEntry_16_31" NameSpace="Custom">
- <LSB>16</LSB>
- <MSB>31</MSB>
+ <LSB>15</LSB>
+ <MSB>0</MSB>
<Sign>Unsigned</Sign>
</StructEntry>
<StructEntry Name="StructEntry_16" NameSpace="Custom">
- <Bit>16</Bit>
+ <Bit>15</Bit>
</StructEntry>
</StructReg>
diff --git a/src/arvfakecamera.c b/src/arvfakecamera.c
index fbad89a..0ed37bd 100644
--- a/src/arvfakecamera.c
+++ b/src/arvfakecamera.c
@@ -105,22 +105,37 @@ arv_fake_camera_write_memory (ArvFakeCamera *camera, guint32 address, guint32 si
gboolean
arv_fake_camera_read_register (ArvFakeCamera *camera, guint32 address, guint32 *value)
{
- return arv_fake_camera_read_memory (camera, address, sizeof (*value), value);
+ gboolean success;
+ guint32 be_value = 0;
+
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ success = arv_fake_camera_read_memory (camera, address, sizeof (*value), &be_value);
+
+ *value = GUINT32_FROM_BE (be_value);
+
+ return success;
}
gboolean
arv_fake_camera_write_register (ArvFakeCamera *camera, guint32 address, guint32 value)
{
- return arv_fake_camera_write_memory (camera, address, sizeof (value), &value);
+ guint32 be_value = GUINT32_TO_BE (value);
+
+ return arv_fake_camera_write_memory (camera, address, sizeof (value), &be_value);
}
static guint32
_get_register (ArvFakeCamera *camera, guint32 address)
{
+ guint32 value;
+
if (address + sizeof (guint32) > ARV_FAKE_CAMERA_MEMORY_SIZE)
return 0;
- return *((guint32 *) ((void*) (camera->priv->memory + address)));
+ value = *((guint32 *) ((void*) (camera->priv->memory + address)));
+
+ return GUINT32_FROM_BE (value);
}
size_t
@@ -307,12 +322,13 @@ arv_fake_camera_get_stream_address (ArvFakeCamera *camera)
g_return_val_if_fail (ARV_IS_FAKE_CAMERA (camera), NULL);
- value = GUINT32_FROM_BE (_get_register (camera, ARV_GVBS_STREAM_CHANNEL_0_IP_ADDRESS_OFFSET));
+ arv_fake_camera_read_memory (camera, ARV_GVBS_STREAM_CHANNEL_0_IP_ADDRESS_OFFSET, sizeof (value), &value);
inet_address = g_inet_address_new_from_bytes ((guint8 *) &value, G_SOCKET_FAMILY_IPV4);
stream_socket_address = g_inet_socket_address_new
(inet_address,
_get_register (camera, ARV_GVBS_STREAM_CHANNEL_0_PORT_OFFSET));
+
g_object_unref (inet_address);
return stream_socket_address;
@@ -463,10 +479,11 @@ arv_fake_camera_new (const char *serial_number)
arv_fake_camera_write_register (fake_camera, ARV_GVBS_TIMESTAMP_TICK_FREQUENCY_LOW_OFFSET, 1000000000);
arv_fake_camera_write_register (fake_camera, ARV_GVBS_CONTROL_CHANNEL_PRIVILEGE_OFFSET, 0);
+ arv_fake_camera_write_register (fake_camera, ARV_GVBS_STREAM_CHANNEL_0_PACKET_SIZE_OFFSET, 2000);
+
arv_fake_camera_write_register (fake_camera, ARV_GVBS_N_STREAM_CHANNELS_OFFSET, 1);
- arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_TEST,
- ARV_FAKE_CAMERA_TEST_REGISTER_DEFAULT);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_TEST, ARV_FAKE_CAMERA_TEST_REGISTER_DEFAULT);
return fake_camera;
}
diff --git a/tests/data/genicam.xml b/tests/data/genicam.xml
index 65cf99b..fe46044 100644
--- a/tests/data/genicam.xml
+++ b/tests/data/genicam.xml
@@ -132,7 +132,7 @@
<Cachable>NoCache</Cachable>
<PollingTime>5</PollingTime>
<Sign>Unsigned</Sign>
- <Endianess>LittelEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<IntReg Name="IntRegisterB">
@@ -145,7 +145,7 @@
<Cachable>NoCache</Cachable>
<PollingTime>5</PollingTime>
<Sign>Unsigned</Sign>
- <Endianess>LittelEndian</Endianess>
+ <Endianess>BigEndian</Endianess>
</IntReg>
<IntSwissKnife Name="IntSwissKnifeTest">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]