| | | | |
| |
| Bodo Bauer wrote:
> [...]
> 238738:Logical > Frame Error
> 239791:Integrity > Integrity reset
> 239791:Logical > Frame Error
> 239795:Integrity > Integrity reset
> 239795:Logical > Frame Error
> 239799:Integrity > Integrity reset
> 239799:Logical > Frame Error
> 239803:Integrity > Integrity reset
> 239803:Logical > Frame Error
> 239807:Integrity > Integrity reset
> [...]
Ok. This is indeed the result if you run the original LNP package. There
are several problems with your sources, too. So try the following to get
things done:
First, go to the lnpd subdir and edit rcxtty.c. In function tty_init you
find a line with:
ios.c_cflag = CREAD | ...
it should read:
ios.c_cflag = CREAD | CLOCAL | CS8 | (highspeed ? 0 : PARENB | PARODD);
You could take a look at the rcxtty.c file in the util/dll-src subdir of
brickOS, you will find the same initialization. This will wipe out the
frame errors. But your program won't run, anyway. You should change some
things so you will get:
PC PROGRAM:
===========================================================
#include <liblnp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <string.h>
#define MY_PORT 7
void addr_handler(const unsigned char* data,unsigned char length,
unsigned char src)
{
switch(data[0]) {
case 's':
printf( "%s\n", &data[1] );
break;
case 'i':
printf( "%d\n", data[1] * 256 + data[2] );
break;
default:
printf( "unknown type\n" );
}
fflush( stdout );
}
int main ( int argc, char **argv ) {
if ( lnp_init ( 0, 0, 0, 0, 0 ) ) {
perror ( "lnp_init" );
exit(1);
} else {
printf ( "init OK\n" );
}
lnp_addressing_set_handler (MY_PORT, addr_handler );
while ( 1 ) {
};
return 0;
}
----------------------------------------------------------
RCX PROGRAM:
==========================================================
#include <lnp.h>
#include <conio.h>
#include <string.h>
#include <lnp-logical.h>
#include <dkey.h>
#define MY_PORT 2
#define DEST_HOST 0x8
#define DEST_PORT 0x7
#define DEST_ADDR ( DEST_HOST << 4 | DEST_PORT )
unsigned char buf[3];
unsigned char len = 3;
void printInt(int i)
{
int result;
buf[0] = 'i';
memcpy(buf + 1, &i, 2);
result = lnp_addressing_write( buf, len, DEST_ADDR, MY_PORT);
}
wakeup_t prgmKeyCheck(wakeup_t data)
{
return dkey == KEY_PRGM;
}
int main ( int argc, char **argv )
{
int c=0;
lnp_logical_range ( 0 );
while( 1 ) {
if( prgmKeyCheck( 0 ) ) break;
printInt( c );
cputw( c++ );
msleep ( 200 );
}
cputs ( "done" );
return 0;
}
-------------------------------------------------------------
| | | | | | | | | | | | | On Sun, 2003-01-05 at 10:21, Michael Obenland wrote:
> Bodo Bauer wrote:
>
> > [...]
> > 238738:Logical > Frame Error
> > 239791:Integrity > Integrity reset
> > 239791:Logical > Frame Error
> > 239795:Integrity > Integrity reset
> > 239795:Logical > Frame Error
> > 239799:Integrity > Integrity reset
> > 239799:Logical > Frame Error
> > 239803:Integrity > Integrity reset
> > 239803:Logical > Frame Error
> > 239807:Integrity > Integrity reset
> > [...]
>
>
> Ok. This is indeed the result if you run the original LNP package. There
> are several problems with your sources, too. So try the following to get
> things done:
This works in deed! Thank you so much Michael! No way I would have found
this myself.
BB
| | | | | | | | | | | | | | |
| |
| Hi everyone,
I have to say I have found these messages very interesting, and was wanting
to use lnp myself but i do not know where to write and make my programs. And
I would also like to find out more about how you write the pc code and the
rcx code below, and how this works and where it goes?
I have a good understanding of programming, it's just this is a very new
area to me, and is truly very interesting,
> PC PROGRAM:
> ===========================================================
> #include <liblnp.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/time.h>
> #include <sys/types.h>
> #include <string.h>
>
> #define MY_PORT 7
>
> void addr_handler(const unsigned char* data,unsigned char length,
> unsigned char src)
> {
> switch(data[0]) {
> case 's':
> printf( "%s\n", &data[1] );
> break;
> case 'i':
> printf( "%d\n", data[1] * 256 + data[2] );
> break;
> default:
> printf( "unknown type\n" );
> }
> fflush( stdout );
> }
>
> int main ( int argc, char **argv ) {
>
> if ( lnp_init ( 0, 0, 0, 0, 0 ) ) {
> perror ( "lnp_init" );
> exit(1);
> } else {
> printf ( "init OK\n" );
> }
>
> lnp_addressing_set_handler (MY_PORT, addr_handler );
>
> while ( 1 ) {
> };
>
> return 0;
> }
>
> ----------------------------------------------------------
> RCX PROGRAM:
> ==========================================================
> #include <lnp.h>
> #include <conio.h>
> #include <string.h>
> #include <lnp-logical.h>
> #include <dkey.h>
>
> #define MY_PORT 2
> #define DEST_HOST 0x8
> #define DEST_PORT 0x7
> #define DEST_ADDR ( DEST_HOST << 4 | DEST_PORT )
>
> unsigned char buf[3];
> unsigned char len = 3;
>
> void printInt(int i)
> {
> int result;
>
> buf[0] = 'i';
> memcpy(buf + 1, &i, 2);
> result = lnp_addressing_write( buf, len, DEST_ADDR, MY_PORT);
> }
>
> wakeup_t prgmKeyCheck(wakeup_t data)
> {
> return dkey == KEY_PRGM;
> }
>
> int main ( int argc, char **argv )
> {
> int c=0;
>
> lnp_logical_range ( 0 );
> while( 1 ) {
> if( prgmKeyCheck( 0 ) ) break;
> printInt( c );
> cputw( c++ );
> msleep ( 200 );
> }
> cputs ( "done" );
> return 0;
> }
> -------------------------------------------------------------
Does anyone one know of any good books or websites for this topic?
So far I have BrickOS configured and running in cygwin, and I also have
winLNP downloaded and placed it in my brickOS directory like the site i was
reading told me to. But as for what to do now I am stuck.
If anyone could help with the above questions I would be most grateful.
Thanks
Andrew
| | | | | | | | | | | | | | | | |
| |
| On Tue, 2003-01-28 at 12:03, Andrew Tait wrote:
> Hi everyone,
>
> I have to say I have found these messages very interesting, and was wanting
> to use lnp myself but i do not know where to write and make my programs. And
> I would also like to find out more about how you write the pc code and the
> rcx code below, and how this works and where it goes?
>
> I have a good understanding of programming, it's just this is a very new
> area to me, and is truly very interesting,
I don't know anything about Windows, but I started using LNP on Linux
with good results lately. It really isn't that hard once you get your
first programm running ... :)
I wrote a little remote-control/monitor app based on LNP. While for
Gnome (Linux), the LNP stuff is very general and may give you a point to
start. You find the project at http://brickrc.sourceforge.net Or just
look at the source in the CVS browser at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/brickrc/brickRC/ . Of
interest for you will be src/rcx.[ch] and rcx/remote.c. The first file
handles sending/receiving messages on the PC side. There is nothing
Linux or gnome specific in this file at all, you should be able to use
it as is in your own project. The other file is the RCX application
sending sensor state and controlling the output ports.
Let me know if you have any questions about this code, I'm happy to
help.
BB
| | | | | | |