COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
GigE Vision functions
Collaboration diagram for GigE Vision functions:

Functions

vector< gige_acknowledge_ackgige_discover ()
 Discover GIGE Camera. More...
 
gige_handlegige_open (char address[18], uint8_t privilege, uint32_t heartbeat_msec, uint32_t socket_usec, uint32_t streambps)
 Connect to camera. More...
 
int gige_writereg (gige_handle *handle, uint32_t address, uint32_t data)
 Write Register. More...
 
uint32_t gige_readreg (gige_handle *handle, uint32_t address)
 Read GIGE Register. More...
 
uint32_t gige_readmem (gige_handle *handle, uint32_t address, uint32_t nbytes)
 Read GIGE memory. More...
 
void gige_close (gige_handle *handle)
 Close GigE Camera. More...
 
uint32_t gige_address_to_value (char *address)
 IP Address to value. More...
 
char * gige_value_to_address (uint32_t value)
 IP Value to address. More...
 
int prosilica_config (gige_handle *handle, uint32_t format, uint32_t xbin, uint32_t ybin, uint32_t xsize, uint32_t ysize, uint32_t xoffset, uint32_t yoffset)
 Configure Prosilica camera. More...
 
int prosilica_image (gige_handle *handle, uint16_t emode, uint32_t exposure, uint32_t gain, uint8_t *buffer, uint16_t bsize)
 Take Prosilica image. More...
 
int a35_image (gige_handle *handle, uint32_t frames, uint8_t *buffer, uint16_t bsize)
 Take A35 image stream. More...
 
int a35_config (gige_handle *handle, uint32_t xsize, uint32_t ysize, uint32_t video_rate)
 Configure a35 camera. More...
 
int pt1000_image (gige_handle *handle, uint32_t frames, uint8_t *buffer, uint16_t bsize)
 Take PT1000 image stream. More...
 
int pt1000_config (gige_handle *handle, uint32_t xsize, uint32_t ysize)
 Configure pt1000 camera. More...
 

Detailed Description

Function Documentation

vector<gige_acknowledge_ack> gige_discover ( )

Discover GIGE Camera.

Broadcast GIGE DISCOVERY_CMD, accepting all the reponses and returning them in a vector of gige_acknowledge_ack.

Returns
Vector of gige_acknowledge_ack containing responses.
333 {
334  int32_t nbytes;
335  vector<gige_acknowledge_ack> gige_list;
336  socket_channel tchan;
338  int on = 1;
339  vector<socket_channel> ifaces;
340 
342  if (!ifaces.size()) return (gige_list);
343 
344  for (uint16_t i=0; i<ifaces.size(); ++i)
345  {
346  if ((socket_open(&tchan, NetworkType::UDP, ifaces[i].baddress, 3956, SOCKET_TALK, true, 100000)) < 0) return (gige_list);
347 
348  if ((setsockopt(tchan.cudp,SOL_SOCKET,SO_BROADCAST,(char*)&on,sizeof(on))) < 0)
349  {
350  close(tchan.cudp);
351  continue;
352  }
353 
354  uint16to(0x4201,(uint8_t *)&handle.creg.flag,ByteOrder::BIGENDIAN);
356  uint16to(0x0000,(uint8_t *)&handle.creg.length,ByteOrder::BIGENDIAN);
357  uint16to(++handle.req_id,(uint8_t *)&handle.creg.req_id,ByteOrder::BIGENDIAN);
358 
359  if ((nbytes=sendto(tchan.cudp,(char *)handle.cbyte,8,0,(struct sockaddr *)&tchan.caddr,sizeof(tchan.caddr))) < 0)
360  {
361  close(tchan.cudp);
362  continue;
363  }
364 
365  tchan.addrlen = sizeof(tchan.caddr);
366 
367  while((nbytes=recvfrom(tchan.cudp,(char *)handle.cbyte,256,0,static_cast<struct sockaddr *>(nullptr),static_cast<socklen_t *>(nullptr))) > 0)
368  {
369  handle.cack.ack_id = uint16from((uint8_t *)&handle.cack.ack_id,ByteOrder::BIGENDIAN);
370  if (handle.cack.ack_id != handle.req_id) continue;
371 
372  handle.cack.status = uint16from((uint8_t *)&handle.cack.status,ByteOrder::BIGENDIAN);
373  handle.cack.acknowledge = uint16from((uint8_t *)&handle.cack.acknowledge,ByteOrder::BIGENDIAN);
374  handle.cack.length = uint16from((uint8_t *)&handle.cack.length,ByteOrder::BIGENDIAN);
375 
379  handle.cack_ack.mac_high = uint16from((uint8_t *)&handle.cack_ack.mac_high,ByteOrder::BIGENDIAN);
380  handle.cack_ack.mac_low = uint32from((uint8_t *)&handle.cack_ack.mac_low,ByteOrder::BIGENDIAN);
383  handle.cack_ack.address = uint32from((uint8_t *)&handle.cack_ack.address,ByteOrder::BIGENDIAN);
384  handle.cack_ack.subnet = uint32from((uint8_t *)&handle.cack_ack.subnet,ByteOrder::BIGENDIAN);
385  handle.cack_ack.gateway = uint32from((uint8_t *)&handle.cack_ack.gateway,ByteOrder::BIGENDIAN);
386  gige_list.push_back(handle.cack_ack);
387  }
388 
389  close(tchan.cudp);
390  }
391 
392  return (gige_list);
393 }
vector< socket_channel > socket_find_addresses(NetworkType ntype)
Discover interfaces.
Definition: socketlib.cpp:547
uint16_t length
Definition: gige_lib.h:266
Agent socket using Unicast UDP.
uint8_t cbyte[600]
Definition: gige_lib.h:345
uint32_t ip_config_options
Definition: gige_lib.h:293
int i
Definition: rw_test.cpp:37
uint16_t req_id
Request ID.
Definition: gige_lib.h:355
void uint16to(uint16_t value, uint8_t *pointer, ByteOrder order)
16 bit unsigned integer to memory
Definition: mathlib.cpp:613
uint16_t length
Definition: gige_lib.h:256
#define GIGE_CMD_DISCOVERY
Definition: gige_lib.h:51
uint16_t req_id
Definition: gige_lib.h:257
gige_acknowledge_ack cack_ack
Definition: gige_lib.h:350
#define SOCKET_TALK
Talk followed by optional listen (sendto address)
Definition: socketlib.h:82
uint32_t ip_config_current
Definition: gige_lib.h:294
int32_t cudp
Definition: socketlib.h:120
uint16_t ack_id
Definition: gige_lib.h:267
uint16_t acknowledge
Definition: gige_lib.h:265
uint16_t status
Definition: gige_lib.h:264
Definition: socketlib.h:115
Big Endian byte order.
struct sockaddr_in caddr
Definition: socketlib.h:122
uint16_t mac_high
Definition: gige_lib.h:291
uint32_t subnet
Definition: gige_lib.h:298
uint32_t device_mode
Definition: gige_lib.h:289
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
int addrlen
Definition: socketlib.h:128
uint32_t uint32from(uint8_t *pointer, ByteOrder order)
Memory to 32 bit unsigned integer.
Definition: mathlib.cpp:442
uint32_t mac_low
Definition: gige_lib.h:292
uint16_t spec_major
Definition: gige_lib.h:287
uint32_t gateway
Definition: gige_lib.h:300
uint32_t address
Definition: gige_lib.h:296
gige_acknowledge cack
Definition: gige_lib.h:348
uint16_t flag
Definition: gige_lib.h:254
int32_t socket_open(socket_channel *channel, NetworkType ntype, const char *address, uint16_t port, uint16_t role, bool blocking, uint32_t usectimeo, uint32_t rcvbuf, uint32_t sndbuf)
Open UDP socket.
Definition: socketlib.cpp:51
Definition: gige_lib.h:336
uint16_t command
Definition: gige_lib.h:255
uint16_t spec_minor
Definition: gige_lib.h:288
uint16_t uint16from(uint8_t *pointer, ByteOrder order)
Memory to 16 bit unsigned integer.
Definition: mathlib.cpp:395
gige_command creg
Definition: gige_lib.h:347
gige_handle* gige_open ( char  address[18],
uint8_t  privilege,
uint32_t  heartbeat_msec,
uint32_t  socket_usec,
uint32_t  streambps 
)

