nv2_common.c File Reference

#include "NeovisionII/nv2_common.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Include dependency graph for nv2_common.c:

Go to the source code of this file.

Functions

uint32_t nv2_pixel_type_bytes_per_pixel (enum nv2_pixel_type typ)
 Get the number of bytes used per pixel of a given type.
void nv2_image_patch_init_empty (struct nv2_image_patch *p)
 Initialize with the current protocol version, and zeros elsewhere.
void nv2_image_patch_destroy (struct nv2_image_patch *p)
 Free the data array associated with p, and reinitialize to an empty state.
void nv2_image_patch_set_training_label (struct nv2_image_patch *p, const char *label)
 Copy a training label into the image patch.
void nv2_image_patch_set_remote_command (struct nv2_image_patch *p, const char *command)
 Copy a remote command into the image patch.
void nv2_patch_label_init_empty (struct nv2_patch_label *l)
 Initialize with the current protocol version, and zeros elsewhere.
void nv2_fatal_impl (const char *file, int line, const char *function, const char *what)
 Helper for nv2_fatal.
void nv2_warn_impl (const char *file, int line, const char *function, const char *what)
 Helper for nv2_warn.
size_t nv2_robust_write (int fd, const void *const data, size_t const nbytes)
 Keep doing write() calls until either all the bytes are written or an error occurs.
size_t nv2_robust_read (int fd, void *buf, size_t nbytes, int *nchunks_return)
 Keep doing read() calls until either all the bytes are read or an error occurs.

Detailed Description

Definition in file nv2_common.c.


Function Documentation

void nv2_fatal_impl ( const char *  file,
int  line,
const char *  function,
const char *  what 
)

Helper for nv2_fatal.

Definition at line 113 of file nv2_common.c.

void nv2_image_patch_destroy ( struct nv2_image_patch p  ) 

Free the data array associated with p, and reinitialize to an empty state.

Definition at line 77 of file nv2_common.c.

References nv2_image_patch_init_empty().

Referenced by nv2_label_reader_destroy(), nv2_label_reader_send_patch(), nv2_label_reader_send_patch_sync(), and nv2_label_server_destroy().

void nv2_image_patch_init_empty ( struct nv2_image_patch p  ) 

Initialize with the current protocol version, and zeros elsewhere.

This function does NOT free any data associated with p->data; it is up to the caller to do that (if necessary) before calling this function.

Definition at line 64 of file nv2_common.c.

References NV2_PATCH_PROTOCOL_VERSION.

Referenced by nv2_image_patch_destroy(), nv2_label_reader_create(), nv2_label_reader_send_patch(), nv2_label_reader_send_patch_sync(), nv2_label_server_create(), and nv2_label_server_get_current_patch().

void nv2_image_patch_set_remote_command ( struct nv2_image_patch p,
const char *  command 
)

Copy a remote command into the image patch.

Definition at line 94 of file nv2_common.c.

void nv2_image_patch_set_training_label ( struct nv2_image_patch p,
const char *  label 
)

Copy a training label into the image patch.

Definition at line 85 of file nv2_common.c.

void nv2_patch_label_init_empty ( struct nv2_patch_label l  ) 

Initialize with the current protocol version, and zeros elsewhere.

Definition at line 103 of file nv2_common.c.

References nv2_patch_label::confidence, and NV2_LABEL_PROTOCOL_VERSION.

Referenced by nv2_label_reader_create(), and nv2_label_reader_get_current_label().

uint32_t nv2_pixel_type_bytes_per_pixel ( enum nv2_pixel_type  typ  ) 

Get the number of bytes used per pixel of a given type.

Definition at line 49 of file nv2_common.c.

References nv2_fatal.

Referenced by nv2_label_reader_send_patch_sync().

size_t nv2_robust_read ( int  fd,
void *  buf,
size_t  nbytes,
int *  nchunks 
)

Keep doing read() calls until either all the bytes are read or an error occurs.

Returns the number of bytes read; if this number is less than the number of requested bytes (nbytes), then it means that some error occurred

Parameters:
nchunks if not null, then the total number of read() system calls performed will be returned through this pointer

Definition at line 170 of file nv2_common.c.

size_t nv2_robust_write ( int  fd,
const void *  data,
size_t  nbytes 
)

Keep doing write() calls until either all the bytes are written or an error occurs.

Returns the number of bytes written; if this number is less than the number of requested bytes (nbytes), then it means that some error occurred

Definition at line 136 of file nv2_common.c.

Referenced by nv2_label_reader_send_patch_sync(), and nv2_label_server_send_label().

void nv2_warn_impl ( const char *  file,
int  line,
const char *  function,
const char *  what 
)

Helper for nv2_warn.

Definition at line 125 of file nv2_common.c.

Generated on Sun May 8 08:42:45 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3