Hello again everyone,

Thanks for your responses last time.  I have one more
question, though.  I got a hid driver for my device
loaded.  Now I'm trying to write a simple program so
that I can send it data (1 byte at a time).  
Now i'm confused because I don't know if all I have to
do is : 

1)fp.open( "/proc/bus/usb/001/..." ) and then I can
start writing and reading from it assume the driver is
taking care packing the urb and communicating with the
device.

or
2)actual make some systems call from within my program


I have included my very simple program for you guys to
look at:
//#include <stdio.h>

#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main( int argc, char ** argv ){
 
  ifstream fpin;
  ofstream fpout;
  char tpath[] = "/proc/bus/usb/001/"; 
  
    char *path;
  
  if( argc > 1 ){
    path = new char [strlen( tpath ) + strlen( argv[1]
) + 1] ;
    path[0] = 0;
    strncpy( path, tpath, strlen( tpath ) );
    path[strlen( tpath ) ] = 0 ;
    strncat ( path, argv[1],strlen( argv[1] ) );
    path[ strlen( tpath) + strlen( argv[1] ) ] = 0;
  
   
    fpin.open( path, ifstream::in );
    fpout.open( path, ifstream::out);
  
  }
  cout<<"\nPath:: "<<path<<endl;
  
  char data [1];
  
  
  
  //fpin.open( path, ifstream::in );
  
  if ( !fpin.is_open() ) {
    perror( "Unable to open hid device" );
  } 
  else
    printf( "Opened device!!!\n" );
  
  //  fpout.open( path, ifstream::out);

  if( !fpout.is_open() ){
    perror( "Unable to open hid device" );
  }
  else
    printf( "Opened device!!!\n" );
  

  data[0] = 0x02;
  int ret_code;
  
  void * fp_out =  fpout.write( data, 1 );

  if( !fp_out ){
    cout<<"Writing failed\n"<<endl;
  }
  else
    cout<<"Sent data"<<endl;

  data[0] = '\0';
  
  while( fpin.read( data, 1 ) ){
    
    printf( "This is response: %#x.", data[0] );
    cout<<endl;
  }
  
  delete path;
  return 1;

}

when I execute it sends me back a bunch of hexadecimal
values, so I'm not sure if i'm opening the correct
file descriptor. 

Thanks any help is greatly appreciated.


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
_______________________________________________
Muscle mailing list
[EMAIL PROTECTED]
http://lists.musclecard.com/mailman/listinfo/muscle

Reply via email to