Connect to camera.

Establish a GVCP control connection to a GIGE camera, at the indicated address, with the requested privileges. Once the camera connection is opened, some register must be either read or written within the supplied Heartbeat_Timeout period or the conection will be shut down.

Parameters
addressIP address of the desired camera
privilegeRequested privilege.
heartbeat_msecPeriod between commands to keep connection open.
socket_usecTimeout on socket listen calls.
streambpsBytes per Second throttle on camera flow rate (socket_usec will be increased to match decreasing streambps.)
Returns
A handle to the camera to be used for all subsequent calls.
65 {
66  int32_t iretn;
67  int32_t nbytes;
68  uint32_t myip, theirip, bcastip;
69  struct sockaddr_in raddr;
71  uint8_t bufferin[GIGE_MAX_PACKET];
72  vector<socket_channel> ifaces;
73 
74  if ((handle=new (gige_handle)) == NULL) return nullptr;
75 
76  if (streambps < 100000) streambps = 100000;
77  if (streambps > 100000000) streambps = 100000000;
78  handle->streambps = streambps;
79 
80  // Adjust SO_RCVTIMEO to be long enough to receive twice largest command packet at expected flow rate.
81  if (socket_usec < (uint32_t)(1024000000/streambps)) socket_usec = (uint32_t)(1024000000/streambps);
82 
83  // Open Command socket
84  if ((iretn=socket_open(&handle->command, NetworkType::UDP, address, 3956, SOCKET_TALK, true, socket_usec)) < 0)
85  {
86  delete(handle);
87  return nullptr;
88  }
89 
90  // See if we can get control
91  iretn = gige_writereg(handle, GIGE_REG_CCP,privilege);
92 
93  // Set Heartbeat Timeout
94  if ((iretn = gige_writereg(handle,GIGE_REG_GVCP_HEARTBEAT_TIMEOUT,heartbeat_msec)) < 0)
95  {
96  close(handle->command.cudp);
97  delete(handle);
98  return nullptr;
99  }
100 
101  // Adjust SO_RCVTIMEO to be long enough to receive twice stream largest packet at expected flow rate.
102  if (socket_usec < (uint32_t)(16384000000./streambps)) socket_usec = (uint32_t)(16384000000/streambps);
103 
104  // Open Stream socket
105  if ((iretn=socket_open(&handle->stream, NetworkType::UDP, (char *)"", 0, SOCKET_LISTEN,true,socket_usec)) < 0)
106  {
107  close(handle->command.cudp);
108  return nullptr;
109  delete(handle);
110  }
111 
112  uint32_t n=134217728;
113 // uint32_t n=83886080;
114 // uint32_t n=838860;
115 #if defined(COSMOS_LINUX_OS) || defined(COSMOS_CYGWIN_OS) || defined(COSMOS_MAC_OS)
116  setsockopt(handle->stream.cudp, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n));
117 #else
118  setsockopt(handle->stream.cudp, SOL_SOCKET, SO_RCVBUF, (const char *)&n, sizeof(n));
119 #endif
120 
121  // Find our own IP address to send to camera
122  theirip = (uint32_t)(*(uint32_t*)&handle->command.caddr.sin_addr);
124  for (uint16_t i=0; i<ifaces.size(); ++i)
125  {
126  myip = (uint32_t)(*(uint32_t*)&ifaces[i].caddr.sin_addr);
127  bcastip = (uint32_t)(*(uint32_t*)&ifaces[i].baddr.sin_addr);
128  if ((theirip & (~bcastip)) == (myip & (~bcastip)))
129  strcpy(handle->stream.address,ifaces[i].address);
130  }
131  memcpy((char *)&handle->stream.caddr, (char *)&raddr, sizeof(raddr));
132 
133  if ((iretn=gige_writereg(handle,GIGE_REG_SCDA,gige_address_to_value(handle->stream.address))) < 0)
134  {
135  close(handle->command.cudp);
136  close(handle->stream.cudp);
137  delete(handle);
138  return nullptr;
139  }
140 
141  if ((iretn=gige_writereg(handle,GIGE_REG_SCP,handle->stream.cport)) < 0)
142  {
143  close(handle->command.cudp);
144  close(handle->stream.cudp);
145  delete(handle);
146  return nullptr;
147  }
148 
149  uint32_t bsize;
150  for (bsize=512; bsize<GIGE_MAX_PACKET; bsize+=100)
151  {
152  if (bsize > GIGE_MAX_PACKET) bsize = GIGE_MAX_PACKET;
153  iretn = gige_writereg(handle,GIGE_REG_SCPS,0xc0000000+bsize);
154  iretn = gige_readreg(handle,GIGE_REG_SCPS)%65536;
155  nbytes=recvfrom(handle->stream.cudp,(char *)bufferin,GIGE_MAX_PACKET,0,static_cast<struct sockaddr *>(nullptr),static_cast<socklen_t *>(nullptr));
156  if (nbytes < 0) break;
157  }
158  handle->bestsize = bsize - 100;
159 
160  if ((iretn=gige_writereg(handle,GIGE_REG_SCPS,(uint32_t)handle->bestsize)) < 0)
161  {
162  close(handle->command.cudp);
163  close(handle->stream.cudp);
164  delete(handle);
165  return nullptr;
166  }
167  iretn = gige_writereg(handle,GIGE_REG_SCP,0);
168 
169  return (handle);
170 }
vector< socket_channel > socket_find_addresses(NetworkType ntype)
Discover interfaces.
Definition: socketlib.cpp:547
Agent socket using Unicast UDP.
uint16_t bsize
Definition: netperf_listen.cpp:71
int i
Definition: rw_test.cpp:37
uint32_t streambps
Flow rate.
Definition: gige_lib.h:357
#define GIGE_MAX_PACKET
Definition: gige_lib.h:162
#define GIGE_REG_SCDA
Definition: gige_lib.h:143
int iretn
Definition: rw_test.cpp:37
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
#define SOCKET_TALK
Talk followed by optional listen (sendto address)
Definition: socketlib.h:82
char address[]
Definition: netperf_listen.cpp:69
#define GIGE_REG_SCP
Definition: gige_lib.h:137
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
#define GIGE_REG_CCP
Definition: gige_lib.h:126
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
#define GIGE_REG_GVCP_HEARTBEAT_TIMEOUT
Definition: gige_lib.h:110
#define SOCKET_LISTEN
Listen followed by optional talk (recvfrom INADDRANY)
Definition: socketlib.h:84
#define GIGE_REG_SCPS
Definition: gige_lib.h:139
uint32_t gige_address_to_value(char *address)
IP Address to value.
Definition: gige_lib.cpp:400
int32_t socket_open(socket_channel *channel, NetworkType ntype, const char *address, uint16_t port, uint16_t role, bool blocking, uint32_t usectimeo, uint32_t rcvbuf, uint32_t sndbuf)
Open UDP socket.
Definition: socketlib.cpp:51
Definition: gige_lib.h:336
int gige_writereg ( gige_handle handle,
uint32_t  address,
uint32_t  data 
)

