[avr] add cmd check on sensor id

This commit is contained in:
Bart Van Der Meerssche 2011-01-28 10:57:26 +01:00
parent 9fbbb99a88
commit 62f36ce02d
1 changed files with 30 additions and 19 deletions

View File

@ -302,18 +302,23 @@ void ctrlCmdGet(uint8_t cmd)
case 'c': /* sensor counter value */ case 'c': /* sensor counter value */
ctrlReadCharFromRxBuffer(&i); ctrlReadCharFromRxBuffer(&i);
if (i < MAX_SENSORS) {
cli(); cli();
tmp32 = sensor[i].counter; tmp32 = sensor[i].counter;
sei(); sei();
ctrlWriteCharToTxBuffer(i); ctrlWriteCharToTxBuffer(i);
ctrlWriteLongToTxBuffer(tmp32); ctrlWriteLongToTxBuffer(tmp32);
}
break; break;
case 'm': /* sensor meterconstant */ case 'm': /* sensor meterconstant */
ctrlReadCharFromRxBuffer(&i); ctrlReadCharFromRxBuffer(&i);
if (i < MAX_SENSORS) {
ctrlWriteCharToTxBuffer(i); ctrlWriteCharToTxBuffer(i);
ctrlWriteShortToTxBuffer(sensor[i].meterconst); ctrlWriteShortToTxBuffer(sensor[i].meterconst);
}
break; break;
case 'w': /* watchdog counter */ case 'w': /* watchdog counter */
@ -396,6 +401,8 @@ void ctrlCmdSet(uint8_t cmd)
case 'c': /* sensor counter value */ case 'c': /* sensor counter value */
ctrlReadCharFromRxBuffer(&i); ctrlReadCharFromRxBuffer(&i);
if (i < MAX_SENSORS) {
ctrlReadLongFromRxBuffer(&tmp32); ctrlReadLongFromRxBuffer(&tmp32);
cli(); cli();
@ -404,10 +411,13 @@ void ctrlCmdSet(uint8_t cmd)
ctrlWriteCharToTxBuffer(i); ctrlWriteCharToTxBuffer(i);
ctrlWriteLongToTxBuffer(tmp32); ctrlWriteLongToTxBuffer(tmp32);
}
break; break;
case 'm': /* sensor meterconstant */ case 'm': /* sensor meterconstant */
ctrlReadCharFromRxBuffer(&i); ctrlReadCharFromRxBuffer(&i);
if (i < MAX_SENSORS) {
ctrlReadShortFromRxBuffer(&tmp16); ctrlReadShortFromRxBuffer(&tmp16);
cli(); cli();
@ -416,6 +426,7 @@ void ctrlCmdSet(uint8_t cmd)
ctrlWriteCharToTxBuffer(i); ctrlWriteCharToTxBuffer(i);
ctrlWriteShortToTxBuffer(sensor[i].meterconst); ctrlWriteShortToTxBuffer(sensor[i].meterconst);
}
break; break;
case 'w': /* watchdog counter */ case 'w': /* watchdog counter */