]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blobdiff - rpp-test-sw/commands/cmd_can.c
Change license to MIT
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd_can.c
index c815dddaca4b05edcb4e53b562543e0ef3363f65..e042acfa871317086d107bea37a186d3f669471e 100644 (file)
@@ -1,15 +1,31 @@
 /*
- * Copyright (C) 2012-2014 Czech Technical University in Prague
+ * Copyright (C) 2012-2014, 2016 Czech Technical University in Prague
  *
  * Created on: 28.2.2013
  *
  * Authors:
  *     - Michal Horn
  *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  *
  * File : cmd_can.c
  *
@@ -115,22 +131,22 @@ static struct rpp_can_rx_config rx_config[] = {
                .type = RPP_CAN_MIXED,
                .controller = 1,
                .msg_obj = 1,
-               .id = 1,
-               .mask = 0x7fffff,
+               .id = 0,
+               .mask = 0,
        },
        {
                .type = RPP_CAN_MIXED,
                .controller = 2,
                .msg_obj = 1,
-               .id = 1,
-               .mask = 0x7fffff,
+               .id = 0,
+               .mask = 0,
        },
        {
                .type = RPP_CAN_MIXED,
                .controller = 3,
                .msg_obj = 1,
-               .id = 1,
-               .mask = 0x7fffff,
+               .id = 0,
+               .mask = 0,
        }
 };
 
@@ -737,6 +753,11 @@ int cmd_do_can_dump(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
                return 1;
        }
 
+       if (controller_id < 1 || controller_id > 3) {
+               rpp_sci_printf("Invalid controller ID\n");
+               return -CMDERR_NODEV;
+       }
+
        rpp_can_init(&can_config);
 
        while (cmd_io->getc(cmd_io) < 0) {
@@ -744,7 +765,7 @@ int cmd_do_can_dump(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
                if (rx_ind) {
                        if (rpp_can_read(controller_id-1, &pdu) == SUCCESS) {
                                if (pdu.id & CAN_EFF_FLAG)
-                                       rpp_sci_printf("can%u  %08X  [%u]  ", controller_id & (~CAN_EFF_FLAG), pdu.id, pdu.dlc);
+                                       rpp_sci_printf("can%u  %08X  [%u]  ", controller_id, pdu.id & (~CAN_EFF_FLAG), pdu.dlc);
                                else
                                        rpp_sci_printf("can%u  %03X  [%u]  ", controller_id, pdu.id, pdu.dlc);
 
@@ -1071,11 +1092,16 @@ cmd_des_t const cmd_des_can_test={
     "    appropriate error code is printed.\n"
     "\n"
     "At the end the CAN bus is reset and left with the configuration from\n"
-    "test 1. Any previous configuration is canceled, but is not deleted, so\n"
-    "any following call of `caninit` command will restore the CAN bus to\n"
-    "previous configuration.\n"
+    "test 1.\n"
+    "\n"
+    "The command can be called even after the CAN bus has been already\n"
+    "configured by previous invocation of the `caninit` command. The\n"
+    "previous timing configuration set by `cantiming#` command not\n"
+    "modified. Therefore, calling `caninit` after this command finishes\n"
+    "restores the previous timing settings.\n"
     "\n"
-    "For error codes description refer please the API documentation for the rpp-test-sw.\n"
+    "For error codes description please refer to the API documentation for\n"
+    "the rpp-test-sw.\n"
     "\n"
     "### Example ###\n"
     "\n"