troubles with UNO

hi.
i m thinking i have troubles with my new UNO.

i m under seven, 64 bits.

with a simple led blinking sketch the UNO is working.

But with my sketch ( double communication with a software i m developping) , no.

The sketch is good working with a Duemillanova, with arduino software 0018.
I have made an adaptation of my script for UNO, with arduino software 0022, because of some minor changes in Wstring.h ( append function)

My app is sending to arduino keywords, and the arduino replies to it or do things.

I m thinking this troubles is more a trouble from the arduino than from my sketch: from time to time the arduino works and sends data as desired to my app, in USB/ serial.
From time to time, the COM port doesnt show up in arduino software, despite it is plugged and appears in windows manager.
Im then obliged to reset physically the arduino to get it back appearing in arduino software.

Voilà, i know this seems quite strange, but everything is very good working with FTDI drivers. I hope this could be the case with the new system. Hope someone can help ! :wink:

here is my sketch , in case of,

//dernière mise à jour: 20 février 2011 pour UNO sous logiciel 0022
//ce sketch est conçu pour fonctionner avec WhiteCat Lighting Board
//sit: http://www.le-chat-noir-numerique.fr

//#include <WString.h> //necessaire en versions précédentes 018


//chaine des ordres venant de whitecat
#define maxLength 36
String inString = String(maxLength);   
char end_data[]={"ED/"};//whitecat demande la mise en 0 ou 1 de la sortie digital

int threshold_analog=0;
//definitions paramètres com:
const int BAUDRATE=9600;//9600 pour 13 IO et 6 ANA ok //11400 pour 54 IO
//11400 ppour 54 IO
//définitions du nombre de capteurs ( doit concorder aussi dans whitecat -> arduino cfg)
const int NBR_ANALOG=6;
const int NBR_DIGITAL=13;
//création d'un tableau de définition pour les I/O 
bool digital_is_output[NBR_DIGITAL];
bool allow_analog_read[NBR_ANALOG];
bool allow_pwm_write[NBR_DIGITAL];
////////////////////////////////////////////////////
//tableaux de stockage des valeurs reçues en input
byte buffer_analog[NBR_ANALOG];
byte old_buffer_analog[NBR_ANALOG];
byte buffer_digital[NBR_DIGITAL];
byte old_buffer_digital[NBR_DIGITAL];
int valeur_pwm[NBR_DIGITAL];

/////////////////////////////////////////////////////////////////
void setup()
{
Serial.begin(BAUDRATE);
 ////////////////////////////////////////////////////////////////////////////////
digital_is_output[2]=1;
digital_is_output[3]=1;
digital_is_output[4]=1;
digital_is_output[5]=1;
digital_is_output[6]=1;
digital_is_output[7]=0;
digital_is_output[8]=0;
digital_is_output[9]=1;//sortie mais PWM
digital_is_output[10]=1;//sortie mais PWM
digital_is_output[11]=0;
digital_is_output[12]=0;
digital_is_output[13]=0;

allow_pwm_write[9]=1;
allow_pwm_write[10]=1;
/*autorisation de lecture des analogues. Si vous ne définnissez pas =1 l'analogue ne
sera pas envoyé à WhiteCat*/
allow_analog_read[0]=1;
allow_analog_read[1]=1;
allow_analog_read[2]=1;
allow_analog_read[3]=1;
allow_analog_read[4]=1;
allow_analog_read[5]=1;
////////////////////////
//INITIALISATION DES ON/OFF
for(int i=2; i<NBR_DIGITAL; i++)
{
if(digital_is_output[i]==1){pinMode(i,OUTPUT);}
else {pinMode(i,INPUT);}
}
}
/////////////////////////////////////////////////////////////////

void loop()
{
  while(Serial.available() > 0) {
    char inChar=Serial.read(); // lire caractere
    if(inChar!='\0')
    {    // un caractere nul marque la fin d'un ordre...
    
      if (inString.length() <maxLength ) // ne pas dépasser la capacité du buffer
      {
        inString+=inChar;  // inString contient les caracteres recus
      } 
      else {
        inString = inChar;  // erreur on prend le caractere comme premier
      }

    } 
 
    read_order();
    
  }

}
/////////////////////////////////////////////////////////////
void read_order()
{
if (inString[0]=='S' && inString[1]=='D' && inString[2]=='/' )
      {
      arduino_to_whitecat();//lecture des IO et analogs IN et envoi à whitecat
      inString="";//nettoyage de l'ordre
      } 
if (inString[0]=='D' && inString[1]=='O' && inString[2]=='/' && inString.endsWith(end_data) )
{
whitecat_to_dig();//envoi par white cat des IO
inString="";//nettoyage de l'ordre
} 
if (inString[0]=='P' && inString[1]=='W' && inString[2]=='/' && inString.endsWith(end_data) )
{
whitecat_to_pwm();//envoi par whitecat des pwm
inString="";//nettoyage de l'ordre
} 
}
///////////////////////////////////////////////////////////////////////
void whitecat_to_dig()
{
for(int i=2; i<NBR_DIGITAL; i++)
{
if(digital_is_output[i]==1 &&  allow_pwm_write[i]==0)
{//32= valeur 0
if(inString[i+3]!=32){digitalWrite(i,HIGH);} else {digitalWrite(i,LOW);}
}
}
}
//////////////////////////////////////////////////////////////////////
void whitecat_to_pwm()
{
for(int i=2; i<NBR_DIGITAL; i++)
{
if(allow_pwm_write[i]==1)
{
valeur_pwm[i]=byte(inString[i+3]-1);
analogWrite(i,valeur_pwm[i]);
}

}
}
//////////////////////////////////////////////////////////////////////
void arduino_to_whitecat()
{
//digitales///////////////////
bool change_on_dig=0;
for(int i=2;i<NBR_DIGITAL;i++)//on zappe les états de TX RX en pins 0 et 1
{
old_buffer_digital[i]=buffer_digital[i];
//si le digital est une entrée
if(digital_is_output[i]==0 && allow_pwm_write[i]==0)
   {
    buffer_digital[i]= digitalRead(i);
    if(old_buffer_digital[i]!=buffer_digital[i])
    {change_on_dig=1; } 
  }
}

//analogues////////////////////
bool change_on_ang=0;
for(int i=0;i<NBR_ANALOG;i++)
{
 old_buffer_analog[i]=buffer_analog[i]; 
   if(allow_analog_read[i]==1)//si on autorise la lecture de cet analog
   {
    int temp_val=analogRead(i); 
    if((temp_val/4)>old_buffer_analog[i]+threshold_analog || (temp_val/4)<old_buffer_analog[i]-threshold_analog)
    {
    buffer_analog[i]=byte(temp_val/4);
    change_on_ang=1;
    }
   }  
}
//envois
 if(change_on_dig==1)
{
 Serial.print("DG/");
 Serial.write(buffer_digital,NBR_DIGITAL);
 Serial.println("");
}
 if(change_on_ang==1)
{
 Serial.print("AN/");
 Serial.write(buffer_analog,NBR_ANALOG);
 Serial.println(""); 
} 
}
/////////////////////////////////////////////////////////////////////////

ok, this sounds in fact a trouble with wstring.h includeded in the core of arduino. can anybody help me to understand this scrip problem ?

Sounds like the 8U2 firmware bug (again). It doesn't affect the Duemilanove since it doesn't have an 8U2.

http://arduino.cc/en/Hacking/DFUProgramming8U2

hum... So the firmware problem would make that PWM and OUPUTS ON OFF would not work ? thats right ?

should i try to re-write the bootloader ? can anyone confirm me this ?