Subject:
|
Hi-speed port communication
|
Newsgroups:
|
lugnet.robotics.nxt
|
Date:
|
Fri, 4 Jan 2008 00:36:45 GMT
|
Viewed:
|
31790 times
|
| |
| |
I've been getting a number of emails from some people who want to know how to
use the hi-speed RS-485 port 4 functionality in the NXT using the standard
firmware. With John Barnes' help I now know how to get it to work correctly.
Here is a simple program that demonstrates how to send a message to a device
attached to the hi-speed port:
#define MESS_WAIT 20
void SendRS485Message(const string msg)
{
byte mlen = ArrayLen(msg);
SetHSOutputBuffer(0, mlen, msg);
SetHSOutputBufferOutPtr(0);
SetHSOutputBufferInPtr(mlen);
SetHSState(HS_SEND_DATA);
SetHSFlags(HS_UPDATE); //send it
}
task main()
{
SetSensorType(IN_4, SENSOR_TYPE_HIGHSPEED);
SetHSState(HS_INITIALISE);
SetHSFlags(HS_UPDATE);
Wait(10);
while (true) {
SendRS485Message("goofy");
Wait(50);
}
}
Once you have initialized the port type and the hi-speed state machine by
calling SetHsState(HS_INITIALISE) and SetHsFlags(HS_UPDATE) then reading
messages is about as simple as calling GetHSInputBuffer(offset, size, buffer);
According to folks at LEGO you can simply use a sensor wire to connect two NXTs
together on port 4 and send data back and forth using this sort of code.
John Hansen
|
|
Message has 2 Replies: | | Re: Hi-speed port communication
|
| (...) Thanks John. I agree that from the electrical point of view, just connecting one port 4 to another port 4 should just work with no hardware other than the cable (for short lengths, like the cables that come with the NXT). For longer cables, a (...) (17 years ago, 5-Jan-08, to lugnet.robotics.nxt)
|
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in NXT programmable brick
|
|
|
|