Write Register.

Write indicated GigE register with provided data.

Parameters
handleHandle for GigE camera as returned from gige_open.
addressAddress of register.
dataData to be written.
Returns
Zero or negative error.
193 {
194  int32_t nbytes, ncount;
195 
196  uint16to(0x4201,(uint8_t *)&handle->creg.flag,ByteOrder::BIGENDIAN);
198  uint16to(0x0008,(uint8_t *)&handle->creg.length,ByteOrder::BIGENDIAN);
199  uint16to(++handle->req_id,(uint8_t *)&handle->creg.req_id,ByteOrder::BIGENDIAN);
200  uint32to(address,(uint8_t *)&handle->creg.address,ByteOrder::BIGENDIAN);
201  uint32to(data,(uint8_t *)&handle->creg.data,ByteOrder::BIGENDIAN);
202  if ((nbytes=sendto(handle->command.cudp,(char *)handle->cbyte,16,0,(struct sockaddr *)&handle->command.caddr,sizeof(handle->command.caddr))) < 0)
203  {
204 #ifdef COSMOS_WIN_OS
205  return(-WSAGetLastError());
206 #else
207  return (-errno);
208 #endif
209  }
210 
211  handle->command.addrlen = sizeof(handle->command.caddr);
212 
213  ncount = 100;
214  do
215  {
216  nbytes = recvfrom(handle->command.cudp,(char *)handle->cbyte,12,0,(struct sockaddr *)&handle->command.caddr,(socklen_t *)&handle->command.addrlen);
217  } while (nbytes <= 0 && ncount--);
218 
219  handle->cack.status = uint16from((uint8_t *)&handle->cack.status,ByteOrder::BIGENDIAN);
220  handle->cack.acknowledge = uint16from((uint8_t *)&handle->cack.acknowledge,ByteOrder::BIGENDIAN);
221  handle->cack.length = uint16from((uint8_t *)&handle->cack.length,ByteOrder::BIGENDIAN);
222  handle->cack.ack_id = uint16from((uint8_t *)&handle->cack.ack_id,ByteOrder::BIGENDIAN);
223 
224  if (nbytes != 12) return (GIGE_ERROR_NACK);
225 
226  if (handle->cack.ack_id != handle->req_id) return (GIGE_ERROR_NACK);
227 
228  return 0;
229 }
#define GIGE_ERROR_NACK
Definition: cosmos-errno.h:157
uint16_t length
Definition: gige_lib.h:266
uint8_t cbyte[600]
Definition: gige_lib.h:345
uint16_t req_id
Request ID.
Definition: gige_lib.h:355
void uint16to(uint16_t value, uint8_t *pointer, ByteOrder order)
16 bit unsigned integer to memory
Definition: mathlib.cpp:613
uint16_t length
Definition: gige_lib.h:256
uint16_t req_id
Definition: gige_lib.h:257
#define GIGE_CMD_WRITEREG
Definition: gige_lib.h:55
void uint32to(uint32_t value, uint8_t *pointer, ByteOrder order)
32 bit unsigned integer to memory
Definition: mathlib.cpp:551
char address[]
Definition: netperf_listen.cpp:69
int32_t cudp
Definition: socketlib.h:120
uint16_t ack_id
Definition: gige_lib.h:267
uint16_t acknowledge
Definition: gige_lib.h:265
uint16_t status
Definition: gige_lib.h:264
Big Endian byte order.
struct sockaddr_in caddr
Definition: socketlib.h:122
int addrlen
Definition: socketlib.h:128
socket_channel command
Command channel.
Definition: gige_lib.h:339
uint32_t data
Definition: gige_lib.h:259
uint32_t address
Definition: gige_lib.h:258
gige_acknowledge cack
Definition: gige_lib.h:348
uint16_t flag
Definition: gige_lib.h:254
uint16_t command
Definition: gige_lib.h:255
uint16_t uint16from(uint8_t *pointer, ByteOrder order)
Memory to 16 bit unsigned integer.
Definition: mathlib.cpp:395
gige_command creg
Definition: gige_lib.h:347
uint32_t gige_readreg ( gige_handle handle,
uint32_t  address 
)

