botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
bsSerialServer.c File Reference

BotSense bsProxy server plug-in DLL RS-232 serial device module. More...

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "rnr/rnrconfig.h"
#include "rnr/log.h"
#include "rnr/new.h"
#include "rnr/netmsgs.h"
#include "rnr/serdev.h"
#include "botsense/BotSense.h"
#include "botsense/libBotSense.h"
#include "botsense/bsProxyModIF.h"
#include "botsense/bsSerial.h"
#include "botsense/bsSerialMsgs.h"

Go to the source code of this file.

Classes

struct  BsModCtlBlk_T
 Module resource control block structure type. More...
 

Macros

#define BSMOD_MAX_HANDLES   8
 Maximum number of module supported simultaneous virtual connections.
 
#define BSMOD_T_READ   1000000
 default read time out (usec)
 
#define BSMOD_T_TRANS   2000000
 default transaction time out (usec)
 
#define BSMOD_T_WRITE   1000000
 default write time out (usec)
 

Functions

static BsModCtlBlk_TbsModCtlBlkNew (int fd, const char *sDevUri, BsSerialReqOpenArgs_T *pDevCfg, bool_t bTrace)
 Allocate a new resource control block. More...
 
static void bsModCtlBlkDelete (BsModCtlBlk_T *pCtlBlk)
 Delete an allocated resource control block. More...
 
