Subject:
|
Re: Bluetooth Commands via Perl
|
Newsgroups:
|
lugnet.robotics.nxt
|
Date:
|
Wed, 6 Sep 2006 16:29:54 GMT
|
Viewed:
|
9902 times
|
| |
| |
In lugnet.robotics.nxt, David Wallace wrote:
> Has anyone successfully been able to send BT commands to the NXT using Perl on
> Windows and get a response?
I guess no one is using Perl to communicate with the NXT over Bluetooth. Or
everyone is busy building bots.
I found something that seems to work reliably on my HP Laptop running Windows
2000. It has a built-in CSR Bluetooth module that is 1.1 compliant and is driven
by an HP BT stack (probably bought from Widcomm or someone else).
I'll include what works for me in case anyone else is looking for this info:
$data = "\x02\x00\x01\x88"; # Get Firmware Version
open(PORT, "+> :raw", COM6);
syswrite(PORT, $data, length data);
sysread PORT, $len, 2;
sysread PORT, $result, ord($len);
The result can then be printed or handled however you like. Of course, this is
just a quick-and-dirty version that has no error-handling and uses my COM port.
The first read gets the length value and the second read gets the remaining data
sent by the NXT based on this length.
I also verified that it works for Get Battery Level and Get Device Info.
I would be interested in hearing if anyone else has success with this or if it
doesn't work. I would also be interested in hearing if anyone has a better way.
David Wallace
|
|
Message has 1 Reply:
Message is in Reply To:
| | Bluetooth Commands via Perl
|
| Has anyone successfully been able to send BT commands to the NXT using Perl on Windows and get a response? I've been trying to send the Get Firmware command and have not gotten a successful response. Here is a short script: $data = (...) (18 years ago, 4-Sep-06, to lugnet.robotics.nxt)
|
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in NXT programmable brick
|
|
|
|