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