To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 3824
3823  |  3825
Subject: 
Odd sensor, perhaps?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 14 Oct 2004 06:21:46 GMT
Viewed: 
6443 times
  
Okay, I've trimmed down the program to try to figure out what is wrong, I
have attached the working version. The problem is, if I change the
TouchSensor from S3 to S2, the program will build and download fine, but it
will not do anything when run. If I do change the TouchSensor from S3 to S2,
and comment out the declaration of the LightSensor, then the program works
also.

I'm looking into it further, but would like to know if anyone has had
experience with this already? I will post more if I find anything
conclusive.

Is there some reason I cannot use C++ to attach a touchsensor to S2?

Thanks for any insights,
Randy

Code follows:

//This file is for definitions - located in /util/dll-src
#include <config.h>

#if defined(CONF_DSENSOR)

#include <c++/Battery.H>
#include <conio.h>
#include <unistd.h>
#include <tm.h>
#include <c++/LightSensor.H>
#include <c++/TouchSensor.H>
#include <c++/Motor.H>
#include <remote.h>                // For Remote
#include <lnp.h>                // For Remote

// Call the constructors & destructors of global objects

typedef void (*Ftor)();
extern "C" Ftor __ctors[], __ctors_end[];
extern "C" Ftor __dtors[], __dtors_end[];
int main2();

int main()
{
   Ftor* f;
   int r;

   // call constructors
   for (f = __ctors; f != __ctors_end; f++)
     (*f)();

   r = main2();

   // call destructors
   for (f = __dtors; f != __dtors_end; f++)
     (*f)();

   return r;
}

Battery battery;
TouchSensor touchsensor(TouchSensor::S3);
LightSensor lightsensor(LightSensor::S1);
Motor motorA(Motor::A);

int main2( void )
{
   motorA.brake();
   motorA.speed( 1 );
   motorA.forward( 1 );

   while (!shutdown_requested())
   {
      cputs("batt");
      sleep(1);
      cputs("yes");
      sleep(1);
      lcd_int(battery.get());
      sleep(1);
   }

   return 0;
}

#else
#warning batt.C requires CONF_DSENSOR
#warning batt demo will do nothing
int main(int argc, char *argv[]) {
  return 0;
}
#endif // CONF_DSENSOR



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