summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2018-03-29 18:53:59 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-03-29 18:53:59 +0100
commit360a946e98c68d2a2bbac58d7d672f00a9ff6083 (patch)
tree5cb239a706098100eb41a6be95445439d4285ed7
downloadcanopied-360a946e98c68d2a2bbac58d7d672f00a9ff6083.tar.bz2
Initial bits for Canopied
-rw-r--r--.gitignore3
-rw-r--r--CODE_OF_CONDUCT.mdwn20
-rw-r--r--COPYING27
-rw-r--r--Cargo.toml6
-rw-r--r--README.mdwn6
-rw-r--r--notes/iso-15765-2.mdwn71
-rw-r--r--src/main.rs3
7 files changed, 136 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..70e3cae
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+
+/target
+**/*.rs.bk
diff --git a/CODE_OF_CONDUCT.mdwn b/CODE_OF_CONDUCT.mdwn
new file mode 100644
index 0000000..a340fb0
--- /dev/null
+++ b/CODE_OF_CONDUCT.mdwn
@@ -0,0 +1,20 @@
+_The Gitano Community_ is dedicated to providing a harassment-free experience
+for everyone, regardless of gender, gender identity and expression, sexual
+orientation, disability, physical appearance, body size, age, race, or
+religion. We do not tolerate harassment of participants in any form.
+
+This code of conduct applies to all _The Gitano Community_ spaces, including
+our mailing lists such as `gitano-dev@gitano.org.uk`, our IRC channels such as
+`#gitano` on Freenode, and at any in-person event at which members of the
+community attend, both online and off. Anyone who violates this code of conduct
+may be sanctioned or expelled from these spaces at the discretion of the Gitano
+Community Managers.
+
+Some _The Gitano Community_ spaces may have additional rules in place, which
+will be made clearly available to participants. Participants are responsible
+for knowing and abiding by these rules.
+
+The full text of the code of conduct / contributor covenant / anti-harassment
+policy can be found at: <https://www.gitano.org.uk/covenant/>. Should the text
+of that page differ from the content of this file then the newer content on the
+website takes precedence.
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d9c2c68
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,27 @@
+Copyright 2018 Daniel Silverstone <dsilvers@digital-scurf.org>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of their contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..22a95f6
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "canopied"
+version = "0.1.0"
+authors = ["Daniel Silverstone <dsilvers@digital-scurf.org>"]
+
+[dependencies]
diff --git a/README.mdwn b/README.mdwn
new file mode 100644
index 0000000..2bf68a4
--- /dev/null
+++ b/README.mdwn
@@ -0,0 +1,6 @@
+Canopied
+========
+
+Canopied is a CAN based car logging and data service application designed to run
+on a small computer embedded into a car and attached to the OBD-II CAN bus.
+
diff --git a/notes/iso-15765-2.mdwn b/notes/iso-15765-2.mdwn
new file mode 100644
index 0000000..24d8230
--- /dev/null
+++ b/notes/iso-15765-2.mdwn
@@ -0,0 +1,71 @@
+ISO 15765-2
+===========
+
+Also known as CAN-TP or ISO-TP, this is the packetisation and flow control
+scheme which underlies the unified diagnostic services which underlies OBD-II
+
+In order to be non-blocking, our handling of ISO-TP will have to be around a
+state machine. Since we need to handle both sending and receiving of large
+packets, we'll have to have state machines for both.
+
+ISO-TP always operates with CAN messages with the full eight bytes of payload.
+When the packets would be short, ISO-TP pads them. It is safe to pad with zero,
+255, or whatever we choose. We will likely use zero.
+
+For payloads of fewer than eight bytes, a single CAN packet is needed. For
+more than seven bytes of payload, more than one packet must be transmitted,
+which invokes the need for flow control frames.
+
+All ISO-TP packets begin with a four bit header in the top nibble of the first
+byte of the packet. Currently this can take one of four values:
+
+0. Single frame (SF) - The transaction has a payload of fewer than 8 bytes,
+ this is the only CAN frame in it.
+1. First frame (FF) - The transaction has a payload of 8 or more bytes, this
+ is the first frame in the transaction. Subsequent frames shall be
+ transmitted following acknowledgement by the recipient with a flow control
+ frame.
+2. Consecutive frame (CF) - These are the continuations of a long transaction
+ and contain up to seven more bytes of the payload.
+3. Flow control frame (FC) - These are sent by the recipient of a FF and set
+ the parameters by which the rest of the CFs may be transmitted. Depending
+ on the chosen parameters, there may be subsequent FCs needed to get the
+ whole transaction through.
+
+In SF, the lower nibble is the number of bytes in the frame, excluding the
+first (so 0 to 7). Subsequent bytes in the frame are the payload, padded if
+necessary.
+
+In FF, the lower nibble of the first byte, and the whole of the second byte,
+form a 12 bit value for the number of bytes in the ISO-TP transaction. This in
+theory allows for up to 4095 bytes, though most ECUs will balk at more than a
+few hundred. The rest of the frame (6 bytes worth) are the first six bytes of
+the transaction.
+
+In CF, the lower nibble of the first byte is a simple counter, starting at 1
+after the first FF and incrementing and wrapping as necessary. This allows for
+the recipient to notice if it has missed a frame. The remaining up-to-seven
+bytes are the next chunk of the transaction.
+
+In FC, the lower nibble of the first byte is a command/status enumeration:
+
+0. Continue to send
+1. Wait please
+2. Overflow/abort
+
+In practice, most ECUs will only ever use 0 or 2. If the FC is a continue then
+the second byte is the number of CFs to send before waiting for a new FC (zero
+means send them all) and the third byte is the inter-frame timing
+requirements. 0 to 127 is in ms, 241 to 249 mean 100µs to 900µs respectively.
+
+Sadly some ECUs get these wrong, so don't be surprised if they send more
+slowly or more quickly.
+
+Since we're a super-powerful computer (yes, even a Pi counts as that) we can
+always send an FC which says "gimme it all, as fast as you can" which is
+rendered as a frame consisting of the 3 in the upper nibble of the first byte
+and everything else being zero.
+
+Since the car computers may not be quite so powerful, to send, we should
+always honour the FC limits. This means we need to use non-blocking timers and
+have a moderately complex sending state machine.
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..e7a11a9
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}