Main Page | Namespace List | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

yepp Class Reference

Main abstraction for the YEPP NEU USB. More...

#include <yepp.h>

Collaboration diagram for yepp:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 yepp ()
 Default constructor.Just some initialization.

 ~yepp ()
 Destructor.

void init (struct usb_device *dev, int usb_debug=0) throw (UsbException, YeppException)
 Open device and check if it is supported.

string last_error ()
 Pops all the unread errors from the stack.

void control (int request, unsigned char lsb, unsigned char msb) throw (UsbException, YeppException)
 Sends a control message with yepp::retries retries.

void recv (int request, unsigned char lsb, unsigned char msb, char *buffer, int size) throw (UsbException)
 Reads data from player with control messages.

void send (int request, unsigned char lsb, unsigned char msb, char *buffer, int size) throw (UsbException)
 Sends data to player with control messages.

void move_track (bool internal, unsigned int from, unsigned int to) throw (YeppException, UsbException)
 Change the playlist order.

void get_device_info (void) throw (UsbException, YeppException)
 Ask the device its info string and store it into yepp::device_info_string private attrib.

void get_device_info (string &dev_info) throw (UsbException, YeppException)
 Copy the device info string into the parameter.

void get_playlist (void) throw (YeppException, UsbException)
 Retrieves both internal and external playlist.

void get_playlist (bool internal) throw (YeppException, UsbException)
 Retrieves playlist.

void get_playlist (yeppPlaylist &internal, yeppPlaylist &external) throw (YeppException, UsbException)
 Make a copy of internal and external playlist into supplied parameters.

void get_external_mem_info (void) throw (YeppException, UsbException)
 Gets info about external memory.

void get_device_capacity (int &internal, int &int_avail, int &ext, int &ext_avail)
 Gets total/available bytes in internal and external memory.

void delete_track (unsigned int trackno, bool internal=true) throw (YeppException, UsbException)
 Deletes a track from internal or external memory.

void download (const char *filename, bool internal=true, void(*callback)(int, int)=NULL) throw (UsbException, YeppException)
 Sends a local file to the player's internal or external memory.

void format (bool internal=true) throw (YeppException, UsbException)
 Formats internal memory or external flash.

void upload (unsigned int trackno, string filename="", void(*callback)(int, int)=NULL) throw (YeppException, UsbException)
 Upload a file from the Yepp to the PC.

void reset_read_ep (void) throw (UsbException, YeppException)
 Resets the read endpoint using libusb usb_resetep.

void reset_write_ep (void) throw (UsbException, YeppException)
 Resets the write endpoint using libusb usb_resetep.


Public Attributes

const int vendor
 Holds 0x4E8 (Samsung).

const int product
 Holds 0x5A00 (YEPP-NEU).


Protected Member Functions

void last_error (string error)
 Push an error to the stack.

void last_error (const char *method, const char *format,...)
void clear_send_buffer (void)
 Buffer cleaning.

void clear_bulk_buffer (void)
 Buffer cleaning.

void clear_recv_buffer (void)
 Buffer cleaning.

void clear_control_buffer (void)
 Buffer cleaning.

void clear_buffers (void)
 Clears send and receive buffers.NOT BULK BUFFER.

void clear_halt (unsigned int endpoint) throw (YeppException, UsbException)
 Implements libusb clear_halt.

void reset_ep (unsigned int endpoint) throw (YeppException, UsbException)
 Reset an endpoint.

int file_present (const char *filename, bool internal)
 Checks wheter this file is already present in internal or external playlist.

void build_trackID (string &trackID, string filename)
 Build a trackID as used in download command.


Protected Attributes

usb_device * dev
 Got from user in yepp::init.

usb_dev_handle * dev_handle
 Got from yepp::dev.

int usb_debug
 Flag passed to libusb usb_set_debug.

int timeout
 Timeout (in milliseconds) used in USB commands.

int retries
 Number of retries for each send/receive command.


Private Attributes

stack< string > error_stack
 Error stack.

string device_info_string
 As read from device.

int has_external_mem
 < 0 if still not checked, 0 if not, > 0 if yes.

int device_capacity
 Capacity of internal memory, in bytes.

int device_space_available
 Available space in internal memory, in bytes.

int external_capacity
 Capacity of external memory, in bytes.

int external_space_available
 Available space in external memory, in bytes.

char send_buffer [USB_BLOCK_SIZE *2]
 Buffer for send commands.

char recv_buffer [USB_BLOCK_SIZE]
 Buffer for receive commands.

char bulk_buffer [YEPP_BULKBUFFER]
 Buffer for bulk transfers.

char control_buffer [USB_BLOCK_SIZE]
 Buffer for control response.

