---
name: "NJB_Open"
section: "3"
platform: "linux"
package: "libnjb1-doc"
version: "1.1-2"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/NJB_Open"
---

# NJB\_Open(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)](/NJB_Discover/3.md).

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)](/NJB_Discover/3.md)