Read GIGE Register.

Read indicated GigE register and return data.

Parameters
handleHandle for GigE camera as returned from gige_open.
addressAddress of register.
Returns
Contents of register as 4 byte unsigned integer.
238 {
239  int32_t nbytes, ncount;
240 
241  uint16to(0x4201,(uint8_t *)&handle->creg.flag,ByteOrder::BIGENDIAN);
243  uint16to(0x0004,(uint8_t *)&handle->creg.length,ByteOrder::BIGENDIAN);
244  uint16to(++handle->req_id,(uint8_t *)&handle->creg.req_id,ByteOrder::BIGENDIAN);
245  uint32to(address,(uint8_t *)&handle->creg.address,ByteOrder::BIGENDIAN);
246  if ((nbytes=sendto(handle->command.cudp,(char *)handle->cbyte,12,0,(struct sockaddr *)&handle->command.caddr,sizeof(handle->command.caddr))) < 0)
247  {
248 #ifdef COSMOS_WIN_OS
249  return(-WSAGetLastError());
250 #else
251  return (-errno);
252 #endif
253  }
254 
255  handle->command.addrlen = sizeof(handle->command.caddr);
256 
257  ncount = 100;
258  do
259  {
260  nbytes = recvfrom(handle->command.cudp,(char *)handle->cbyte,12,0,(struct sockaddr *)&handle->command.caddr,(socklen_t *)&handle->command.addrlen);
261  } while (nbytes <= 0 && ncount--);
262 
263  handle->cack.ack_id = uint16from((uint8_t *)&handle->cack.ack_id,ByteOrder::BIGENDIAN);
264  if (handle->cack.ack_id != handle->req_id) return (GIGE_ERROR_NACK);
265 
266  handle->cack.status = uint16from((uint8_t *)&handle->cack.status,ByteOrder::BIGENDIAN);
267  handle->cack.acknowledge = uint16from((uint8_t *)&handle->cack.acknowledge,ByteOrder::BIGENDIAN);
268  handle->cack.length = uint16from((uint8_t *)&handle->cack.length,ByteOrder::BIGENDIAN);
269 
270  if (nbytes != 12) return (GIGE_ERROR_NACK);
271 
272  handle->cack.data = uint32from((uint8_t *)&handle->cack.data,ByteOrder::BIGENDIAN);
273 
274  return (handle->cack.data);
275 }
#define GIGE_ERROR_NACK
Definition: cosmos-errno.h:157
uint32_t data
Definition: gige_lib.h:268
uint16_t length
Definition: gige_lib.h:266
uint8_t cbyte[600]
Definition: gige_lib.h:345
#define GIGE_CMD_READREG
Definition: gige_lib.h:54
uint16_t req_id
Request ID.
Definition: gige_lib.h:355
void uint16to(uint16_t value, uint8_t *pointer, ByteOrder order)
16 bit unsigned integer to memory
Definition: mathlib.cpp:613
uint16_t length
Definition: gige_lib.h:256
uint16_t req_id
Definition: gige_lib.h:257
void uint32to(uint32_t value, uint8_t *pointer, ByteOrder order)
32 bit unsigned integer to memory
Definition: mathlib.cpp:551
char address[]
Definition: netperf_listen.cpp:69
int32_t cudp
Definition: socketlib.h:120
uint16_t ack_id
Definition: gige_lib.h:267
uint16_t acknowledge
Definition: gige_lib.h:265
uint16_t status
Definition: gige_lib.h:264
Big Endian byte order.
struct sockaddr_in caddr
Definition: socketlib.h:122
int addrlen
Definition: socketlib.h:128
uint32_t uint32from(uint8_t *pointer, ByteOrder order)
Memory to 32 bit unsigned integer.
Definition: mathlib.cpp:442
socket_channel command
Command channel.
Definition: gige_lib.h:339
uint32_t address
Definition: gige_lib.h:258
gige_acknowledge cack
Definition: gige_lib.h:348
uint16_t flag
Definition: gige_lib.h:254
uint16_t command
Definition: gige_lib.h:255
uint16_t uint16from(uint8_t *pointer, ByteOrder order)
Memory to 16 bit unsigned integer.
Definition: mathlib.cpp:395
gige_command creg
Definition: gige_lib.h:347
uint32_t gige_readmem ( gige_handle handle,
uint32_t  address,
uint32_t  size 
)

Read GIGE memory.

Read indicated GigE memory and return data.

