|
I'm trying to write a BrickOS program that I can use to check the voltage on
other RCXs (which use standard firmware).
I want to send the Get Battery Power command (0x30 and 0x38), and display the
returned value on the display.
Can anyone tell me if this seems correct?
I think I'm having a problem with my LNP handler. When I run it, the IR segment
on the other RCX lights up, like it's getting a message. But, my BrickOS RCX
does nothing.
---------
// BrickOS program to poll an RCX with standard firmware and display the
battery voltage on the BrickOS LCD
// I'm not sure which of these I really need, so I included them all
#include <conio.h>
#include <unistd.h>
#include <dbutton.h>
#include <dsensor.h>
#include <dmotor.h>
#include <rom/system.h>
#include <sys/lcd.h>
#include <sys/battery.h>
#include <dsound.h>
#include <remote.h>
#include <lnp.h>
#include <lnp-logical.h>
#include <lnp/lnp.h>
#include <stdlib.h>
void MyLNP(const unsigned char *data, unsigned char length)
{
dsound_system(DSOUND_BEEP);
// just display whatever value comes back
lcd_int(data[4]);
}
int
main()
{
int r;
// this call must switch between 0x30 and 0x38
char writethat[7] = {0x55,0xff,0x00,0x30,0xcf,0x30,0xcf};
char writethis[7] = {0x55,0xff,0x00,0x38,0xc7,0x38,0xc7};
// reply = c7/cf, ushort millivolts
cls();
lnp_integrity_set_handler(MyLNP);
r = lnp_logical_write(writethis,7);
while (!shutdown_requested())
{
if (PRESSED(dbutton(),BUTTON_PROGRAM))
{
r = lnp_logical_write(writethat,7);
while (PRESSED(dbutton(),BUTTON_PROGRAM))
msleep(1);
r = lnp_logical_write(writethis,7);
}
msleep(1);
}
return 0;
}
--------
Thanks
Steve
|
|
Message has 1 Reply: | | Re: RCX to RCX LNP
|
| (...) AFAIK there is no way to receive Lego-Messages, except by editing lnp.c and adding that by hand. The only Lego-Messages that brickos knows of, are those from the remote control and the "send message" opcode (0xf7). It may be worthwhile to add (...) (19 years ago, 12-Aug-05, to lugnet.robotics.rcx.legos)
|
4 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|