| 1 |
/* |
| 2 |
GigE interface wrapper on araviss |
| 3 |
Copyright (C) 2016 Hendrik Beijeman ([email protected]) |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Lesser General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2.1 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public |
| 16 |
License along with this library; if not, write to the Free Software |
| 17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
#include "ArvGeneric.h" |
| 20 |
#include "BlackFly.h" |
| 21 |
|
| 22 |
using namespace arv; |
| 23 |
|
| 24 |
BlackFly::BlackFly(void *camera_device) : ArvGeneric(camera_device) |
| 25 |
{ |
| 26 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 27 |
} |
| 28 |
|
| 29 |
bool BlackFly::_custom_settings() |
| 30 |
{ |
| 31 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 32 |
::ArvDevice *dev = this->dev; |
| 33 |
#define WRITE_REGISTER(reg, val) \ |
| 34 |
{ \ |
| 35 |
error = nullptr; \ |
| 36 |
result = arv_device_write_register(dev, (reg), (val), &error); \ |
| 37 |
if ((result != 1) || (error != nullptr)) \ |
| 38 |
{ \ |
| 39 |
goto error; \ |
| 40 |
} \ |
| 41 |
} |
| 42 |
|
| 43 |
gboolean result; |
| 44 |
guint32 val; |
| 45 |
GError *error = nullptr; |
| 46 |
|
| 47 |
int i; |
| 48 |
for (i = 0; i < 4; i++) |
| 49 |
{ |
| 50 |
WRITE_REGISTER(0xF0F00614UL, 0x00000000UL); /* Set Isochronous transfer off */ |
| 51 |
WRITE_REGISTER(0xF0F00608UL, 0xE0000000UL); /* Set Current video format 7 */ |
| 52 |
WRITE_REGISTER(0xF0F00604UL, 0x00000000UL); /* Set Current video mode 0 */ |
| 53 |
|
| 54 |
WRITE_REGISTER(0xF0F00630UL, 0x00800000UL); /* Little Endian, please! */ |
| 55 |
|
| 56 |
WRITE_REGISTER(0xF0F00A08UL, 0x00000000UL); /* Mode0 IMAGE_POSITION (max)*/ |
| 57 |
WRITE_REGISTER(0xF0F00A0CUL, 0x08000600UL); /* Mode0 IMAGE_SIZE (max) */ |
| 58 |
WRITE_REGISTER(0xF0F00A10UL, 0x0a000000UL); /* Mode0 IMAGE_FORMAT, configure RAW16 */ |
| 59 |
WRITE_REGISTER(0xF0F00A7CUL, 0x40000000UL); /* Mode0 IMAGE_POSITION/COLOR_CODING_ID */ |
| 60 |
WRITE_REGISTER(0xF0F00A44UL, 0x34540000UL); /* Mode0 BYTE_PER_PACKET */ |
| 61 |
|
| 62 |
/* Disable auto-frame-rate */ |
| 63 |
WRITE_REGISTER(0xF0F0081CUL, 0xC2000FFFUL); /* FRAME_RATE, No AUTO, OFF */ |
| 64 |
} |
| 65 |
|
| 66 |
return true; |
| 67 |
|
| 68 |
error: |
| 69 |
return false; |
| 70 |
} |
| 71 |
|
| 72 |
bool BlackFly::connect(void) |
| 73 |
{ |
| 74 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 75 |
bool const ret = ArvGeneric::connect(); |
| 76 |
if (ret) |
| 77 |
{ |
| 78 |
this->_configure(); |
| 79 |
} |
| 80 |
return ret; |
| 81 |
} |
| 82 |
|
| 83 |
void BlackFly::_fixup(void) |
| 84 |
{ |
| 85 |
::ArvDevice *dev = this->dev; |
| 86 |
#define WRITE_REGISTER(reg, val) \ |
| 87 |
{ \ |
| 88 |
error = nullptr; \ |
| 89 |
result = arv_device_write_register(dev, (reg), (val), &error); \ |
| 90 |
if ((result != 1) || (error != nullptr)) \ |
| 91 |
{ \ |
| 92 |
goto error; \ |
| 93 |
} \ |
| 94 |
} |
| 95 |
|
| 96 |
gboolean result; |
| 97 |
guint32 val; |
| 98 |
GError *error = nullptr; |
| 99 |
|
| 100 |
int i; |
| 101 |
for (i = 0; i < 4; i++) |
| 102 |
{ |
| 103 |
WRITE_REGISTER(0xF0F00614UL, 0x00000000UL); /* Isochronous transfer off */ |
| 104 |
WRITE_REGISTER(0xF0F00630UL, 0x00800000UL); /* Little Endian, please! */ |
| 105 |
} |
| 106 |
error: |
| 107 |
return; |
| 108 |
} |
| 109 |
|
| 110 |
void BlackFly::exposure_start(void) |
| 111 |
{ |
| 112 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 113 |
/* At some point in stream start, the endianness gets reset by the camera itself... why? genicam? */ |
| 114 |
this->_fixup(); |
| 115 |
ArvGeneric::exposure_start(); |
| 116 |
} |
| 117 |
|
| 118 |
bool BlackFly::_configure(void) |
| 119 |
{ |
| 120 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 121 |
this->_set_initial_config(); |
| 122 |
return this->_get_initial_config(); |
| 123 |
} |
| 124 |
|
| 125 |
bool BlackFly::_get_initial_config(void) |
| 126 |
{ |
| 127 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 128 |
ArvGeneric::_get_initial_config(); |
| 129 |
|
| 130 |
/* Pitch can only be found in the datasheet, so hardcode ours here */ |
| 131 |
this->cam.pixel_pitch.set_single(3.45); |
| 132 |
|
| 133 |
/* Probably can find this somewhere in genicam, too, but it depends on framerate |
| 134 |
* and the maximum exposure is consequently not published */ |
| 135 |
this->cam.exposure.update(5000, 11900000); |
| 136 |
} |
| 137 |
|
| 138 |
bool BlackFly::_set_initial_config(void) |
| 139 |
{ |
| 140 |
printf("%s\n", __PRETTY_FUNCTION__); |
| 141 |
ArvGeneric::_set_initial_config(); |
| 142 |
this->_custom_settings(); |
| 143 |
} |