Parameters
handleHandle for GigE camera as returned from gige_open.
addressAddress of memory.
sizeSize of memory area to read.
Returns
Contents of register as 4 byte unsigned integer.
285 {
286  int32_t nbytes, ncount;
287 
288  uint16to(0x4201,(uint8_t *)&handle->creg.flag,ByteOrder::BIGENDIAN);
290  uint16to(0x0008,(uint8_t *)&handle->creg.length,ByteOrder::BIGENDIAN);
291  uint16to(++handle->req_id,(uint8_t *)&handle->creg.req_id,ByteOrder::BIGENDIAN);
292  address = 4 * (address / 4);
293  uint32to(address,(uint8_t *)&handle->creg.address,ByteOrder::BIGENDIAN);
294  size = 4 * (size / 4);
295  uint32to(size,(uint8_t *)&handle->creg.data,ByteOrder::BIGENDIAN);
296  if ((nbytes=sendto(handle->command.cudp,(char *)handle->cbyte,16,0,(struct sockaddr *)&handle->command.caddr,sizeof(struct sockaddr_in))) < 0)
297  {
298 #ifdef COSMOS_WIN_OS
299  return(-WSAGetLastError());
300 #else
301  return (-errno);
302 #endif
303  }
304 
305  handle->command.addrlen = sizeof(handle->command.caddr);
306 
307  ncount = 100;
308  do
309  {
310  nbytes = recvfrom(handle->command.cudp,(char *)handle->cbyte,size+12,0,(struct sockaddr *)&handle->command.caddr,(socklen_t *)&handle->command.addrlen);
311  } while (nbytes <= 0 && ncount--);
312 
313  handle->cack.ack_id = uint16from((uint8_t *)&handle->cack.ack_id,ByteOrder::BIGENDIAN);
314  if (handle->cack.ack_id != handle->req_id) return (GIGE_ERROR_NACK);
315 
316  handle->cack.status = uint16from((uint8_t *)&handle->cack.status,ByteOrder::BIGENDIAN);
317  handle->cack.acknowledge = uint16from((uint8_t *)&handle->cack.acknowledge,ByteOrder::BIGENDIAN);
318  handle->cack.length = uint16from((uint8_t *)&handle->cack.length,ByteOrder::BIGENDIAN);
319  handle->cack_mem.address = uint32from((uint8_t *)&handle->cack_mem.address,ByteOrder::BIGENDIAN);
320 
321  if ((uint32_t)nbytes != size+12) return (GIGE_ERROR_NACK);
322 
323 
324  return ((uint32_t)nbytes-12);
325 }
uint32_t address
Definition: gige_lib.h:277
#define GIGE_ERROR_NACK
Definition: cosmos-errno.h:157
gige_acknowledge_mem cack_mem
Definition: gige_lib.h:349
uint16_t length
Definition: gige_lib.h:266
uint8_t cbyte[600]
Definition: gige_lib.h:345
uint16_t req_id
Request ID.
Definition: gige_lib.h:355
void uint16to(uint16_t value, uint8_t *pointer, ByteOrder order)
16 bit unsigned integer to memory
Definition: mathlib.cpp:613
uint16_t length
Definition: gige_lib.h:256
uint16_t req_id
Definition: gige_lib.h:257
void uint32to(uint32_t value, uint8_t *pointer, ByteOrder order)
32 bit unsigned integer to memory
Definition: mathlib.cpp:551
char address[]
Definition: netperf_listen.cpp:69
int32_t cudp
Definition: socketlib.h:120
uint16_t ack_id
Definition: gige_lib.h:267
uint16_t acknowledge
Definition: gige_lib.h:265
uint16_t status
Definition: gige_lib.h:264
Big Endian byte order.
struct sockaddr_in caddr
Definition: socketlib.h:122
int addrlen
Definition: socketlib.h:128
uint32_t uint32from(uint8_t *pointer, ByteOrder order)
Memory to 32 bit unsigned integer.
Definition: mathlib.cpp:442
socket_channel command
Command channel.
Definition: gige_lib.h:339
uint32_t data
Definition: gige_lib.h:259
uint32_t address
Definition: gige_lib.h:258
gige_acknowledge cack
Definition: gige_lib.h:348
uint16_t flag
Definition: gige_lib.h:254
#define GIGE_CMD_READMEM
Definition: gige_lib.h:56
uint16_t command
Definition: gige_lib.h:255
uint16_t uint16from(uint8_t *pointer, ByteOrder order)
Memory to 16 bit unsigned integer.
Definition: mathlib.cpp:395
gige_command creg
Definition: gige_lib.h:347
void gige_close ( gige_handle handle)

Close GigE Camera.

Close an existing Control Channel to a GigE camera by writing 0 to the CCP register and closing all sockets.

Parameters
handleHandle for GigE camera as returned from gige_open.
178 {
179 
180  gige_writereg(handle, GIGE_REG_CCP,0x00000000);
181  close(handle->command.cudp);
182  close(handle->stream.cudp);
183 }
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
int32_t cudp
Definition: socketlib.h:120
#define GIGE_REG_CCP
Definition: gige_lib.h:126
socket_channel stream
Stream channel.
Definition: gige_lib.h:341
socket_channel command
Command channel.
Definition: gige_lib.h:339
uint32_t gige_address_to_value ( char *  address)

IP Address to value.

Convert a 17 character IP address string to a 4 byte unsigned integer.

Parameters
addressDot notation IP address.
Returns
4 byte unsigned integer in same order.
401 {
402  union
403  {
404  uint8_t byte[4];
405  uint32_t value;
406  } v;
407 
408  sscanf(address,"%hhu.%hhu.%hhu.%hhu",&v.byte[3],&v.byte[2],&v.byte[1],&v.byte[0]);
409 
410  return (v.value);
411 }
char address[]
Definition: netperf_listen.cpp:69
char* gige_value_to_address ( uint32_t  value)

IP Value to address.

Convert a 4 byte unsigned integer to a dot notation address string.

Parameters
value4 byte unsigned integer.
Returns
String containing dot notation address.
419 {
420  static char address[18];
421  union
422  {
423  uint8_t byte[4];
424  uint32_t value;
425  } v;
426 
427  v.value = value;
428  sprintf(address,"%u.%u.%u.%u",v.byte[3],v.byte[2],v.byte[1],v.byte[0]);
429  return (address);
430 }
char address[]
Definition: netperf_listen.cpp:69
int prosilica_config ( gige_handle handle,
uint32_t  format,
uint32_t  xbin,
uint32_t  ybin,
uint32_t  xsize,
uint32_t  ysize,
uint32_t  xoffset,
uint32_t  yoffset 
)

Configure Prosilica camera.

Setup the basic image parameters for a Prosilica camera being used over GIGE. The camera must first be opened with a call to gige_open.

