Asynchronous BT Connection using sockets

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

Moderators: 99jonathan, roger, imaqine

Asynchronous BT Connection using sockets

Postby djschembri » Sat Mar 17, 2012 3:04 pm

I have a socket connection between my PC and my NXT robot.

I am getting an error when I attempt to send a command to the robot before receiving the response of the previous command:

Send to Robot
Receive reply
(Works)

Send to robot
Send to robot
--Error--

Is there a way I can send data asynchronously over the BT connection?

Thanks
Darryl
djschembri
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 10:41 pm

Re: Asynchronous BT Connection using sockets

Postby gloomyandy » Sat Mar 17, 2012 3:53 pm

What are the commands you are trying to send? Why do you want them to be asynchronous?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Asynchronous BT Connection using sockets

Postby djschembri » Sat Mar 17, 2012 4:41 pm

Hi,

I was sending 2 types of commands. One was time driven (sensor information request), and the other was event driven and the time it was sent was random (command to move motors)

Hence there were cases where the time difference between these 2 commands was very small, so the robot wouldnt have time to respond to the first command when the second one arrived, and it resulted in an error.

Ultimately I decided that the move motor commands did not require a response from the robot, so that solved the problem for me.

Thanks
djschembri
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 10:41 pm

Re: Asynchronous BT Connection using sockets

Postby djschembri » Tue Apr 10, 2012 4:29 pm

Is it possible to have the robot sending to and receiving data from a socket simultaneously? Does the Bluetooth connection allow it?
djschembri
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 10:41 pm

Re: Asynchronous BT Connection using sockets

Postby gloomyandy » Tue Apr 10, 2012 5:44 pm

Yes you can read and write simultaneously on a Bluetooth connection, but not on USB if you are using the Lego Fantom driver (this is a Lego driver limitation, it only allows a single thread to be in the driver at any time)....

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

Re: Asynchronous BT Connection using sockets

Postby djschembri » Tue Apr 10, 2012 10:55 pm

Thanks
djschembri
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 10:41 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff