![]() |
botsense
3.2.0
RoadNarrows Client-Server Proxied Services Framework
|
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_T * | bsModCtlBlkNew (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_T * | bsModInfo () |
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_T * | BsModCallbacks |
module to bsProxy callbacks | |
static BsModRsrcTbl_T * | BsModRsrcTbl |
module resource table | |
BotSense bsProxy server plug-in DLL RS-232 serial device module.
Definition in file bsSerialServer.c.
int bsModClose | ( | BsVConnHnd_T | hndVConn | ) |
Close the serial device and disassociate virtual connection handle.
The specific serial resources are freed.
hndVConn | Virtual connection handle. |
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.
|
static |
Delete an allocated resource control block.
pCtlBlk | Pointer to allocated control block. |
Definition at line 153 of file bsSerialServer.c.
References BsModCtlBlk_T::m_sDevUri.
Referenced by bsModClose(), and bsModExit().
|
static |
Allocate a new resource control block.
fd | Opened device file descriptor ≥ 0. |
sDevUri | Device URI. |
pDevCfg | Device configuration parameters. |
bTrace | Do [not] trace messages. |
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().
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.
const BsModInfo_T* bsModInfo | ( | ) |
Query for the static module information.
Definition at line 783 of file bsSerialServer.c.
References BsModInfo.
int bsModInit | ( | const char * | sModUri, |
const BsModProxyCb_T * | pCallbacks | ||
) |
Initialize serial module.
Called once after module is loaded.
sModUri | Expanded, canonical module path name. |
pCallbacks | Pointer to a set of module -> bsProxy core callback functions. |
Definition at line 500 of file bsSerialServer.c.
References BS_OK, BSMOD_MAX_HANDLES, BsModUri, and BsModProxyCb_T::m_cbModRsrcTblNew.
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.
hndVConn | Virtual connection handle. |
bTrace | Do [not] enable message tracing on this handle. |
sDevUri | Device URI. |
argbuf | Packed specific open configuration arguments submessage. |
uArgSize | Size of packed argumets in buffer (number of bytes). |
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.
int bsModRequest | ( | BsVConnHnd_T | hndVConn, |
BsTid_T | uTid, | ||
BsMsgId_T | uMsgIdReq, | ||
byte_t | bufReq[], | ||
size_t | uReqLen | ||
) |
Service a serial request.
hndVConn | Virtual connection handle. |
uTid | Request-Response transaction id. |
uMsgIdReq | Request message id. |
bufReq | Packed request message buffer. |
uReqLen | Size of request in buffer (number of bytes). |
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.
|
static |
Service a serial read request.
hndVConn | Virtual connection handle. |
uTid | Request-Response transaction id. |
uMsgIdReq | Request message id. |
bufReq | Packed request message buffer. |
uReqLen | Size of request in buffer (number of bytes). |
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().
|
static |
Service a serial write-read transaction request.
hndVConn | Virtual connection handle. |
uTid | Request-Response transaction id. |
uMsgIdReq | Request message id. |
bufReq | Packed request message buffer. |
uReqLen | Size of request in buffer (number of bytes). |
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().
|
static |
Service a serial write request.
hndVConn | Virtual connection handle. |
uTid | Request-Response transaction id. |
uMsgIdReq | Request message id. |
bufReq | Packed request message buffer. |
uReqLen | Size of request in buffer (number of bytes). |
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().
int bsModTrace | ( | BsVConnHnd_T | hndVConn, |
bool_t | bTrace | ||
) |
Enable/disable message tracing on handle.
hndVConn | Virtual connection handle. |
bTrace | Do [not] enable message tracing on this handle. |
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.
|
static |
Module static information.
Definition at line 72 of file bsSerialServer.c.
Referenced by bsModInfo().