static int bsModSerialReqRead (BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
 Service a serial read request. More...
 
static int bsModSerialReqWrite (BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
 Service a serial write request. More...
 
static int bsModSerialReqTrans (BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
 Service a serial write-read transaction request. More...
 
int bsModInit (const char *sModUri, const BsModProxyCb_T *pCallbacks)
 Initialize serial module. More...
 
void bsModExit ()
 Exit serial module. More...
 
int bsModOpen (BsVConnHnd_T hndVConn, bool_t bTrace, const char *sDevUri, byte_t argbuf[], size_t uArgSize)
 Open a serial device and associate with the given handle. More...
 
int bsModClose (BsVConnHnd_T hndVConn)
 Close the serial device and disassociate virtual connection handle. More...
 
int bsModRequest (BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
 Service a serial request. More...
 
int bsModTrace (BsVConnHnd_T hndVConn, bool_t bTrace)
 Enable/disable message tracing on handle. More...
 
const BsModInfo_TbsModInfo ()
 Query for the static module information. More...
 

Variables

static BsModInfo_T BsModInfo
 Module static information. More...
 
static const char * BsModUri
 module canonical name
 
static const BsModProxyCb_TBsModCallbacks
 module to bsProxy callbacks
 
static BsModRsrcTbl_TBsModRsrcTbl
 module resource table
 

Detailed Description

BotSense bsProxy server plug-in DLL RS-232 serial device module.

LastChangedDate
2010-08-20 11:36:38 -0600 (Fri, 20 Aug 2010)
Rev
568
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file bsSerialServer.c.

Function Documentation

int bsModClose ( BsVConnHnd_T  hndVConn)

Close the serial device and disassociate virtual connection handle.

The specific serial resources are freed.

Parameters
hndVConnVirtual connection handle.
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 650 of file bsSerialServer.c.

References BS_ECODE_INTERNAL, BS_ECODE_NO_VCONN, BS_OK, BSMOD_LOG_ERROR, BSMOD_RSRC_IS_INUSE, BSMOD_TRY_VCONN_HND_RANGE, bsModCtlBlkDelete(), BsModProxyCb_T::m_cbModRsrcRemove, and BsModCtlBlk_T::m_fd.

651 {
652  BsModCtlBlk_T *pCtlBlk;
653 
654  // check if handle is in valid range
655  BSMOD_TRY_VCONN_HND_RANGE(hndVConn);
656 
657  // check is resouce is in-use (i.e. opened)
658  if( !BSMOD_RSRC_IS_INUSE(BsModRsrcTbl, hndVConn) )
659  {
661  "Resources for virtual connection not found.");
662  return -BS_ECODE_NO_VCONN;
663  }
664 
665  // remove resource from module's resource table
667  hndVConn);
668 
669  if( pCtlBlk == NULL )
670  {
671  BSMOD_LOG_ERROR(hndVConn, BS_ECODE_INTERNAL, "No module resource found.");
672  return -BS_ECODE_INTERNAL;
673  }
674 
675  if( pCtlBlk->m_fd >= 0 )
676  {
677  SerDevClose(pCtlBlk->m_fd);
678  LOGDIAG2("VConn=%d: SerDevClose(fd=%d).", hndVConn, pCtlBlk->m_fd);
679  }
680 
681  bsModCtlBlkDelete(pCtlBlk);
682 
683  return BS_OK;
684 }
#define BSMOD_LOG_ERROR(hndVConn, ecode, efmt,...)
Log Interface Module Error.
Definition: bsProxyModIF.h:405
#define BSMOD_RSRC_IS_INUSE(pRsrcTbl, hndVConn)
Test if the resource table resource handle slot is in-use.
Definition: bsProxyModIF.h:169
Module resource control block structure type.
Definition: bsI2CServer.c:103
#define BS_OK
not an error, success
Definition: BotSense.h:66
static void bsModCtlBlkDelete(BsModCtlBlk_T *pCtlBlk)
Delete an allocated resource control block.
#define BSMOD_TRY_VCONN_HND_RANGE(hndVConn)
Check if handle is within the range of module handles.
Definition: bsProxyModIF.h:499
void *(* m_cbModRsrcRemove)(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn)
Remove a resource from the resource table.
Definition: bsProxyModIF.h:320
#define BS_ECODE_INTERNAL
internal error (bug)
Definition: BotSense.h:93
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int m_fd
/dev/null open file descriptor
Definition: bsNullServer.c:109
static void bsModCtlBlkDelete ( BsModCtlBlk_T pCtlBlk)
static

Delete an allocated resource control block.

Parameters
pCtlBlkPointer to allocated control block.

Definition at line 153 of file bsSerialServer.c.

References BsModCtlBlk_T::m_sDevUri.

Referenced by bsModClose(), and bsModExit().

154 {
155  if( pCtlBlk != NULL )
156  {
157  delete((void *)(pCtlBlk->m_sDevUri));
158  delete(pCtlBlk);
159  }
160 }
const char * m_sDevUri
I2C device path name.
Definition: bsI2CServer.c:107
static BsModCtlBlk_T* bsModCtlBlkNew ( int  fd,
const char *  sDevUri,
BsSerialReqOpenArgs_T pDevCfg,
bool_t  bTrace 
)
static

Allocate a new resource control block.

Parameters
fdOpened device file descriptor ≥ 0.
sDevUriDevice URI.
pDevCfgDevice configuration parameters.
bTraceDo [not] trace messages.
Returns
Pointer to new allocated control block.

Definition at line 131 of file bsSerialServer.c.

References BsModCtlBlk_T::m_bTrace, BsModCtlBlk_T::m_fd, BsModCtlBlk_T::m_sDevUri, and BsModCtlBlk_T::m_stDevCfg.

Referenced by bsModOpen().

135 {
136  BsModCtlBlk_T *pCtlBlk;
137 
138  pCtlBlk = NEW(BsModCtlBlk_T);
139 
140  pCtlBlk->m_fd = fd;
141  pCtlBlk->m_sDevUri = new_strdup(sDevUri);
142  pCtlBlk->m_stDevCfg = *pDevCfg;
143  pCtlBlk->m_bTrace = bTrace;
144 
145  return pCtlBlk;
146 }
Module resource control block structure type.
Definition: bsI2CServer.c:103
bool_t m_bTrace
do [not] trace messages
Definition: bsI2CServer.c:108
const char * m_sDevUri
I2C device path name.
Definition: bsI2CServer.c:107
BsSerialReqOpenArgs_T m_stDevCfg
serial device configuration
int m_fd
/dev/null open file descriptor
Definition: bsNullServer.c:109
void bsModExit ( )

Exit serial module.

Called once prior to module being unloaded.

All open serial devices will be closed.

Definition at line 520 of file bsSerialServer.c.

References BSMOD_MAX_HANDLES, bsModCtlBlkDelete(), BsModUri, BsModProxyCb_T::m_cbModRsrcTblDelete, BsModCtlBlk_T::m_fd, and BsModRsrcTbl_T::m_vecRsrc.

521 {
522  int index;
523  BsModCtlBlk_T *pCtlBlk;
524 
525  // free all module virtual connnection resources.
526  for(index=0; index<BSMOD_MAX_HANDLES; ++index)
527  {
528  if( (pCtlBlk = (BsModCtlBlk_T *)BsModRsrcTbl->m_vecRsrc[index]) != NULL )
529  {
530  if( pCtlBlk->m_fd >= 0 )
531  {
532  SerDevClose(pCtlBlk->m_fd);
533  }
534  bsModCtlBlkDelete(pCtlBlk);
535  }
536  }
537 
538  // free resource table
540 
541  delete((char *)BsModUri);
542 }
static const char * BsModUri
module canonical name
void(* m_cbModRsrcTblDelete)(BsModRsrcTbl_T *pRsrcTbl)
Delete an allocated resource table.
Definition: bsProxyModIF.h:294
Module resource control block structure type.
Definition: bsI2CServer.c:103
static void bsModCtlBlkDelete(BsModCtlBlk_T *pCtlBlk)
Delete an allocated resource control block.
#define BSMOD_MAX_HANDLES
Maximum number of module supported simultaneous virtual connections.
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
void ** m_vecRsrc
vecRsrc[index] -> rsrc
Definition: bsProxyModIF.h:139
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int m_fd
/dev/null open file descriptor
Definition: bsNullServer.c:109
const BsModInfo_T* bsModInfo ( )

Query for the static module information.

Returns
Pointer to module static information.

Definition at line 783 of file bsSerialServer.c.

References BsModInfo.

784 {
785  return &BsModInfo;
786 }
static BsModInfo_T BsModInfo
Module static information.
int bsModInit ( const char *  sModUri,
const BsModProxyCb_T pCallbacks 
)

Initialize serial module.

Called once after module is loaded.

Parameters
sModUriExpanded, canonical module path name.
pCallbacksPointer to a set of module -> bsProxy core callback functions.
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 500 of file bsSerialServer.c.

References BS_OK, BSMOD_MAX_HANDLES, BsModUri, and BsModProxyCb_T::m_cbModRsrcTblNew.

501 {
502  BsModUri = new_strdup(sModUri);
503 
504  // save bsProxy server callbacks
505  BsModCallbacks = pCallbacks;
506 
507  // create module resource table
509 
510  return BS_OK;
511 }
static const char * BsModUri
module canonical name
#define BS_OK
not an error, success
Definition: BotSense.h:66
#define BSMOD_MAX_HANDLES
Maximum number of module supported simultaneous virtual connections.
BsModRsrcTbl_T *(* m_cbModRsrcTblNew)(int nMaxResources)
Allocatae a new module resource table of fixed size.
Definition: bsProxyModIF.h:284
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int bsModOpen ( BsVConnHnd_T  hndVConn,
bool_t  bTrace,
const char *  sDevUri,
byte_t  argbuf[],
size_t  uArgSize 
)

Open a serial device and associate with the given handle.

Subsequent calls to the module use the given handle to associate the specific module-device instance.

The argument buffer contains packed message arguements specific to the device and module.

Note
Each call to this exported function will open the serial device and set the appropriate configuration, even if the device is already opened by this or another module.
It is the responsibile of the client to ensure consistency if more than one virtual connection is established.
Parameters
hndVConnVirtual connection handle.
bTraceDo [not] enable message tracing on this handle.
sDevUriDevice URI.
argbufPacked specific open configuration arguments submessage.
uArgSizeSize of packed argumets in buffer (number of bytes).
Returns
On success, returns a unique resource descriptor ≥ 0 which is typically an opened file descriptor or socket descriptor, but can be module defined.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 572 of file bsSerialServer.c.

References BS_ECODE_BAD_MSG, BS_ECODE_BUSY, BS_ECODE_NO_RSRC, BS_ECODE_SYS, BSMOD_LOG_ERROR, BSMOD_LOG_NMERROR, BSMOD_LOG_SYSERROR, BSMOD_MAX_HANDLES, BSMOD_RSRC_INUSE_COUNT, BSMOD_RSRC_IS_INUSE, BSMOD_TRY_VCONN_HND_RANGE, bsModCtlBlkNew(), BsSerialUnpackReqOpenArgs(), BsSerialReqOpenArgs_T::m_baudrate, BsSerialReqOpenArgs_T::m_bytesize, BsModProxyCb_T::m_cbModRsrcAdd, BsSerialReqOpenArgs_T::m_parity, BsSerialReqOpenArgs_T::m_rtscts, BsSerialReqOpenArgs_T::m_stopbits, and BsSerialReqOpenArgs_T::m_xonxoff.

577 {
578  BsModCtlBlk_T *pCtlBlk;
579  BsSerialReqOpenArgs_T devcfg;
580  int fd;
581  int rc;
582 
583  // Check if handle is in valid range.
584  BSMOD_TRY_VCONN_HND_RANGE(hndVConn);
585 
586  // Check if resources are available.
588  {
590  "InUseCount=%u: No more resources available.",
592  return -BS_ECODE_NO_RSRC;
593  }
594 
595  // Check if the resource in resource table is not already in-use.
596  else if( BSMOD_RSRC_IS_INUSE(BsModRsrcTbl, hndVConn) )
597  {
598  BSMOD_LOG_ERROR(hndVConn, BS_ECODE_BUSY,
599  "Module virtual connection handle already in use");
600  return -BS_ECODE_BUSY;
601  }
602 
603  // unpack device configuration arguments submessage
604  rc = BsSerialUnpackReqOpenArgs(argbuf, uArgSize, &devcfg, bTrace);
605 
606  if( rc < 0 )
607  {
608  BSMOD_LOG_NMERROR(hndVConn, rc,
609  "Unpacking failed on BsSerialReqOpenArgs submessage");
610  return -BS_ECODE_BAD_MSG;
611  }
612 
613  // open serial device
614  fd = SerDevOpen(sDevUri, (int)devcfg.m_baudrate, (int)devcfg.m_bytesize,
615  (int)devcfg.m_parity, (int)devcfg.m_stopbits,
616  devcfg.m_rtscts, devcfg.m_xonxoff);
617 
618  if( fd < 0 )
619  {
620  BSMOD_LOG_SYSERROR(hndVConn, "SerDevOpen(%s,...).", sDevUri);
621  return -BS_ECODE_SYS;
622  }
623 
624  // allocate a new control block and initialize
625  pCtlBlk = bsModCtlBlkNew(fd, sDevUri, &devcfg, bTrace);
626 
627  // add to module resource table
628  BsModCallbacks->m_cbModRsrcAdd(BsModRsrcTbl, hndVConn, pCtlBlk);
629 
630  LOGDIAG2("VConn=%d: %d=SerDevOpen(dev=%s, %d,%d,%c,%d, rts=%s, xon=%s).",
631  hndVConn, fd, sDevUri,
632  (int)devcfg.m_baudrate, (int)devcfg.m_bytesize,
633  devcfg.m_parity, (int)devcfg.m_stopbits,
634  (devcfg.m_rtscts? "true": "false"),
635  (devcfg.m_xonxoff? "true": "false"));
636 
637  return fd;
638 }
#define BSMOD_LOG_ERROR(hndVConn, ecode, efmt,...)
Log Interface Module Error.
Definition: bsProxyModIF.h:405
#define BSMOD_LOG_NMERROR(hndVConn, nmecode, efmt,...)
Log Interface Module NetMsgs (Un)Packing Error.
Definition: bsProxyModIF.h:419
#define BSMOD_RSRC_IS_INUSE(pRsrcTbl, hndVConn)
Test if the resource table resource handle slot is in-use.
Definition: bsProxyModIF.h:169
bool_t m_xonxoff
xonxoff
Definition: bsSerialMsgs.h:67
bool_t m_rtscts
rtscts
Definition: bsSerialMsgs.h:66
#define BSMOD_LOG_SYSERROR(hndVConn, efmt,...)
Log Interface Module System Error.
Definition: bsProxyModIF.h:431
char m_parity
parity
Definition: bsSerialMsgs.h:64
Module resource control block structure type.
Definition: bsI2CServer.c:103
byte_t m_bytesize
bytesize
Definition: bsSerialMsgs.h:63
uint_t m_baudrate
baudrate
Definition: bsSerialMsgs.h:62
int(* m_cbModRsrcAdd)(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn, void *pRsrc)
Add a new resource to the resource table.
Definition: bsProxyModIF.h:305
#define BS_ECODE_SYS
system (errno) error
Definition: BotSense.h:92
#define BSMOD_TRY_VCONN_HND_RANGE(hndVConn)
Check if handle is within the range of module handles.
Definition: bsProxyModIF.h:499
#define BS_ECODE_BAD_MSG
bad message
Definition: BotSense.h:76
#define BSMOD_RSRC_INUSE_COUNT(pRsrcTbl)
Get the resouce table current in-use count.
Definition: bsProxyModIF.h:208
#define BS_ECODE_NO_RSRC
no resource available
Definition: BotSense.h:85
#define BSMOD_MAX_HANDLES
Maximum number of module supported simultaneous virtual connections.
INLINE_IN_H int BsSerialUnpackReqOpenArgs(byte_t buf[], size_t uMsgLen, BsSerialReqOpenArgs_T *pStruct, bool_t bTrace)
Unpack a BsSerialReqOpenArgs ITV message in big-endian byte order from the input buffer.
Definition: bsSerialMsgs.h:245
byte_t m_stopbits
stopbits
Definition: bsSerialMsgs.h:65
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
static BsModCtlBlk_T * bsModCtlBlkNew(int fd, const char *sDevUri, BsSerialReqOpenArgs_T *pDevCfg, bool_t bTrace)
Allocate a new resource control block.
#define BS_ECODE_BUSY
resource busy
Definition: BotSense.h:86
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int bsModRequest ( BsVConnHnd_T  hndVConn,
BsTid_T  uTid,
BsMsgId_T  uMsgIdReq,
byte_t  bufReq[],
size_t  uReqLen 
)

Service a serial request.

Note
A module-specific request service must send a response.
Parameters
hndVConnVirtual connection handle.
uTidRequest-Response transaction id.
uMsgIdReqRequest message id.
bufReqPacked request message buffer.
uReqLenSize of request in buffer (number of bytes).
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 699 of file bsSerialServer.c.

References BS_ECODE_BAD_VCONN_HND, BS_ECODE_NO_VCONN, BS_ECODE_UNKNOWN_REQ, BSMOD_IS_VCONN_HANDLE, BSMOD_RSRC, BSMOD_SEND_ERROR_RSP, bsModSerialReqRead(), bsModSerialReqTrans(), bsModSerialReqWrite(), BsSerialMsgIdReqRead, BsSerialMsgIdReqTrans, and BsSerialMsgIdReqWrite.

704 {
705  BsModCtlBlk_T *pCtlBlk;
706 
707  // check if handle is in valid range
708  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
709  {
711  "Module vconn handle out-of-range.");
712  return -BS_ECODE_BAD_VCONN_HND; \
713  }
714 
715  // retrieve resource control block
716  pCtlBlk = (BsModCtlBlk_T *)BSMOD_RSRC(BsModRsrcTbl, hndVConn);
717 
718  // check resource
719  if( pCtlBlk == NULL )
720  {
722  "No resources for virtual connection found.");
723  return -BS_ECODE_NO_VCONN;
724  }
725 
726  switch( uMsgIdReq )
727  {
729  return bsModSerialReqRead(hndVConn, uTid, uMsgIdReq, bufReq, uReqLen);
731  return bsModSerialReqTrans(hndVConn, uTid, uMsgIdReq, bufReq, uReqLen);
733  return bsModSerialReqWrite(hndVConn, uTid, uMsgIdReq, bufReq, uReqLen);
734  default:
736  "MsgId=%u.", uMsgIdReq);
737  return -BS_ECODE_UNKNOWN_REQ;
738  }
739 }
#define BS_ECODE_UNKNOWN_REQ
unknown request
Definition: BotSense.h:81
static int bsModSerialReqRead(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
Service a serial read request.
Module resource control block structure type.
Definition: bsI2CServer.c:103
#define BSMOD_IS_VCONN_HANDLE(hndVConn)
Test if the handle is in the valid module virtual connection range.
Definition: bsProxyModIF.h:149
static int bsModSerialReqTrans(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
Service a serial write-read transaction request.
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
Definition: BotSense.h:79
static int bsModSerialReqWrite(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
Service a serial write request.
#define BSMOD_RSRC(pRsrcTbl, hndVConn)
Get the resource given the handle.
Definition: bsProxyModIF.h:196
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80
#define BSMOD_SEND_ERROR_RSP(pCb, hndVConn, uTid, ecode, efmt,...)
Log <b><i>BotSense</i></b> Error and Send Error Response.
Definition: bsProxyModIF.h:447
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
static int bsModSerialReqRead ( BsVConnHnd_T  hndVConn,
BsTid_T  uTid,
BsMsgId_T  uMsgIdReq,
byte_t  bufReq[],
size_t  uReqLen 
)
static

Service a serial read request.

Note
A module-specific request service must send a response.
Parameters
hndVConnVirtual connection handle.
uTidRequest-Response transaction id.
uMsgIdReqRequest message id.
bufReqPacked request message buffer.
uReqLenSize of request in buffer (number of bytes).
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 175 of file bsSerialServer.c.

References BS_ECODE_BAD_MSG, BS_ECODE_BAD_VCONN_HND, BS_ECODE_NO_VCONN, BS_ECODE_SYS, BS_OK, BSMOD_IS_VCONN_HANDLE, BSMOD_RSRC, BSMOD_SEND_ERROR_RSP, BSMOD_SEND_NMERROR_RSP, BSMOD_SEND_SYSERROR_RSP, BSMOD_T_READ, BSPROXY_BUF_BODY, BSPROXY_MSG_MAX_LEN, BsSerialMsgIdRspRead, BsSerialPackRspRead(), BsSerialUnpackReqRead(), BsModCtlBlk_T::m_bTrace, BsModProxyCb_T::m_cbSendRsp, BsSerialRspRead_T::m_count, BsModCtlBlk_T::m_fd, BsSerialRspRead_T::m_readbuf, BsSerialReqRead_T::m_readlen, and BsSerialRspRead_T::u.

Referenced by bsModRequest().

180 {
181  static BsSerialMsgId_T uMsgIdRsp = BsSerialMsgIdRspRead;
182 
183  BsModCtlBlk_T *pCtlBlk; // resource control block
184  BsSerialReqRead_T msgReq; // request message
185  BsSerialRspRead_T msgRsp; // response message
186  byte_t bufRsp[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
187  int n; // number of bytes/return code
188 
189  //
190  // Parameter checks
191  //
192  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
193  {
195  "Module vconn handle out-of-range.");
196  return -BS_ECODE_BAD_VCONN_HND; \
197  }
198 
199  // retrieve the resource control block
200  pCtlBlk = (BsModCtlBlk_T *)BSMOD_RSRC(BsModRsrcTbl, hndVConn);
201 
202  if( pCtlBlk == NULL )
203  {
205  "No resources for virtual connection found.");
206  return -BS_ECODE_NO_VCONN;
207  }
208 
209  //
210  // Unpack client request.
211  //
212  n = BsSerialUnpackReqRead(bufReq, uReqLen, &msgReq, pCtlBlk->m_bTrace);
213 
214  // check unpacking return code
215  if( n < 0 )
216  {
217  BSMOD_SEND_NMERROR_RSP(BsModCallbacks, hndVConn, uTid, n,
218  "MsgId=%u", uMsgIdReq);
219  return -BS_ECODE_BAD_MSG;
220  }
221 
222  //
223  // Execute client request.
224  //
225  n = (int)SerDevRead(pCtlBlk->m_fd, msgRsp.m_readbuf.u.m_buf,
226  (size_t)msgReq.m_readlen, BSMOD_T_READ);
227 
228  // check operation return code
229  if( n < 0 )
230  {
231  BSMOD_SEND_SYSERROR_RSP(BsModCallbacks, hndVConn, uTid,
232  "SerDevRead(%d,...).", pCtlBlk->m_fd);
233  return -BS_ECODE_SYS;
234  }
235 
236  LOGDIAG3("VConn=%d: %d=SerDevRead(fd=%d, buf=%p, count=%zu, usec=%u).",
237  hndVConn, n, pCtlBlk->m_fd, msgRsp.m_readbuf.u.m_buf,
238  (size_t)msgReq.m_readlen, BSMOD_T_READ);
239 
240  //
241  // Pack server response.
242  //
243  msgRsp.m_readbuf.m_count = (byte_t)n;
244 
245  // pack
246  n = BsSerialPackRspRead(&msgRsp, BSPROXY_BUF_BODY(bufRsp), pCtlBlk->m_bTrace);
247 
248  // check packing return code
249  if( n < 0 )
250  {
251  BSMOD_SEND_NMERROR_RSP(BsModCallbacks, hndVConn, uTid, n,
252  "MsgId=%u", uMsgIdRsp);
253  return -BS_ECODE_BAD_MSG;
254  }
255 
256  //
257  // Send response.
258  //
259  BsModCallbacks->m_cbSendRsp(hndVConn, uTid, uMsgIdRsp, bufRsp, (size_t)n);
260 
261  return BS_OK;
262 }
INLINE_IN_H int BsSerialUnpackReqRead(byte_t buf[], size_t uMsgLen, BsSerialReqRead_T *pStruct, bool_t bTrace)
Unpack a BsSerialReqRead ITV message in big-endian byte order from the input buffer.
Definition: bsSerialMsgs.h:288
byte_t m_readlen
readlen
Definition: bsSerialMsgs.h:80
union BsSerialRspRead_T::@16::@17 u
aligned vector items
#define BSMOD_T_READ
default read time out (usec)
INLINE_IN_H int BsSerialPackRspRead(BsSerialRspRead_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsSerialRspRead ITV message in big-endian byte order into the output buffer.
Definition: bsSerialMsgs.h:353
size_t m_count
vector item count
Definition: bsSerialMsgs.h:124
BsSerialMsgId_T
Definition: bsSerialMsgs.h:35
Module resource control block structure type.
Definition: bsI2CServer.c:103
bool_t m_bTrace
do [not] trace messages
Definition: bsI2CServer.c:108
#define BSMOD_IS_VCONN_HANDLE(hndVConn)
Test if the handle is in the valid module virtual connection range.
Definition: bsProxyModIF.h:149
#define BS_OK
not an error, success
Definition: BotSense.h:66
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
Definition: BotSense.h:79
#define BS_ECODE_SYS
system (errno) error
Definition: BotSense.h:92
#define BS_ECODE_BAD_MSG
bad message
Definition: BotSense.h:76
void(* m_cbSendRsp)(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufRsp[], size_t uRspLen)
Send module-specific repsonse callback function.
Definition: bsProxyModIF.h:246
#define BSMOD_RSRC(pRsrcTbl, hndVConn)
Get the resource given the handle.
Definition: bsProxyModIF.h:196
#define BSMOD_SEND_NMERROR_RSP(pCb, hndVConn, uTid, nmecode, efmt,...)
Log NetMsgs (Un)Packing Error and Send Error Response.
Definition: bsProxyModIF.h:464
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
Definition: BotSense.h:272
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80
#define BSMOD_SEND_SYSERROR_RSP(pCb, hndVConn, uTid, efmt,...)
Log System Error and Send Error Response.
Definition: bsProxyModIF.h:481
#define BSPROXY_MSG_MAX_LEN
total message maximum length
Definition: BotSense.h:259
#define BSMOD_SEND_ERROR_RSP(pCb, hndVConn, uTid, ecode, efmt,...)
Log <b><i>BotSense</i></b> Error and Send Error Response.
Definition: bsProxyModIF.h:447
struct BsSerialRspRead_T::@16 m_readbuf
vector
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int m_fd
/dev/null open file descriptor
Definition: bsNullServer.c:109
static int bsModSerialReqTrans ( BsVConnHnd_T  hndVConn,
BsTid_T  uTid,
BsMsgId_T  uMsgIdReq,
byte_t  bufReq[],
size_t  uReqLen 
)
static

Service a serial write-read transaction request.

Note
A module-specific request service must send a response.
Parameters
hndVConnVirtual connection handle.
uTidRequest-Response transaction id.
uMsgIdReqRequest message id.
bufReqPacked request message buffer.
uReqLenSize of request in buffer (number of bytes).
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 380 of file bsSerialServer.c.

References BS_ECODE_BAD_MSG, BS_ECODE_BAD_VCONN_HND, BS_ECODE_NO_VCONN, BS_ECODE_SYS, BS_OK, BSMOD_IS_VCONN_HANDLE, BSMOD_RSRC, BSMOD_SEND_ERROR_RSP, BSMOD_SEND_NMERROR_RSP, BSMOD_SEND_SYSERROR_RSP, BSMOD_T_READ, BSMOD_T_WRITE, BSPROXY_BUF_BODY, BSPROXY_MSG_MAX_LEN, BsSerialMsgIdRspRead, BsSerialPackRspRead(), BsSerialUnpackReqTrans(), BsModCtlBlk_T::m_bTrace, BsModProxyCb_T::m_cbSendRsp, BsSerialReqTrans_T::m_count, BsSerialRspRead_T::m_count, BsModCtlBlk_T::m_fd, BsSerialRspRead_T::m_readbuf, BsSerialReqTrans_T::m_readlen, BsSerialReqTrans_T::m_writebuf, BsSerialReqTrans_T::u, and BsSerialRspRead_T::u.

Referenced by bsModRequest().

385 {
386  static BsSerialMsgId_T uMsgIdRsp = BsSerialMsgIdRspRead;
387 
388  BsModCtlBlk_T *pCtlBlk; // resource control block
389  BsSerialReqTrans_T msgReq; // request message
390  BsSerialRspRead_T msgRsp; // response message
391  byte_t bufRsp[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
392  int n; // number of bytes/return code
393 
394  //
395  // Parameter checks
396  //
397  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
398  {
400  "Module vconn handle out-of-range.");
401  return -BS_ECODE_BAD_VCONN_HND; \
402  }
403 
404  // retrieve the resource control block
405  pCtlBlk = (BsModCtlBlk_T *)BSMOD_RSRC(BsModRsrcTbl, hndVConn);
406 
407  if( pCtlBlk == NULL )
408  {
410  "No resources for virtual connection found.");
411  return -BS_ECODE_NO_VCONN;
412  }
413 
414  //
415  // Unpack client request.
416  //
417  n = BsSerialUnpackReqTrans(bufReq, uReqLen, &msgReq, pCtlBlk->m_bTrace);
418 
419  // check unpacking return code
420  if( n < 0 )
421  {
422  BSMOD_SEND_NMERROR_RSP(BsModCallbacks, hndVConn, uTid, n,
423  "MsgId=%u", uMsgIdReq);
424  return -BS_ECODE_BAD_MSG;
425  }
426 
427  //
428  // Execute client request.
429  //
430  n = (int)SerDevWrite(pCtlBlk->m_fd, msgReq.m_writebuf.u.m_buf,
431  (size_t)msgReq.m_writebuf.m_count, BSMOD_T_WRITE);
432 
433  // check operation return code
434  if( n < 0 )
435  {
436  BSMOD_SEND_SYSERROR_RSP(BsModCallbacks, hndVConn, uTid,
437  "SerDevWrite(%d,...).", pCtlBlk->m_fd);
438  return -BS_ECODE_SYS;
439  }
440 
441  LOGDIAG3("VConn=%d: %d=SerDevWrite(fd=%d, buf=%p, count=%zu, usec=%u).",
442  hndVConn, n, pCtlBlk->m_fd, msgReq.m_writebuf.u.m_buf,
443  (size_t)msgReq.m_writebuf.m_count, BSMOD_T_WRITE);
444 
445  n = (int)SerDevRead(pCtlBlk->m_fd, msgRsp.m_readbuf.u.m_buf,
446  (size_t)msgReq.m_readlen, BSMOD_T_READ);
447 
448  // check operation return code
449  if( n < 0 )
450  {
451  BSMOD_SEND_SYSERROR_RSP(BsModCallbacks, hndVConn, uTid,
452  "SerDevRead(%d,...).", pCtlBlk->m_fd);
453  return -BS_ECODE_SYS;
454  }
455 
456  LOGDIAG3("VConn=%d: %d=SerDevRead(fd=%d, buf=%p, count=%zu, usec=%u)).",
457  hndVConn, n, pCtlBlk->m_fd, msgRsp.m_readbuf.u.m_buf,
458  (size_t)msgReq.m_readlen, BSMOD_T_READ);
459 
460  //
461  // Pack server response.
462  //
463  msgRsp.m_readbuf.m_count = (byte_t)n;
464 
465  // pack
466  n = BsSerialPackRspRead(&msgRsp, BSPROXY_BUF_BODY(bufRsp), pCtlBlk->m_bTrace);
467 
468  // check packing return code
469  if( n < 0 )
470  {
471  BSMOD_SEND_NMERROR_RSP(BsModCallbacks, hndVConn, uTid, n,
472  "MsgId=%u", uMsgIdRsp);
473  return -BS_ECODE_BAD_MSG;
474  }
475 
476  //
477  // Send response.
478  //
479  BsModCallbacks->m_cbSendRsp(hndVConn, uTid, uMsgIdRsp, bufRsp, (size_t)n);
480 
481  return BS_OK;
482 }
#define BSMOD_T_WRITE
default write time out (usec)
union BsSerialRspRead_T::@16::@17 u
aligned vector items
#define BSMOD_T_READ
default read time out (usec)
INLINE_IN_H int BsSerialPackRspRead(BsSerialRspRead_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsSerialRspRead ITV message in big-endian byte order into the output buffer.
Definition: bsSerialMsgs.h:353
size_t m_count
vector item count
Definition: bsSerialMsgs.h:124
BsSerialMsgId_T
Definition: bsSerialMsgs.h:35
Module resource control block structure type.
Definition: bsI2CServer.c:103
bool_t m_bTrace
do [not] trace messages
Definition: bsI2CServer.c:108
#define BSMOD_IS_VCONN_HANDLE(hndVConn)
Test if the handle is in the valid module virtual connection range.
Definition: bsProxyModIF.h:149
union BsSerialReqTrans_T::@14::@15 u
aligned vector items
#define BS_OK
not an error, success
Definition: BotSense.h:66
byte_t m_readlen
readlen
Definition: bsSerialMsgs.h:106
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
Definition: BotSense.h:79
struct BsSerialReqTrans_T::@14 m_writebuf
vector
#define BS_ECODE_SYS
system (errno) error
Definition: BotSense.h:92
#define BS_ECODE_BAD_MSG
bad message
Definition: BotSense.h:76
void(* m_cbSendRsp)(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufRsp[], size_t uRspLen)
Send module-specific repsonse callback function.
Definition: bsProxyModIF.h:246
#define BSMOD_RSRC(pRsrcTbl, hndVConn)
Get the resource given the handle.
Definition: bsProxyModIF.h:196
size_t m_count
vector item count
Definition: bsSerialMsgs.h:98
#define BSMOD_SEND_NMERROR_RSP(pCb, hndVConn, uTid, nmecode, efmt,...)
Log NetMsgs (Un)Packing Error and Send Error Response.
Definition: bsProxyModIF.h:464
INLINE_IN_H int BsSerialUnpackReqTrans(byte_t buf[], size_t uMsgLen, BsSerialReqTrans_T *pStruct, bool_t bTrace)
Unpack a BsSerialReqTrans ITV message in big-endian byte order from the input buffer.
Definition: bsSerialMsgs.h:331
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
Definition: BotSense.h:272
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80
#define BSMOD_SEND_SYSERROR_RSP(pCb, hndVConn, uTid, efmt,...)
Log System Error and Send Error Response.
Definition: bsProxyModIF.h:481
#define BSPROXY_MSG_MAX_LEN
total message maximum length
Definition: BotSense.h:259
#define BSMOD_SEND_ERROR_RSP(pCb, hndVConn, uTid, ecode, efmt,...)
Log <b><i>BotSense</i></b> Error and Send Error Response.
Definition: bsProxyModIF.h:447
struct BsSerialRspRead_T::@16 m_readbuf
vector
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int m_fd
/dev/null open file descriptor
Definition: bsNullServer.c:109
static int bsModSerialReqWrite ( BsVConnHnd_T  hndVConn,
BsTid_T  uTid,
BsMsgId_T  uMsgIdReq,
byte_t  bufReq[],
size_t  uReqLen 
)
static

Service a serial write request.

Note
A module-specific request service must send a response.
Parameters
hndVConnVirtual connection handle.
uTidRequest-Response transaction id.
uMsgIdReqRequest message id.
bufReqPacked request message buffer.
uReqLenSize of request in buffer (number of bytes).
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 277 of file bsSerialServer.c.

References BS_ECODE_BAD_MSG, BS_ECODE_BAD_VCONN_HND, BS_ECODE_NO_VCONN, BS_ECODE_SYS, BS_OK, BSMOD_IS_VCONN_HANDLE, BSMOD_RSRC, BSMOD_SEND_ERROR_RSP, BSMOD_SEND_NMERROR_RSP, BSMOD_SEND_SYSERROR_RSP, BSMOD_T_WRITE, BSPROXY_BUF_BODY, BSPROXY_MSG_MAX_LEN, BsSerialMsgIdRspWrite, BsSerialPackRspWrite(), BsSerialUnpackReqWrite(), BsModCtlBlk_T::m_bTrace, BsSerialRspWrite_T::m_byteswritten, BsModProxyCb_T::m_cbSendRsp, BsSerialReqWrite_T::m_count, BsModCtlBlk_T::m_fd, BsSerialReqWrite_T::m_writebuf, and BsSerialReqWrite_T::u.

Referenced by bsModRequest().

282 {
283  static BsSerialMsgId_T uMsgIdRsp = BsSerialMsgIdRspWrite;
284 
285  BsModCtlBlk_T *pCtlBlk; // resource control block
286  BsSerialReqWrite_T msgReq; // request message
287  BsSerialRspWrite_T msgRsp; // response message
288  byte_t bufRsp[BSPROXY_MSG_MAX_LEN]; // req/rsp buffer
289  int n; // number of bytes/return code
290 
291  //
292  // Parameter checks
293  //
294  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
295  {
297  "Module vconn handle out-of-range.");
298  return -BS_ECODE_BAD_VCONN_HND; \
299  }
300 
301  // retrieve the resource control block
302  pCtlBlk = (BsModCtlBlk_T *)BSMOD_RSRC(BsModRsrcTbl, hndVConn);
303 
304  if( pCtlBlk == NULL )
305  {
307  "No resources for virtual connection found.");
308  return -BS_ECODE_NO_VCONN;
309  }
310 
311  //
312  // Unpack client request.
313  //
314  n = BsSerialUnpackReqWrite(bufReq, uReqLen, &msgReq, pCtlBlk->m_bTrace);
315 
316  // check unpacking return code
317  if( n < 0 )
318  {
319  BSMOD_SEND_NMERROR_RSP(BsModCallbacks, hndVConn, uTid, n,
320  "MsgId=%u", uMsgIdReq);
321  return -BS_ECODE_BAD_MSG;
322  }
323 
324  //
325  // Execute client request.
326  //
327  n = (int)SerDevWrite(pCtlBlk->m_fd, msgReq.m_writebuf.u.m_buf,
328  (size_t)msgReq.m_writebuf.m_count, BSMOD_T_WRITE);
329 
330  // check operation return code
331  if( n < 0 )
332  {
333  BSMOD_SEND_SYSERROR_RSP(BsModCallbacks, hndVConn, uTid,
334  "SerDevWrite(%d,...).", pCtlBlk->m_fd);
335  return -BS_ECODE_SYS;
336  }
337 
338  LOGDIAG3("VConn=%d: %d=SerDevWrite(fd=%d, buf=%p, count=%zu, usec=%u).",
339  hndVConn, n, pCtlBlk->m_fd, msgReq.m_writebuf.u.m_buf,
340  (size_t)msgReq.m_writebuf.m_count, BSMOD_T_WRITE);
341 
342  //
343  // Pack server response.
344  //
345  msgRsp.m_byteswritten = (byte_t)n;
346 
347  // pack
348  n = BsSerialPackRspWrite(&msgRsp, BSPROXY_BUF_BODY(bufRsp),
349  pCtlBlk->m_bTrace);
350 
351  // check packing return code
352  if( n < 0 )
353  {
354  BSMOD_SEND_NMERROR_RSP(BsModCallbacks, hndVConn, uTid, n,
355  "MsgId=%u", uMsgIdRsp);
356  return -BS_ECODE_BAD_MSG;
357  }
358 
359  //
360  // Send response.
361  //
362  BsModCallbacks->m_cbSendRsp(hndVConn, uTid, uMsgIdRsp, bufRsp, (size_t)n);
363 
364  return BS_OK;
365 }
union BsSerialReqWrite_T::@18::@19 u
aligned vector items
#define BSMOD_T_WRITE
default write time out (usec)
struct BsSerialReqWrite_T::@18 m_writebuf
vector
BsSerialMsgId_T
Definition: bsSerialMsgs.h:35
Module resource control block structure type.
Definition: bsI2CServer.c:103
bool_t m_bTrace
do [not] trace messages
Definition: bsI2CServer.c:108
#define BSMOD_IS_VCONN_HANDLE(hndVConn)
Test if the handle is in the valid module virtual connection range.
Definition: bsProxyModIF.h:149
#define BS_OK
not an error, success
Definition: BotSense.h:66
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
Definition: BotSense.h:79
#define BS_ECODE_SYS
system (errno) error
Definition: BotSense.h:92
INLINE_IN_H int BsSerialUnpackReqWrite(byte_t buf[], size_t uMsgLen, BsSerialReqWrite_T *pStruct, bool_t bTrace)
Unpack a BsSerialReqWrite ITV message in big-endian byte order from the input buffer.
Definition: bsSerialMsgs.h:417
#define BS_ECODE_BAD_MSG
bad message
Definition: BotSense.h:76
void(* m_cbSendRsp)(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufRsp[], size_t uRspLen)
Send module-specific repsonse callback function.
Definition: bsProxyModIF.h:246
#define BSMOD_RSRC(pRsrcTbl, hndVConn)
Get the resource given the handle.
Definition: bsProxyModIF.h:196
size_t m_count
vector item count
Definition: bsSerialMsgs.h:149
#define BSMOD_SEND_NMERROR_RSP(pCb, hndVConn, uTid, nmecode, efmt,...)
Log NetMsgs (Un)Packing Error and Send Error Response.
Definition: bsProxyModIF.h:464
byte_t m_byteswritten
byteswritten
Definition: bsSerialMsgs.h:169
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
Definition: BotSense.h:272
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80
INLINE_IN_H int BsSerialPackRspWrite(BsSerialRspWrite_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsSerialRspWrite ITV message in big-endian byte order into the output buffer.
Definition: bsSerialMsgs.h:439
#define BSMOD_SEND_SYSERROR_RSP(pCb, hndVConn, uTid, efmt,...)
Log System Error and Send Error Response.
Definition: bsProxyModIF.h:481
#define BSPROXY_MSG_MAX_LEN
total message maximum length
Definition: BotSense.h:259
#define BSMOD_SEND_ERROR_RSP(pCb, hndVConn, uTid, ecode, efmt,...)
Log <b><i>BotSense</i></b> Error and Send Error Response.
Definition: bsProxyModIF.h:447
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
int m_fd
/dev/null open file descriptor
Definition: bsNullServer.c:109
int bsModTrace ( BsVConnHnd_T  hndVConn,
bool_t  bTrace 
)

Enable/disable message tracing on handle.

Parameters
hndVConnVirtual connection handle.
bTraceDo [not] enable message tracing on this handle.
Returns
On success, BS_OK is returned.
On error, the appropriate < 0 negated BotSense Error Code is returned.

Definition at line 749 of file bsSerialServer.c.

References BS_ECODE_BAD_VCONN_HND, BS_ECODE_NO_VCONN, BS_OK, BSMOD_IS_VCONN_HANDLE, BSMOD_LOG_ERROR, BSMOD_RSRC, and BsModCtlBlk_T::m_bTrace.

750 {
751  BsModCtlBlk_T *pCtlBlk;
752 
753  // check if handle is in valid range
754  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
755  {
757  "Module vconn handle out-of-range.");
758  return -BS_ECODE_BAD_VCONN_HND;
759  }
760 
761  // retrieve resource control block
762  pCtlBlk = (BsModCtlBlk_T *)BSMOD_RSRC(BsModRsrcTbl, hndVConn);
763 
764  // check resource
765  if( pCtlBlk == NULL )
766  {
768  "No resources for virtual connection found.");
769  return -BS_ECODE_NO_VCONN;
770  }
771 
772  pCtlBlk->m_bTrace = bTrace;
773 
774  return BS_OK;
775 }
#define BSMOD_LOG_ERROR(hndVConn, ecode, efmt,...)
Log Interface Module Error.
Definition: bsProxyModIF.h:405
Module resource control block structure type.
Definition: bsI2CServer.c:103
bool_t m_bTrace
do [not] trace messages
Definition: bsI2CServer.c:108
#define BSMOD_IS_VCONN_HANDLE(hndVConn)
Test if the handle is in the valid module virtual connection range.
Definition: bsProxyModIF.h:149
#define BS_OK
not an error, success
Definition: BotSense.h:66
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
Definition: BotSense.h:79
#define BSMOD_RSRC(pRsrcTbl, hndVConn)
Get the resource given the handle.
Definition: bsProxyModIF.h:196
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80

Variable Documentation

BsModInfo_T BsModInfo
static
Initial value:
=
{
.mod_name = BS_SER_SERVER_MOD,
.brief = "Raw R2-232 serial proxied device.",
.version = "2.0.0",
.date = "2010.03.09",
.maintainer = "RaodNarrows LLC",
.license = "(C) 2010 RoadNarrows LLC. All rights reserved."
}
#define BS_SER_SERVER_MOD
server plugin dll module
Definition: bsSerial.h:66

Module static information.

Definition at line 72 of file bsSerialServer.c.

Referenced by bsModInfo().