const unsigned int read_endpoint
const unsigned int write_endpoint
const unsigned char data_length
yeppPlaylist playlist
 Internal playlist.

yeppPlaylist ext_playlist
 External playlist, if available.


Friends

ostream & operator<< (ostream &os, yepp &u)
 Friendly printout of the class status.


Detailed Description

Main abstraction for the YEPP NEU USB.

See also:
yeppPlaylist

Definition at line 188 of file yepp.h.


Constructor & Destructor Documentation

yepp::yepp  )  [inline]
 

Default constructor.Just some initialization.

Definition at line 278 of file yepp.h.

References data_length, dev, dev_handle, device_capacity, device_space_available, external_capacity, external_space_available, has_external_mem, product, read_endpoint, retries, timeout, usb_debug, vendor, and write_endpoint.

yepp::~yepp  ) 
 

Destructor.

Closes device using libusb and releases interface.


Member Function Documentation

void yepp::last_error string  error  )  [protected]
 

Push an error to the stack.

void yepp::last_error const char *  method,
const char *  format,
  ...
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void yepp::clear_send_buffer void   )  [protected]
 

Buffer cleaning.

void yepp::clear_bulk_buffer void   )  [protected]
 

Buffer cleaning.

void yepp::clear_recv_buffer void   )  [protected]
 

Buffer cleaning.

void yepp::clear_control_buffer void   )  [protected]
 

Buffer cleaning.

void yepp::clear_buffers void   )  [protected]
 

Clears send and receive buffers.NOT BULK BUFFER.

void yepp::clear_halt unsigned int  endpoint  )  throw (YeppException, UsbException) [protected]
 

Implements libusb clear_halt.

void yepp::reset_ep unsigned int  endpoint  )  throw (YeppException, UsbException) [protected]
 

Reset an endpoint.

Exceptions:
YeppException if ::init not called
UsbException if usb_resetep returns an error

int yepp::file_present const char *  filename,
bool  internal
[protected]
 

Checks wheter this file is already present in internal or external playlist.

Parameters:
filename Name of the file
internal Check internal memory or external?
Returns:
int
  • 0 if not present
  • 1 if present
  • -1 if error

void yepp::build_trackID string &  trackID,
string  filename
[protected]
 

Build a trackID as used in download command.

trackID is 12 bytes long.

Parameters:
trackID Reference to the string that will hold the trackID
filename File name of the file you are going to dl to player

void yepp::init struct usb_device *  dev,
int  usb_debug = 0
throw (UsbException, YeppException)
 

Open device and check if it is supported.

A device is supported vendor/devid are yepp::vendor / yepp::product Opens the device using libusb, sets config and claims interface

Parameters:
dev The device you want to check
usb_debug Pass the flag down to libusb. Ranges from 0 (min) to 4 (max)
Note:
Sets internal error
Exceptions:
UsbException If cannot open device, set configuration or claim interface
YeppException If invalid dev parameter or device not supported

string yepp::last_error  ) 
 

Pops all the unread errors from the stack.

void yepp::control int  request,
unsigned char  lsb,
unsigned char  msb
throw (UsbException, YeppException)
 

Sends a control message with yepp::retries retries.

Parameters:
request bRequest USB parameter
lsb wIndex Least Significant Byte
msb wIndex Most Significant Byte
Note:
Sets internal error

bRequestType = 0xC0

wValue = 0x00

See also:
yepp::last_error

yepp::retries

yepp::timeout

Exceptions:
UsbException If unable to send control after yepp::retries
YeppException If unexpected control response

void yepp::recv int  request,
unsigned char  lsb,
unsigned char  msb,
char *  buffer,
int  size
throw (UsbException)
 

Reads data from player with control messages.

First sends a control message specified by first 3 parameters: request is control code, lsb and msb are the index. Then reads size bytes of data into buffer (usb_bulk_read). Last terminates transaction with control 0x0A wIndex 0xFFFF

Parameters:
request Send this control request before reading the data
lsb LSB of the wIndex parameter of control message
msb MSB of the wIndex parameter of control message
buffer Pointer to pre-allocated buffer where raw data is stored
size Number of bytes to read
See also:
last_error

control

Note:
Sets internal error
Exceptions:
UsbException If bulk read fails (or any control msg)

void yepp::send int  request,
unsigned char  lsb,
unsigned char  msb,
char *  buffer,
int  size
throw (UsbException)
 

Sends data to player with control messages.

First sends a control message specified by first 3 parameters: request is control code, lsb and msb are the index. Then sends size bytes of data from buffer to the player (usb_bulk_write). Last terminates transaction with control 0x0A wIndex 0xFFFF

