ROBOTC.net forums
http://www.robotc.net/forums/

What happend to the sendMessageWithParm()-function?
http://www.robotc.net/forums/viewtopic.php?f=1&t=671
Page 1 of 1

Author:  dgraf [ Sat Aug 09, 2008 4:33 pm ]
Post subject:  What happend to the sendMessageWithParm()-function?

hi everybody

I tested robotC in version 1.0 and wrote quite a long program with bluetooth communication between three NXTs. They connected automatically and sent messages to each other with the function called sendMessageWithParm(). The parameters were three integers called command, parameter1 and parameter2. So the final code line looked like that:
Code:
   sendMessageWithParm(command, parameter1, parameter2);


Now I bought the Single License and installed RobotC 1.05. I also downloaded the new firmware to the NXT. But my code didn't want to compile with the following error message:
Code:
**Error**:Procedure call Parameters don't match declaration for 'sendMessageWithParm(short &nMessage, short &nParm1, short &nParm2, short &nParm3)'


So I changed the variable-type and added a fourth one:

Code:
   sendMessageWithParm((short) command, (short) parameter1, (short) parameter2, (short) parameter3);


The programm know compiles but sends nothing over bluetooth and the error remains:

Code:
**Error**:Parameter   'sendMessageWithParm::command' index must   evaluation to   one   byte value
**Error**:Parameter   'sendMessageWithParm::parameter1' index must   evaluation to   one   byte value
**Error**:Parameter   'sendMessageWithParm::parameter2' index must   evaluation to   one   byte value
**Error**:Parameter   'sendMessageWithParm::parameter3' index must   evaluation to   one   byte value


Does anybody know what this means? In the documentation the messaging-functions vanished, there is no sample which uses this function, so I don't know what to change?

Author:  Dick Swan [ Wed Aug 13, 2008 3:26 am ]
Post subject:  Re: What happend to the sendMessageWithParm()-function?

This is my fault. Sorry. I didn't realize that anyone was using this capability in ROBOTC. It was originally added to provide Bluetooth messaging support for ROBOLAB which uses a subset of the ROBOTC firmware and could not be easily extended to the more powerful and robust messaging functionality found in ROBOTC.

The best "solution" is to revise your code to use the more robust "bluetooth functions mentioned below. I'm a little reluctant to re-add to ROBOTC because the implementation was less robust with the possibility of dropped messages through buffer overflows which is less likely than the solution described here.

Code:
cCmdMessageWriteToBluetooth(nStream, pData, nLength, nQueueID)
cCmdMessageWriteToBluetooth(pData, nLength, nQueueID)

cCmdMessageGetSize(nQueueID)
cCmdMessageRead(pData, nLengthToRead, nQueueID)

The easiest way is to write a small function with sames parameters as "SendMessageWithParms" that simply fills a struct with your messages parms and then sends as a message on 'nQueuieID' 1. This is essentially what the missing message function did.

Similarly, on the read side, you cann "GetSize" to see if there is a message. If so, call "cCmdeMessageRead" to read the message into same struct declaration as for send. Wrap both of these in a new function that is called whenever you want to read.

If you want, I'll write a version of these and send to you. Please communicate directly via email to dickswan@sbcglobal.net on this as it will get a faster response from me.

I'm surprised that you mentioned three NXTs. You must be doing the external connection management within your program? I assume single master and two slaves. And the slaves only need to talk to master. Is communication only master to slave. Or is there slave to master messages as well. [Did we already talk about this?]

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/