kvaser_interface.h
Go to the documentation of this file.
00001 /*
00002 * Unpublished Copyright (c) 2009-2017 AutonomouStuff, LLC, All Rights Reserved.
00003 *
00004 * This file is part of the Kvaser ROS 1.0 driver which is released under the MIT license.
00005 * See file LICENSE included with this software or go to https://opensource.org/licenses/MIT for full license details.
00006 */
00007 
00008 // Define a class that supports a basic CAN interface that's independent of the hardware and driver library used
00009 // Different libraries can be created to define all these functions for a specific driver library
00010 
00011 #ifndef KVASER_INTERFACE_HPP
00012 #define KVASER_INTERFACE_HPP
00013 
00014 //C++ Includes
00015 #include <iostream>
00016 
00017 //OS Includes
00018 #include <unistd.h>
00019 
00020 namespace AS
00021 {
00022 namespace CAN
00023 {
00024   enum return_statuses
00025   {
00026     OK = 0,
00027     INIT_FAILED = -1,
00028     BAD_PARAM = -2,
00029     NO_CHANNELS_FOUND = -3,
00030     CHANNEL_CLOSED = -4,
00031     NO_MESSAGES_RECEIVED = -5,
00032     READ_FAILED = -6,
00033     WRITE_FAILED = -7,
00034     CLOSE_FAILED = -8
00035   };
00036 
00037   class KvaserCan
00038   {
00039   public:
00040     KvaserCan();
00041 
00042     ~KvaserCan();
00043 
00044     // Called to pass in parameters and open can link
00045     return_statuses open(const int& hardware_id,
00046                          const int& circuit_id,
00047                          const int& bitrate,
00048                          const bool& echo_on = true);
00049 
00050     // Close the can link
00051     return_statuses close();
00052 
00053     // Check to see if the CAN link is open
00054     bool is_open();
00055 
00056     // Read a message
00057     return_statuses read(long *id,
00058                          unsigned char *msg,
00059                          unsigned int *size,
00060                          bool *extended,
00061                          unsigned long *time);
00062 
00063     // Send a message
00064     return_statuses write(const long& id,
00065                           unsigned char *msg,
00066                           const unsigned int& size,
00067                           const bool& extended);
00068 
00069   private:
00070     void *handle;
00071     bool on_bus;
00072   };
00073 
00074   // Converts error messages to human-readable strings
00075   std::string return_status_desc(const return_statuses& ret);
00076 }
00077 }
00078 #endif


kvaser_interface
Author(s): Joshua Whitley , Daniel Stanek
autogenerated on Fri Jun 21 2019 19:31:13