54 #include "rnr/rnrconfig.h" 56 #include "rnr/netmsgs.h" 74 .brief =
"Raw I2C Bus proxied device.",
77 .maintainer =
"RaodNarrows LLC",
78 .license =
"(C) 2010 RoadNarrows LLC. All rights reserved.",
105 const NMMsgDef_T *pMsgDef;
109 return pMsgDef!=NULL? pMsgDef->m_sMsgName:
"unknown";
125 const char *sDevName,
134 NULL, (
size_t)0, &bsI2CAppInfo, bInitTrace);
155 return bsServerReqCloseDev(pClient, hndVConn);
194 uReadLen, (
size_t)BSI2C_RSPREAD_READBUF_LEN);
197 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
202 msgReq.
m_addr = (ushort_t)i2cAddr;
216 n = bsClientTrans(pClient, hndVConn,
217 msgIdReq, buf, (
size_t)n,
218 msgIdRsp, buf,
sizeof(buf));
238 memcpy(rbuf, msgRsp.
m_readbuf.
u.m_buf, uReadLen);
240 return (
int)uReadLen;
279 "write_len=%zu > max_len=%zu",
280 uWriteLen, (
size_t)BSI2C_REQWRITE_WRITEBUF_LEN);
283 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
288 msgReq.
m_addr = (ushort_t)i2cAddr;
289 memcpy(msgReq.
m_writebuf.
u.m_buf, wbuf, uWriteLen);
303 n = bsClientTrans(pClient, hndVConn,
304 msgIdReq, buf, (
size_t)n,
305 msgIdRsp, buf,
sizeof(buf));
365 "write_len=%zu > max_len=%zu",
366 uWriteLen, (
size_t)BSI2C_REQTRANS_WRITEBUF_LEN);
370 uReadLen, (
size_t)BSI2C_RSPREAD_READBUF_LEN);
373 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
378 msgReq.
m_addr = (ushort_t)i2cAddr;
379 memcpy(msgReq.
m_writebuf.
u.m_buf, wbuf, uWriteLen);
394 n = bsClientTrans(pClient, hndVConn,
395 msgIdReq, buf, (
size_t)n,
396 msgIdRsp, buf,
sizeof(buf));
416 memcpy(rbuf, msgRsp.
m_readbuf.
u.m_buf, uReadLen);
418 return (
int)uReadLen;
435 i2c_addr_t bufScan[],
454 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
459 n = bsClientTrans(pClient, hndVConn,
460 msgIdReq, NULL, (
size_t)0,
461 msgIdRsp, buf,
sizeof(buf));
482 bufScan[i] = (i2c_addr_t)msgRsp.
m_scan.
u.m_buf[i];
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.
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...
#define BSCLIENT_TRY_ECODE(pClient, ecode, efmt,...)
Check if <b><i>BotSense</i></b> return value is not an error ( < 0).
#define BS_ECODE_BAD_VAL
bad value
size_t m_count
vector item count
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. ...
<b><i>BotSense</i></b> bsProxy client library I2C bus interface.
#define BS_I2C_SERVER_MOD
server plugin dll module
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. ...
The Client Structure Type.
struct BsI2CReqWrite_T::@4 m_writebuf
vector
struct BsI2CRspRead_T::@2 m_readbuf
vector
size_t m_count
vector item count
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. ...
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
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.
<b><i>BotSense</i></b> client library information and callbacks to application-specific data...
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.
struct BsI2CRspScan_T::@6 m_scan
vector
size_t m_count
vector item count
byte_t m_byteswritten
byteswritten
#define BSCLIENT_TRY_EXPR(pClient, expr, ecode, efmt,...)
Check if expression evaluates to true.
size_t m_count
vector item count
int bsI2CReqOpen(BsClient_P pClient, const char *sDevName, bool_t bInitTrace)
Request proxy server to establish a virtual connection to an I2C bus device.
#define BSI2C_REQTRANS_WRITEBUF_LEN
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.
const char * bsI2CGetMsgName(BsClient_P pClient, BsVConnHnd_T hndVConn, uint_t uMsgId)
Get the I2C message name.
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
#define BSI2C_RSPREAD_READBUF_LEN
#define BSCLIENT_HAS_VCONN(pClient, hnd)
Tests if the handle is valid and there is an established virtual connection.
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.
#define BSI2C_REQWRITE_WRITEBUF_LEN
int bsI2CReqClose(BsClient_P pClient, BsVConnHnd_T hndVConn)
Request proxy server to close client's proxied I2C device vitual connection.
#define BSCLIENT_TRY_NM_ECODE(pClient, nmecode, efmt,...)
Check if NetMsgs (un)packing return value is not an error ( < 0).
static BsClientAppInfo_T bsI2CAppInfo
<b><i>BotSense</i></b> client application information.
#define BSPROXY_MSG_MAX_LEN
total message maximum length
const NMMsgDef_T * BsI2CLookupMsgDef(BsI2CMsgId_T eMsgId)
Look up the message definition associated with the message id.
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. ...
const char * app_name
application name
<b><i>BotSense</i></b> package top-level, unifying header declarations.
int BsVConnHnd_T
virtual connection handle type