Reference

NJB_Close(3)

open or close an NJB device

NAME

NJB_Open, NJB_Close - open or close an NJB device

LIBRARY

libnjb

SYNOPSIS

#include <libnjb.h>

extern int njb_error

int NJB_Open (njb_t *njb)

void NJB_Close (njb_t *njb)

DESCRIPTION

The NJB_Open function opens the data pipes on the specifed NJB device for reading and writing, and performs a "handshake" to verify that the device is communicating as expected. The *njb parameter must first have been initialized via a call to NJB_Discover(3).

After the open is complete, the following members of the njb structure are initialized:

njb.id[16]

The 16-byte unique identifier for the NJB.

njb.idstring[33]

An ASCII string representation of the unique NJB ID, suitable for printing.

njb.libcount

The 64-bit library count value for the NJB.

NJB_Close closes the data pipes for an open NJB device.

RETURN VALUES

NJB_Open returns 0 on a successful operation. On failure, it returns -1 and sets njb_error to one of the following:

EO_BADCOUNT

The library counter on the NJB could not be verified.

EO_BADNJBID

The NJB ID has changed during the handshake.

EO_BADSTATUS

The NJB returned a "failure" status during the handshake.

EO_DEVICE

Couldn't open the appropriate /dev/ugen device for reading or writing.

EO_NOMEM

Couldn't allocate enough memory to store the device name, or for the pathname for the temporary directory where files are stored during a file transfer.

EO_RDSHORT

The NJB returned fewer bytes than expected in response to a command.

EO_USBBLK

An I/O error occured when speaking on the bulk data pipe.

EO_USBCTL

An I/O error occured when speaking on the control pipe.

SEE ALSO

NJB_Discover(3)