Parameters
handlePointer to gige_handle returned by gige_open.
formatPixel format for output as defined in GigE Vision Prosilica constants.
xbinFactor for binning in x direction.
ybinFactor for binning in y direction.
xsizeNumber of pixels in x direction.
ysizeNumber of pixels in y direction.
xoffsetStarting pixel of sub-image in x direction.
yoffsetStarting pixel of sub-image in y direction.
Returns
Zero, or negative error.
641 {
642  uint32_t maxx, maxy, maxbx, maxby;
643  int32_t iretn;
644 
645  if((iretn=gige_readreg(handle,PROSILICA_SensorWidth)) < 0) return iretn;
646  maxx = iretn;
647  if((iretn=gige_readreg(handle,PROSILICA_SensorHeight)) < 0) return iretn;
648  maxy = iretn;
649  if((iretn=gige_readreg(handle,PROSILICA_BinningXMax)) < 0) return iretn;
650  maxbx = iretn;
651  if((iretn=gige_readreg(handle,PROSILICA_BinningYMax)) < 0) return iretn;
652  maxby = iretn;
653 
654  if (xbin > 1 || ybin > 1)
655  {
656  xoffset = yoffset = 0;
657  if (xbin > maxbx) xbin = maxbx;
658  if (ybin > maxby) ybin = maxby;
659  }
660 
661  if (xsize > (maxx/xbin)-xoffset) xsize = (maxx/xbin)-xoffset;
662  if (ysize > (maxy/xbin)-yoffset) ysize = (maxy/ybin)-yoffset;
663 
664  if ((iretn=gige_writereg(handle,PROSILICA_BinningXValue,xbin-1)) < 0) return iretn;
665  if ((iretn=gige_writereg(handle,PROSILICA_BinningYValue,ybin-1)) < 0) return iretn;
666  if ((iretn=gige_writereg(handle,PROSILICA_RegionX,xoffset)) < 0) return iretn;
667  if ((iretn=gige_writereg(handle,PROSILICA_RegionY,yoffset)) < 0) return iretn;
668  if ((iretn=gige_writereg(handle,PROSILICA_Width,xsize)) < 0) return iretn;
669  if ((iretn=gige_writereg(handle,PROSILICA_Height,ysize)) < 0) return iretn;
670  if ((iretn=gige_writereg(handle,PROSILICA_PixelFormat,format)) < 0) return iretn;
671  if ((iretn=gige_writereg(handle,PROSILICA_StreamBytesPerSec,handle->streambps)) < 0) return iretn;
672 
673  return 0;
674 }
uint32_t streambps
Flow rate.
Definition: gige_lib.h:357
int iretn
Definition: rw_test.cpp:37
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
#define PROSILICA_Width
Definition: gige_lib.h:192
#define PROSILICA_RegionX
Definition: gige_lib.h:194
#define PROSILICA_Height
Definition: gige_lib.h:193
#define PROSILICA_BinningYMax
Definition: gige_lib.h:177
#define PROSILICA_BinningYValue
Definition: gige_lib.h:178
#define PROSILICA_BinningXMax
Definition: gige_lib.h:175
#define PROSILICA_RegionY
Definition: gige_lib.h:195
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
#define PROSILICA_SensorWidth
Definition: gige_lib.h:173
#define PROSILICA_PixelFormat
Definition: gige_lib.h:182
#define PROSILICA_StreamBytesPerSec
Definition: gige_lib.h:179
#define PROSILICA_BinningXValue
Definition: gige_lib.h:176
#define PROSILICA_SensorHeight
Definition: gige_lib.h:174
int prosilica_image ( gige_handle handle,
uint16_t  emode,
uint32_t  exposure,
uint32_t  gain,
uint8_t *  buffer,
uint16_t  bsize 
)

Take Prosilica image.

Command Prosilica camera being used over GIGE to take a single image of the indicated exposure length. The resulting image will be stored in the provided image buffer.

Parameters
handlePointer to gige_handle returned by gige_open.
emodeOne of PROSILICA_ExposureMode_AutoOff, PROSILICA_ExposureMode_AutoOnce, PROSILICA_ExposureMode_Auto.
exposureExposure time in usec.
gainDN mutiplicative value.
bufferPointer to buffer for storing image.
bsizeMaximum size of buffer.
Returns
Zero, or negative error.
688 {
689  int32_t iretn, nbytes;
690  uint32_t tbytes, pbytes;
691  uint8_t *bufferin;
692  double mjd;
693 
694  bufferin = (uint8_t *)malloc(bsize);
695  if (bufferin == NULL)
696  return (-errno);
697 
698  iretn = gige_writereg(handle,GIGE_REG_SCP,handle->stream.cport);
699  if ((iretn=gige_writereg(handle,GIGE_REG_SCPS,bsize)) < 0)
700  return iretn;
701  if ((iretn=gige_writereg(handle,PROSILICA_ExposureMode,emode)) < 0)
702  return iretn;
703  if (emode != PROSILICA_ExposureMode_AutoOff)
704  {
705  if((iretn=gige_readreg(handle,PROSILICA_ExposureValue)) < 0)
706  return iretn;
707  exposure = iretn;
708  }
709  else
710  {
711  if ((iretn=gige_writereg(handle,PROSILICA_ExposureValue,exposure)) < 0)
712  return iretn;
713  }
714  if ((iretn=gige_writereg(handle,PROSILICA_GainValue,gain)) < 0)
715  return iretn;
717  return iretn;
719  return iretn;
720  if ((iretn = gige_readreg(handle,PROSILICA_PayloadSize)) < 0)
721  return iretn;
722  pbytes = iretn;
723 
724 // COSMOS_USLEEP(exposure);
725 // COSMOS_USLEEP(520000);
726  tbytes = 0;
727  uint32_t elapsed=0;
728  uint32_t telapsed=2*(exposure+1e6*pbytes/handle->streambps);
729  mjd = currentmjd(0.);
730  while (tbytes < pbytes && elapsed<telapsed)
731  {
732  if ((nbytes=recvfrom(handle->stream.cudp,(char *)bufferin,bsize,0,static_cast<struct sockaddr *>(nullptr),static_cast<socklen_t *>(nullptr))) > 0)
733  {
734  switch (bufferin[4])
735  {
736  case 1:
737  break;
738  case 2:
739  break;
740  case 3:
741  memcpy(&buffer[tbytes], &bufferin[8], nbytes-8);
742  tbytes += nbytes-8;
743  break;
744  }
745  }
746  elapsed = (uint32_t)(1e6*86400.*(currentmjd(0.)-mjd)+.5);
747 // iretn = gige_readreg(handle,GIGE_REG_CCP);
748  }
749 
750 // sdt2 = sqrt((sdt2 - sdt*sdt/count)/(count-1));
751 // sdt /= count;
753  iretn = gige_writereg(handle,GIGE_REG_SCP,0);
754  free(bufferin);
755  return (tbytes);
756 
757 }
#define PROSILICA_ExposureMode
Definition: gige_lib.h:211
#define PROSILICA_AcquisitionCommand_Start
Definition: gige_lib.h:199
uint16_t bsize
Definition: netperf_listen.cpp:71
uint32_t streambps
Flow rate.
Definition: gige_lib.h:357
int iretn
Definition: rw_test.cpp:37
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
#define PROSILICA_PayloadSize
Definition: gige_lib.h:196
#define PROSILICA_ExposureValue
Definition: gige_lib.h:220
uint16_t cport
Definition: socketlib.h:130
#define GIGE_REG_SCP
Definition: gige_lib.h:137
int32_t cudp
Definition: socketlib.h:120
static char buffer[255]
Definition: propagator_simple.cpp:60
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
#define PROSILICA_AcquisitionMode_SingleFrame
Definition: gige_lib.h:203
double mjd
Definition: udp_send.cpp:41
#define PROSILICA_ExposureMode_AutoOff
Do not automatically adjust exposure.
Definition: gige_lib.h:213
#define PROSILICA_AcquisitionMode
Definition: gige_lib.h:201
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
socket_channel stream
Stream channel.
Definition: gige_lib.h:341
#define PROSILICA_GainValue
Definition: gige_lib.h:227
#define GIGE_REG_SCPS
Definition: gige_lib.h:139
#define PROSILICA_AcquisitionCommand
Definition: gige_lib.h:197
#define PROSILICA_AcquisitionCommand_Stop
Definition: gige_lib.h:198
int a35_image ( gige_handle handle,
uint32_t  frames,
uint8_t *  buffer,
uint16_t  bsize 
)

