1
+ .. _internalapi :
2
+
1
3
Internal API
2
4
============
3
5
@@ -46,7 +48,6 @@ They **might** implement the following:
46
48
and thus might not provide message filtering:
47
49
48
50
49
-
50
51
Concrete instances are usually created by :class: `can.Bus ` which takes the users
51
52
configuration into account.
52
53
@@ -66,19 +67,53 @@ methods:
66
67
67
68
68
69
70
+ About the IO module
71
+ -------------------
72
+
73
+ Handling of the different file formats is implemented in :mod: `can.io `.
74
+ Each file/IO type is within a separate module and ideally implements both a *Reader * and a *Writer *.
75
+ The reader usually extends :class: `can.io.generic.BaseIOHandler `, while
76
+ the writer often additionally extends :class: `can.Listener `,
77
+ to be able to be passed directly to a :class: `can.Notifier `.
78
+
79
+
80
+
81
+ Adding support for new file formats
82
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83
+
84
+ This assumes that you want to add a new file format, called *canstore *.
85
+ Ideally add both reading and writing support for the new file format, although this is not strictly required.
86
+
87
+ 1. Create a new module: *can/io/canstore.py *
88
+ (*or * simply copy some existing one like *can/io/csv.py *)
89
+ 2. Implement a reader ``CanstoreReader `` (which often extends :class: `can.io.generic.BaseIOHandler `, but does not have to).
90
+ Besides from a constructor, only ``__iter__(self) `` needs to be implemented.
91
+ 3. Implement a writer ``CanstoreWriter `` (which often extends :class: `can.io.generic.BaseIOHandler ` and :class: `can.Listener `, but does not have to).
92
+ Besides from a constructor, only ``on_message_received(self, msg) `` needs to be implemented.
93
+ 4. Document the two new classes (and possibly additional helpers) with docstrings and comments.
94
+ Please mention features and limitations of the implementation.
95
+ 5. Add a short section to the bottom of *doc/listeners.rst *.
96
+ 6. Add tests where appropriate, for example by simply adding a test case called
97
+ `class TestCanstoreFileFormat(ReaderWriterTest) ` to *test/logformats_test.py *.
98
+ That should already handle all of the general testing.
99
+ Just follow the way the other tests in there do it.
100
+ 7. Add imports to *can/__init__py * and *can/io/__init__py * so that the
101
+ new classes can be simply imported as *from can import CanstoreReader, CanstoreWriter *.
102
+
103
+
104
+
69
105
IO Utilities
70
- ------------
106
+ ~~~~~~~~~~~~
71
107
72
108
73
109
.. automodule :: can.io.generic
74
110
:members:
75
111
76
112
77
113
78
- Other Util
79
- ----------
114
+ Other Utilities
115
+ ---------------
80
116
81
117
82
118
.. automodule :: can.util
83
119
:members:
84
-
0 commit comments