Eiffel and Mindstorms
-
- Posts: 224
- Joined: 30 Oct 2010, 04:10
- Location: 127.0.0.1
- Contact:
Re: Eiffel and Mindstorms
Add a try/catch block in the C++ program and use some of the code on the library's page to find out what the library says the error is
it will tell you which class threw threw the exception and what it THINKS is wrong
it will tell you which class threw threw the exception and what it THINKS is wrong
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
Re: Eiffel and Mindstorms
Okay, this is the error:
Invalid COM port or COM port in use
error code: 257
error type: 3
Function "connect" in class "Bluetooth"
Now that I have the correct com port (again), it worked once and only once. Now I get this error again, with no changes to code. So, why is the port busy? Is it a bluetooth, C++, or NXT problem?
Invalid COM port or COM port in use
error code: 257
error type: 3
Function "connect" in class "Bluetooth"
Now that I have the correct com port (again), it worked once and only once. Now I get this error again, with no changes to code. So, why is the port busy? Is it a bluetooth, C++, or NXT problem?
Re: Eiffel and Mindstorms
I have found several references on the net where people had similar problems (the bluetooth to NXT worked some and then quit with a "port busy" error), but no cause/solution.
Has anyone here experienced this and been able to fix it?
jjj
Has anyone here experienced this and been able to fix it?
jjj
Re: Eiffel and Mindstorms
Depends on Bluetooth hardware and drivers (and Bluetooth stack used), as well as operating system.
Usually when this happens you haven't cleaned up everything, or left it in a broken state. Depending on how you access the serial connection to the NXT, you can close and reset the serial port. That usually did the trick for me. On the other hand, I didn't use Fantom for Bluetooth, but talked to the serial ports directly...
Usually when this happens you haven't cleaned up everything, or left it in a broken state. Depending on how you access the serial connection to the NXT, you can close and reset the serial port. That usually did the trick for me. On the other hand, I didn't use Fantom for Bluetooth, but talked to the serial ports directly...
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
-
- Posts: 224
- Joined: 30 Oct 2010, 04:10
- Location: 127.0.0.1
- Contact:
Re: Eiffel and Mindstorms
I had the exact same error I found that you fix it by changing one line in
Change this:
to this:
Sorry for not replying sooner
-tim
bluetooth.cpp
Change this:
Code: Select all
handle = CreateFile(port.c_str(), GENERIC_READ | GENERIC_WRITE, 0,0,OPEN_EXISTING,0,0);
Code: Select all
handle = CreateFile(port.c_str(), GENERIC_READ | GENERIC_WRITE, 0,NULL,OPEN_EXISTING,0,NULL);
-tim
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
Re: Eiffel and Mindstorms
Tim,
Thanks for the answer. The visual studio 10 project seems to test okay now; but calling the library routine from Eiffel gives the same error as before. The comport seems to be the same; I've built the library with the changed file (I think).
Maybe I will try a differenct C library.
Or, if someone could tell me how to determine the byte codes to send using the fantom api, I would just use fantom directly. For example, in the following code from the nxt++ library (link in previous post):
void NXT::Motor::SetForward(Comm::NXTComm* comm, int port, int power)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, power, 0x01 | 0x04, 0x01, 0, 0x20, 0, 0, 0, 0 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
How did the author determine the values to place in the "directCommandBuffer"?
thank,
jjj
Thanks for the answer. The visual studio 10 project seems to test okay now; but calling the library routine from Eiffel gives the same error as before. The comport seems to be the same; I've built the library with the changed file (I think).
Maybe I will try a differenct C library.
Or, if someone could tell me how to determine the byte codes to send using the fantom api, I would just use fantom directly. For example, in the following code from the nxt++ library (link in previous post):
void NXT::Motor::SetForward(Comm::NXTComm* comm, int port, int power)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, power, 0x01 | 0x04, 0x01, 0, 0x20, 0, 0, 0, 0 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
How did the author determine the values to place in the "directCommandBuffer"?
thank,
jjj
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: Eiffel and Mindstorms
The values are in the Lego Mindstorms documentation:
http://mindstorms.lego.com/en-us/suppor ... fault.aspx
download the Bluetooth developer kit...
Andy
http://mindstorms.lego.com/en-us/suppor ... fault.aspx
download the Bluetooth developer kit...
Andy
Re: Eiffel and Mindstorms
You must also edit the header nxt.h and comment out the line where it includes network.htimpattinson wrote:Remove the references toboxer41a wrote: 2. The link to the bluetoothlibrary looks promising but I get numorous errors.
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(127) : warning C4005: 'AF_MAX' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(479) : see previous definition of 'AF_MAX'
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(163) : warning C4005: 'SO_DONTLINGER' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(402) : see previous definition of 'SO_DONTLINGER'
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(206) : error C2011: 'sockaddr' : 'struct' type redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(485) : see declaration of 'sockaddr'
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(384) : error C2143: syntax error : missing '}' before 'constant'network.h
andnetwork.cpp
I am using this library at the moment with VC++ - 2010 and it works fine 4 me
PS.I don't think it's a wrapper around the Fantom API as such.mightor wrote: I found this C++ wrapper: http://www.norgesgade14.dk/bluetoothlibrary.php ,
When debugging, I found it uses the Windows API to open a comport and send bytes, no mention of any Fantom stuff
I was having this same trouble when I found your post. I just tried it with Visual C++ Express 10.0 and it works fine.
Sample 10 linked from Anders' Mindstorms site - http://www.norgesgade14.dk/bluetoothlibrary.php - is a good one to try (no sensors needed, etc - mine are all the way down in the basement; too far)
Before running the program, you will need to establish a BT partnership between PC and NXT - see http://staff.science.uva.nl/~toto/Work/ ... Steps.html
Finally, you will need to guess the PC's com port that is being used by the NXT.
In your main.cpp, try numbers 1, 2, 3, up to ? I don't know how many there are, but mine connected 5:
int main()
{
try{
cout << "Try to connect to the NXT" << endl;
//connection->connect(40);
connection->connect(5);
.
.
.
Finally, you should check out Anders' remote control and source code for it at bottom of this page: http://www.norgesgade14.dk/bluetoothremote.php
JD
Who is online
Users browsing this forum: Semrush [Bot] and 13 guests