├── .gitignore ├── obd2.h ├── README.md ├── obd2.cpp └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | -------------------------------------------------------------------------------- /obd2.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @brief Access library for OBD2 data 3 | * 4 | * @details Encapsulate OBD2 access for a minimum set of PIDs 5 | * An OBD2 adapter with ELM327 compatible command set is assumed 6 | * @see http://elmelectronics.com/DSheets/ELM327DS.pdf 7 | * An extensive list of OBD2 PIDs is given in 8 | * @see https://en.wikipedia.org/wiki/OBD-II_PIDs 9 | * 10 | * 11 | * @copyright Copyright (C) 2015, Helmut Schmidt 12 | * 13 | * @license MPL-2.0 14 | * 15 | **************************************************************************/ 16 | 17 | #ifndef INCLUDE_OBD2 18 | #define INCLUDE_OBD2 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | /** Part 1: Functions to access the OBD2 adapter 30 | * 31 | */ 32 | 33 | /** 34 | * Initialize the OBD2 access. 35 | * Must be called before using any of the other functions. 36 | * @param obd2_device [IN] the name of the device on which the OBD2 adapter is attached 37 | * @param baudrate [IN] baud rate (see definitions in ) 38 | * @note for bluetooth SPP connections the baudrate is normally ignored 39 | * @return true on when the OBD2 _dongle_ could be accessed. 40 | * @note this command does _not_ check the connection to the vehicle OBD bus 41 | * as this may depend on other conditions (such as ignition state) 42 | * @note CHECK this may block for a while as bluetooth connection setup can take up to 3.5 sec 43 | */ 44 | bool obd2_init(const char* obd2_device, unsigned int baudrate); 45 | 46 | /** 47 | * Release the OBD2 access. 48 | * @return true on success. 49 | */ 50 | bool obd2_deinit(); 51 | 52 | /** 53 | * Read the engine RPM from OBD2 54 | * @param engine_rpm returns the engine rpm in 1/min 55 | * @param timestamp returns a system timestamp in ms (milliseconds) derived from clock_gettime(CLOCK_MONOTONIC); 56 | * @return true on success. 57 | */ 58 | bool obd2_read_engine_rpm(float* engine_rpm, uint64_t* timestamp); 59 | 60 | /** 61 | * Read the vehicle speed from OBD2 62 | * @param engine_load returns the engine load in % 63 | * @param timestamp returns a system timestamp in ms (milliseconds) derived from clock_gettime(CLOCK_MONOTONIC); 64 | * @return true on success. 65 | */ 66 | bool obd2_read_engine_load(float* engine_load, uint64_t* timestamp); 67 | 68 | /** 69 | * Read the vehicle speed from OBD2 70 | * @param vehicle_speed returns the vehicle speed in km/h 71 | * @param timestamp returns a system timestamp in ms (milliseconds) derived from clock_gettime(CLOCK_MONOTONIC); 72 | * @return true on success. 73 | */ 74 | bool obd2_read_vehicle_speed(float* vehicle_speed, uint64_t* timestamp); 75 | 76 | /** 77 | * Read the ambient air temperature from OBD2 78 | * @param ambient_air_temperature returns the ambient air temperature in °C 79 | * @param timestamp returns a system timestamp in ms (milliseconds) derived from clock_gettime(CLOCK_MONOTONIC); 80 | * @return true on success. 81 | */ 82 | bool obd2_read_ambient_air_temperature(float* ambient_air_temperature, uint64_t* timestamp); 83 | 84 | 85 | /** Part 2: Utility functions and conversion factors 86 | * 87 | */ 88 | 89 | /** 90 | * Get system timestamp 91 | * @return returns a system timestamp in ms (milliseconds) derived from clock_gettime(CLOCK_MONOTONIC); 92 | */ 93 | uint64_t obd2_get_timestamp(); 94 | 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif //INCLUDE_OBD2 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rpi_obd2 2 | ======== 3 | Minimalistic access to OBD2 data with an ELM327 compatible adapter 4 | 5 | 6 | Connecting to Bluetooth-OBD on my openSUSE laptop 7 | ------------------------------------------------- 8 | * Check whether the built-in bluetooth adapter is active or blocked 9 | * `hciconfig -a` or `hciconfig dev` 10 | * `sudo rfkill list` 11 | * If it's blocked and/or down: unblock and activate it (order seems to be unimportant) 12 | * `sudo rfkill unblock bluetooth` 13 | * `sudo hciconfig hci0 up` 14 | * Search for the bluetooth dongle 15 | * `hcitool scan` 16 | * This command reports the MAC address of all found BT devices, like 00:0B:0D:84:B3:A0 17 | * Check offered services with `sdptool browse 00:0B:0D:84:B3:A0` 18 | * Bind the bluetooth donge to a rfcomm device 19 | * `sudo rfcomm bind 0 00:0B:0D:84:B3:A0` 20 | * Now the device /dev/rfcomm0 is created 21 | * Try to connect to the device 22 | * `cat /dev/rfcomm0` 23 | * `minicom -D /dev/rfcomm0` 24 | * (call as sudo if you are not member of group dialout) 25 | * TODO: CHECK what's the purpose of 26 | * `rfcomm connect 0` 27 | * `l2ping -c3 00:0B:0D:84:B3:A0` 28 | * TODO: CHECK how to enter the PIN when there is no GUI (KDE asked me for the PIN ...) 29 | * ?? ==> http://www.linurs.org/linux/Bluetooth.html 30 | * ?? ==> https://en.wikibooks.org/wiki/Linux_Guide/Linux_and_Bluetooth 31 | * !!?? ==> https://www.raspberrypi.org/forums/viewtopic.php?f=53&t=53299 ==> https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=87138&p=752712#p752712 32 | * !!!! bluez-simple-agent ==> http://fabcirablog.weebly.com/blog/reading-a-cars-obdii-port-with-a-raspberry-pi || http://gersic.com/connecting-your-raspberry-pi-to-a-bluetooth-obd-ii-adapter/ || https://mobileandpi.wordpress.com/tag/bluez-simple-agent/ || http://bobbylindsey.com/blog/?p=14 || http://diyapps.blogspot.de/2015/02/eclipse-open-iot-challenge-obd-part1.html + http://diyapps.blogspot.de/2015/02/eclipse-open-iot-challenge-obd-part2.html 33 | 34 | Useful ELM327 commands 35 | ---------------------- 36 | Note: all commands must be terminated by \r (CR). 37 | Sending just a CR repeats the last command?! 38 | 39 | AT commands 40 | * `ATZ` Reset (`ATD` seems to be a synonym) 41 | * Most (all?) OBD2 dongles will send a version string as response 42 | * `ATDP` Display used protocol (e.g. CAN) 43 | * Bus connection must be initialized first, e.g. by sending `0100` 44 | * `ATE0` Disable character echo (default: `ATE1`: character echo on) 45 | * `ATL0` Disable sending LF after CR (default: `ATL1`: LF is sent after CR) 46 | * `ATS0` Disable sending spaces between hex characters (default: `ATS1`: spaces are sent between hex characters) 47 | * This command is not supported by my OBD2 dongle (apparently only a cheap ELM327 clone) 48 | 49 | OBD2 data access: 50 | The first command sent after power up will initialize the bus connection 51 | and may take longer. 52 | The general command format is where 53 | * SID is the Service ID (in our case always 01) and 54 | * PID is the Parameter ID (identifying the parameter to read out) 55 | 56 | All commands and responses are coded as 2-digit hex numbers without prefix. 57 | The response format is 58 | 59 | The following commands may be useful 60 | (see also https://en.wikipedia.org/wiki/OBD-II_PIDs) 61 | * `0100` List supported PIDs in range 01..1F 62 | * returns 4 bytes as bitmask 63 | * `0104` Engine load 64 | * returns 1 byte (A): LOAD_PCT[%] = A*100/255 65 | * `010C` Engine RPM 66 | * returns 2 bytes (A,B): RPM [1/min] = ((A*256)+B)/4 67 | * `010D` Vehicle Speed 68 | * returns 1 byte (A): VSS [km/h] = A 69 | * `0110` Mass Air Flow 70 | * returns 2 bytes (A,B): MAF [g/s] = ((A*256)+B) / 100 71 | * not availble on my car 72 | * `011F` Run time since engine start 73 | * returns 2 bytes (A,B): RUNTIM [s] = (A*256)+B 74 | * `0146` Ambient air temperature 75 | * returns 1 byte (A): AAT[°C] = A-40 76 | 77 | 78 | 79 | 80 | References 81 | ---------- 82 | * [rfkill](http://linux.die.net/man/1/rfkill) 83 | * [rfkill- ubuntuusers](https://wiki.ubuntuusers.de/rfkill) 84 | * [SDB:ELM327_based_ODB2_scan_tool](https://en.opensuse.org/SDB:ELM327_based_ODB2_scan_tool) 85 | 86 | ?? https://www.modmypi.com/blog/installing-the-raspberry-pi-nano-bluetooth-dongle 87 | ?? http://unix.stackexchange.com/questions/92255/how-do-i-connect-and-send-data-to-a-bluetooth-serial-port-on-linux 88 | ?? http://stackoverflow.com/questions/15028953/sending-binary-data-over-bluetooth-rfcomm-spp-converts-0x0a-to-0x0d-0x0a 89 | 90 | -------------------------------------------------------------------------------- /obd2.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @brief Access library for OBD2 data 3 | * 4 | * @details Encapsulate OBD2 access for a minimum set of PIDs 5 | * An OBD2 adapter with ELM327 compatible command set is assumed 6 | * @see http://elmelectronics.com/DSheets/ELM327DS.pdf 7 | * An extensive list of OBD2 PIDs is given in 8 | * @see https://en.wikipedia.org/wiki/OBD-II_PIDs 9 | * 10 | * 11 | * @copyright Copyright (C) 2015, Helmut Schmidt 12 | * 13 | * @license MPL-2.0 14 | * 15 | **************************************************************************/ 16 | 17 | //provided interface 18 | #include 19 | //standard c library functions 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /** 35 | * INTERNAL DEFINES 36 | * 37 | * 38 | */ 39 | 40 | #define OBD_SID_01 0x01 41 | TODO finde nicer name 42 | 43 | #define OBD_PID_LOAD_PCT 0x04 44 | #define OBD_PID_RPM 0x0C 45 | #define OBD_PID_VSS 0x0D 46 | #define OBD_PID_MAF 0x10 47 | #define OBD_PID_RUNTIM 0x1F 48 | #define OBD_PID_AAT 0x46 49 | 50 | 51 | 52 | /** 53 | * INTERNAL FUNCTIONS 54 | * 55 | * 56 | */ 57 | 58 | 59 | /** 60 | * Open OBD2 ELM327 device for with given baud rate 61 | * @ref http://tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html 62 | * @param gps_device [IN] device, e.g. "/dev/rfcomm0" 63 | * @param baudrate [IN] baud rate (see definitions in ) 64 | * @note for bluetooth SPP connections the baudrate is normally ignored 65 | * @return file descriptor of OBD2 device 66 | */ 67 | static int obd2_open_device(const char* obd2_device, unsigned int baudrate) 68 | { 69 | int fd,c, res; 70 | struct termios oldtio,newtio; 71 | 72 | /* 73 | Open modem device for reading and writing and not as controlling tty 74 | because we don't want to get killed if linenoise sends CTRL-C. 75 | */ 76 | fd = open(obd2_device, O_RDWR | O_NOCTTY ); 77 | if (fd <0) 78 | { 79 | return fd; 80 | } 81 | 82 | tcgetattr(fd,&oldtio); /* save current serial port settings */ 83 | bzero(&newtio, sizeof(newtio)); /* clear struct for new port settings */ 84 | 85 | /* 86 | BAUDRATE: Set bps rate. You could also use cfsetispeed and cfsetospeed. 87 | CRTSCTS : output hardware flow control (only used if the cable has 88 | all necessary lines. See sect. 7 of Serial-HOWTO) 89 | CS8 : 8n1 (8bit,no parity,1 stopbit) 90 | CLOCAL : local connection, no modem contol 91 | CREAD : enable receiving characters 92 | */ 93 | newtio.c_cflag = GNSS_BAUDRATE | CS8 | CLOCAL | CREAD; 94 | 95 | /* 96 | IGNPAR : ignore bytes with parity errors 97 | ICRNL : map CR to NL (otherwise a CR input on the other computer 98 | will not terminate input) 99 | otherwise make device raw (no other input processing) 100 | */ 101 | newtio.c_iflag = IGNPAR; 102 | 103 | /* 104 | Raw output. 105 | */ 106 | newtio.c_oflag = 0; 107 | 108 | /* 109 | ICANON : enable canonical input 110 | disable all echo functionality, and don't send signals to calling program 111 | */ 112 | newtio.c_lflag = ICANON; TODO CHECK DISABLE 113 | 114 | /* 115 | initialize all control characters 116 | default values can be found in /usr/include/termios.h, and are given 117 | in the comments, but we don't need them here 118 | */ 119 | newtio.c_cc[VINTR] = 0; /* Ctrl-c */ 120 | newtio.c_cc[VQUIT] = 0; /* Ctrl-\ */ 121 | newtio.c_cc[VERASE] = 0; /* del */ 122 | newtio.c_cc[VKILL] = 0; /* @ */ 123 | newtio.c_cc[VEOF] = 4; /* Ctrl-d */ 124 | newtio.c_cc[VTIME] = 0; /* inter-character timer unused */ 125 | newtio.c_cc[VMIN] = 1; /* blocking read until 1 character arrives */ 126 | newtio.c_cc[VSWTC] = 0; /* '\0' */ 127 | newtio.c_cc[VSTART] = 0; /* Ctrl-q */ 128 | newtio.c_cc[VSTOP] = 0; /* Ctrl-s */ 129 | newtio.c_cc[VSUSP] = 0; /* Ctrl-z */ 130 | newtio.c_cc[VEOL] = 0; /* '\0' */ 131 | newtio.c_cc[VREPRINT] = 0; /* Ctrl-r */ 132 | newtio.c_cc[VDISCARD] = 0; /* Ctrl-u */ 133 | newtio.c_cc[VWERASE] = 0; /* Ctrl-w */ 134 | newtio.c_cc[VLNEXT] = 0; /* Ctrl-v */ 135 | newtio.c_cc[VEOL2] = 0; /* '\0' */ 136 | 137 | /* 138 | now clean the modem line and activate the settings for the port 139 | */ 140 | tcflush(fd, TCIFLUSH); 141 | tcsetattr(fd,TCSANOW,&newtio); 142 | 143 | /* 144 | Done 145 | */ 146 | return fd; 147 | } 148 | 149 | 150 | 151 | 152 | static bool obd2_send_command(const char* cmd) 153 | { 154 | } 155 | 156 | 157 | static bool obd2_decode_response(const char* cmd) 158 | { 159 | //make minimum assumptions! 160 | //check for SID/PID 161 | } 162 | 163 | static bool obd2_request_pid(const unsigned char sid, const unsigned char sid) 164 | { 165 | } 166 | 167 | static bool obd2_receive_pid(const unsigned char sid, const unsigned char sid) 168 | { 169 | } 170 | 171 | 172 | 173 | /** 174 | * EXTERNAL FUNCTIONS provided by this module 175 | * @ref obd2.h 176 | * 177 | * 178 | */ 179 | 180 | static pthread_t g_obd2_thread; 181 | static int g_obd2_fd = -1; 182 | 183 | 184 | bool obd2_init(const char* obd2_device, unsigned int baudrate) 185 | { 186 | //only open the device with appropriate settings (?canonical?) 187 | //but try to check ATZ response (provide back device ID/version)? 188 | //better not canonical ==> check for ">" prompt ???? 189 | //Take care: bluetooth connection setup may take long! 190 | //??!! raw mode http://stackoverflow.com/questions/15028953/sending-binary-data-over-bluetooth-rfcomm-spp-converts-0x0a-to-0x0d-0x0a 191 | 192 | bool retval = true; 193 | 194 | g_obd2_fd = obd2_open_device(obd2_device, baudrate); 195 | if (g_obd2_fd >= 0) 196 | { 197 | TODO ATZ 198 | } 199 | else 200 | { 201 | retval = false; 202 | } 203 | 204 | return retval; 205 | } 206 | 207 | bool obd2_deinit() 208 | { 209 | //only close device 210 | } 211 | 212 | bool obd2_read_engine_load(float* engine_load, uint64_t* timestamp) 213 | { 214 | // `0104` Engine load: returns 1 byte (A): LOAD_PCT[%] = A*100/255 215 | 216 | } 217 | 218 | 219 | bool obd2_read_engine_rpm(float* engine_rpm, uint64_t* timestamp) 220 | { 221 | //`010C` Engine RPM: returns 2 bytes (A,B): RPM [1/min] = ((A*256)+B)/4 222 | 223 | } 224 | 225 | 226 | bool obd2_read_vehicle_speed(float* vehicle_speed, uint64_t* timestamp) 227 | { 228 | //`010D` Vehicle Speed: returns 1 byte (A): VSS [km/h] = A 229 | } 230 | 231 | bool obd2_read_ambient_air_temperature(float* ambient_air_temperature, uint64_t* timestamp) 232 | { 233 | // `0146` Ambient air temperature: returns 1 byte (A): AAT[°C] = A-40 234 | 235 | } 236 | 237 | 238 | uint64_t obd2_get_timestamp() 239 | { 240 | struct timespec time_value; 241 | if (clock_gettime(CLOCK_MONOTONIC, &time_value) != -1) 242 | { 243 | return (time_value.tv_sec*1000 + time_value.tv_nsec/1000000); 244 | } 245 | else 246 | { 247 | return 0xFFFFFFFFFFFFFFFF; 248 | } 249 | } 250 | 251 | 252 | #ifdef OBD2_TEST 253 | int main() 254 | { 255 | bool result; 256 | float value; 257 | uint64_t timestamp, start, stop; 258 | 259 | start = obd2_get_timestamp(); 260 | result = obd2_init("/dev/rfcomm0", B38400); 261 | if (result) 262 | { 263 | printf("INIT OK [DURATION = %d ms]\n", stop-start); 264 | } 265 | else 266 | { 267 | printf("INIT FAILURE [DURATION = %d ms]\n", stop-start); 268 | return(); 269 | } 270 | 271 | start = obd2_get_timestamp(); 272 | result = obd2_read_engine_rpm(&value, ×tamp); 273 | stop = obd2_get_timestamp(); 274 | if (result) 275 | { 276 | printf("RPM=%f [DURATION = %d ms]\n", value, stop-start); 277 | } 278 | else 279 | { 280 | printf("RPM read failure\n"); 281 | } 282 | 283 | start = obd2_get_timestamp(); 284 | result = obd2_read_vehicle_speed(&value, ×tamp); 285 | stop = obd2_get_timestamp(); 286 | if (result) 287 | { 288 | printf("VSS=%f [DURATION = %d ms]\n", value, stop-start); 289 | } 290 | else 291 | { 292 | printf("VSS read failure\n"); 293 | } 294 | 295 | start = obd2_get_timestamp(); 296 | result = obd2_read_ambient_air_temperature(&value, ×tamp); 297 | stop = obd2_get_timestamp(); 298 | if (result) 299 | { 300 | printf("AAT=%f [DURATION = %d ms]\n", value, stop-start); 301 | } 302 | else 303 | { 304 | printf("AAT read failure\n"); 305 | } 306 | 307 | start = obd2_get_timestamp(); 308 | result = obd2_deinit(); 309 | stop = obd2_get_timestamp(); 310 | if (result) 311 | { 312 | printf("DEINIT OK [DURATION = %d ms]\n", stop-start); 313 | } 314 | else 315 | { 316 | printf("DEINIT FAILURE [DURATION = %d ms]\n", stop-start); 317 | } 318 | 319 | } 320 | #endif //#ifdef OBD2_TEST -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License, version 2.0 2 | 3 | 1. Definitions 4 | 5 | 1.1. "Contributor" 6 | 7 | means each individual or legal entity that creates, contributes to the 8 | creation of, or owns Covered Software. 9 | 10 | 1.2. "Contributor Version" 11 | 12 | means the combination of the Contributions of others (if any) used by a 13 | Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | 17 | means Covered Software of a particular Contributor. 18 | 19 | 1.4. "Covered Software" 20 | 21 | means Source Code Form to which the initial Contributor has attached the 22 | notice in Exhibit A, the Executable Form of such Source Code Form, and 23 | Modifications of such Source Code Form, in each case including portions 24 | thereof. 25 | 26 | 1.5. "Incompatible With Secondary Licenses" 27 | means 28 | 29 | a. that the initial Contributor has attached the notice described in 30 | Exhibit B to the Covered Software; or 31 | 32 | b. that the Covered Software was made available under the terms of 33 | version 1.1 or earlier of the License, but not also under the terms of 34 | a Secondary License. 35 | 36 | 1.6. "Executable Form" 37 | 38 | means any form of the work other than Source Code Form. 39 | 40 | 1.7. "Larger Work" 41 | 42 | means a work that combines Covered Software with other material, in a 43 | separate file or files, that is not Covered Software. 44 | 45 | 1.8. "License" 46 | 47 | means this document. 48 | 49 | 1.9. "Licensable" 50 | 51 | means having the right to grant, to the maximum extent possible, whether 52 | at the time of the initial grant or subsequently, any and all of the 53 | rights conveyed by this License. 54 | 55 | 1.10. "Modifications" 56 | 57 | means any of the following: 58 | 59 | a. any file in Source Code Form that results from an addition to, 60 | deletion from, or modification of the contents of Covered Software; or 61 | 62 | b. any new file in Source Code Form that contains any Covered Software. 63 | 64 | 1.11. "Patent Claims" of a Contributor 65 | 66 | means any patent claim(s), including without limitation, method, 67 | process, and apparatus claims, in any patent Licensable by such 68 | Contributor that would be infringed, but for the grant of the License, 69 | by the making, using, selling, offering for sale, having made, import, 70 | or transfer of either its Contributions or its Contributor Version. 71 | 72 | 1.12. "Secondary License" 73 | 74 | means either the GNU General Public License, Version 2.0, the GNU Lesser 75 | General Public License, Version 2.1, the GNU Affero General Public 76 | License, Version 3.0, or any later versions of those licenses. 77 | 78 | 1.13. "Source Code Form" 79 | 80 | means the form of the work preferred for making modifications. 81 | 82 | 1.14. "You" (or "Your") 83 | 84 | means an individual or a legal entity exercising rights under this 85 | License. For legal entities, "You" includes any entity that controls, is 86 | controlled by, or is under common control with You. For purposes of this 87 | definition, "control" means (a) the power, direct or indirect, to cause 88 | the direction or management of such entity, whether by contract or 89 | otherwise, or (b) ownership of more than fifty percent (50%) of the 90 | outstanding shares or beneficial ownership of such entity. 91 | 92 | 93 | 2. License Grants and Conditions 94 | 95 | 2.1. Grants 96 | 97 | Each Contributor hereby grants You a world-wide, royalty-free, 98 | non-exclusive license: 99 | 100 | a. under intellectual property rights (other than patent or trademark) 101 | Licensable by such Contributor to use, reproduce, make available, 102 | modify, display, perform, distribute, and otherwise exploit its 103 | Contributions, either on an unmodified basis, with Modifications, or 104 | as part of a Larger Work; and 105 | 106 | b. under Patent Claims of such Contributor to make, use, sell, offer for 107 | sale, have made, import, and otherwise transfer either its 108 | Contributions or its Contributor Version. 109 | 110 | 2.2. Effective Date 111 | 112 | The licenses granted in Section 2.1 with respect to any Contribution 113 | become effective for each Contribution on the date the Contributor first 114 | distributes such Contribution. 115 | 116 | 2.3. Limitations on Grant Scope 117 | 118 | The licenses granted in this Section 2 are the only rights granted under 119 | this License. No additional rights or licenses will be implied from the 120 | distribution or licensing of Covered Software under this License. 121 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 122 | Contributor: 123 | 124 | a. for any code that a Contributor has removed from Covered Software; or 125 | 126 | b. for infringements caused by: (i) Your and any other third party's 127 | modifications of Covered Software, or (ii) the combination of its 128 | Contributions with other software (except as part of its Contributor 129 | Version); or 130 | 131 | c. under Patent Claims infringed by Covered Software in the absence of 132 | its Contributions. 133 | 134 | This License does not grant any rights in the trademarks, service marks, 135 | or logos of any Contributor (except as may be necessary to comply with 136 | the notice requirements in Section 3.4). 137 | 138 | 2.4. Subsequent Licenses 139 | 140 | No Contributor makes additional grants as a result of Your choice to 141 | distribute the Covered Software under a subsequent version of this 142 | License (see Section 10.2) or under the terms of a Secondary License (if 143 | permitted under the terms of Section 3.3). 144 | 145 | 2.5. Representation 146 | 147 | Each Contributor represents that the Contributor believes its 148 | Contributions are its original creation(s) or it has sufficient rights to 149 | grant the rights to its Contributions conveyed by this License. 150 | 151 | 2.6. Fair Use 152 | 153 | This License is not intended to limit any rights You have under 154 | applicable copyright doctrines of fair use, fair dealing, or other 155 | equivalents. 156 | 157 | 2.7. Conditions 158 | 159 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in 160 | Section 2.1. 161 | 162 | 163 | 3. Responsibilities 164 | 165 | 3.1. Distribution of Source Form 166 | 167 | All distribution of Covered Software in Source Code Form, including any 168 | Modifications that You create or to which You contribute, must be under 169 | the terms of this License. You must inform recipients that the Source 170 | Code Form of the Covered Software is governed by the terms of this 171 | License, and how they can obtain a copy of this License. You may not 172 | attempt to alter or restrict the recipients' rights in the Source Code 173 | Form. 174 | 175 | 3.2. Distribution of Executable Form 176 | 177 | If You distribute Covered Software in Executable Form then: 178 | 179 | a. such Covered Software must also be made available in Source Code Form, 180 | as described in Section 3.1, and You must inform recipients of the 181 | Executable Form how they can obtain a copy of such Source Code Form by 182 | reasonable means in a timely manner, at a charge no more than the cost 183 | of distribution to the recipient; and 184 | 185 | b. You may distribute such Executable Form under the terms of this 186 | License, or sublicense it under different terms, provided that the 187 | license for the Executable Form does not attempt to limit or alter the 188 | recipients' rights in the Source Code Form under this License. 189 | 190 | 3.3. Distribution of a Larger Work 191 | 192 | You may create and distribute a Larger Work under terms of Your choice, 193 | provided that You also comply with the requirements of this License for 194 | the Covered Software. If the Larger Work is a combination of Covered 195 | Software with a work governed by one or more Secondary Licenses, and the 196 | Covered Software is not Incompatible With Secondary Licenses, this 197 | License permits You to additionally distribute such Covered Software 198 | under the terms of such Secondary License(s), so that the recipient of 199 | the Larger Work may, at their option, further distribute the Covered 200 | Software under the terms of either this License or such Secondary 201 | License(s). 202 | 203 | 3.4. Notices 204 | 205 | You may not remove or alter the substance of any license notices 206 | (including copyright notices, patent notices, disclaimers of warranty, or 207 | limitations of liability) contained within the Source Code Form of the 208 | Covered Software, except that You may alter any license notices to the 209 | extent required to remedy known factual inaccuracies. 210 | 211 | 3.5. Application of Additional Terms 212 | 213 | You may choose to offer, and to charge a fee for, warranty, support, 214 | indemnity or liability obligations to one or more recipients of Covered 215 | Software. However, You may do so only on Your own behalf, and not on 216 | behalf of any Contributor. You must make it absolutely clear that any 217 | such warranty, support, indemnity, or liability obligation is offered by 218 | You alone, and You hereby agree to indemnify every Contributor for any 219 | liability incurred by such Contributor as a result of warranty, support, 220 | indemnity or liability terms You offer. You may include additional 221 | disclaimers of warranty and limitations of liability specific to any 222 | jurisdiction. 223 | 224 | 4. Inability to Comply Due to Statute or Regulation 225 | 226 | If it is impossible for You to comply with any of the terms of this License 227 | with respect to some or all of the Covered Software due to statute, 228 | judicial order, or regulation then You must: (a) comply with the terms of 229 | this License to the maximum extent possible; and (b) describe the 230 | limitations and the code they affect. Such description must be placed in a 231 | text file included with all distributions of the Covered Software under 232 | this License. Except to the extent prohibited by statute or regulation, 233 | such description must be sufficiently detailed for a recipient of ordinary 234 | skill to be able to understand it. 235 | 236 | 5. Termination 237 | 238 | 5.1. The rights granted under this License will terminate automatically if You 239 | fail to comply with any of its terms. However, if You become compliant, 240 | then the rights granted under this License from a particular Contributor 241 | are reinstated (a) provisionally, unless and until such Contributor 242 | explicitly and finally terminates Your grants, and (b) on an ongoing 243 | basis, if such Contributor fails to notify You of the non-compliance by 244 | some reasonable means prior to 60 days after You have come back into 245 | compliance. Moreover, Your grants from a particular Contributor are 246 | reinstated on an ongoing basis if such Contributor notifies You of the 247 | non-compliance by some reasonable means, this is the first time You have 248 | received notice of non-compliance with this License from such 249 | Contributor, and You become compliant prior to 30 days after Your receipt 250 | of the notice. 251 | 252 | 5.2. If You initiate litigation against any entity by asserting a patent 253 | infringement claim (excluding declaratory judgment actions, 254 | counter-claims, and cross-claims) alleging that a Contributor Version 255 | directly or indirectly infringes any patent, then the rights granted to 256 | You by any and all Contributors for the Covered Software under Section 257 | 2.1 of this License shall terminate. 258 | 259 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user 260 | license agreements (excluding distributors and resellers) which have been 261 | validly granted by You or Your distributors under this License prior to 262 | termination shall survive termination. 263 | 264 | 6. Disclaimer of Warranty 265 | 266 | Covered Software is provided under this License on an "as is" basis, 267 | without warranty of any kind, either expressed, implied, or statutory, 268 | including, without limitation, warranties that the Covered Software is free 269 | of defects, merchantable, fit for a particular purpose or non-infringing. 270 | The entire risk as to the quality and performance of the Covered Software 271 | is with You. Should any Covered Software prove defective in any respect, 272 | You (not any Contributor) assume the cost of any necessary servicing, 273 | repair, or correction. This disclaimer of warranty constitutes an essential 274 | part of this License. No use of any Covered Software is authorized under 275 | this License except under this disclaimer. 276 | 277 | 7. Limitation of Liability 278 | 279 | Under no circumstances and under no legal theory, whether tort (including 280 | negligence), contract, or otherwise, shall any Contributor, or anyone who 281 | distributes Covered Software as permitted above, be liable to You for any 282 | direct, indirect, special, incidental, or consequential damages of any 283 | character including, without limitation, damages for lost profits, loss of 284 | goodwill, work stoppage, computer failure or malfunction, or any and all 285 | other commercial damages or losses, even if such party shall have been 286 | informed of the possibility of such damages. This limitation of liability 287 | shall not apply to liability for death or personal injury resulting from 288 | such party's negligence to the extent applicable law prohibits such 289 | limitation. Some jurisdictions do not allow the exclusion or limitation of 290 | incidental or consequential damages, so this exclusion and limitation may 291 | not apply to You. 292 | 293 | 8. Litigation 294 | 295 | Any litigation relating to this License may be brought only in the courts 296 | of a jurisdiction where the defendant maintains its principal place of 297 | business and such litigation shall be governed by laws of that 298 | jurisdiction, without reference to its conflict-of-law provisions. Nothing 299 | in this Section shall prevent a party's ability to bring cross-claims or 300 | counter-claims. 301 | 302 | 9. Miscellaneous 303 | 304 | This License represents the complete agreement concerning the subject 305 | matter hereof. If any provision of this License is held to be 306 | unenforceable, such provision shall be reformed only to the extent 307 | necessary to make it enforceable. Any law or regulation which provides that 308 | the language of a contract shall be construed against the drafter shall not 309 | be used to construe this License against a Contributor. 310 | 311 | 312 | 10. Versions of the License 313 | 314 | 10.1. New Versions 315 | 316 | Mozilla Foundation is the license steward. Except as provided in Section 317 | 10.3, no one other than the license steward has the right to modify or 318 | publish new versions of this License. Each version will be given a 319 | distinguishing version number. 320 | 321 | 10.2. Effect of New Versions 322 | 323 | You may distribute the Covered Software under the terms of the version 324 | of the License under which You originally received the Covered Software, 325 | or under the terms of any subsequent version published by the license 326 | steward. 327 | 328 | 10.3. Modified Versions 329 | 330 | If you create software not governed by this License, and you want to 331 | create a new license for such software, you may create and use a 332 | modified version of this License if you rename the license and remove 333 | any references to the name of the license steward (except to note that 334 | such modified license differs from this License). 335 | 336 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 337 | Licenses If You choose to distribute Source Code Form that is 338 | Incompatible With Secondary Licenses under the terms of this version of 339 | the License, the notice described in Exhibit B of this License must be 340 | attached. 341 | 342 | Exhibit A - Source Code Form License Notice 343 | 344 | This Source Code Form is subject to the 345 | terms of the Mozilla Public License, v. 346 | 2.0. If a copy of the MPL was not 347 | distributed with this file, You can 348 | obtain one at 349 | http://mozilla.org/MPL/2.0/. 350 | 351 | If it is not possible or desirable to put the notice in a particular file, 352 | then You may include the notice in a location (such as a LICENSE file in a 353 | relevant directory) where a recipient would be likely to look for such a 354 | notice. 355 | 356 | You may add additional accurate notices of copyright ownership. 357 | 358 | Exhibit B - "Incompatible With Secondary Licenses" Notice 359 | 360 | This Source Code Form is "Incompatible 361 | With Secondary Licenses", as defined by 362 | the Mozilla Public License, v. 2.0. 363 | 364 | --------------------------------------------------------------------------------