MbedOS 6 Problem

Hello,everyone.
There is a problem with the version of MbedOS 6. Why is there such an error?

SerialBase::attach(callback , &PS3::getdata, SerialBase::RxIrq);
{Too many arguments to function call, expected at most 2, have 3clang(typecheck_call_too_many_args_at_most)}

Thank you!

Hi there,

That is not a problem of Mbed OS6, but of your knowledge. Wrong syntax = error. And because there again missing a context I will try some telepathic magic.

Declaration of the attach looks like - void attach(Callback<void()> func, IrqType type = RxIrq); - two parametrs (focus on commas)
So this SerialBase::attach(callback , &PS3::getdata, SerialBase::RxIrq); is wrong because there are 3 parameters, how compiler wrote.
It might look like this SerialBase::attach(callback(PS3::getdata), SerialBase::RxIrq); probably.

BR, Jan

#include “PS3.h”

PS3::PS3(PinName TX, PinName RX) : SerialBase(TX, RX, 115200)
{
PS3Data[0] = 128;
PS3Data[1] = 0;
PS3Data[2] = 0;
PS3Data[3] = 64;
PS3Data[4] = 64;
PS3Data[5] = 64;
PS3Data[6] = 64;
PS3Data[7] = 0;
addflag = 0;
baud(115200);
SerialBase::attach(callback(&PS3::getdata), SerialBase::RxIrq);
}
void PS3::getdata()
{
if(SerialBase::readable())
{
while(SerialBase::_base_getc() != 128)
{
}
for(int i = 1;i < 8;i++)
{
*(PS3Data+i) = SerialBase::_base_getc();
}
}
if(addflag)
(*fpFunc)();
}
void PS3::myattach()
{
SerialBase::attach(callback(&PS3::getdata), SerialBase::RxIrq);
}

void PS3::addattach(void (*Func)())
{
fpFunc = Func;
addflag = 1;
}

void PS3::nothingFunc()
{
}

bool PS3::getButtonState(int button)
{
return ((PS3Data+(button>>4)) >> (button & 0x0f)) & 1;
}
bool PS3::getSELECTState()
{
return getButtonState(migi) & getButtonState(hidari);
}
bool PS3::getSTARTState()
{
return getButtonState(ue) & getButtonState(sita);
}
int PS3::getRightJoystickXaxis()
{
return (int)PS3Data[5]-64;
}
int PS3::getRightJoystickYaxis()
{
return (int)PS3Data[6]
-1+64;
}
int PS3::getLeftJoystickXaxis()
{
return (int)PS3Data[3]-64;
}
int PS3::getLeftJoystickYaxis()
{
return (int)PS3Data[4]-1+64;
}
double PS3::getRightJoystickAngle()
{
return atan2(double(PS3Data[6]
-1+64), double(PS3Data[5]-64))double(180/PI);
}
double PS3::getLeftJoystickAngle()
{
return atan2(double(PS3Data[4]
-1+64), double(PS3Data[3]-64))*double(180/PI);
}
void PS3::printdata()
{
SerialBase pc(USBTX, USBRX);
for(int i = 0; i < 8; i++)
{
pc.printf(“%.4d”, PS3Data[i]);
}
}