b-CAP client library More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <arpa/inet.h>#include <netinet/in.h>#include <netdb.h>#include <fcntl.h>#include <termios.h>#include "denso_ros_control/b-Cap.h"
Go to the source code of this file.
Classes | |
| struct | BCAP_ARG |
| BCAP_ARG. More... | |
| struct | BCAP_PACKET |
| BCAP_PACKET. More... | |
Macros | |
| #define | __LITTLE_ENDIAN__ |
| #define | BCAP_EOT 0x04 /* size of packet terminater(EOT) */ |
| #define | BCAP_FUNC_Controller_Connect 3 |
| #define | BCAP_FUNC_Controller_Disconnect 4 |
| #define | BCAP_FUNC_Controller_Execute 17 |
| #define | BCAP_FUNC_Controller_GetRobot 7 |
| #define | BCAP_FUNC_Controller_GetTask 8 |
| #define | BCAP_FUNC_Controller_GetVariable 9 |
| #define | BCAP_FUNC_Robot_Change 66 |
| #define | BCAP_FUNC_Robot_Execute 64 |
| #define | BCAP_FUNC_Robot_GetVariable 62 |
| #define | BCAP_FUNC_Robot_Move 72 |
| #define | BCAP_FUNC_Robot_Release 84 |
| #define | BCAP_FUNC_Service_Start 1 |
| #define | BCAP_FUNC_Service_Stop 2 |
| #define | BCAP_FUNC_Task_GetVariable 85 |
| #define | BCAP_FUNC_Task_Release 99 |
| #define | BCAP_FUNC_Task_Start 88 |
| #define | BCAP_FUNC_Task_Stop 89 |
| #define | BCAP_FUNC_Variable_GetValue 101 |
| #define | BCAP_FUNC_Variable_PutValue 102 |
| #define | BCAP_FUNC_Variable_PutValue 102 |
| #define | BCAP_FUNC_Variable_Release 111 |
| #define | BCAP_MAX_ARG_SIZE 0x1000000 /* max arg size (bytes) */ |
| #define | BCAP_MAX_PACKET_SIZE 0x1000000 /* max packet size (bytes) */ |
| #define | BCAP_SIZE_ARGARRAYS 4 /* size of arrays */ |
| #define | BCAP_SIZE_ARGBASE (BCAP_SIZE_ARGLEN+BCAP_SIZE_ARGTYPE+BCAP_SIZE_ARGARRAYS) |
| #define | BCAP_SIZE_ARGLEN 4 /* size of length */ |
| #define | BCAP_SIZE_ARGNUM 2 /* size of Args */ |
| #define | BCAP_SIZE_ARGSTRLEN 4 /* size of string length */ |
| #define | BCAP_SIZE_ARGTYPE 2 /* size of type */ |
| #define | BCAP_SIZE_BASE |
| #define | BCAP_SIZE_CRC 2 /* size of CRC */ |
| #define | BCAP_SIZE_EOT 1 /* size of terminater(EOT) */ |
| #define | BCAP_SIZE_FUNCID 4 /* size of FunctionID */ |
| #define | BCAP_SIZE_LEN 4 /* size of message size */ |
| #define | BCAP_SIZE_RESERVE 2 /* size of reserved */ |
| #define | BCAP_SIZE_SERIAL 2 /* size of serial number */ |
| #define | BCAP_SIZE_SOH 1 /* size of header(SOH) */ |
| #define | BCAP_SOH 0x01 /* size of packet header(SOH) */ |
| #define | DebugPrint(message) |
| #define | DebugPrint2(f, a, b) |
| #define | LOCALBUFFER_SZ 1024 |
| #define | LOCALRECBUFFER_SZ 1024 |
Typedefs | |
| typedef struct BCAP_ARG | BCAP_ARG |
| typedef struct BCAP_PACKET | BCAP_PACKET |
Functions | |
| static BCAP_ARG * | Arg_Create (u_short iType, u_int lArrays, u_int lLength, void *data) |
| static void | Arg_Release (BCAP_ARG *pArg) |
| BCAP_HRESULT | bCap_Close (int iSockFd) |
| BCAP_HRESULT | bCap_ControllerConnect (int iSockFd, char *pStrCtrlname, char *pStrProvName, char *pStrPcName, char *pStrOption, u_int *plhController) |
| BCAP_HRESULT | bCap_ControllerDisconnect (int iSockFd, u_int lhController) |
| BCAP_HRESULT | bCap_ControllerExecute (int iSockFd, u_int lhController, char *pStrCommand, char *pStrOption, void *pResult) |
| BCAP_HRESULT | bCap_ControllerExecute2 (int iSockFd, u_int lhController, char *pStrCommand, BCAP_VARIANT *pVntOption, BCAP_VARIANT *pVntResult) |
| BCAP_HRESULT | bCap_ControllerGetRobot (int iSockFd, u_int lhController, char *pStrRobotName, char *pStrOption, u_int *plhRobot) |
| BCAP_HRESULT | bCap_ControllerGetTask (int iSockFd, u_int lhController, char *pTskName, char *pstrOption, u_int *plhVar) |
| BCAP_HRESULT | bCap_ControllerGetVariable (int iSockFd, u_int lhController, char *pVarName, char *pstrOption, u_int *plhVar) |
| BCAP_HRESULT | bCap_Open (const char *pIPStr, int iPort, int *iSockFd) |
| BCAP_HRESULT | bCap_RobotChange (int iSockFd, u_int lhRobot, char *pStrCommand) |
| BCAP_HRESULT | bCap_RobotExecute (int iSockFd, u_int lhRobot, char *pStrCommand, char *pStrOption, void *pResult) |
| BCAP_HRESULT | bCap_RobotExecute2 (int iSockFd, u_int lhRobot, char *pStrCommand, BCAP_VARIANT *pVntOption, BCAP_VARIANT *pVntResult) |
| BCAP_HRESULT | bCap_RobotExecuteSlaveMove (int iSockFd, u_int lhRobot, char *pStrCommand, float *pfOption, void *pResult) |
| BCAP_HRESULT | bCap_RobotGetVariable (int iSockFd, u_int lhRobot, char *pVarName, char *pstrOption, u_int *plhVar) |
| BCAP_HRESULT | bCap_RobotMove (int iSockFd, u_int lhRobot, long lComp, char *pStrPose, char *pStrOption) |
| BCAP_HRESULT | bCap_RobotRelease (int iSockFd, u_int lhRobot) |
| BCAP_HRESULT | bCap_ServiceStart (int iSockFd) |
| BCAP_HRESULT | bCap_ServiceStop (int iSockFd) |
| BCAP_HRESULT | bCap_TaskGetVariable (int iSockFd, u_int lhTask, char *pVarName, char *pstrOption, u_int *plhVar) |
| BCAP_HRESULT | bCap_TaskRelease (int iSockFd, u_int lhTask) |
| BCAP_HRESULT | bCap_TaskStart (int iSockFd, u_int lhTask, long lMode, char *pStrOption) |
| BCAP_HRESULT | bCap_TaskStop (int iSockFd, u_int lhTask, long lMode, char *pStrOption) |
| BCAP_HRESULT | bCap_VariableGetValue (int iSockFd, u_int lhVar, void *pVntValue) |
| BCAP_HRESULT | bCap_VariablePutValue (int iSockFd, u_int lhVar, u_short iType, u_int lArrays, void *pVntValue) |
| BCAP_HRESULT | bCap_VariableRelease (int iSockFd, u_int lhVar) |
| static BCAP_HRESULT | bCapSendAndRec (int iSockFd, BCAP_PACKET *pSndPacket, BCAP_PACKET *pRecPacket) |
| static void | bFree (void *pPtr) |
| static void * | bMalloc (size_t size) |
| static u_int | copyFromBSTR (void *pDstAsciiPtr, void *pSrcBstrPtr) |
| static u_int | copyToBSTR (void *pbDstPtr, void *pbSrcPtr) |
| static u_int | copyValue (void *pDst, void *pVntValue, u_int lLength) |
| static u_int | copyVariantFromArg (BCAP_VARIANT *pVntDst, BCAP_ARG *pArg) |
| static BCAP_HRESULT | Packet_AddArg (BCAP_PACKET *pPacket, BCAP_ARG *pNewArg) |
| static BCAP_PACKET * | Packet_Create (u_int lFuncID) |
| static BCAP_HRESULT | Packet_Deserialize (void *pBinData, BCAP_PACKET *pPacket) |
| static BCAP_ARG ** | Packet_GetLastArgHandle (BCAP_PACKET *pPacket) |
| static BCAP_HRESULT | Packet_GetResult (BCAP_PACKET *pRecPacket, void *pResult) |
| static void | Packet_Release (BCAP_PACKET *pPacket) |
| static BCAP_HRESULT | Packet_Send (int iSd, BCAP_PACKET *pPacket) |
| static BCAP_HRESULT | Packet_Serialize (BCAP_PACKET *pPacket, void *pBinData) |
| static u_char * | receivePacket (int iSockFd, int *retryp) |
| static BCAP_HRESULT | sendBinary (int iSockFd, u_char *pBuff, u_int lSize) |
| static u_int | sizeOfVariant (BCAP_VARIANT vntValue) |
| static u_int | sizeOfVarType (u_short iType) |
Variables | |
| int | failed_to_send_packet = 0 |
| static u_short | m_iSerialNo = 1 |
| static long | m_lAllocCount = 0 |
| static long | m_lAllocSize = 0 |
| #define BCAP_MAX_ARG_SIZE 0x1000000 /* max arg size (bytes) */ |
| #define BCAP_MAX_PACKET_SIZE 0x1000000 /* max packet size (bytes) */ |
| #define BCAP_SIZE_ARGBASE (BCAP_SIZE_ARGLEN+BCAP_SIZE_ARGTYPE+BCAP_SIZE_ARGARRAYS) |
| #define BCAP_SIZE_BASE |
| typedef struct BCAP_PACKET BCAP_PACKET |
Arg_Create
Create and allocate b-Cap argument structure
@param iType : [in] Variable type
@param lArrays : [in] Arrays
@param lDataSize : [in] total byte of ( "*data" )
@param *data : [in] value pointer
@retval allocated pointer is returned
@detail Note:When BSTR is used, *data must be store "Length:4byte" + "DoubleByte String"
See alose function CopyToBSTR().
|
static |
| BCAP_HRESULT bCap_Close | ( | int | iSockFd | ) |
| BCAP_HRESULT bCap_ControllerConnect | ( | int | iSockFd, |
| char * | pStrCtrlname, | ||
| char * | pStrProvName, | ||
| char * | pStrPcName, | ||
| char * | pStrOption, | ||
| u_int * | plhController | ||
| ) |
Controller_Connect
Controller_Connect
@param iSockFd : [in] Socket descriptor @param pStrCtrlname : [in] CtrlName in AsciiZ @param pStrProvName : [in] ProvName in AsciiZ @param pStrPcName : [in] PCName in AsciiZ @param pStrOption : [in] Option string in AsciiZ @param plhController : [out] handle of the controller that returned from the robot controller. @retval BCAP_HRESULT
| BCAP_HRESULT bCap_ControllerDisconnect | ( | int | iSockFd, |
| u_int | lhController | ||
| ) |
| BCAP_HRESULT bCap_ControllerExecute | ( | int | iSockFd, |
| u_int | lhController, | ||
| char * | pStrCommand, | ||
| char * | pStrOption, | ||
| void * | pResult | ||
| ) |
Controller_Execute
Controller_Execute
@param iSockFd : [in] Socket descriptor
@param lhController : [in] controller handle
@param pStrCommand : [in] command string in AsciiZ
@param pstrOption : [in] option string in AsciiZ
@param *pResult : [out] value stored pointer
@retval BCAP_HRESULT
@detail Note: This function write value into *pResult,
So, Client program must allocate enough memory as *pResult.
| BCAP_HRESULT bCap_ControllerExecute2 | ( | int | iSockFd, |
| u_int | lhController, | ||
| char * | pStrCommand, | ||
| BCAP_VARIANT * | pVntOption, | ||
| BCAP_VARIANT * | pVntResult | ||
| ) |
Controller_Execute
Controller_Execute with a variant option
@param iSockFd : [in] Socket descriptor @param lhController : [in] controller handle @param pStrCommand : [in] command string in AsciiZ @param iOption : [in] option value in Integer(VT_I2) @param plResult : [out] result value @retval BCAP_HRESULT
| BCAP_HRESULT bCap_ControllerGetRobot | ( | int | iSockFd, |
| u_int | lhController, | ||
| char * | pStrRobotName, | ||
| char * | pStrOption, | ||
| u_int * | plhRobot | ||
| ) |
Controller_GetRobot
Controller_GetRobot
@param iSockFd : [in] Socket descriptor @param lhController : [in] controller handle @param pStrRobotName : [in] Robot name string in AsciiZ @param pStrOption : [in] Option string in AsciiZ @param lhRobot : [out] robot handle @retval BCAP_HRESULT
| BCAP_HRESULT bCap_ControllerGetTask | ( | int | iSockFd, |
| u_int | lhController, | ||
| char * | pTskName, | ||
| char * | pstrOption, | ||
| u_int * | plhVar | ||
| ) |
Controller_GetTask
Controller_GetTask
@param iSockFd : [in] Socket descriptor @param lhController : [in] controller handle @param pTskName : [in] task name string in AsciiZ @param pstrOption : [in] option string in AsciiZ @param plhVar : [out] task handle @retval BCAP_HRESULT
| BCAP_HRESULT bCap_ControllerGetVariable | ( | int | iSockFd, |
| u_int | lhController, | ||
| char * | pVarName, | ||
| char * | pstrOption, | ||
| u_int * | plhVar | ||
| ) |
Controller_GetVariable
Controller_GetVariable
@param iSockFd : [in] Socket descriptor @param lhController : [in] controller handle @param pVarName : [in] Variable name string in AsciiZ @param pstrOption : [in] Option string in AsciiZ @param plhVar : [out] variable handle @retval BCAP_HRESULT
| BCAP_HRESULT bCap_Open | ( | const char * | pIPStr, |
| int | iPort, | ||
| int * | iSockFd | ||
| ) |
| BCAP_HRESULT bCap_RobotChange | ( | int | iSockFd, |
| u_int | lhRobot, | ||
| char * | pStrCommand | ||
| ) |
| BCAP_HRESULT bCap_RobotExecute | ( | int | iSockFd, |
| u_int | lhRobot, | ||
| char * | pStrCommand, | ||
| char * | pStrOption, | ||
| void * | pResult | ||
| ) |
Robot_Execute
Robot_Execute
@param iSockFd : [in] Socket descriptor
@param lhRobot : [in] robot handle
@param pStrCommand : [in] command string in AsciiZ
@param pstrOption : [in] option string in AsciiZ
@param *pResult : [out] value stored pointer
@retval BCAP_HRESULT
@detail Note: This function write value into *pResult,
So, Client program must allocate enough memory as *pResult.
| BCAP_HRESULT bCap_RobotExecute2 | ( | int | iSockFd, |
| u_int | lhRobot, | ||
| char * | pStrCommand, | ||
| BCAP_VARIANT * | pVntOption, | ||
| BCAP_VARIANT * | pVntResult | ||
| ) |
Robot_Execute
Robot_Execute with a variant option
@param iSockFd : [in] Socket descriptor @param lhRobot : [in] robot handle @param pStrCommand : [in] command string in AsciiZ @param iOption : [in] option value in Integer(VT_I2) @param plResult : [out] result value @retval BCAP_HRESULT
| BCAP_HRESULT bCap_RobotExecuteSlaveMove | ( | int | iSockFd, |
| u_int | lhRobot, | ||
| char * | pStrCommand, | ||
| float * | pfOption, | ||
| void * | pResult | ||
| ) |
Robot_Execute for SlaveMove
Robot_Execute
@param iSockFd : [in] Socket descriptor
@param lhRobot : [in] robot handle
@param pStrCommand : [in] command string in AsciiZ
@param pstrOption : [in] option string in AsciiZ
@param *pResult : [out] value stored pointer
@retval BCAP_HRESULT
@detail Note: This function write value into *pResult,
So, Client program must allocate enough memory as *pResult.
| BCAP_HRESULT bCap_RobotGetVariable | ( | int | iSockFd, |
| u_int | lhRobot, | ||
| char * | pVarName, | ||
| char * | pstrOption, | ||
| u_int * | plhVar | ||
| ) |
Robot_GetVariable
Robot_GetVariable
@param iSockFd : [in] Socket descriptor @param lhRobot : [in] robot handle @param pVarName : [in] Variable name string in AsciiZ @param pstrOption : [in] Option string in AsciiZ @param plhVar : [out] result value = variable handle @retval BCAP_HRESULT
| BCAP_HRESULT bCap_RobotMove | ( | int | iSockFd, |
| u_int | lhRobot, | ||
| long | lComp, | ||
| char * | pStrPose, | ||
| char * | pStrOption | ||
| ) |
| BCAP_HRESULT bCap_RobotRelease | ( | int | iSockFd, |
| u_int | lhRobot | ||
| ) |
| BCAP_HRESULT bCap_ServiceStart | ( | int | iSockFd | ) |
| BCAP_HRESULT bCap_ServiceStop | ( | int | iSockFd | ) |
| BCAP_HRESULT bCap_TaskGetVariable | ( | int | iSockFd, |
| u_int | lhTask, | ||
| char * | pVarName, | ||
| char * | pstrOption, | ||
| u_int * | plhVar | ||
| ) |
Task_GetVariable
Task_GetVariable
@param iSockFd : [in] Socket descriptor @param lhTask : [in] task handle @param pVarName : [in] Variable name string in AsciiZ @param pstrOption : [in] Option string in AsciiZ @param plhVar : [out] result value = variable handle @retval BCAP_HRESULT
| BCAP_HRESULT bCap_TaskRelease | ( | int | iSockFd, |
| u_int | lhTask | ||
| ) |
| BCAP_HRESULT bCap_TaskStart | ( | int | iSockFd, |
| u_int | lhTask, | ||
| long | lMode, | ||
| char * | pStrOption | ||
| ) |
| BCAP_HRESULT bCap_TaskStop | ( | int | iSockFd, |
| u_int | lhTask, | ||
| long | lMode, | ||
| char * | pStrOption | ||
| ) |
| BCAP_HRESULT bCap_VariableGetValue | ( | int | iSockFd, |
| u_int | lhVar, | ||
| void * | pVntValue | ||
| ) |
Variable_GetValue
Variable_GetValue
@param iSockFd : [in] Socket descriptor
@param lhVar : [in] robot handle
@param *pVntValue : [out] value stored pointer
@retval BCAP_HRESULT
@detail Note: This function write value into *pVntValue,
So, Client program must allocate enough memory as *pVntValue.
| BCAP_HRESULT bCap_VariablePutValue | ( | int | iSockFd, |
| u_int | lhVar, | ||
| u_short | iType, | ||
| u_int | lArrays, | ||
| void * | pVntValue | ||
| ) |
| BCAP_HRESULT bCap_VariableRelease | ( | int | iSockFd, |
| u_int | lhVar | ||
| ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Deserialize from byte array into packet.
Change from byte arrays into struct.
@param *pSrcBinData : [in] Byte pointer to send.
@param *pDstPacket : [out] packet pointer to store
@retval BCAP_HRESULT is returned.
@detail bin ---> struct
Note: If something wrong, then release this packet and included args.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Receive bCap Packet
Receive bCap Packet from server
@retval u_char pointer storing recieved packet
@detail Note: If valid pointer is returned, this function allocate memory for sotring packet.
Never forget to free() the pointer.
And If NULL pointer is returned , then was allocation error/
|
static |
Send bCap Packet
Send bCap Packet to server
@param pRecPacket : [out] Received packet pointer
@retval u_char pointer storing recieved packet
Note: If valid pointer is returned, this function allocate memory for sotring packet.
Never forget to free() the pointer.
And If NULL pointer is returned , then was allocation error/
|
static |
get size of Variant
get size of Variant
| BCAP_VARIANT | : [in] Variant Value |
| size | of Variant(bytes) Note 1: If (iType = VT_BSTR), then this function returns BCAP_SIZE_ARGSTRLEN (= 4 bytes) Note 2: Not support VT_VARIANT,VT_EMPTY,VT_NULL,VT_ERROR,VT_CY,VT_DATE |
get size of variable
get size of variable
| iType | : [in] Variable type |
| size | of variable. Note 1: If (iType = VT_BSTR), then this function returns BCAP_SIZE_ARGSTRLEN (= 4 bytes) Note 2: Not support VT_VARIANT,VT_EMPTY,VT_NULL,VT_ERROR,VT_CY,VT_DATE |
| int failed_to_send_packet = 0 |