]> git.tdb.fi Git - model-railway-devices.git/blobdiff - arducontrol/monitor.c
Drop the pretense of C89, put declarations where they make sense
[model-railway-devices.git] / arducontrol / monitor.c
index 9b5154dddfcf1d2209b3253436ac9b0ee2289421..7966c3da40eb0e46cac63c4282924b9dc5995c32 100644 (file)
@@ -74,12 +74,11 @@ uint8_t monitor_command(const uint8_t *cmd_buf, uint8_t cmd_length)
 {
        if(cmd_buf[0]==READ_TRACK_CURRENT)
        {
-               uint8_t reply[3];
-
                if(cmd_length!=1)
                        return LENGTH_ERROR;
 
                uint16_t value = track_current_milliamps();
+               uint8_t reply[3];
                reply[0] = TRACK_CURRENT;
                reply[1] = value>>8;
                reply[2] = value;
@@ -101,12 +100,11 @@ uint8_t monitor_command(const uint8_t *cmd_buf, uint8_t cmd_length)
        }
        else if(cmd_buf[0]==READ_INPUT_VOLTAGE)
        {
-               uint8_t reply[3];
-
                if(cmd_length!=1)
                        return LENGTH_ERROR;
 
                uint16_t value = input_voltage_millivolts();
+               uint8_t reply[3];
                reply[0] = INPUT_VOLTAGE;
                reply[1] = value>>8;
                reply[2] = value;