botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
bsI2C.doxy
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: BotSense
4 //
5 // File: bsI2C.doxy
6 //
7 // Description:
8 // This file contains the doxygen directives to document the BotSense Standard
9 // I2C Module. This module comes standard with the BotSense package.
10 //
11 ////////////////////////////////////////////////////////////////////////////////
12 
13 /*! \file */
14 
15 /* ---------------------------------------------------------------------------
16  * I2C
17  * --------------------------------------------------------------------------*/
18 
19 /*!
20  * \ingroup bsmod
21  * \defgroup bsmod_i2c I2C
22  *
23  * BotSense standanrd raw \h_i2c module.
24  *
25  * \section bsmod_intro Introduction
26  * The client side C/C++ interfaces are provided by the header file
27  * \ref include/botsense/bsI2C.h "botsense/bsI2C.h" in conjunction with
28  * the libraries libbsclient_i2c.a or libbsclient_i2c.so.
29  * For python clients, the python module
30  * \ref bsPython/modules/BotSense/bsI2C.py "BotSense.bsI2C"
31  * provides wrapper functions for the C libraries.
32  *
33  * The server side \ref man_bsproxy "bsProxy" plug-in is the Dynamic Link
34  * Library (DLL) libbsserver_i2c.so.
35  *
36  * \par Source Subdirectory:
37  * bsModules/bsI2C
38  * \{
39  */
40 
41 /*! \} */ /* end bsmod_i2c */
42 
43 
44 /* ---------------------------------------------------------------------------
45  * I2C Client
46  * --------------------------------------------------------------------------*/
47 
48 /*!
49  * \ingroup bsmod_i2c
50  * \defgroup bsmod_i2c_cli Client Interfaces
51  *
52  * The BotSense standard \h_i2c client side interfaces provide APIs for C/C++
53  * and python applications.
54  *
55  * \{
56  */
57 
58 /*! \} */ /* end bsmod_i2c_cli */
59 
60 /*!
61  * \ingroup bsmod_i2c_cli
62  * \defgroup man_libbsclient_i2c libbsclient_i2c Man Pages
63  *
64  * The libbsclient_i2c library provides the functional API between
65  * client applications on one side and request-response messages to/from
66  * the \ref man_bsproxy "bsProxy" server on the other side.
67  * The \ref man_libbotsense "libbotsense" client library mediates the
68  * client-server session.
69  *
70  * \{
71  */
72 
73 /*!
74 \ingroup man_libbsclient_i2c
75 \defgroup man_bsI2CGetMsgName bsI2CGetMsgName
76 \par Synopsis:
77 <tt>
78 \#include "rnr/rnrconfig.h"\n
79 \#include "botsense/BotSense.h"\n
80 \#include "botsense/libBotSense.h"\n
81 \#include "botsense/bsI2C.h"\n\n
82 const char * \ref bsI2CGetMsgName(\ref BsClient_P pClient,
83  \ref BsVConnHnd_T hndVConn,
84  uint_t uMsgId);
85 </tt>
86 
87 <b>Description:</b>\n
88 \copydoc bsI2CGetMsgName
89  */
90 
91 /*!
92 \ingroup man_libbsclient_i2c
93 \defgroup man_bsI2CReqClose bsI2CReqClose
94 \par Synopsis:
95 <tt>
96 \#include "rnr/rnrconfig.h"\n
97 \#include "botsense/BotSense.h"\n
98 \#include "botsense/libBotSense.h"\n
99 \#include "botsense/bsI2C.h"\n\n
100 int \ref bsI2CReqClose(\ref BsClient_P pClient,
101  \ref BsVConnHnd_T hndVConn);
102 </tt>
103 
104 <b>Description:</b>\n
105 \copydoc bsI2CReqClose
106  */
107 
108 /*!
109 \ingroup man_libbsclient_i2c
110 \defgroup man_bsI2CReqOpen bsI2CReqOpen
111 \par Synopsis:
112 <tt>
113 \#include "rnr/rnrconfig.h"\n
114 \#include "botsense/BotSense.h"\n
115 \#include "botsense/libBotSense.h"\n
116 \#include "botsense/bsI2C.h"\n\n
117 int \ref bsI2CReqOpen(\ref BsClient_P pClient,
118  const char *sDevName,
119  bool_t bInitTrace);
120 </tt>
121 
122 <b>Description:</b>\n
123 \copydoc bsI2CReqOpen
124  */
125 
126 /*!
127 \ingroup man_libbsclient_i2c
128 \defgroup man_bsI2CReqRead bsI2CReqRead
129 \par Synopsis:
130 <tt>
131 \#include "rnr/rnrconfig.h"\n
132 \#include "rnr/i2c.h"\n
133 \#include "botsense/BotSense.h"\n
134 \#include "botsense/libBotSense.h"\n
135 \#include "botsense/bsI2C.h"\n\n
136 int \ref bsI2CReqRead(\ref BsClient_P pClient,
137  \ref BsVConnHnd_T hndVConn,
138  i2c_addr_t i2cAddr,
139  size_t uReadLen,
140  byte_t rbuf[]);
141 </tt>
142 
143 <b>Description:</b>\n
144 \copydoc bsI2CReqRead
145  */
146 
147 /*!
148 \ingroup man_libbsclient_i2c
149 \defgroup man_bsI2CReqTrans bsI2CReqTrans
150 \par Synopsis:
151 <tt>
152 \#include "rnr/rnrconfig.h"\n
153 \#include "rnr/i2c.h"\n
154 \#include "botsense/BotSense.h"\n
155 \#include "botsense/libBotSense.h"\n
156 \#include "botsense/bsI2C.h"\n\n
157 int \ref bsI2CReqTrans(\ref BsClient_P pClient,
158  \ref BsVConnHnd_T hndVConn,
159  i2c_addr_t i2cAddr,
160  byte_t wbuf[],
161  size_t uWriteLen,
162  size_t uReadLen,
163  byte_t rbuf[]);
164 </tt>
165 
166 <b>Description:</b>\n
167 \copydoc bsI2CReqTrans
168  */
169 
170 /*!
171 \ingroup man_libbsclient_i2c
172 \defgroup man_bsI2CReqWrite bsI2CReqWrite
173 \par Synopsis:
174 <tt>
175 \#include "rnr/rnrconfig.h"\n
176 \#include "rnr/i2c.h"\n
177 \#include "botsense/BotSense.h"\n
178 \#include "botsense/libBotSense.h"\n
179 \#include "botsense/bsI2C.h"\n\n
180 int \ref bsI2CReqWrite(\ref BsClient_P pClient,
181  \ref BsVConnHnd_T hndVConn,
182  i2c_addr_t i2cAddr,
183  byte_t wbuf[],
184  size_t uWriteLen);
185 </tt>
186 
187 <b>Description:</b>\n
188 \copydoc bsI2CReqWrite
189  */
190 
191 /*! \} */ /* end bsmod_libbsclient_i2c */
192 
193 
194 /*!
195  * \ingroup bsmod_i2c_cli
196  * \defgroup bsI2C_py BotSense.bsI2C Python Module
197  *
198  * \{
199 The bsI2C module under the BotSense python package provides python
200 applications an interface to communicate with proxied i2c devices.
201 The underlining compiled extension module _bsI2C.so library provides the
202 provides the shim between python calling conventions and the C
203 libbsclient_i2c.[a,so] library.
204 
205 \sa \ref BotSense.bsI2C
206 
207 \par Example:
208 \code
209 #
210 # Example use of BotSense.bsI2C Module
211 #
212 
213 import sys
214 
215 import BotSense.BotSenseTypes as bsTypes
216 import BotSense.BotSenseError as bsError
217 import BotSense.BotSenseServer as bsServer
218 import BotSense.bsI2C as bsI2C
219 
220 # create a BotSense client
221 cli = bsTypes.BsClient('myi2c')
222 
223 # connect to the bsProxy server at the given host name and listening port
224 try:
225  bsServer.ServerConnect(cli, serverHostName="robot1", serverPort=9196)
226 except bsError.BotSenseError, inst:
227  print inst
228  sys.exit(8)
229 
230 # open a virtual connection to a proxied I2C device
231 try:
232  hndVConn = bsI2C.I2CReqOpen(cli, "/dev/i2c-1")
233 except bsError.BotSenseError, inst:
234  print inst
235  sys.exit(8)
236 print "Example: established virtual connection %d" % (hndVConn)
237 
238 # the I2C device attached to the I2C bus
239 i2cAddr = 0x20
240 
241 # execute a write-read transaction to the device
242 try:
243  rsp = bsI2C.I2CReqTrans(cli, hndVConn, i2cAddr, '\x01', 6)
244 except bsError.BotSenseError, inst:
245  print inst
246  sys.exit(8)
247 print "Read response %s" % (repr(rsp))
248 
249 # close the virtual connection
250 try:
251  bsI2C.I2CReqClose(cli, hndVConn)
252 except bsError.BotSenseError, inst:
253  print inst
254  sys.exit(8)
255 
256 # close the connection to the bsProxy server
257 try:
258  bsServer.ServerDisconnect(cli)
259 except bsError.BotSenseError, inst:
260  print inst
261  sys.exit(8)
262 
263 # delete the client
264 del cli
265 \endcode
266  */
267 
268 /*! \} */ /* end bsI2C_py */
269 
270 
271 /* ---------------------------------------------------------------------------
272  * I2C Server
273  * --------------------------------------------------------------------------*/
274 
275 /*!
276  * \ingroup bsmod_i2c
277  * \defgroup bsmod_i2c_srv Server Plug-In
278  *
279  * BotSense \ref man_bsproxy "bsProxy" server plug-in DLL for proxied raw
280  * \h_i2c devices.
281  *
282  * See \ref bsModules/bsI2C/bsI2CServer.c
283  *
284  * \{
285  */
286 
287 /*! \} */ /* end bsmod_i2c_srv */
288 
289 /*!
290  * \ingroup bsmod_i2c_srv
291  * \defgroup bsmod_i2c_srv_cfg I2C Configuration
292  *
293  * The \h_i2c plug-in XML configuration will be supported in BotSense v3.1.0.
294  * \{
295  */
296 
297 /*! \} */ /* end bsmod_i2c_srv_cfg */
298 
299 
300 /* ---------------------------------------------------------------------------
301  * I2C XML
302  * --------------------------------------------------------------------------*/
303 
304 /*!
305  * \ingroup bsmod_i2c
306  * \defgroup bsmod_i2c_xml XML Message Set
307 
308 The bsI2CMsgs.xml specification defines the set of messages
309 for BotSense virtual connections exstablished
310 between BotSense clients and raw \h_i2c devices proxied by
311 the \ref bsserver "bsProxy" server.
312 
313 The \h_i2c messages are terminated between the BotSense client
314 libbsclient_i2c.so shared library or libbsclient_i2c.a static library
315 and the bsProxy plug-in libbsserver_i2c.so interface module DLL.
316 
317 The message encoding is 8-bit Id-Type-Value (itv). All message fields are
318 packed in big-endian order.
319 
320 \include bsModules/bsI2C/bsI2CMsgs.xml
321 
322  */