LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Connection to NXT block Question

Geoff, you're forgetting that filename length is important.  Smiley Wink

Jaco, you've probably noticed in the LEGO Direct Commands document that there are many references to the ASCIIZ [15.3 + NULL] format.  In most of the NXT communication protocol, filename sizes are fixed.  In the case that a filename is less than the maximum size, the name must be padded with NULL bytes to reach the maximum size of 20 bytes.

(15 chars) + (1 period) + (3 chars) + (1 NULL) = 20 bytes maximum

Have a look at the attached screenshot of a small VI I wrote.  I hope I've documented it well enough for you to understand everything that's going on.
------
James Blair
NI R&D
Message 11 of 17
(6,465 Views)
James,

Ah, well, I guess that makes sense. How quickly I forget 🙂

Of course, that could be made clearer in the BDK....

Thanks for helping!

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 12 of 17
(6,460 Views)
Hi,

KEWL!!!

Yes I have fixed the error and it now it starts the program thats on it.
Though i tried doing the same with the integer values I have to pass to the NXT but it's not recognizing the input.
Am i formulating the input for an integer correctly?

Regards Jaco.
0 Kudos
Message 13 of 17
(6,452 Views)

Hi all,
I seem to be formulating he packet  incorrectly since I get output "#2".

Should I also send the 1 as an string value  = “1” and test in the NXT for text value = “1”?

Thanks Jaco

0 Kudos
Message 14 of 17
(6,451 Views)
Glad that the program is starting.

However, I'm not sure what you are trying to do next. The second Send Direct Command VI is sending the start program direct command again (command 0). Do you want to write a message to an inbox on the NXT? If so, the message write direct command is command 0x09. Refer to page 9 of Appendix 2 of the Bluetooth Developer Kit. The message data for the message write direct command is treated as a string.

Hope this helps,

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 15 of 17
(6,425 Views)
Jaco, the "#2" you see doesn't indicate a poorly formed message.  Since the readBuffer output of the sendDirectCommand VI is an array, the "#2" is LabVIEW's way of showing you that array contains two elements.  Since you asked for a two-byte response, this is exactly the behavior I would have expected.  You can also see similar notation on the three-byte array you construct in the while loop -- its length is indicated with a "#3."

I looked back through the documentation, and it isn't clear to me whether you should send hex values for numbers, or their ASCII equivalents.  I also have heard someone mention that numbers should be sent as full 32-bit values.  So, I think one of the following three arrays should work to send the message "1" to inbox 0, but I'm not sure which one will (all values in hex):

[ 09, 00, 02, 31, 00 ] -- ASCII 1
[ 09, 00, 02, 01, 00 ] -- hex 1
[ 09, 00, 05, 01, 00, 00, 00, 00 ] -- hex 1 in 32-bit value, little-endian byte order
------
James Blair
NI R&D
Message 16 of 17
(6,417 Views)

Hi all,
I changed the app on the NXT to respond to strings. Then I changed the message packet format to include a string. Now it works. Thanks guys.
The remote works great even though the toolkit will be released next year making all this effort meaningless.
Regards Jaco

Download All
0 Kudos
Message 17 of 17
(6,405 Views)