To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcxOpen lugnet.robotics.rcx in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / 2948
2947  |  2949
Subject: 
brickOS is slower than NQC for sending message
Newsgroups: 
lugnet.robotics.rcx
Date: 
Thu, 26 Jun 2008 14:48:51 GMT
Viewed: 
17709 times
  
I tested two ways with brickOS and NQC, source as below, you will find the NQC
can only send about 80 messages in 4s, brickOS can send all 255 messages, but
need 20s, in other word, NQC needs 50ms for sending a message, or brickOS needs
above 100ms for sending a message, do you agree this?

// brickOS
// sendnumbers.c
#include <lnp-logical.h>
#include <rom/lcd.h>
#include <time.h>
int main(int argc, char *argv[]) {
    int i;
    lnp_logical_range(1);
    in ttime = get_system_up_time();
    for (i = 1; i < 256; i++) {
        send_msg(i);
        lcd_int((get_system_up_time() - time)/10);
    }
    sleep(2);
    return 0;
}

// receivenumbers.c
#include <lnp.h>
#include <lnp-logical.h>
#include <rom/lcd.h>
int main(int argc, char *argv[]) {
    lnp_logical_range(1);
    while (1) {
          lcd_int(lnp_rcx_message);
          clear_msg();
          get_msg();
    }
    return 0;
}

// NQC
// sendnumbers.nqc
#define TIMER 0
int time;
task main () {
  int i;
  SetTxPower(TX_POWER_HI);
  time = 0;
  SetUserDisplay(time, 0);
  ClearTimer(TIMER);
  for (i = 1; i < 256; i++) {
    SendMessage(i);
    time = FastTimer(TIMER);
  }
  until (false);
}

// receivenumbers.nqc
int cnt = 0;
task main () {
  SetTxPower(TX_POWER_HI);
  SetUserDisplay(cnt, 0);
  until (false) {
    ClearMessage();
    until (Message() > 0);
    cnt++;
  }
}



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR