Page 1 of 1

Retrieve sensor reading over bluetooth using Direct Commands

Posted: 25 Jul 2013, 21:00
by krytie75
My friend and I are currently working on a project that utilises two NXTs connected via Bluetooth. We are using the NXC language.

We are trying to do all of the interfacing between the two NXTs via Direct Control from the master to the slave, in order not to have to write a seperate program for the slave and worry about the complexities of 'mailboxing' etc. (With (apparantely) very little tutorial or learning information on this subject available on the internet we are finding this quite difficult.)

So far we have managed to control all of the output devices on the slave, from the master (i.e motors etc), but cannot find a way to remotely retrieve the current reading on an input device on the slave (i.e light sensor). Is this possible?

I have read a little about 'RemoteGetSensorValue' but it seems you have to have John Hansens modded firmware to enable this command and my friend doesn't want to run a non-official firmware on his brick.

Any help or advice you can offer would be greatly appreciated!

Re: Retrieve sensor reading over bluetooth using Direct Commands

Posted: 26 Jul 2013, 08:41
by HaWe
yes, oh, yes, you are oh so right, BT connection (or even rs485) is a HUGE problem with NXC. :(
(I meanwhile resigned about this issue: Unfortunately there is no easy and convenient network protocol available - and probably never will be. IMO, a complete fw-rewrite has to be carried out for this subject regardless of (in-)compatibility to the inadequate Lego mailbox system.)

About your FW question: I am already using the EFW but I don't get any information about

Code: Select all

RemoteGetSensorValue
neither when typing it into the editor and pressing <F1>.
So I actually doubt that this is a FW issue.
On the other hand, there are some different Remote****** functions which indeed need the enhanced fw, not sure if you'll find any you may use for your requirements. The documentations and tutorials about those different functions are, actually... , hmmh..., well...: I think you'll see.... ;)

So nevertheless, if you are using NXC you are really well advised to use the EFW because
a) it's downwards compatible to the Lego FW,
b) it fixes some bugs which have never been fixed by Lego (like some i2c issues),
c) it provides many valuable additional features - and
d) anyway, you may always switch-back to the std fw by reloading it from the mindstorms folder (e.g., via NXT-G).

Re: Retrieve sensor reading over bluetooth using Direct Commands

Posted: 26 Jul 2013, 12:20
by krytie75
Thanks for the reply Doc-Helmut.

To give you a little more background to the project - The requirements of our system are surprisingly simple. The slave NXT is mounted on a moveable platform relative to the master NXT so BT connection is our only option for connectivity (otherwise we may have experimented with rs485). The bulk of the work can be (and is) run on the master with occasional polling of the sensors attached to the slave and an even less occasional activation of the motors on the slave.

It seems to me that without this extremely basic functionality, the Direct Commands over BT system is almost completely useless. Why bother including the system if you can't send basic commands and receive basic sensor inputs? I mean this really is the very least you would want out of a BT connection.


Getting on to the firmware, I must apologise, I made a mistake in my original post. The command which I referred to is:

RemoteGetInputValue http://bricxcc.sourceforge.net/nbc/nxcd ... fe2604ba01

NOT

RemoteGetSensorValue

Perhaps this will help you answer my following question which is:

Is there any way (with or without the EFW) to simply retreive sensor values from a slave NXT over BT via direct command? If not, does anyone know a simple way to do this via the non direct command method (i.e mailboxing)?


Thank you for your comments about the EFW. I have a few questions about that also:
- You say it's 'downwards compatible' with the Lego FW. What do you mean by this? If I have one NXT with EFW and one with original FW, they can still communicate but only utilising the commands and functionality available in the original FW?
- Is there any sort of guide listing all of the new features and how to use them? From your previous comment, I'm guessing not.

Thanks again for your time and input!

Re: Retrieve sensor reading over bluetooth using Direct Commands

Posted: 26 Jul 2013, 12:57
by HaWe
to your last couple of questions please look at this:
http://sourceforge.net/apps/phpbb/mindb ... p?f=3&t=49
at the end of the TOP you may find some links to NXC references.
You may use all NXT-G functions plus most of the NXC API functions both by the Lego FW and the EFW,
but you may use some additional NXC features only by the EFW.

To your 1st couple of question I can't help you unfortunately.
I honestly do not know any way to use direct commands as they are currently available.
It seems to me that without this extremely basic functionality, the Direct Commands over BT system is almost completely useless. Why bother including the system if you can't send basic commands and receive basic sensor inputs? I mean this really is the very least you would want out of a BT connection.
I fully agree and I meanwhile often suggested and asked John to improve the network thing for BT and rs485 like, e.g., described here
https://sourceforge.net/apps/phpbb/mind ... 862#p16429
but he regrettably did not start improving it so far.
Maybe it was better if there were really good tutorials, a detailed documentation, and many practical code examples, but it doesn't - that's why I gave up.