11 years, 8 months ago.

class "mbed::Serial" has no member"Even"

Im not able to compile the code im am using. it was working fine and now I cant compile it and the messages im getting are as follows:

Error: class "mbed::Serial" has no member "Even" Line: 181, Col: 24 Error: class "mbed::Serial" has no member "Even" Line: 183, Col: 26 Warning: variable "getserial" was declared but never referenced

Please find my code below.

#include "mbed.h"

LocalFileSystem local("local");
FILE *Datalogging = fopen("/local/testAnalogue.csv", "w");

DigitalOut Red(p21);
DigitalOut Green(p22);
DigitalOut Black(p20);
DigitalOut Yellow(p19);
DigitalOut Brown(p18);
DigitalOut Orange(p17);
DigitalIn input1(p23);
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
DigitalOut myled4(LED4);

AnalogIn ain(p15);

Serial pc(USBTX, USBRX);
Serial uart(p28, p27);

int state=0;
float angle=0;
void high_torque()
{
    switch (state)
    {
        case 0:        
            Orange = 1;         
            Yellow = 0;
            myled2 = 1;       
            wait (0.01);
            state = 1;
            angle +=7.5;
            break;
        case 1:        
            Black = 1;
            Brown = 0;
            myled3 = 1;       
            wait (0.01);
            state = 2;
            angle +=7.5;
            break;
        case 2:
            Yellow = 1;
            Orange = 0;
            myled2 = 0;
            wait (0.01);
            state = 3;
            angle +=7.5;
            break;
        case 3:
            Brown = 1;
            Black = 0;
            myled3 = 0;
            wait (0.01);  
            state = 0;
            angle +=7.5;
            break;
        default:
            state = 0;
            break;
    }
}

void restart_motor()
{
    int i = 0;
    for (i= 0;i<3;i++)
    {
        state = 3;
        high_torque();
        state = 2;
        high_torque();
        state = 1;
        high_torque();
        state = 0;
        high_torque();
    }
    angle = 0;
    state = 0;
}

void low_torque()
{
        Yellow = 0;
        myled2 = 1;       
        wait (0.1);
        
        Black = 1;
        myled1 = 0;
        wait (0.1);
                
        Brown = 0;
        myled3 = 1;       
        wait (0.1);
        
        Yellow = 1;
        myled2 = 0;
        wait (0.1);
        
        Orange = 0;
        myled4 = 1;
        wait (0.1);
        
        Brown = 1;
        myled3 = 0;
        wait (0.1);
                
        Black = 0;
        myled1 = 1;        
        wait (0.1);
        
        Orange = 1;
        myled4 = 0;
        wait (0.1);
}
float getdb (float average)
{
    if (average >=2.75)
        average = -40;
     else if (average >=2.72)
        average = -50;
     else if (average >=2.62)
        average = -60;
     else if (average >=2.35)
        average = -70;
     else if (average >=2.06)
        average = -80;
     else if (average >=1.78)
        average = -90;
     else if (average >=1.50)
        average = -100;
     else if (average >=1.32)
        average = -110;
     else 
        average = -120;
     return average;
}

void find(char getserial[])
{
    int i;
    for (i = 0;i<50;i++)
    {
        if (getserial[i] == '*' && i ==0)
        {
            //if (getserial[i+1]=='*' && getserial[i+2]=='*')
                
        }
    }
}
    
void writefile(float average)
{
    fprintf(Datalogging, "%.1f , %.3f\n",angle, average);   
}

void fgetserial()
{
    char start = uart.getc();
    while (start !=13)
    {   
        start = uart.getc();
    }
    start = uart.getc();
    while (start != 13 )
    {
        pc.putc(start);
        fprintf(Datalogging, "%c",start); 
        start = uart.getc();        
    }
    fprintf(Datalogging, ",");
}
                
int main() {
    int trial = 0;
    float getserial[10];
    pc.baud(1200);
    pc.format(8,Serial::Even,2);
    uart.baud(1200);
    uart.format(8,Serial::Even,2);
    pc.printf("Echoes back to the screen anything you type\n");        
    int counter = 0;
    float average=0;
    while(trial != 2) {
    AnalogIn ain(p15);
    for (counter = 0; counter <100;counter++)
    {
        //getserial[counter] = ain.read();
        average += ain.read();
        wait(0.001);
    }
    average = average /100;
    average = average *3.3;    
   
     DigitalIn test(p15);
     fgetserial();
     
     printf("\n value = %f \n ",getdb(average)); 
     writefile(average);
     average = 0;  
     if (angle <90)
        high_torque();      
     else 
     {
        restart_motor();   
        trial++;
     }
      
    }
    fclose(Datalogging);
    while(1);
}

1 Answer

11 years, 8 months ago.

Please use code tags around your code, it is unreadable now. (<<code>> and <</code>>)

Anyway, click on the mbed library in that program, then at right side you can update it. Current mbed version should accept Serial::Even, old ones too, but somewhere in between some versions don't accept it.

Accepted Answer