Take A35 image stream.

Command A35 camera being used over GIGE to take a stream of images of the indicated exposure length. The resulting image will be stored in the provided image buffer.

Parameters
handlePointer to gige_handle returned by gige_open.
framesNumber of images to store.
bufferPointer to buffer for storing image.
bsizeNumber of bytes to expect at a go.
Returns
Zero, or negative error.
480 {
481  int32_t iretn, nbytes;
482  uint32_t tbytes, pbytes;
483  uint8_t *bufferin;
484  double mjd;
485 
486  bufferin = (uint8_t *)malloc(bsize);
487  if (bufferin == NULL)
488  return (-errno);
489 
491 
492  iretn = gige_writereg(handle,GIGE_REG_SCP,handle->stream.cport);
493  if ((iretn=gige_writereg(handle,GIGE_REG_SCPS,bsize)) < 0)
494  return iretn;
495  if ((iretn=gige_writereg(handle,A35_ACQUISITIONSTART,1)) < 0)
496  return iretn;
497  pbytes = gige_readreg(handle,A35_WIDTH) * gige_readreg(handle,A35_HEIGHT) * frames * 2;
498 
499  tbytes = 0;
500  uint32_t elapsed=0;
501  uint32_t telapsed=500000 + 2 * 1e6 * pbytes / handle->streambps;
502  mjd = currentmjd(0.);
503  while (tbytes < pbytes && elapsed<telapsed)
504  {
505  if ((nbytes=recvfrom(handle->stream.cudp,(char *)bufferin,bsize,0,static_cast<struct sockaddr *>(nullptr),static_cast<socklen_t *>(nullptr))) > 0)
506  {
507  switch (bufferin[4])
508  {
509  case 1:
510  break;
511  case 2:
512  break;
513  case 3:
514  memcpy(&buffer[tbytes], &bufferin[8], nbytes-8);
515  tbytes += nbytes-8;
516  break;
517  }
518  }
519  elapsed = (uint32_t)(1e6*86400.*(currentmjd(0.)-mjd)+.5);
520 // iretn = gige_readreg(handle,GIGE_REG_CCP);
521  }
522 
523 // sdt2 = sqrt((sdt2 - sdt*sdt/count)/(count-1));
524 // sdt /= count;
525  iretn = gige_writereg(handle,A35_ACQUISITIONSTOP,1);
526  iretn = gige_writereg(handle,GIGE_REG_SCP,0);
527  free(bufferin);
528  return (tbytes);
529 
530 }
uint16_t bsize
Definition: netperf_listen.cpp:71
uint32_t streambps
Flow rate.
Definition: gige_lib.h:357
#define GIGE_REG_SCDA
Definition: gige_lib.h:143
int iretn
Definition: rw_test.cpp:37
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
char address[17]
Definition: socketlib.h:134
uint16_t cport
Definition: socketlib.h:130
#define GIGE_REG_SCP
Definition: gige_lib.h:137
int32_t cudp
Definition: socketlib.h:120
static char buffer[255]
Definition: propagator_simple.cpp:60
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
double mjd
Definition: udp_send.cpp:41
#define A35_ACQUISITIONSTART
Definition: gige_lib.h:421
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
#define A35_HEIGHT
Definition: gige_lib.h:419
socket_channel stream
Stream channel.
Definition: gige_lib.h:341
#define A35_WIDTH
Definition: gige_lib.h:418
#define A35_ACQUISITIONSTOP
Definition: gige_lib.h:422
#define GIGE_REG_SCPS
Definition: gige_lib.h:139
uint32_t gige_address_to_value(char *address)
IP Address to value.
Definition: gige_lib.cpp:400
int a35_config ( gige_handle handle,
uint32_t  xsize,
uint32_t  ysize,
uint32_t  video_rate 
)

Configure a35 camera.

Setup the basic image parameters for a a35 camera being used over GIGE. The camera must first be opened with a call to gige_open.

Parameters
handlePointer to gige_handle returned by gige_open.
xsizeNumber of pixels in x direction.
ysizeNumber of pixels in y direction.
video_rate30 or 60 Hz.
Returns
Zero, or negative error.
442 {
443  uint32_t maxx, maxy;
444  int32_t iretn;
445 
446  if((iretn=gige_readreg(handle,A35_WIDTH)) < 0) return iretn;
447  maxx = iretn;
448  if((iretn=gige_readreg(handle,A35_HEIGHT)) < 0) return iretn;
449  maxy = iretn;
450 
451  if (xsize > (maxx)) xsize = (maxx);
452  if (ysize > (maxy)) ysize = (maxy);
453 
454  if ((iretn=gige_writereg(handle,A35_WIDTH,xsize)) < 0) return iretn;
455  if ((iretn=gige_writereg(handle,A35_HEIGHT,ysize)) < 0) return iretn;
456  if ((iretn=gige_writereg(handle,0xE984, 3)) < 0) return iretn; // Set to 14 bit mode
457  if ((iretn=gige_writereg(handle,A35_PIXELFORMAT, A35_PIXELFORMAT_14BIT)) < 0) return iretn; // Set to 14 bit mode
458  if ((iretn=gige_writereg(handle,A35_CMOSBITDEPTH,3)) < 0) return iretn;
459  if ((iretn=gige_writereg(handle,A35_SENSORVIDEOSTANDARD,video_rate)) < 0) return iretn;
460 // if ((iretn=gige_writereg(handle,A35_IMAGEADJUST,A35_IMAGEADJUST_MANUAL)) < 0) return iretn;
461  if ((iretn=gige_writereg(handle,A35_IMAGEADJUST,A35_IMAGEADJUST_AUTOBRIGHT)) < 0) return iretn;
462 
463  // Set shutter to manual
464 // gige_writereg(handle, A35_FFCMODE, A35_FFCMODE_EXTERNAL); // Set FFC to manual
465  gige_writereg(handle, A35_FFCMODE, A35_FFCMODE_MANUAL); // Set FFC to manual
466 
467  return 0;
468 }
#define A35_IMAGEADJUST
Definition: gige_lib.h:436
int iretn
Definition: rw_test.cpp:37
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
#define A35_PIXELFORMAT
Definition: gige_lib.h:420
#define A35_CMOSBITDEPTH
Definition: gige_lib.h:434
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
#define A35_FFCMODE_MANUAL
Definition: gige_lib.h:449
#define A35_FFCMODE
Definition: gige_lib.h:429
#define A35_IMAGEADJUST_AUTOBRIGHT
Definition: gige_lib.h:460
#define A35_HEIGHT
Definition: gige_lib.h:419
#define A35_WIDTH
Definition: gige_lib.h:418
#define A35_SENSORVIDEOSTANDARD
Definition: gige_lib.h:430
#define A35_PIXELFORMAT_14BIT
Definition: gige_lib.h:444
int pt1000_image ( gige_handle handle,
uint32_t  frames,
uint8_t *  buffer,
uint16_t  bsize 
)

