[Oberon] FPGA - nRF24L01 `RPI Net' server

Tomas Kral thomas.kral at email.cz
Mon Apr 23 11:32:46 CEST 2018


Hi,

I have wanted to do `network time client' exercise by Paul Reed, left
on hold since last year, but ended up coding simple `Net' server,
supporting only subset of messages, those needed to set Oberon time.

Executing `Net.GetTime RPI ~' does things and sets time picked from
RPI, good.
I dump packet headers, as it is interesting to follow
packet exchange, also for debugging.

Output below [Ctrl-C to exit]: 
valid header 
52 4 54 255
name request
RPI
53 0 79 54
RPI set
valid header 
70 0 54 79
time request
71 4 79 54
^C

Now I need someone to click regularly on `Net.GetTime RPI ~' for me, to
keep my Oberon time in sync :-)

I wonder if it makes sense to implement full net server?
Code skeleton below.

   while(true)
   {
      receivehead( &head1 );
      if ( head1.valid ) { 
         cout << "valid header \n";
         printf ("%d %d %d %d\n", head1.typ, head1.len, head1.sadr,
   head1.dadr); switch ( head1.typ ) {
            case NRQ:
               cout << "name request\n";
               i = 0; do { 
                  receive(&x); id[i++] = x;
                  if (i == 7) { id[7] = 0; x = 0; };
               }
               while ( x != 0 );
               while ( i++ < head1.len ) receive(&x);
               printf ( "%s\n", id );
               if ( strcmp( id, "RPI" ) == 0 ) {
                  setpartner( id ); send( NRS, 0, dmy );
                  printf( "%s set\n", partner );
               };
               break;
            case TRQ:
               cout << "time request\n";
               uxobtime(&obtime);
               i = 0; appendw( obtime, idb, 4, &i );
               send( TIM, 4, idb );
               break;
            default:
               cout << "skipped\n";
               skip ( head1.len );
               break;
         };
      }
      delay(1);
   }

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list