[avr] cmd parameter checking for enable/disable

This commit is contained in:
Bart Van Der Meerssche 2011-01-28 16:30:50 +01:00
parent 3cff549f8c
commit 035bc2d4fe
1 changed files with 17 additions and 11 deletions

View File

@ -289,8 +289,11 @@ void ctrlCmdGet(uint8_t cmd)
case 'e': /* port enabled | disabled */
ctrlReadCharFromRxBuffer(&i);
ctrlWriteCharToTxBuffer(i);
ctrlWriteCharToTxBuffer((enabled >> i) & 0x01);
if (i < MAX_SENSORS) {
ctrlWriteCharToTxBuffer(i);
ctrlWriteCharToTxBuffer((enabled >> i) & 0x01);
}
break;
case 'p': /* phy-to-logical mapping */
@ -374,17 +377,20 @@ void ctrlCmdSet(uint8_t cmd)
case 'e': /* port enabled | disabled */
ctrlReadCharFromRxBuffer(&i);
ctrlReadCharFromRxBuffer(&tmp8);
if (tmp8) {
enabled |= (1 << i);
}
else {
enabled &= ~(1 << i);
}
if (i < MAX_SENSORS) {
ctrlReadCharFromRxBuffer(&tmp8);
ctrlWriteCharToTxBuffer(i);
ctrlWriteCharToTxBuffer((enabled >> i) & 0x01);
if (tmp8) {
enabled |= (1 << i);
}
else {
enabled &= ~(1 << i);
}
ctrlWriteCharToTxBuffer(i);
ctrlWriteCharToTxBuffer((enabled >> i) & 0x01);
}
break;
case 'p': /* phy-to-logical mapping */