Parameters:
request Send this control request before sending the data
lsb LSB of the wIndex parameter of control message
msb MSB of the wIndex parameter of control message
buffer Pointer to buffer where raw data is stored
size Number of bytes to send
Exceptions:
UsbException If Bulk write fails (Or any control message)
See also:
last_error

control

yepp::retries

Note:
Sets internal error

void yepp::move_track bool  internal,
unsigned int  from,
unsigned int  to
throw (YeppException, UsbException)
 

Change the playlist order.

The track number [from] will be moved to the playlist order [to]. First track is numbered 0.

Parameters:
internal Internal memory or external flash?
from Move this track
to New order of the track
Note:
Sets internal error
Exceptions:
YeppException if
  • Insane values of from/to parameters
  • Wrong Move response from device
  • Wrong Execute response from device
  • May be thrown by get_playlist
UsbException if
  • Any USB communication error
  • May be thrown by get_playlist

void yepp::get_device_info void   )  throw (UsbException, YeppException)
 

Ask the device its info string and store it into yepp::device_info_string private attrib.

Device info should be something like

#\0":02.110 20000819YP-NESU .
Exceptions:
UsbException If Control/Bulk communication error
YeppException Device data length <= 3. Probably wrong

void yepp::get_device_info string &  dev_info  )  throw (UsbException, YeppException)
 

Copy the device info string into the parameter.

Parameters:
dev_info Device info string will be stored here.
See also:
yepp::get_device_info (void)

void yepp::get_playlist void   )  throw (YeppException, UsbException)
 

Retrieves both internal and external playlist.

See also:
yepp::get_playlist(bool internal)

void yepp::get_playlist bool  internal  )  throw (YeppException, UsbException)
 

Retrieves playlist.

Sets capacity/available. Instantiates yepp::playlist / yepp::ext_playlist

Parameters:
internal Playlist from internal memory?
See also:
yepp::get_playlist(void)
Exceptions:
YeppException 
  • If wrong reponse for Get Playlist command
  • If reported playlist length < 0
  • If cannot build playlist from received data (probably internal bug)
UsbException If bulk/control msg fails

void yepp::get_playlist yeppPlaylist internal,
yeppPlaylist external
throw (YeppException, UsbException)
 

Make a copy of internal and external playlist into supplied parameters.

See also:
yepp::get_playlist (void)

void yepp::get_external_mem_info void   )  throw (YeppException, UsbException)
 

Gets info about external memory.

Asks for the external playlist and parses output. Sets yepp::external_capacity, yepp::has_external_mem, yepp::external_space_available.

Exceptions:
YeppException If evice returned a playlist length < 0 (Should be always > 0) or wrong response format for get playlist command
UsbException From any bulk/control

void yepp::get_device_capacity int &  internal,
int &  int_avail,
int &  ext,
int &  ext_avail
 

Gets total/available bytes in internal and external memory.

These are internally cached values

Parameters:
internal Internal memory capacity. If -1 call yepp::get_playlist
int_avail Available internal memory. If -1 call yepp::get_playlist
ext External memory capacity. If -1 call yepp::get_playlist
ext_avail Available external memory. If -1 call yepp::get_playlist

void yepp::delete_track unsigned int  trackno,
bool  internal = true
throw (YeppException, UsbException)
 

Deletes a track from internal or external memory.

Gets playlist if necessary.

Parameters:
trackno Track number X (starting at 0)
internal Delete track in internal or external memory?
Exceptions:
YeppException If
  • trackno is either < 1 or > of the no of tracks
  • Device returned a wrong answer to the delete command
  • Wrong Delete track response from device
UsbException If any USB communication error

void yepp::download const char *  filename,
bool  internal = true,
void(*  callback)(int, int) = NULL
throw (UsbException, YeppException)
 

Sends a local file to the player's internal or external memory.

Parameters:
filename Name of the file to be sent to the player
internal Send to internal memory if TRUE
callback Callback function. It will be called after sending the 512 bytes chunk to the player. It will be passed as parameters:
  • the number of bytes already sent to the player
  • the total number of bytes to be sent (filesize)
Exceptions:
UsbException If any USB communication problem (may be issued by get_playlist)
YeppException If
  • Asked to store in external mem but player doesn't have ext mem
  • Cannot open input file
  • File already in device memory
  • Filesize is greater than available space
  • Wrong Download Track response from device
  • may be issued by get_playlist

void yepp::format bool  internal = true  )  throw (YeppException, UsbException)
 

Formats internal memory or external flash.

Parameters:
internal If true try to format internal memory
Exceptions:
YeppException When any response from the device seems wrong
UsbException When there's a communication error with the device

void yepp::upload unsigned int  trackno,
string  filename = "",
void(*  callback)(int, int) = NULL
throw (YeppException, UsbException)
 

