USB communications PC (libusb) - NXT (leJOS)

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

Moderators: 99jonathan, roger, imaqine

USB communications PC (libusb) - NXT (leJOS)

Postby Mr.K » Tue Jan 24, 2012 12:21 pm

Hi! I'm trying to send messages from my PC to the NXT with a host application written in C using libusb API (actually, I've tried with libusb-1.0 and now I'm using usb.h library) and the receiver on NXT using, obviusly, leJOS API.
I've done it before with the leJOS PC API for the host side and, of course, it worked fine. But now with usb.h my NXT stays waiting for connection (in call USB.waitForConnection()) while the host PC has supposedly been connected and sends the message correctly.
Is there any known way to connect my PC application to the NXT using libusb? If you want I can write any part of my code.
Thanks!!
Mr.K
New User
 
Posts: 2
Joined: Tue Jan 24, 2012 11:59 am

Re: USB communications PC (libusb) - NXT (leJOS)

Postby gloomyandy » Tue Jan 24, 2012 1:10 pm

Hi,
Is this on Windows or Linux?

Either way I would use the leJOS library code (written in C) as the basis for doing this. On Windows that will mean using the Lego Fantom driver (which is probably a good thing as using libUSB on Windows is a bit of a nightmare), or on Linux this uses libUSB and will act as a guide as to how to do it. The source for both the linux and Windows USB interfaces can be found here:
http://lejos.svn.sourceforge.net/viewvc ... k/jfantom/
and here:
http://lejos.svn.sourceforge.net/viewvc ... nk/libnxt/

If you are using your own code remember that unless you open the NXT side in RAW mode then you will need to add some additional protocol to the connection to handle connection startup and packet headers. Take a look at the Java code for all of the details...

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

Re: USB communications PC (libusb) - NXT (leJOS)

Postby Mr.K » Tue Jan 24, 2012 3:05 pm

Oh, sorry, it's in Linux.
This code is exactly which I took as a guide. I think the problem coul be what you said, I'm not opening the NXT side in RAW mode. I'll work on it tomorrow.
Thank you very much Andy!
Mr.K
New User
 
Posts: 2
Joined: Tue Jan 24, 2012 11:59 am


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 6 guests

more stuff