libnjb 2.2.7

Data Structures | Typedefs | Functions | Variables
base.c File Reference
`#include "libnjb.h"`
`#include "njb_error.h"`
`#include "defs.h"`
`#include "base.h"`
`#include "protocol.h"`
`#include "protocol3.h"`
`#include "usb_io.h"`

## Data Structures
struct | njb_device_entry

## Typedefs
typedef struct njb_device_entry | njb_device_entry_t

## Functions
int | njb_discover (njb_t *njbs, int limit, int *count)
void | njb_close (njb_t *njb)
int | njb_open (njb_t *njb)
void | njb_set_debug (int flags)
int | njb_debug (int flags)
char * | njb_get_usb_device_name (njb_t *njb)
int | njb_device_is_usb20 (njb_t *njb)
njb_protocol_type_t | njb_get_device_protocol (njb_t *njb)

## Variables
int | njb_debug_flags = 0
int | __sub_depth = 0

## Detailed Description

This file contains the basic stuff for opening the device on the USB bus and similar things. Here are the jukebox detection algorithms for example.

## Function Documentation

## ◆ njb_close()

void njb_close | ( | njb_t * | njb | ) |

Close a specific njb for reading and writing.

Parameters

  njb | the jukebox object to close

References njb_struct::dev, njb_struct::device_type, NJB_DEVICE_NJB1, njb_struct::usb_bulk_out_ep, and njb_struct::usb_interface.

## ◆ njb_debug()

int njb_debug | ( | int | flags | ) |

get the current debug flags

Parameters

  flags | a binary mask that remove some of the flags.

References njb_debug_flags.

Referenced by usb_pipe_read(), usb_pipe_write(), and usb_setup().

## ◆ njb_device_is_usb20()

int njb_device_is_usb20 | ( | njb_t * | njb | ) |

Tell if a device is USB 2.0 or not

Returns
  1 if the device is USB 2.0, 0 if it is USB 1.1

## ◆ njb_discover()

int njb_discover | ( | njb_t * | njbs,
|  | int | limit,
|  | int * | count
| ) |  |

Search the USB bus for a Nomad JukeBox. We can handle up to NJB_MAX_DEVICES JukeBox's per USB simultaneously (a value arbitrarily set in base.h, because it's easier to work with a fixed size array than build dynamically growing code...if anyone really plans on having more than NJB_MAX_DEVICES jukeboxes on their system, they can recompile with a bigger number). The USB device starts at usb0 and goes to usbNNN where NNN is USB_MAX_DEVICES. Check each bus for a usb device. Return -1 if errors occurred...though this doesn't mean we failed to find devices. *count gives the number of NJB devices that were found. Store the resulting NJB structues structure into the njbs[NJB_MAX_DEVICES] array.

Parameters

  njbs | an array of jukeboxes to fill up. The array must be NJB_MAX_DEVICES large.
  limit | a variable that is supposed to limit the number of devices retrieved, currently not used.
  count | a pointer to a variable that will hold the number of devices found after the call to this function.

Returns
  0 on OK, -1 on failure.

Referenced by NJB_Discover().

## ◆ njb_get_device_protocol()

njb_protocol_type_t njb_get_device_protocol | ( | njb_t * | njb | ) |

Tell which protocol version a device is using.

## ◆ njb_get_usb_device_name()

char* njb_get_usb_device_name | ( | njb_t * | njb | ) |

Get a device name from its USB characteristics.

References njb_struct::device_type.

Referenced by NJB_Get_Device_Name().

## ◆ njb_open()

int njb_open | ( | njb_t * | njb | ) |

Open a specific njb for reading and writing.

Parameters

  njb | the jukebox object to open

Returns
  0 on success, -1 on failure

Referenced by NJB_Open().

## ◆ njb_set_debug()

void njb_set_debug | ( | int | flags | ) |

Set the debug flags to use.

Parameters

  flags | the flags to set

References njb_debug_flags.

Referenced by NJB_Set_Debug().

## Variable Documentation

## ◆ __sub_depth

int __sub_depth = 0

The current subroutine depth for all of libnjb (global)

Referenced by usb_setup().

## ◆ njb_debug_flags

int njb_debug_flags = 0

The current debug flags for all if libnjb (global)

Referenced by njb_debug(), and njb_set_debug().