Take PT1000 image stream.

Command PT1000 camera being used over GIGE to take a stream of images of the indicated exposure length. The resulting image will be stored in the provided image buffer.

Parameters
handlePointer to gige_handle returned by gige_open.
framesNumber of images to store.
bufferPointer to buffer for storing image.
bsizeNumber of bytes to expect at a go.
Returns
Zero, or negative error.
575 {
576  int32_t iretn, nbytes;
577  uint32_t tbytes, pbytes;
578  uint8_t *bufferin;
579  double mjd;
580 
581  bufferin = (uint8_t *)malloc(bsize);
582  if (bufferin == nullptr)
583  return (-errno);
584 
586 
587  iretn = gige_writereg(handle,GIGE_REG_SCP,handle->stream.cport);
588  if ((iretn=gige_writereg(handle,GIGE_REG_SCPS,bsize)) < 0)
589  return iretn;
590  if ((iretn=gige_writereg(handle,PT1000::AcquisitionStartReg,1)) < 0)
591  return iretn;
592  pbytes = gige_readreg(handle,PT1000::WidthReg) * gige_readreg(handle,PT1000::HeightReg) * frames * 2;
593 
594  tbytes = 0;
595  uint32_t elapsed=0;
596  uint32_t telapsed=500000 + 2 * 1e6 * pbytes / handle->streambps;
597  mjd = currentmjd(0.);
598  while (tbytes < pbytes && elapsed<telapsed)
599  {
600  if ((nbytes=recvfrom(handle->stream.cudp,(char *)bufferin,bsize,0,static_cast<struct sockaddr *>(nullptr),static_cast<socklen_t *>(nullptr))) > 0)
601  {
602  switch (bufferin[4])
603  {
604  case 1:
605  break;
606  case 2:
607  break;
608  case 3:
609  memcpy(&buffer[tbytes], &bufferin[8], nbytes-8);
610  tbytes += nbytes-8;
611  break;
612  }
613  }
614  elapsed = (uint32_t)(1e6*86400.*(currentmjd(0.)-mjd)+.5);
615 // iretn = gige_readreg(handle,GIGE_REG_CCP);
616  }
617 
618 // sdt2 = sqrt((sdt2 - sdt*sdt/count)/(count-1));
619 // sdt /= count;
620  iretn = gige_writereg(handle,PT1000::AcquisitionStopReg,1);
621  iretn = gige_writereg(handle,GIGE_REG_SCP,0);
622  free(bufferin);
623  return (tbytes);
624 
625 }
uint16_t bsize
Definition: netperf_listen.cpp:71
uint32_t streambps
Flow rate.
Definition: gige_lib.h:357
Definition: gige_lib.h:476
#define GIGE_REG_SCDA
Definition: gige_lib.h:143
int iretn
Definition: rw_test.cpp:37
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
char address[17]
Definition: socketlib.h:134
Definition: gige_lib.h:484
uint16_t cport
Definition: socketlib.h:130
#define GIGE_REG_SCP
Definition: gige_lib.h:137
int32_t cudp
Definition: socketlib.h:120
static char buffer[255]
Definition: propagator_simple.cpp:60
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
double mjd
Definition: udp_send.cpp:41
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
socket_channel stream
Stream channel.
Definition: gige_lib.h:341
Definition: gige_lib.h:483
Definition: gige_lib.h:477
#define GIGE_REG_SCPS
Definition: gige_lib.h:139
uint32_t gige_address_to_value(char *address)
IP Address to value.
Definition: gige_lib.cpp:400
int pt1000_config ( gige_handle handle,
uint32_t  xsize,
uint32_t  ysize 
)

Configure pt1000 camera.

Setup the basic image parameters for a pt1000 camera being used over GIGE. The camera must first be opened with a call to gige_open.

Parameters
handlePointer to gige_handle returned by gige_open.
xsizeNumber of pixels in x direction.
ysizeNumber of pixels in y direction.
video_rate30 or 60 Hz.
Returns
Zero, or negative error.
542 {
543  uint32_t maxx, maxy;
544  int32_t iretn;
545 
546  if((iretn=gige_readreg(handle,PT1000::WidthReg)) < 0) return iretn;
547  maxx = iretn;
548  if((iretn=gige_readreg(handle,PT1000::HeightReg)) < 0) return iretn;
549  maxy = iretn;
550 
551  if (xsize > (maxx)) xsize = (maxx);
552  if (ysize > (maxy)) ysize = (maxy);
553 
554  if ((iretn=gige_writereg(handle,PT1000::WidthReg,xsize)) < 0) return iretn;
555  if ((iretn=gige_writereg(handle,PT1000::HeightReg,ysize)) < 0) return iretn;
556 // if ((iretn=gige_writereg(handle,0xE984, 3)) < 0) return iretn; // Set to 14 bit mode
557  if ((iretn=gige_writereg(handle,PT1000::PixelFormatReg, PT1000Format::Mono16)) < 0) return iretn; // Set to 14 bit mode
558 
559  // Set shutter to manual
561 
562  return 0;
563 }
Definition: gige_lib.h:480
Definition: gige_lib.h:476
int iretn
Definition: rw_test.cpp:37
Definition: gige_lib.h:508
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
Definition: gige_lib.h:482
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
Definition: gige_lib.h:490
Definition: gige_lib.h:477