To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.legolandOpen lugnet.legoland in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 LEGOLAND / 38
37  |  39
Subject: 
Sending messages to the RCX from a VC++ program
Newsgroups: 
lugnet.legoland
Date: 
Sun, 14 May 2000 12:49:59 GMT
Viewed: 
3201 times
  
Hi,
We are trying to communicate with our LegoMindstorm robot from Microsoft Visual
C++. We have our robot already programmed to respond to messages of values 1,2
and 3 (this has been tested using NQC and the robot responds correctly). But we
are having problems sending messages to the robot from our project in
DevStudio. We are tring to use the ActiveX control - Spirit.ocx but it is not
working. The first thing we did was added the spirit.ocx to our project. Then
we use the following code to use it:
        CSpirit *pmySpirit = new CSpirit();
long value2 = pmySpirit->GetComPortNo();
pmySpirit->SetComPortNo(value2);
pmySpirit->SetLinkType(0);
pmySpirit->SetPBrick(1);
BOOL value = pmySpirit->InitComm();
BOOL value1 = pmySpirit->PBAliveOrNot();

if(value1 && value)
{
// send message
pmySpirit->SendPBMessage(2,1);
pmySpirit->CloseComm();
}

delete (pmySpirit);

We are getting a very strange warning when we run our program but it goes away
when we click ignore :

"Debug Assertion Failed!!
Program: c:\PROGRAM
FILES\DEVSTUDIO\MYPROJECTS\TESTING\DEBUG\TESING.EXE
File: Winocc.cpp
Line: 364

For information on how your program can cause an assertion
failure, see the VisualC++ documentation on asserts.

Please retry to debug the application."

Abort          Retry           Ignore

This warning is related to the winocc.cpp file?? Also, the value we get back
for the GetComPortNo() function is very strange - shouldn't it be 1,2,3 or 4?
Also the InitComm() function returns a strange value - it should be 1 to
indicate that communication has been established with the RCX but we get
6615584. We are really stuck on it and it is for our final year project in
college so we would be very grateful if anyone could help us. Even if anyone
has successfully managed to send messages to the RCX by writing to the serial
port and sending it the correct packet, we would be grateful to hear about it.
All we want to do is send a 1, a 2 or a 3 to our robot from a DevStudio
project. Any help at all will be greatly appreciated.

Thanks in advance,

Sinead & Louisa



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR