]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
mout: Make return value of rpp_mout_diag more consistent with other functions
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 13 Apr 2016 15:03:36 +0000 (17:03 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 13 Apr 2016 15:03:36 +0000 (17:03 +0200)
I checked that this change does affect neither the Simulink block nor
rpp-test-sw.

rpp/include/rpp/mout.h
rpp/src/rpp/mout.c

index 1250dd82fd7c9605c6ed5c565fbc6cee3c8173bf..8c1910b61842f346c9526e6f0293151d5cdd64fc 100644 (file)
@@ -3,7 +3,7 @@
  *
  * @file mout.h
  *
- * @copyright Copyright (C) 2013 Czech Technical University in Prague
+ * @copyright Copyright (C) 2013, 2016 Czech Technical University in Prague
  *
  * @author Carlos Jenkins <carlos@jenkins.co.cr>
  */
@@ -69,12 +69,11 @@ int8_t rpp_mout_get(uint8_t pin);
  *
  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
  *
- * Note that rpp_mout_set() calls this routine already before returning.
- *
  * @param[in] pin       The pin number to read [1-6].
  *
- * @return SUCCESS is output is operating normally.
- *         FAILURE if a faulty condition was detected.
+ * @return 0 the pin is low, i.e. fault detected,
+ *         1 the pin is high, i.e. normal operation,
+ *         -RPP_EINVAL pin number out of range
  */
 int8_t rpp_mout_diag(uint8_t pin);
 
index c5a93d61b7e8641c037ca1a02ead733274f5244f..d8f116b7f0d51623c05ef66deebbdece7f1d8b6b 100644 (file)
@@ -113,16 +113,15 @@ int8_t rpp_mout_get(uint8_t pin)
 
 int8_t rpp_mout_diag(uint8_t pin)
 {
+       int ret;
        // Check range
        if ((pin < 1) || (pin > 6))
-               return -1;
+               return -RPP_EINVAL;
 
 #ifndef FREERTOS_POSIX
        RPP_MUTEX_LOCK(mutex_mout);
-       if (drv_mout_diag(pin - 1) == 0) {
-               RPP_MUTEX_UNLOCK(mutex_mout);
-               return FAILURE;
-       }
+       ret = drv_mout_diag(pin - 1);
+       RPP_MUTEX_UNLOCK(mutex_mout);
 #endif
-       return SUCCESS;
+       return ret;
 }