Fix some issues for string based constructors

Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Adelin Dobre
2018-07-27 15:46:16 +03:00
committed by Mihai Tudor Panu
parent 8f11061de3
commit 2975bae075
22 changed files with 257 additions and 264 deletions

View File

@ -161,81 +161,81 @@ BMA250E::BMA250E(std::string initStr) : mraaIo(initStr)
}
std::string::size_type sz;
for(std::string tok:upmTokens) {
if(tok.substr(0,11) == "enableFIFO:") {
bool useFIFO = std::stoi(tok.substr(11),&sz,0);
for(std::string tok : upmTokens) {
if(tok.substr(0, 11) == "enableFIFO:") {
bool useFIFO = std::stoi(tok.substr(11), &sz, 0);
enableFIFO(useFIFO);
}
if(tok.substr(0,9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9),&sz,0);
if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0);
tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1),nullptr,0);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val);
}
if(tok.substr(0,9) == "setRange:") {
BMA250E_RANGE_T scale = (BMA250E_RANGE_T)std::stoi(tok.substr(9),nullptr,0);
if(tok.substr(0, 9) == "setRange:") {
BMA250E_RANGE_T scale = (BMA250E_RANGE_T)std::stoi(tok.substr(9), nullptr, 0);
setRange(scale);
}
if(tok.substr(0,13) == "setBandwidth:") {
BMA250E_BW_T bw = (BMA250E_BW_T)std::stoi(tok.substr(13),nullptr,0);
if(tok.substr(0, 13) == "setBandwidth:") {
BMA250E_BW_T bw = (BMA250E_BW_T)std::stoi(tok.substr(13), nullptr, 0);
setBandwidth(bw);
}
if(tok.substr(0,13) == "setPowerMode:") {
BMA250E_POWER_MODE_T power = (BMA250E_POWER_MODE_T)std::stoi(tok.substr(13),nullptr,0);
if(tok.substr(0, 13) == "setPowerMode:") {
BMA250E_POWER_MODE_T power = (BMA250E_POWER_MODE_T)std::stoi(tok.substr(13), nullptr, 0);
setPowerMode(power);
}
if(tok.substr(0,17) == "fifoSetWatermark:") {
BMA250E_RANGE_T wm = (BMA250E_RANGE_T)std::stoi(tok.substr(17),nullptr,0);
if(tok.substr(0, 17) == "fifoSetWatermark:") {
BMA250E_RANGE_T wm = (BMA250E_RANGE_T)std::stoi(tok.substr(17), nullptr, 0);
fifoSetWatermark(wm);
}
if(tok.substr(0,11) == "fifoConfig:") {
BMA250E_FIFO_MODE_T mode = (BMA250E_FIFO_MODE_T)std::stoi(tok.substr(11),&sz,0);
if(tok.substr(0, 11) == "fifoConfig:") {
BMA250E_FIFO_MODE_T mode = (BMA250E_FIFO_MODE_T)std::stoi(tok.substr(11), &sz, 0);
tok = tok.substr(11);
BMA250E_FIFO_DATA_SEL_T axes = (BMA250E_FIFO_DATA_SEL_T)std::stoi(tok.substr(sz+1),nullptr,0);
BMA250E_FIFO_DATA_SEL_T axes = (BMA250E_FIFO_DATA_SEL_T)std::stoi(tok.substr(sz+1), nullptr, 0);
fifoConfig(mode, axes);
}
if(tok.substr(0,20) == "setInterruptEnable0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20),nullptr,0);
if(tok.substr(0, 20) == "setInterruptEnable0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0);
setInterruptEnable0(bits);
}
if(tok.substr(0,20) == "setInterruptEnable1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20),nullptr,0);
if(tok.substr(0, 20) == "setInterruptEnable1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0);
setInterruptEnable1(bits);
}
if(tok.substr(0,20) == "setInterruptEnable2:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20),nullptr,0);
if(tok.substr(0, 20) == "setInterruptEnable2:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0);
setInterruptEnable2(bits);
}
if(tok.substr(0,17) == "setInterruptMap0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17),nullptr,0);
if(tok.substr(0, 17) == "setInterruptMap0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0);
setInterruptMap0(bits);
}
if(tok.substr(0,17) == "setInterruptMap1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17),nullptr,0);
if(tok.substr(0, 17) == "setInterruptMap1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0);
setInterruptMap1(bits);
}
if(tok.substr(0,17) == "setInterruptMap2:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17),nullptr,0);
if(tok.substr(0, 17) == "setInterruptMap2:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0);
setInterruptMap2(bits);
}
if(tok.substr(0,16) == "setInterruptSrc:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(16),nullptr,0);
if(tok.substr(0, 16) == "setInterruptSrc:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(16), nullptr, 0);
setInterruptSrc(bits);
}
if(tok.substr(0,26) == "setInterruptOutputControl:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(26),nullptr,0);
if(tok.substr(0, 26) == "setInterruptOutputControl:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(26), nullptr, 0);
setInterruptOutputControl(bits);
}
if(tok.substr(0,26) == "setInterruptLatchBehavior:") {
BMA250E_RST_LATCH_T latch = (BMA250E_RST_LATCH_T)std::stoi(tok.substr(26),nullptr,0);
if(tok.substr(0, 26) == "setInterruptLatchBehavior:") {
BMA250E_RST_LATCH_T latch = (BMA250E_RST_LATCH_T)std::stoi(tok.substr(26), nullptr, 0);
setInterruptLatchBehavior(latch);
}
if(tok.substr(0,24) == "enableRegisterShadowing:") {
bool shadow = std::stoi(tok.substr(24),nullptr,0);
if(tok.substr(0, 24) == "enableRegisterShadowing:") {
bool shadow = std::stoi(tok.substr(24), nullptr, 0);
enableRegisterShadowing(shadow);
}
if(tok.substr(0,22) == "enableOutputFiltering:") {
bool filter = std::stoi(tok.substr(22),nullptr,0);
if(tok.substr(0, 22) == "enableOutputFiltering:") {
bool filter = std::stoi(tok.substr(22), nullptr, 0);
enableOutputFiltering(filter);
}
}