Upload a file from the Yepp to the PC.

Parameters:
trackno Number of track to retrieve
filename Name of the file to store the track to
callback Callback function. It will be called after reading the 512 bytes chunk from the player. It will be passed as parameters:
  • the number of bytes already read from the player
  • the total number of bytes to be read (filesize)
Exceptions:
YeppException If
  • Cannot find this track number in the playlists
  • Cannot open file for writing
  • Wrong Upload Track response
  • May be issued by get_playlist
UsbException If any USB communication problem (may be issued by get_playlist

void yepp::reset_read_ep void   )  throw (UsbException, YeppException)
 

Resets the read endpoint using libusb usb_resetep.

Also clears halt status.

Exceptions:
UsbException 
YeppException 
See also:
yepp::reset_ep

void yepp::reset_write_ep void   )  throw (UsbException, YeppException)
 

Resets the write endpoint using libusb usb_resetep.

Also clears halt status.

Exceptions:
UsbException 
YeppException 
See also:
yepp::reset_ep


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
yepp u
[friend]
 

Friendly printout of the class status.


Member Data Documentation

stack<string> yepp::error_stack [private]
 

Error stack.

yepp::init method clears the stack and each error is pushed on the stack. Starting from the most high-level function you can retrieve the full error stack with yepp::last_error(), where the most low-level error is shown as last

Definition at line 195 of file yepp.h.

string yepp::device_info_string [private]
 

As read from device.

Definition at line 197 of file yepp.h.

int yepp::has_external_mem [private]
 

< 0 if still not checked, 0 if not, > 0 if yes.

Definition at line 199 of file yepp.h.

Referenced by yepp().

int yepp::device_capacity [private]
 

Capacity of internal memory, in bytes.

Definition at line 201 of file yepp.h.

Referenced by yepp().

int yepp::device_space_available [private]
 

Available space in internal memory, in bytes.

Definition at line 203 of file yepp.h.

Referenced by yepp().

int yepp::external_capacity [private]
 

Capacity of external memory, in bytes.

Definition at line 205 of file yepp.h.

Referenced by yepp().

int yepp::external_space_available [private]
 

Available space in external memory, in bytes.

Definition at line 207 of file yepp.h.

Referenced by yepp().

char yepp::send_buffer[USB_BLOCK_SIZE *2] [private]
 

Buffer for send commands.

Definition at line 209 of file yepp.h.

char yepp::recv_buffer[USB_BLOCK_SIZE] [private]
 

Buffer for receive commands.

Definition at line 211 of file yepp.h.

char yepp::bulk_buffer[YEPP_BULKBUFFER] [private]
 

Buffer for bulk transfers.

Definition at line 213 of file yepp.h.

char yepp::control_buffer[USB_BLOCK_SIZE] [private]
 

Buffer for control response.

Definition at line 215 of file yepp.h.

const unsigned int yepp::read_endpoint [private]
 

Definition at line 216 of file yepp.h.

Referenced by yepp().

const unsigned int yepp::write_endpoint [private]
 

Definition at line 217 of file yepp.h.

Referenced by yepp().

const unsigned char yepp::data_length [private]
 

Definition at line 218 of file yepp.h.

Referenced by yepp().

yeppPlaylist yepp::playlist [private]
 

Internal playlist.

Definition at line 220 of file yepp.h.

yeppPlaylist yepp::ext_playlist [private]
 

External playlist, if available.

Definition at line 222 of file yepp.h.

struct usb_device* yepp::dev [protected]
 

Got from user in yepp::init.

Definition at line 226 of file yepp.h.

Referenced by yepp().

struct usb_dev_handle* yepp::dev_handle [protected]
 

Got from yepp::dev.

Definition at line 228 of file yepp.h.

Referenced by yepp().

int yepp::usb_debug [protected]
 

Flag passed to libusb usb_set_debug.

Definition at line 230 of file yepp.h.

Referenced by yepp().

int yepp::timeout [protected]
 

Timeout (in milliseconds) used in USB commands.

Definition at line 232 of file yepp.h.

Referenced by yepp().

int yepp::retries [protected]
 

Number of retries for each send/receive command.

Definition at line 234 of file yepp.h.

Referenced by yepp().

const int yepp::vendor
 

Holds 0x4E8 (Samsung).

Definition at line 273 of file yepp.h.

Referenced by yepp().

const int yepp::product
 

Holds 0x5A00 (YEPP-NEU).

Definition at line 275 of file yepp.h.

Referenced by yepp().


The documentation for this class was generated from the following file:
Generated on Sun May 29 16:13:38 2005 for yex by doxygen 1.3.7