Mac OS X User Needed!

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Postby chrimo » Tue May 20, 2008 7:18 pm

Hi,

I've tried the same and it worked out of the box at:

iBook (Intel), OSX 10.5.2, xcode 3.0

With my iMac20 (PPC), I had some problems to compile the code (NXJ 0.6) or flashing the NXT (NXJ 0.5).

I have to analyse problems the next weekends.

Christian
+++ath
chrimo
Novice
 
Posts: 30
Joined: Sun May 18, 2008 8:09 pm
Location: Sauensiek, Germany

lejos 0.6 in macOS

Postby Shawn » Fri Jul 18, 2008 9:35 am

Nelson wrote:I would like to know if someone has successfully installed lejos 0.6 in macOS. If so I would like to know how you did it, because when I try to build using ant command after doing [code]
/lowlevel.h:25:17: error: usb.h: No such file or directory

you are missing libusb

I got it via http://www.macports.org/
and after installing macports used
sudo /opt/local/bin/port install libusb

there are still build errors after doing that but...

...trying to work through that...

...don't hold your breath...
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Re: lejos 0.6 in macOS

Postby Shawn » Fri Jul 18, 2008 10:20 am

Shawn wrote:
Nelson wrote:I would like to know if someone has successfully installed lejos 0.6 in macOS. If so I would like to know how you did it, because when I try to build using ant command after doing
/lowlevel.h:25:17: error: usb.h: No such file or directory

you are missing libusb

I got it via http://www.macports.org/
and after installing macports used
sudo /opt/local/bin/port install libusb

there are still build errors after doing that but...

...trying to work through that...

...don't hold your breath...



after that I get

nxjflash:
[cc] 1 total files to be compiled.
[cc] Starting link
[cc] ld: library not found for -lusb


Having a look at the build patch for the .5 version it has:

Code: Select all
<pathelement location="${includePath}"/>

where includePath is defined as:
Code: Select all
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/


I have soyLatte (to get java6) so I wonder if I should try changing that
...

I noticed a sort of similar note --On Mac OS X, Netbeans expects all JVMs to be located in the /System/Library/Frameworks/JavaVM.framework directory. Users have reported success in symlinking /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home to the SoyLatte directory.

Anyway...

I know looking at
Code: Select all
 sudo /opt/local/bin/port contents libusb


where my libusb is...

Port libusb contains:
/opt/local/bin/libusb-config
/opt/local/include/usb.h
/opt/local/include/usbpp.h
/opt/local/lib/libusb-0.1.4.4.4.dylib
/opt/local/lib/libusb-0.1.4.dylib
/opt/local/lib/libusb.a
/opt/local/lib/libusb.dylib
/opt/local/lib/libusb.la
/opt/local/lib/libusbpp-0.1.4.4.4.dylib
/opt/local/lib/libusbpp-0.1.4.dylib
/opt/local/lib/libusbpp.a
/opt/local/lib/libusbpp.dylib
/opt/local/lib/libusbpp.la
/opt/local/lib/pkgconfig/libusb.pc

I've tried hacking the build file by adding

Code: Select all
 <fileset dir="/opt/local/include">
                                       <include name=""/>
                                    </fileset>
                   <fileset dir="/opt/local/lib">
                                           
                      <include name=" libusb-0.1.4.4.4.dylib"/>
                      <include name="libusb-0.1.4.dylib"/>
                      <include name="libusb.a"/>
                      <include name="libusb.dylib"/>
                      <include name="libusb.la"/>
                      <include name="libusbpp-0.1.4.4.4.dylib"/>
                      <include name="libusbpp-0.1.4.dylib"/>
                      <include name="libusbpp.a"/>
                      <include name="libusbpp.dylib"/>
                      <include name="libusbpp.la"/>
                                           </fileset>
           <fileset dir="/opt/local/include/">
              <include name="usb.h"/>
              <include name="usbpp.h"/>
           </fileset>

but it isn't right and I still get
[cc] ld: library not found for -lusb
Code: Select all
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

osx 10.5.4 Intel - lego fantom driver

Postby Shawn » Mon Jul 21, 2008 3:18 pm

Hello,

I tried compiling the lego fantom driver but can't seem to do in on an intel mac.:cry: The error I get is:

