Hello again,

First off thanks for all the help everyone we have our motors and robostix mostly working for our autonomous quad-rotor helicopter. There is one little problem we have not been able to solve. We are using a 3DM-GX1 Inertial Measurement Unit which operates over rs-232. I purchased the recommended ttl-rs232 level shifter from Acroname http://docwiki.gumstix.org/Serial_adapters. We are plugging the ttl end of the connector into the PXA-S (stuart) pins exposed on the robostix. Earlier someone posted some code for the 3dm-gx1, below is a subset of it. We are getting a really interesting problem. In the main function it appears as if the rs232=ouvre_com() to open the com port operates correctly, but the readgain function stalls the program. What's more interesting is the printf statements are displayed fine through our terminal program (minicom) fine, when the readgain functions are commented out but the moment they are not none of the printf statements show. I don't even understand how this is possible when the printf("Opening COM\n"); and printf("Reading Gains\n"); occur before the readgain function is called. Is there something in my buildroot configuration that I am missing or some other setting that I am missing to get STUART working, or is this more likely a device (3DM-GX1) problem. Thanks for any help you can give as its quite frustrating that a single function is preventing printf statements which are called before the readgain function call from appearing.

//START CODE
#define MODEMDEVICE "/dev/ttyS2"

struct orientation{
   double roll;
   double pitch;
   double yaw;
   double droll;
   double dpitch;
   double dyaw;
   unsigned char commande;
};

unsigned int readgain(int dev,char type);
struct orientation read_3dm(int dev,double accelgain,double
gyrogain,struct orientation prev_angles);
int ouvre_com(void);

int main(int argc, char *argv[])
{
   int rs232,i,j,k;
   struct orientation angles;
   unsigned int accelgain,gyrogain;

   printf("Opening COM\n");
   rs232=ouvre_com();
   printf("Reading Gains\n");
   accelgain=readgain(rs232,'A');
   gyrogain=readgain(rs232,'G');
   printf("Ok\n");

   close(rs232);
   
   return 0;
}

/*--------IMUfunctions---------------------*/
unsigned int readgain(int dev,char type)
{
   unsigned char data,buf[7];
   unsigned int gain;
       data=0x28;
   write(dev,&data,1);
   data=0x00;
   write(dev,&data,1);
   switch(type)
   {
       case 'G':
           data=0x82;
           break;
       case 'A':
           data=0xe6;
           break;
   }
   write(dev,&data,1);
     read(dev,buf,7);
     gain=buf[1]*256+buf[2];
   return gain;
}// end readgain


int ouvre_com(void)
{
   int fd;
   struct termios newtio;

   fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
   if (fd<0) printf("prob ouverture");
   newtio.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
   newtio.c_iflag = IGNBRK;//IGNPAR;
   newtio.c_oflag = 0;

   /* set input mode (non-canonical, no echo,...) */
   newtio.c_lflag = 0;
   newtio.c_cc[VTIME]=0;   /* inter-character timer unused */
   newtio.c_cc[VMIN]=1;   /* blocking read until chars received */
                                                                              

   tcsetattr(fd,TCSANOW,&newtio);
   tcflush(fd, TCIFLUSH);//vide bufffer
     return fd;
}
//END CODE