botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
bsI2CClient.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: BotSense
4 //
5 // Module: bsI2C
6 // Library: libbsclient_i2c
7 // File: bsI2CClient.c
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2010-08-20 11:36:38 -0600 (Fri, 20 Aug 2010) $
12  * $Rev: 568 $
13  *
14  * \brief \h_botsense bsProxy client proxied \h_i2c bus device library.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  *
18  * \copyright
19  * \h_copy 2009-2017. RoadNarrows LLC.\n
20  * http://www.roadnarrows.com\n
21  * All Rights Reserved
22  */
23 // Permission is hereby granted, without written agreement and without
24 // license or royalty fees, to use, copy, modify, and distribute this
25 // software and its documentation for any purpose, provided that
26 // (1) The above copyright notice and the following two paragraphs
27 // appear in all copies of the source code and (2) redistributions
28 // including binaries reproduces these notices in the supporting
29 // documentation. Substantial modifications to this software may be
30 // copyrighted by their authors and need not follow the licensing terms
31 // described here, provided that the new terms are clearly indicated in
32 // all files where they apply.
33 //
34 // IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
35 // OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
36 // PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
37 // DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
38 // EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
39 // THE POSSIBILITY OF SUCH DAMAGE.
40 //
41 // THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
42 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
43 // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
44 // "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
45 // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
46 //
47 ////////////////////////////////////////////////////////////////////////////////
48 
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <libgen.h>
52 #include <string.h>
53 
54 #include "rnr/rnrconfig.h"
55 #include "rnr/log.h"
56 #include "rnr/netmsgs.h"
57 #include "rnr/i2c.h"
58 
59 #include "botsense/BotSense.h"
60 #include "botsense/libBotSense.h"
61 #include "botsense/bsI2C.h"
62 #include "botsense/bsI2CMsgs.h"
63 
64 // ---------------------------------------------------------------------------
65 // Private Interface
66 // ---------------------------------------------------------------------------
67 
68 /*!
69  * \brief \h_botsense client application information.
70  */
72 {
73  .app_name = "libbsclient_i2c",
74  .brief = "Raw I2C Bus proxied device.",
75  .version = "2.0.0",
76  .date = "2010.07.20",
77  .maintainer = "RaodNarrows LLC",
78  .license = "(C) 2010 RoadNarrows LLC. All rights reserved.",
79 
80  .fnGetMsgName = bsI2CGetMsgName
81 };
82 
83 // ---------------------------------------------------------------------------
84 // Public Interface
85 // ---------------------------------------------------------------------------
86 
87 /*!
88  * \brief Get the \h_i2c message name.
89  *
90  * For each (virtual connection, message id) 2-tuple, there can be a known
91  * name string (provided the id is valid and an application provides the
92  * information).
93  *
94  * \param pClient \h_botsense client.
95  * \param hndVConn Virtual connection handle.
96  * \param uMsgId Message id.
97  *
98  * \return
99  * Returns message name if it can be determined. Otherwise returns "unknown".
100  */
101 const char *bsI2CGetMsgName(BsClient_P pClient,
102  BsVConnHnd_T hndVConn,
103  uint_t uMsgId)
104 {
105  const NMMsgDef_T *pMsgDef;
106 
107  pMsgDef = BsI2CLookupMsgDef((BsI2CMsgId_T)uMsgId);
108 
109  return pMsgDef!=NULL? pMsgDef->m_sMsgName: "unknown";
110 }
111 
112 /*!
113  * \brief Request proxy server to establish a virtual connection to an \h_i2c
114  * bus device.
115  *
116  * \param pClient \h_botsense client.
117  * \param sDevName Proxied \h_i2c bus device name (e.g. /dev/i2c-0).
118  * \param bInitTrace Initial message tracing enable(true)/disable(false) state.
119  *
120  * \return
121  * On success, the virtual connection handle is returned.\n
122  * \copydoc doc_return_ecode
123  */
125  const char *sDevName,
126  bool_t bInitTrace)
127 {
128  int hnd; // vconn handle / return code
129 
130  //
131  // Execute server transaction (returns handle \h_ge 0 on success).
132  //
133  hnd = bsServerReqOpenDev(pClient, sDevName, BS_I2C_SERVER_MOD,
134  NULL, (size_t)0, &bsI2CAppInfo, bInitTrace);
135 
136  // check transaction return code
137  BSCLIENT_TRY_ECODE(pClient, hnd, "bsServerReqOpenDev(dev='%s') failed.",
138  sDevName);
139 
140  // return handle
141  return hnd;
142 }
143 
144 /*!
145  * \brief Request proxy server to close client's proxied \h_i2c device vitual
146  * connection.
147  *
148  * \param pClient \h_botsense client.
149  * \param hndVConn Handle to virtual connection to close.
150  *
151  * \copydoc doc_return_std
152  */
153 int bsI2CReqClose(BsClient_P pClient, BsVConnHnd_T hndVConn)
154 {
155  return bsServerReqCloseDev(pClient, hndVConn);
156 }
157 
158 /*!
159  * \brief Proxied request to read from a device attached to the \h_i2c bus.
160  *
161  * \param pClient \h_botsense client.
162  * \param hndVConn Handle to virtual connection to close.
163  * \param i2cAddr Address of attached device on the \h_i2c bus.
164  * \param uReadLen Number of bytes to read.
165  * \param [out] rbuf Read buffer.
166  *
167  * \return
168  * Returns number of bytes read on success.\n
169  * \copydoc doc_return_ecode
170  */
172  BsVConnHnd_T hndVConn,
173  i2c_addr_t i2cAddr,
174  size_t uReadLen,
175  byte_t rbuf[])
176 {
177  static BsI2CMsgId_T msgIdReq = BsI2CMsgIdReqRead;
178  static BsI2CMsgId_T msgIdRsp = BsI2CMsgIdRspRead;
179 
180  BsI2CReqRead_T msgReq; // request message
181  BsI2CRspRead_T msgRsp; // response message
182  byte_t buf[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
183  bool_t bTrace; // do [not] trace messages
184  int n; // number of bytes/return code
185 
186  //
187  // Parameter checks.
188  //
189  BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
190  BS_ECODE_BAD_VAL, "VConn=%d", hndVConn);
191 
192  BSCLIENT_TRY_EXPR(pClient, (uReadLen <= (size_t)BSI2C_RSPREAD_READBUF_LEN),
193  BS_ECODE_BAD_VAL, "read_len=%zu > max_len=%zu",
194  uReadLen, (size_t)BSI2C_RSPREAD_READBUF_LEN);
195 
196  // trace state
197  bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
198 
199  //
200  // Set request message values.
201  //
202  msgReq.m_addr = (ushort_t)i2cAddr;
203  msgReq.m_readlen = (byte_t)uReadLen;
204 
205  //
206  // Pack request.
207  //
208  n = BsI2CPackReqRead(&msgReq, BSPROXY_BUF_BODY(buf), bTrace);
209 
210  // check packing return code
211  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdReq);
212 
213  //
214  // Execute request-response transaction.
215  //
216  n = bsClientTrans(pClient, hndVConn,
217  msgIdReq, buf, (size_t)n,
218  msgIdRsp, buf, sizeof(buf));
219 
220  // check transaction return code
221  BSCLIENT_TRY_ECODE(pClient, n, "MsgId=%u: Transaction failed.", msgIdReq);
222 
223  //
224  // Unpack response.
225  //
226  n = BsI2CUnpackRspRead(buf, (size_t)n, &msgRsp, bTrace);
227 
228  // check unpack return code
229  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdRsp);
230 
231  //
232  // Set return values from response.
233  //
234  if( uReadLen > msgRsp.m_readbuf.m_count )
235  {
236  uReadLen = msgRsp.m_readbuf.m_count;
237  }
238  memcpy(rbuf, msgRsp.m_readbuf.u.m_buf, uReadLen);
239 
240  return (int)uReadLen;
241 }
242 
243 /*!
244  * \brief Proxied request to write to a device attached to the \h_i2c bus.
245  *
246  * \param pClient \h_botsense client.
247  * \param hndVConn Handle to virtual connection to close.
248  * \param i2cAddr Address of attached device on the \h_i2c bus.
249  * \param [in] wbuf Write buffer.
250  * \param uWriteLen Number of bytes to write.
251  *
252  * \return
253  * Returns number of bytes written on success.\n
254  * \copydoc doc_return_ecode
255  */
257  BsVConnHnd_T hndVConn,
258  i2c_addr_t i2cAddr,
259  byte_t wbuf[],
260  size_t uWriteLen)
261 {
262  static BsI2CMsgId_T msgIdReq = BsI2CMsgIdReqWrite;
263  static BsI2CMsgId_T msgIdRsp = BsI2CMsgIdRspWrite;
264 
265  BsI2CReqWrite_T msgReq; // request message
266  BsI2CRspWrite_T msgRsp; // response message
267  byte_t buf[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
268  bool_t bTrace; // do [not] trace messages
269  int n; // number of bytes/return code
270 
271  //
272  // Parameter checks.
273  //
274  BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
275  BS_ECODE_BAD_VAL, "VConn=%d", hndVConn);
276 
277  BSCLIENT_TRY_EXPR(pClient,
278  (uWriteLen <= (size_t)BSI2C_REQWRITE_WRITEBUF_LEN), BS_ECODE_BAD_VAL,
279  "write_len=%zu > max_len=%zu",
280  uWriteLen, (size_t)BSI2C_REQWRITE_WRITEBUF_LEN);
281 
282  // trace state
283  bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
284 
285  //
286  // Set request message values.
287  //
288  msgReq.m_addr = (ushort_t)i2cAddr;
289  memcpy(msgReq.m_writebuf.u.m_buf, wbuf, uWriteLen);
290  msgReq.m_writebuf.m_count = uWriteLen;
291 
292  //
293  // Pack request.
294  //
295  n = BsI2CPackReqWrite(&msgReq, BSPROXY_BUF_BODY(buf), bTrace);
296 
297  // check packing return code
298  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdReq);
299 
300  //
301  // Execute request-response transaction.
302  //
303  n = bsClientTrans(pClient, hndVConn,
304  msgIdReq, buf, (size_t)n,
305  msgIdRsp, buf, sizeof(buf));
306 
307  // check transaction return code
308  BSCLIENT_TRY_ECODE(pClient, n, "MsgId=%u: Transaction failed.", msgIdReq);
309 
310  //
311  // Unpack response.
312  //
313  n = BsI2CUnpackRspWrite(buf, (size_t)n, &msgRsp, bTrace);
314 
315  // check unpack return code
316  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdRsp);
317 
318  //
319  // Set return values from response.
320  //
321  return (int)msgRsp.m_byteswritten;
322 }
323 
324 /*!
325  * \brief Proxied request to execute a write-read transaction to a device
326  * attached to the \h_i2c bus.
327  *
328  * \param pClient \h_botsense client.
329  * \param hndVConn Handle to virtual connection to close.
330  * \param i2cAddr Address of attached device on the \h_i2c bus.
331  * \param [in] wbuf Write buffer.
332  * \param uWriteLen Number of bytes to write.
333  * \param uReadLen Number of bytes to read.
334  * \param [out] rbuf Read buffer.
335  *
336  * \return
337  * Returns number of bytes read on success.\n
338  * \copydoc doc_return_ecode
339  */
341  BsVConnHnd_T hndVConn,
342  i2c_addr_t i2cAddr,
343  byte_t wbuf[],
344  size_t uWriteLen,
345  size_t uReadLen,
346  byte_t rbuf[])
347 {
348  static BsI2CMsgId_T msgIdReq = BsI2CMsgIdReqTrans;
349  static BsI2CMsgId_T msgIdRsp = BsI2CMsgIdRspRead;
350 
351  BsI2CReqTrans_T msgReq; // request message
352  BsI2CRspRead_T msgRsp; // response message
353  byte_t buf[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
354  bool_t bTrace; // do [not] trace messages
355  int n; // number of bytes/return code
356 
357  //
358  // Parameter checks.
359  //
360  BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
361  BS_ECODE_BAD_VAL, "VConn=%d", hndVConn);
362 
363  BSCLIENT_TRY_EXPR(pClient,
364  (uWriteLen <= (size_t)BSI2C_REQTRANS_WRITEBUF_LEN), BS_ECODE_BAD_VAL,
365  "write_len=%zu > max_len=%zu",
366  uWriteLen, (size_t)BSI2C_REQTRANS_WRITEBUF_LEN);
367 
368  BSCLIENT_TRY_EXPR(pClient, (uReadLen <= (size_t)BSI2C_RSPREAD_READBUF_LEN),
369  BS_ECODE_BAD_VAL, "read_len=%zu > max_len=%zu",
370  uReadLen, (size_t)BSI2C_RSPREAD_READBUF_LEN);
371 
372  // trace state
373  bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
374 
375  //
376  // Set request message values.
377  //
378  msgReq.m_addr = (ushort_t)i2cAddr;
379  memcpy(msgReq.m_writebuf.u.m_buf, wbuf, uWriteLen);
380  msgReq.m_writebuf.m_count = uWriteLen;
381  msgReq.m_readlen = (byte_t)uReadLen;
382 
383  //
384  // Pack request.
385  //
386  n = BsI2CPackReqTrans(&msgReq, BSPROXY_BUF_BODY(buf), bTrace);
387 
388  // check packing return code
389  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdReq);
390 
391  //
392  // Execute request-response server transaction.
393  //
394  n = bsClientTrans(pClient, hndVConn,
395  msgIdReq, buf, (size_t)n,
396  msgIdRsp, buf, sizeof(buf));
397 
398  // check transaction return code
399  BSCLIENT_TRY_ECODE(pClient, n, "MsgId=%u: Transaction failed.", msgIdReq);
400 
401  //
402  // Unpack response.
403  //
404  n = BsI2CUnpackRspRead(buf, (size_t)n, &msgRsp, bTrace);
405 
406  // check unpack return code
407  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdRsp);
408 
409  //
410  // Set return values from response.
411  //
412  if( uReadLen > msgRsp.m_readbuf.m_count )
413  {
414  uReadLen = msgRsp.m_readbuf.m_count;
415  }
416  memcpy(rbuf, msgRsp.m_readbuf.u.m_buf, uReadLen);
417 
418  return (int)uReadLen;
419 }
420 
421 /*!
422  * \brief Proxied request to scan the \h_i2c bus for all attached devices.
423  *
424  * \param pClient \h_botsense client.
425  * \param hndVConn Handle to virtual connection to close.
426  * \param [out] bufScan Scan buffer.
427  * \param sizeScanBuf Scan buffer size (maximum number of address elements).
428  *
429  * \return
430  * Returns number of devices discovered \h_ge 0 from scan on success.\n
431  * \copydoc doc_return_ecode
432  */
434  BsVConnHnd_T hndVConn,
435  i2c_addr_t bufScan[],
436  size_t sizeScanBuf)
437 {
438  static BsI2CMsgId_T msgIdReq = BsI2CMsgIdReqScan;
439  static BsI2CMsgId_T msgIdRsp = BsI2CMsgIdRspScan;
440 
441  BsI2CRspScan_T msgRsp; // response message
442  byte_t buf[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
443  bool_t bTrace; // do [not] trace messages
444  int i; // working index
445  int n; // number of bytes/return code
446 
447  //
448  // Parameter checks.
449  //
450  BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
451  BS_ECODE_BAD_VAL, "VConn=%d", hndVConn);
452 
453  // trace state
454  bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
455 
456  //
457  // Execute request-response transaction.
458  //
459  n = bsClientTrans(pClient, hndVConn,
460  msgIdReq, NULL, (size_t)0,
461  msgIdRsp, buf, sizeof(buf));
462 
463  // check transaction return code
464  BSCLIENT_TRY_ECODE(pClient, n, "MsgId=%u: Transaction failed.", msgIdReq);
465 
466  //
467  // Unpack response.
468  //
469  n = BsI2CUnpackRspScan(buf, (size_t)n, &msgRsp, bTrace);
470 
471  // check unpack return code
472  BSCLIENT_TRY_NM_ECODE(pClient, n, "MsgId=%u", msgIdRsp);
473 
474  //
475  // Set return values from response.
476  //
477  n = sizeScanBuf < (size_t)msgRsp.m_scan.m_count?
478  (int)sizeScanBuf: (int)msgRsp.m_scan.m_count;
479 
480  for(i=0; i<n; ++i)
481  {
482  bufScan[i] = (i2c_addr_t)msgRsp.m_scan.u.m_buf[i];
483  }
484 
485  return n;
486 }
RspRead.
Definition: bsI2CMsgs.h:42
int bsI2CReqWrite(BsClient_P pClient, BsVConnHnd_T hndVConn, i2c_addr_t i2cAddr, byte_t wbuf[], size_t uWriteLen)
Proxied request to write to a device attached to the I2C bus.
Definition: bsI2CClient.c:256
ushort_t m_addr
addr
Definition: bsI2CMsgs.h:134
struct BsI2CReqTrans_T::@0 m_writebuf
vector
int bsI2CReqTrans(BsClient_P pClient, BsVConnHnd_T hndVConn, i2c_addr_t i2cAddr, byte_t wbuf[], size_t uWriteLen, size_t uReadLen, byte_t rbuf[])
Proxied request to execute a write-read transaction to a device attached to the I2C bus...
Definition: bsI2CClient.c:340
#define BSCLIENT_TRY_ECODE(pClient, ecode, efmt,...)
Check if <b><i>BotSense</i></b> return value is not an error ( &lt; 0).
Definition: libBotSense.h:214
#define BS_ECODE_BAD_VAL
bad value
Definition: BotSense.h:77
size_t m_count
vector item count
Definition: bsI2CMsgs.h:175
union BsI2CReqWrite_T::@4::@5 u
aligned vector items
INLINE_IN_H int BsI2CPackReqTrans(BsI2CReqTrans_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsI2CReqTrans ITV message in big-endian byte order into the output buffer. ...
Definition: bsI2CMsgs.h:280
byte_t m_readlen
readlen
Definition: bsI2CMsgs.h:93
<b><i>BotSense</i></b> bsProxy client library I2C bus interface.
#define BS_I2C_SERVER_MOD
server plugin dll module
Definition: bsI2C.h:62
RspScan.
Definition: bsI2CMsgs.h:46
INLINE_IN_H int BsI2CPackReqWrite(BsI2CReqWrite_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsI2CReqWrite ITV message in big-endian byte order into the output buffer. ...
Definition: bsI2CMsgs.h:366
The Client Structure Type.
Definition: bsLibInternal.h:96
struct BsI2CReqWrite_T::@4 m_writebuf
vector
ushort_t m_addr
addr
Definition: bsI2CMsgs.h:65
ReqRead.
Definition: bsI2CMsgs.h:40
struct BsI2CRspRead_T::@2 m_readbuf
vector
size_t m_count
vector item count
Definition: bsI2CMsgs.h:85
BsI2CMsgId_T
Definition: bsI2CMsgs.h:37
INLINE_IN_H int BsI2CUnpackRspRead(byte_t buf[], size_t uMsgLen, BsI2CRspRead_T *pStruct, bool_t bTrace)
Unpack a BsI2CRspRead ITV message in big-endian byte order from the input buffer. ...
Definition: bsI2CMsgs.h:344
ReqTrans.
Definition: bsI2CMsgs.h:41
ushort_t m_addr
addr
Definition: bsI2CMsgs.h:82
BotSense bsProxy server - client raw I2C NetMsgs XML Definition.
<b><i>BotSense</i></b> client library declarations.
union BsI2CReqTrans_T::@0::@1 u
aligned vector items
RspWrite.
Definition: bsI2CMsgs.h:44
INLINE_IN_H int BsI2CPackReqRead(BsI2CReqRead_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsI2CReqRead ITV message in big-endian byte order into the output buffer.
Definition: bsI2CMsgs.h:237
<b><i>BotSense</i></b> client library information and callbacks to application-specific data...
Definition: libBotSense.h:86
INLINE_IN_H int BsI2CUnpackRspWrite(byte_t buf[], size_t uMsgLen, BsI2CRspWrite_T *pStruct, bool_t bTrace)
Unpack a BsI2CRspWrite ITV message in big-endian byte order from the input buffer.
Definition: bsI2CMsgs.h:430
ReqScan.
Definition: bsI2CMsgs.h:45
struct BsI2CRspScan_T::@6 m_scan
vector
size_t m_count
vector item count
Definition: bsI2CMsgs.h:111
byte_t m_byteswritten
byteswritten
Definition: bsI2CMsgs.h:157
ReqWrite.
Definition: bsI2CMsgs.h:43
#define BSCLIENT_TRY_EXPR(pClient, expr, ecode, efmt,...)
Check if expression evaluates to true.
Definition: libBotSense.h:259
size_t m_count
vector item count
Definition: bsI2CMsgs.h:137
byte_t m_readlen
readlen
Definition: bsI2CMsgs.h:66
int bsI2CReqOpen(BsClient_P pClient, const char *sDevName, bool_t bInitTrace)
Request proxy server to establish a virtual connection to an I2C bus device.
Definition: bsI2CClient.c:124
#define BSI2C_REQTRANS_WRITEBUF_LEN
Definition: bsI2CMsgs.h:75
int bsI2CReqScan(BsClient_P pClient, BsVConnHnd_T hndVConn, i2c_addr_t bufScan[], size_t sizeScanBuf)
Proxied request to scan the I2C bus for all attached devices.
Definition: bsI2CClient.c:433
const char * bsI2CGetMsgName(BsClient_P pClient, BsVConnHnd_T hndVConn, uint_t uMsgId)
Get the I2C message name.
Definition: bsI2CClient.c:101
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
Definition: BotSense.h:272
#define BSI2C_RSPREAD_READBUF_LEN
Definition: bsI2CMsgs.h:102
#define BSCLIENT_HAS_VCONN(pClient, hnd)
Tests if the handle is valid and there is an established virtual connection.
Definition: libBotSense.h:285
int bsI2CReqRead(BsClient_P pClient, BsVConnHnd_T hndVConn, i2c_addr_t i2cAddr, size_t uReadLen, byte_t rbuf[])
Proxied request to read from a device attached to the I2C bus.
Definition: bsI2CClient.c:171
#define BSI2C_REQWRITE_WRITEBUF_LEN
Definition: bsI2CMsgs.h:127
int bsI2CReqClose(BsClient_P pClient, BsVConnHnd_T hndVConn)
Request proxy server to close client&#39;s proxied I2C device vitual connection.
Definition: bsI2CClient.c:153
#define BSCLIENT_TRY_NM_ECODE(pClient, nmecode, efmt,...)
Check if NetMsgs (un)packing return value is not an error ( &lt; 0).
Definition: libBotSense.h:236
static BsClientAppInfo_T bsI2CAppInfo
<b><i>BotSense</i></b> client application information.
Definition: bsI2CClient.c:71
#define BSPROXY_MSG_MAX_LEN
total message maximum length
Definition: BotSense.h:259
const NMMsgDef_T * BsI2CLookupMsgDef(BsI2CMsgId_T eMsgId)
Look up the message definition associated with the message id.
Definition: bsI2CMsgs.c:509
union BsI2CRspScan_T::@6::@7 u
aligned vector items
union BsI2CRspRead_T::@2::@3 u
aligned vector items
INLINE_IN_H int BsI2CUnpackRspScan(byte_t buf[], size_t uMsgLen, BsI2CRspScan_T *pStruct, bool_t bTrace)
Unpack a BsI2CRspScan ITV message in big-endian byte order from the input buffer. ...
Definition: bsI2CMsgs.h:473
const char * app_name
application name
Definition: libBotSense.h:88
<b><i>BotSense</i></b> package top-level, unifying header declarations.
int BsVConnHnd_T
virtual connection handle type
Definition: BotSense.h:151