Code: Select all
gcc-3.3: installation problem, cannot exec `cc1plus': No such file or directory


see http://forums.macosxhints.com/archive/index.php/t-59465.html for details on why gcc3.3 fails on intel. I think I can only do gcc4 on intel.

Still, your jfantom.sh just uses gcc. Are you building with gcc4?

If so :D , let me know what to try building. I see a snapshot dir in svn but it only has /lib /bin and 3rdparty dirs.



Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby Shawn » Mon Jul 21, 2008 3:27 pm

using just gcc it seems to compile fine and I get a.out


is that what I want?
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby gloomyandy » Mon Jul 21, 2008 6:49 pm

Hi shawn,
Can we take a step back here a little. Have you....
1. Got the standard Lego programs and driver installed on your Mac? Can you use it to download firmware and run standard Lego programs? I want to make sure that the standard Lego driver works on your system.
2. Have you installed the Lego Fantom dev kit?
3. Can you build the sample application that comes with that kit? The source is actually in one of the html files so you will have to copy and paste it into an editor and save it. Does it run ok?

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4239
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby Shawn » Mon Jul 21, 2008 11:06 pm

gloomyandy wrote:Hi Andy,
Can we take a step back here a little. Have you....
1. Got the standard Lego programs and driver installed on your Mac? Can you use it to download firmware and run standard Lego programs? I want to make sure that the standard Lego driver works on your system.



Yes, installed V1 and it runs fine using:
Mac OS 10.5 (Leopard) Firmware Fix
LEGO MINDSTORMS NXT Firmware v1.05
at http://mindstorms.lego.com/support/updates/?sw=1.0&fw=0.00&nxtswid=2



gloomyandy wrote:2. Have you installed the Lego Fantom dev kit?


Downloaded -yes. Installed - ??? It's just a fantom folder with documentation, includes, and targets subfolders

gloomyandy wrote:3. Can you build the sample application that comes with that kit? The source is actually in one of the html files so you will have to copy and paste it into an editor and save it. Does it run ok?


is main.cpp the example. Instructions were:
Code: Select all
gcc-3.3 -I <path to SDK include directory> -framework Fantom -dylib_file Library/Frameworks/VISA.framework/Versions/A/VISA:/Library/Frameworks/VISA.framework/Versions /A/VISA -lstdc++ main.cpp


I ran gcc since gcc-3.3 won't work on intel macs

Code: Select all
gcc -I /fantom_sdk/includes -framework Fantom -dylib_file Library/Frameworks/VISA.framework/Versions/A/VISA:/Library/Frameworks/VISA.framework/Versions/A/VISA -lstdc++ main.cpp


and got a.out

How do I run it?
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby Shawn » Mon Jul 21, 2008 11:12 pm

is the a.out file from compiling main.cpp supposed to do something when I run ./a.out?

the next in plugged in and on but the command line soon returns with no message or activity in the brick.

Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby Shawn » Mon Jul 21, 2008 11:27 pm

Shawn wrote:is the a.out file from compiling main.cpp supposed to do something when I run ./a.out?

the next in plugged in and on but the command line soon returns with no message or activity in the brick.

Shawn


debugging shows the program exited normally

(gdb) run
Starting program: /lejos/phantom/a.out
Reading symbols for shared libraries ++++................................................................................ done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done

Program exited normally.

Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby gloomyandy » Mon Jul 21, 2008 11:51 pm

Hi Shawn,
Well if you run the built command (./a.out) and you have an nxt running the standard firmware and connected via USB then it should play a tone and create a file on the nxt. The standard Lego software should not be running on your Mac when you run this test. Also I assume you have not assigned the Lego USB device to VirtualBox or anything (basically you should be able to access the nxt by running the standard Lego software directly on the Mac).

I assume it is not doing this?

If it isn't then you will probably either have to add printf statements into the test app, or compile with the -g debug option and step through the code to work out what is going on... We need to get the sample working to be sure that we can build the leJOS Fantom driver...


Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4239
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Tue Jul 22, 2008 12:01 am

PS Did you have to download and install the "VISA and NiSpyLog frameworks " from national instruments? The Fantom Api instructions say you will have to do this on a Mac....
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4239
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby Shawn » Tue Jul 22, 2008 12:01 am

gloomyandy wrote:Hi Andy,

Well if you run the built command (./a.out) and you have an nxt running the standard firmware and connected via USB then it should play a tone and create a file on the nxt.


OK, it makes a very short high pitched beep. Sorry, I had the sound turned down as it was late...sleeping child nearby...

As for the file, I hear the noise so can I assume everything is ok. Otherwise, what file should I look for on the brick?

We need to get the sample working to be sure that we can build the leJOS Fantom driver...


Are we there yet -- having a working sample? I hear the sound.
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby gloomyandy » Tue Jul 22, 2008 12:20 am

Hi Shawn,
Hey that sounds like good news! The file is called something like example.log, I think. If you look at the sample code the name should be in a string someplace.... If all of that is working we are well on the way....

If the above is ok, can you grab a copy of the snapshot directory from the leJOS svn (it should have bin, lib etc. dirs get the full set, but don't do anything with them yet). Also can you get a copy of the fantom directory again from the leJOS svn.

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4239
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby Shawn » Tue Jul 22, 2008 3:53 am

gloomyandy wrote:Hi Andy,
The file is called something like example.log, I think. If you look at the sample code the name should be in a string someplace


Ok I see it but reading the source, it looks like it deletes the file as well.


Code: Select all
      // Create a file object
      filePtr = nxtPtr->createFile( "example.log", status );
   }
   
   // Creating the file object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
   if( status.isNotFatal())
   {
      ViUInt8 fileBuffer[100] = {};
      ViUInt32 fileSizeInBytes = 100;
      for( ViUInt8 index = 0; index < fileSizeInBytes; ++index )
      {
         fileBuffer[index] = index;
      }
     
      // Open the file for writing, this will also create this file on the NXT.
      filePtr->openForWrite( fileSizeInBytes, status );
     
      // Write the file contents.
      filePtr->write( fileBuffer, fileSizeInBytes, status );
     
      // Close the file.
      filePtr->close( status );
     
      // Destroy the file object.  Note that this does not affect the file on the NXT.
      nxtPtr->destroyFile( filePtr );
     
      // Create a file iterator object which is used to find files on the NXT.
      fileIteratorPtr = nxtPtr->createFileIterator( "*.*" /* find all files on the NXT */,
            status );
   }
   
   // Creating the file iterator object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
   if( status.isNotFatal())
   {
      ViChar fileName[20];
     
      // Iterate through all of the files on the NXT until we find our log file.  Obviously,
      //    this isn't necessary in this simple example but is for illustrative purposes.
      while( status.isNotFatal())
      {
         fileIteratorPtr->getName( fileName, status );
         if( 0 == ::strcmp( fileName, "example.log" ))
         {
            break;
         }
         
         fileIteratorPtr->advance( status );
      }
     
      // Now that we have found our log file, create a file object that corresponds to it.
      filePtr = fileIteratorPtr->getFile( status );
     
      // Destroy the file iterator.
      nxtPtr->destroyFileIterator( fileIteratorPtr );
   }
   
   // Creating the file object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
   if( status.isNotFatal())
   {
      ViUInt8 fileBuffer[100] = {};
      ViUInt32 fileSizeInBytes = 100;
     
      // Open the file for reading.
      filePtr->openForRead( status );
     
      // Read the file contents.
      filePtr->read( fileBuffer, fileSizeInBytes, status );
     
      // Close the file.
      filePtr->close( status );


Here is where is is removed...
Code: Select all
   // Remove the file.  This deletes the file from the NXT.
      filePtr->remove( status );
     
      // Destroy the file object.
      nxtPtr->destroyFile( filePtr );
   }
   
   // Destroy the NXT object.
   nFANTOM100::iNXT::destroyNXT( nxtPtr );
   
   return 0;
}


I tried commenting out //nxtPtr->destroyFile( filePtr );
but I still don't see the file on my brick.

Maybe .log files aren't displayed ...

How would I go about doing printf?
#include <stdio.h>
then what to see if the file is really being created?
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby Shawn » Tue Jul 22, 2008 5:14 am

Hi Andy,


um, it seems like it's failing where it should be Creating the file iterator to loop through and find the example.log.

Code: Select all
// Creating the file iterator object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
    printf("check  status.isNotFatal \n");

   if( status.isNotFatal())
   {
      ViChar fileName[20];
        printf("about to enter while status not fatal  \n");


"about to enter while status not fatal" is never reached

(this is the printf output from the code below)
main
iterator
Creating the NXT iterator status.isNotFatal
Create a file object beforw
after Create a file object
reating the file objecr status.isNotFatal
Open the file for writing
writing
Close the file.
Destroy the file object.
Create a file iterator object which is used to find files on the NXT
check status.isNotFatal
status check over






Code: Select all
int _VI_FUNCC main( int argc, char** argv )
{  printf("\n main \n");
   nFANTOM100::tStatus status;
   nFANTOM100::iNXTIterator* nxtIteratorPtr = NULL;
   nFANTOM100::iNXT* nxtPtr = NULL;
   nFANTOM100::iFile* filePtr = NULL;
   nFANTOM100::iFileIterator* fileIteratorPtr = NULL;
   
   // Create an NXT iterator object which is used to find all accessible NXT devices.
   nxtIteratorPtr = nFANTOM100::iNXT::createNXTIterator(
         false /* don't search for NXTs over Bluetooth (only search USB) */,
         0 /* timeout for Bluetooth discovery ignored */, status );
    printf("iterator \n");
   // Creating the NXT iterator object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
   if( status.isNotFatal())
   {
    printf(" Creating the NXT iterator status.isNotFatal \n");
      // Create an NXT object for the first NXT that was found.  Note that if a NXT is found
      //    over BT, the computer and the NXT must be paired before an NXT object can be
      //    created.  This can be done programatically using the iNXT::pairBluetooth method.
      nxtPtr = nxtIteratorPtr->getNXT( status );
     
      // Destroy the NXT iterator object which we no longer need
      nFANTOM100::iNXT::destroyNXTIterator( nxtIteratorPtr );
   }
   
   // Creating the NXT object could fail, better check status before dereferencing a potentially
   //    NULL pointer.
   if( status.isNotFatal())
   {
      ViUInt8 protocolVersionMajor = 0;
      ViUInt8 protocolVersionMinor = 0;
      ViUInt8 firmwareVersionMajor = 0;
      ViUInt8 firmwareVersionMinor = 0;
     
      // Query the version numbers for the protocol and firmware installed on the NXT.
      nxtPtr->getFirmwareVersion( protocolVersionMajor, protocolVersionMinor,
            firmwareVersionMajor, firmwareVersionMinor, status );
     
      // This is a direct command to play a tone.
      ViUInt8 directCommandBuffer[] = { 0x03, 0x00, 0x18, 0x10, 0x00 };
     
      // Send the direct command to the NXT.
      nxtPtr->sendDirectCommand( false /* a response is not required for this direct command */,
            reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
            NULL /* no response buffer */, 0 /* no response buffer, specify 0 for size */, status );
     
      // Create a file object
        printf(" Create a file object beforw \n");
      filePtr = nxtPtr->createFile( "example.log", status );
        printf("after Create a file object \n");
   }
   
   // Creating the file object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
   if( status.isNotFatal())
   {    printf(" reating the file objecr status.isNotFatal \n");   
     ViUInt8 fileBuffer[100] = {};
      ViUInt32 fileSizeInBytes = 100;
      for( ViUInt8 index = 0; index < fileSizeInBytes; ++index )
      {
         fileBuffer[index] = index;
         printf("index %i", index);
      }
     
      // Open the file for writing, this will also create this file on the NXT.
      filePtr->openForWrite( fileSizeInBytes, status );
        printf(" Open the file for writing \n");   
   // Write the file contents.
      filePtr->write( fileBuffer, fileSizeInBytes, status );
       printf(" writing \n");
      // Close the file.
      filePtr->close( status );
       printf("  Close the file. \n"); 
      // Destroy the file object.  Note that this does not affect the file on the NXT.
      nxtPtr->destroyFile( filePtr );
          printf("  Destroy the file object. \n"); 
      // Create a file iterator object which is used to find files on the NXT.
      fileIteratorPtr = nxtPtr->createFileIterator( "*.*" /* find all files on the NXT */,status );
           printf(" Create a file iterator object which is used to find files on the NXT \n");     
      
   }
   
   // Creating the file iterator object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
    printf("check  status.isNotFatal \n");

   if( status.isNotFatal())
   {
      ViChar fileName[20];
        printf("about to enter while status not fatal  \n");
      // Iterate through all of the files on the NXT until we find our log file.  Obviously,
      //    this isn't necessary in this simple example but is for illustrative purposes.
      while( status.isNotFatal())
      {


this is the point that is never reached (below)
Code: Select all
     printf("status not fatal \n");
         fileIteratorPtr->getName( fileName, status );
         if( 0 == ::strcmp( fileName, "example.log" ))
         {
       printf("example.log found \n");
            break;
         }
         
         fileIteratorPtr->advance( status );
      }
     
      // Now that we have found our log file, create a file object that corresponds to it.
      filePtr = fileIteratorPtr->getFile( status );
     
      // Destroy the file iterator.
      nxtPtr->destroyFileIterator( fileIteratorPtr );
   }


instead it skips to here

Code: Select all
       printf("status check over \n");
   // Creating the file object could fail, better check status before dereferencing a
   //    potentially NULL pointer.
   if( status.isNotFatal())
   {
      ViUInt8 fileBuffer[100] = {};
      ViUInt32 fileSizeInBytes = 100;
     
      // Open the file for reading.
      filePtr->openForRead( status );
        //printf(status);
      // Read the file contents.
      filePtr->read( fileBuffer, fileSizeInBytes, status );
     
   
      // Close the file.
      filePtr->close( status );
     
      // Remove the file.  This deletes the file from the NXT.
      filePtr->remove( status );
     
      // Destroy the file object.
      nxtPtr->destroyFile( filePtr );
   }
   
   // Destroy the NXT object.
   nFANTOM100::iNXT::destroyNXT( nxtPtr );
   
   return 0;
}
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

PreviousNext

Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff