Mar. 14. 2018

Dependencies:   GraphicsFramework GR-PEACH_video LCD_shield_config AsciiFont R_BSP USBHost_custom

Committer:
dkato
Date:
Tue Sep 05 10:01:51 2017 +0000
Revision:
5:49a61433290a
Parent:
HVCApi/HVCApi.c@4:55e0d1f4e55a
Add HVC sensing result stabilizing library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:f5de229c9a00 1 /*---------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 2 /* Copyright(C) 2017 OMRON Corporation */
dkato 0:f5de229c9a00 3 /* */
dkato 0:f5de229c9a00 4 /* Licensed under the Apache License, Version 2.0 (the "License"); */
dkato 0:f5de229c9a00 5 /* you may not use this file except in compliance with the License. */
dkato 0:f5de229c9a00 6 /* You may obtain a copy of the License at */
dkato 0:f5de229c9a00 7 /* */
dkato 0:f5de229c9a00 8 /* http://www.apache.org/licenses/LICENSE-2.0 */
dkato 0:f5de229c9a00 9 /* */
dkato 0:f5de229c9a00 10 /* Unless required by applicable law or agreed to in writing, software */
dkato 0:f5de229c9a00 11 /* distributed under the License is distributed on an "AS IS" BASIS, */
dkato 0:f5de229c9a00 12 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
dkato 0:f5de229c9a00 13 /* See the License for the specific language governing permissions and */
dkato 0:f5de229c9a00 14 /* limitations under the License. */
dkato 0:f5de229c9a00 15 /*---------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 16
dkato 0:f5de229c9a00 17 /*
dkato 0:f5de229c9a00 18 HVC Sample API
dkato 0:f5de229c9a00 19 */
dkato 0:f5de229c9a00 20
dkato 0:f5de229c9a00 21 #include <stdlib.h>
dkato 0:f5de229c9a00 22 #include "HVCApi.h"
dkato 0:f5de229c9a00 23 #include "HVCExtraUartFunc.h"
dkato 0:f5de229c9a00 24
dkato 0:f5de229c9a00 25 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 26 /* Command number */
dkato 0:f5de229c9a00 27 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 28 #define HVC_COM_GET_VERSION (UINT8)0x00
dkato 0:f5de229c9a00 29 #define HVC_COM_SET_CAMERA_ANGLE (UINT8)0x01
dkato 0:f5de229c9a00 30 #define HVC_COM_GET_CAMERA_ANGLE (UINT8)0x02
dkato 0:f5de229c9a00 31 #define HVC_COM_EXECUTE (UINT8)0x03
dkato 0:f5de229c9a00 32 #define HVC_COM_EXECUTEEX (UINT8)0x04
dkato 0:f5de229c9a00 33 #define HVC_COM_SET_THRESHOLD (UINT8)0x05
dkato 0:f5de229c9a00 34 #define HVC_COM_GET_THRESHOLD (UINT8)0x06
dkato 0:f5de229c9a00 35 #define HVC_COM_SET_SIZE_RANGE (UINT8)0x07
dkato 0:f5de229c9a00 36 #define HVC_COM_GET_SIZE_RANGE (UINT8)0x08
dkato 0:f5de229c9a00 37 #define HVC_COM_SET_DETECTION_ANGLE (UINT8)0x09
dkato 0:f5de229c9a00 38 #define HVC_COM_GET_DETECTION_ANGLE (UINT8)0x0A
dkato 0:f5de229c9a00 39 #define HVC_COM_SET_BAUDRATE (UINT8)0x0E
dkato 0:f5de229c9a00 40 #define HVC_COM_REGISTRATION (UINT8)0x10
dkato 0:f5de229c9a00 41 #define HVC_COM_DELETE_DATA (UINT8)0x11
dkato 0:f5de229c9a00 42 #define HVC_COM_DELETE_USER (UINT8)0x12
dkato 0:f5de229c9a00 43 #define HVC_COM_DELETE_ALL (UINT8)0x13
dkato 0:f5de229c9a00 44 #define HVC_COM_GET_PERSON_DATA (UINT8)0x15
dkato 0:f5de229c9a00 45 #define HVC_COM_SAVE_ALBUM (UINT8)0x20
dkato 0:f5de229c9a00 46 #define HVC_COM_LOAD_ALBUM (UINT8)0x21
dkato 0:f5de229c9a00 47 #define HVC_COM_WRITE_ALBUM (UINT8)0x22
dkato 0:f5de229c9a00 48
dkato 0:f5de229c9a00 49 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 50 /* Header for send signal data */
dkato 0:f5de229c9a00 51 typedef enum {
dkato 0:f5de229c9a00 52 SEND_HEAD_SYNCBYTE = 0,
dkato 0:f5de229c9a00 53 SEND_HEAD_COMMANDNO,
dkato 0:f5de229c9a00 54 SEND_HEAD_DATALENGTHLSB,
dkato 0:f5de229c9a00 55 SEND_HEAD_DATALENGTHMSB,
dkato 0:f5de229c9a00 56 SEND_HEAD_NUM
dkato 0:f5de229c9a00 57 }SEND_HEADER;
dkato 0:f5de229c9a00 58 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 59 /* Header for receive signal data */
dkato 0:f5de229c9a00 60 typedef enum {
dkato 0:f5de229c9a00 61 RECEIVE_HEAD_SYNCBYTE = 0,
dkato 0:f5de229c9a00 62 RECEIVE_HEAD_STATUS,
dkato 0:f5de229c9a00 63 RECEIVE_HEAD_DATALENLL,
dkato 0:f5de229c9a00 64 RECEIVE_HEAD_DATALENLM,
dkato 0:f5de229c9a00 65 RECEIVE_HEAD_DATALENML,
dkato 0:f5de229c9a00 66 RECEIVE_HEAD_DATALENMM,
dkato 0:f5de229c9a00 67 RECEIVE_HEAD_NUM
dkato 0:f5de229c9a00 68 }RECEIVE_HEADER;
dkato 0:f5de229c9a00 69
dkato 0:f5de229c9a00 70 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 71 /* Send command signal */
dkato 0:f5de229c9a00 72 /* param : UINT8 inCommandNo command number */
dkato 0:f5de229c9a00 73 /* : INT32 inDataSize sending signal data size */
dkato 0:f5de229c9a00 74 /* : UINT8 *inData sending signal data */
dkato 0:f5de229c9a00 75 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 76 /* : 0...normal */
dkato 0:f5de229c9a00 77 /* : -10...timeout error */
dkato 0:f5de229c9a00 78 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 79 static INT32 HVC_SendCommand(UINT8 inCommandNo, INT32 inDataSize, UINT8 *inData)
dkato 0:f5de229c9a00 80 {
dkato 0:f5de229c9a00 81 INT32 i;
dkato 0:f5de229c9a00 82 INT32 ret = 0;
dkato 0:f5de229c9a00 83 UINT8 sendData[32];
dkato 0:f5de229c9a00 84
dkato 0:f5de229c9a00 85 /* Create header */
dkato 0:f5de229c9a00 86 sendData[SEND_HEAD_SYNCBYTE] = (UINT8)0xFE;
dkato 0:f5de229c9a00 87 sendData[SEND_HEAD_COMMANDNO] = (UINT8)inCommandNo;
dkato 0:f5de229c9a00 88 sendData[SEND_HEAD_DATALENGTHLSB] = (UINT8)(inDataSize&0xff);
dkato 0:f5de229c9a00 89 sendData[SEND_HEAD_DATALENGTHMSB] = (UINT8)((inDataSize>>8)&0xff);
dkato 0:f5de229c9a00 90
dkato 0:f5de229c9a00 91 for(i = 0; i < inDataSize; i++){
dkato 0:f5de229c9a00 92 sendData[SEND_HEAD_NUM + i] = inData[i];
dkato 0:f5de229c9a00 93 }
dkato 0:f5de229c9a00 94
dkato 0:f5de229c9a00 95 /* Send command signal */
dkato 0:f5de229c9a00 96 ret = UART_SendData(SEND_HEAD_NUM+inDataSize, sendData);
dkato 0:f5de229c9a00 97 if(ret != SEND_HEAD_NUM+inDataSize){
dkato 0:f5de229c9a00 98 return HVC_ERROR_SEND_DATA;
dkato 0:f5de229c9a00 99 }
dkato 0:f5de229c9a00 100 return 0;
dkato 0:f5de229c9a00 101 }
dkato 0:f5de229c9a00 102
dkato 0:f5de229c9a00 103 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 104 /* Send command signal of LoadAlbum */
dkato 0:f5de229c9a00 105 /* param : UINT8 inCommandNo command number */
dkato 0:f5de229c9a00 106 /* : INT32 inDataSize sending signal data size */
dkato 0:f5de229c9a00 107 /* : UINT8 *inData sending signal data */
dkato 0:f5de229c9a00 108 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 109 /* : 0...normal */
dkato 0:f5de229c9a00 110 /* : -10...timeout error */
dkato 0:f5de229c9a00 111 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 112 static INT32 HVC_SendCommandOfLoadAlbum(UINT8 inCommandNo, INT32 inDataSize, UINT8 *inData)
dkato 0:f5de229c9a00 113 {
dkato 0:f5de229c9a00 114 INT32 i;
dkato 0:f5de229c9a00 115 INT32 ret = 0;
dkato 0:f5de229c9a00 116 UINT8 *pSendData = NULL;
dkato 0:f5de229c9a00 117
dkato 0:f5de229c9a00 118 pSendData = (UINT8*)malloc(SEND_HEAD_NUM + 4 + inDataSize);
dkato 0:f5de229c9a00 119
dkato 0:f5de229c9a00 120 /* Create header */
dkato 0:f5de229c9a00 121 pSendData[SEND_HEAD_SYNCBYTE] = (UINT8)0xFE;
dkato 0:f5de229c9a00 122 pSendData[SEND_HEAD_COMMANDNO] = (UINT8)inCommandNo;
dkato 0:f5de229c9a00 123 pSendData[SEND_HEAD_DATALENGTHLSB] = (UINT8)4;
dkato 0:f5de229c9a00 124 pSendData[SEND_HEAD_DATALENGTHMSB] = (UINT8)0;
dkato 0:f5de229c9a00 125
dkato 0:f5de229c9a00 126 pSendData[SEND_HEAD_NUM + 0] = (UINT8)(inDataSize & 0x000000ff);
dkato 0:f5de229c9a00 127 pSendData[SEND_HEAD_NUM + 1] = (UINT8)((inDataSize >> 8) & 0x000000ff);
dkato 0:f5de229c9a00 128 pSendData[SEND_HEAD_NUM + 2] = (UINT8)((inDataSize >> 16) & 0x000000ff);
dkato 0:f5de229c9a00 129 pSendData[SEND_HEAD_NUM + 3] = (UINT8)((inDataSize >> 24) & 0x000000ff);
dkato 0:f5de229c9a00 130
dkato 0:f5de229c9a00 131 for(i = 0; i < inDataSize; i++){
dkato 0:f5de229c9a00 132 pSendData[SEND_HEAD_NUM + 4 + i] = inData[i];
dkato 0:f5de229c9a00 133 }
dkato 0:f5de229c9a00 134
dkato 0:f5de229c9a00 135 /* Send command signal */
dkato 0:f5de229c9a00 136 ret = UART_SendData(SEND_HEAD_NUM+4+inDataSize, pSendData);
dkato 0:f5de229c9a00 137 if(ret != SEND_HEAD_NUM + 4 + inDataSize){
dkato 0:f5de229c9a00 138 ret = HVC_ERROR_SEND_DATA;
dkato 0:f5de229c9a00 139 }
dkato 0:f5de229c9a00 140 else{
dkato 0:f5de229c9a00 141 ret = 0;
dkato 0:f5de229c9a00 142 }
dkato 0:f5de229c9a00 143 free(pSendData);
dkato 0:f5de229c9a00 144
dkato 0:f5de229c9a00 145 return ret;
dkato 0:f5de229c9a00 146 }
dkato 0:f5de229c9a00 147
dkato 0:f5de229c9a00 148 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 149 /* Receive header */
dkato 0:f5de229c9a00 150 /* param : INT32 inTimeOutTime timeout time */
dkato 0:f5de229c9a00 151 /* : INT32 *outDataSize receive signal data length */
dkato 0:f5de229c9a00 152 /* : UINT8 *outStatus status */
dkato 0:f5de229c9a00 153 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 154 /* : 0...normal */
dkato 0:f5de229c9a00 155 /* : -20...timeout error */
dkato 0:f5de229c9a00 156 /* : -21...invalid header error */
dkato 0:f5de229c9a00 157 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 158 static INT32 HVC_ReceiveHeader(INT32 inTimeOutTime, INT32 *outDataSize, UINT8 *outStatus)
dkato 0:f5de229c9a00 159 {
dkato 0:f5de229c9a00 160 INT32 ret = 0;
dkato 0:f5de229c9a00 161 UINT8 headerData[32];
dkato 0:f5de229c9a00 162
dkato 0:f5de229c9a00 163 /* Get header part */
dkato 0:f5de229c9a00 164 ret = UART_ReceiveData(inTimeOutTime, RECEIVE_HEAD_NUM, headerData);
dkato 0:f5de229c9a00 165 if(ret != RECEIVE_HEAD_NUM){
dkato 0:f5de229c9a00 166 return HVC_ERROR_HEADER_TIMEOUT;
dkato 0:f5de229c9a00 167 }
dkato 0:f5de229c9a00 168 else if((UINT8)0xFE != headerData[RECEIVE_HEAD_SYNCBYTE]){
dkato 0:f5de229c9a00 169 /* Different value indicates an invalid result */
dkato 0:f5de229c9a00 170 return HVC_ERROR_HEADER_INVALID;
dkato 0:f5de229c9a00 171 }
dkato 0:f5de229c9a00 172
dkato 0:f5de229c9a00 173 /* Get data length */
dkato 0:f5de229c9a00 174 *outDataSize = headerData[RECEIVE_HEAD_DATALENLL] +
dkato 0:f5de229c9a00 175 (headerData[RECEIVE_HEAD_DATALENLM]<<8) +
dkato 0:f5de229c9a00 176 (headerData[RECEIVE_HEAD_DATALENML]<<16) +
dkato 0:f5de229c9a00 177 (headerData[RECEIVE_HEAD_DATALENMM]<<24);
dkato 0:f5de229c9a00 178
dkato 0:f5de229c9a00 179 /* Get command execution result */
dkato 0:f5de229c9a00 180 *outStatus = headerData[RECEIVE_HEAD_STATUS];
dkato 0:f5de229c9a00 181 return 0;
dkato 0:f5de229c9a00 182 }
dkato 0:f5de229c9a00 183
dkato 0:f5de229c9a00 184 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 185 /* Receive data */
dkato 0:f5de229c9a00 186 /* param : INT32 inTimeOutTime timeout time */
dkato 0:f5de229c9a00 187 /* : INT32 inDataSize receive signal data size */
dkato 0:f5de229c9a00 188 /* : UINT8 *outResult receive signal data */
dkato 0:f5de229c9a00 189 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 190 /* : 0...normal */
dkato 0:f5de229c9a00 191 /* : -20...timeout error */
dkato 0:f5de229c9a00 192 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 193 static INT32 HVC_ReceiveData(INT32 inTimeOutTime, INT32 inDataSize, UINT8 *outResult)
dkato 0:f5de229c9a00 194 {
dkato 0:f5de229c9a00 195 INT32 ret = 0;
dkato 0:f5de229c9a00 196
dkato 0:f5de229c9a00 197 if ( inDataSize <= 0 ) return 0;
dkato 0:f5de229c9a00 198
dkato 0:f5de229c9a00 199 /* Receive data */
dkato 0:f5de229c9a00 200 ret = UART_ReceiveData(inTimeOutTime, inDataSize, outResult);
dkato 0:f5de229c9a00 201 if(ret != inDataSize){
dkato 0:f5de229c9a00 202 return HVC_ERROR_DATA_TIMEOUT;
dkato 0:f5de229c9a00 203 }
dkato 0:f5de229c9a00 204 return 0;
dkato 0:f5de229c9a00 205 }
dkato 0:f5de229c9a00 206
dkato 0:f5de229c9a00 207 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 208 /* HVC_GetVersion */
dkato 0:f5de229c9a00 209 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 210 /* : HVC_VERSION *outVersion version data */
dkato 0:f5de229c9a00 211 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 212 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 213 /* : 0...normal */
dkato 0:f5de229c9a00 214 /* : -1...parameter error */
dkato 0:f5de229c9a00 215 /* : other...signal error */
dkato 0:f5de229c9a00 216 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 217 INT32 HVC_GetVersion(INT32 inTimeOutTime, HVC_VERSION *outVersion, UINT8 *outStatus)
dkato 0:f5de229c9a00 218 {
dkato 0:f5de229c9a00 219 INT32 ret = 0;
dkato 0:f5de229c9a00 220 INT32 size = 0;
dkato 0:f5de229c9a00 221
dkato 0:f5de229c9a00 222 if((NULL == outVersion) || (NULL == outStatus)){
dkato 0:f5de229c9a00 223 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 224 }
dkato 0:f5de229c9a00 225
dkato 0:f5de229c9a00 226 /* Send GetVersion command signal */
dkato 0:f5de229c9a00 227 ret = HVC_SendCommand(HVC_COM_GET_VERSION, 0, NULL);
dkato 0:f5de229c9a00 228 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 229
dkato 0:f5de229c9a00 230 /* Receive header */
dkato 0:f5de229c9a00 231 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 232 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 233
dkato 0:f5de229c9a00 234 if ( size > (INT32)sizeof(HVC_VERSION) ) {
dkato 0:f5de229c9a00 235 size = sizeof(HVC_VERSION);
dkato 0:f5de229c9a00 236 }
dkato 0:f5de229c9a00 237
dkato 0:f5de229c9a00 238 /* Receive data */
dkato 0:f5de229c9a00 239 return HVC_ReceiveData(inTimeOutTime, size, (UINT8*)outVersion);
dkato 0:f5de229c9a00 240 }
dkato 0:f5de229c9a00 241
dkato 0:f5de229c9a00 242 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 243 /* HVC_SetCameraAngle */
dkato 0:f5de229c9a00 244 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 245 /* : INT32 inAngleNo camera angle number */
dkato 0:f5de229c9a00 246 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 247 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 248 /* : 0...normal */
dkato 0:f5de229c9a00 249 /* : -1...parameter error */
dkato 0:f5de229c9a00 250 /* : other...signal error */
dkato 0:f5de229c9a00 251 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 252 INT32 HVC_SetCameraAngle(INT32 inTimeOutTime, INT32 inAngleNo, UINT8 *outStatus)
dkato 0:f5de229c9a00 253 {
dkato 0:f5de229c9a00 254 INT32 ret = 0;
dkato 0:f5de229c9a00 255 INT32 size = 0;
dkato 0:f5de229c9a00 256 UINT8 sendData[32];
dkato 0:f5de229c9a00 257
dkato 0:f5de229c9a00 258 if(NULL == outStatus){
dkato 0:f5de229c9a00 259 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 260 }
dkato 0:f5de229c9a00 261
dkato 0:f5de229c9a00 262 sendData[0] = (UINT8)(inAngleNo&0xff);
dkato 0:f5de229c9a00 263 /* Send SetCameraAngle command signal */
dkato 0:f5de229c9a00 264 ret = HVC_SendCommand(HVC_COM_SET_CAMERA_ANGLE, sizeof(UINT8), sendData);
dkato 0:f5de229c9a00 265 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 266
dkato 0:f5de229c9a00 267 /* Receive header */
dkato 0:f5de229c9a00 268 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 269 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 270 return 0;
dkato 0:f5de229c9a00 271 }
dkato 0:f5de229c9a00 272
dkato 0:f5de229c9a00 273 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 274 /* HVC_GetCameraAngle */
dkato 0:f5de229c9a00 275 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 276 /* : INT32 *outAngleNo camera angle number */
dkato 0:f5de229c9a00 277 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 278 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 279 /* : 0...normal */
dkato 0:f5de229c9a00 280 /* : -1...parameter error */
dkato 0:f5de229c9a00 281 /* : other...signal error */
dkato 0:f5de229c9a00 282 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 283 INT32 HVC_GetCameraAngle(INT32 inTimeOutTime, INT32 *outAngleNo, UINT8 *outStatus)
dkato 0:f5de229c9a00 284 {
dkato 0:f5de229c9a00 285 INT32 ret = 0;
dkato 0:f5de229c9a00 286 INT32 size = 0;
dkato 0:f5de229c9a00 287 UINT8 recvData[32];
dkato 0:f5de229c9a00 288
dkato 0:f5de229c9a00 289 if((NULL == outAngleNo) || (NULL == outStatus)){
dkato 0:f5de229c9a00 290 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 291 }
dkato 0:f5de229c9a00 292
dkato 0:f5de229c9a00 293 /* Send GetCameraAngle command signal */
dkato 0:f5de229c9a00 294 ret = HVC_SendCommand(HVC_COM_GET_CAMERA_ANGLE, 0, NULL);
dkato 0:f5de229c9a00 295 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 296
dkato 0:f5de229c9a00 297 /* Receive header */
dkato 0:f5de229c9a00 298 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 299 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 300
dkato 0:f5de229c9a00 301 if ( size > (INT32)sizeof(UINT8) ) {
dkato 0:f5de229c9a00 302 size = sizeof(UINT8);
dkato 0:f5de229c9a00 303 }
dkato 0:f5de229c9a00 304
dkato 0:f5de229c9a00 305 /* Receive data */
dkato 0:f5de229c9a00 306 ret = HVC_ReceiveData(inTimeOutTime, size, recvData);
dkato 0:f5de229c9a00 307 *outAngleNo = recvData[0];
dkato 0:f5de229c9a00 308 return ret;
dkato 0:f5de229c9a00 309 }
dkato 0:f5de229c9a00 310
dkato 0:f5de229c9a00 311 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 312 /* HVC_Execute */
dkato 0:f5de229c9a00 313 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 314 /* : INT32 inExec executable function */
dkato 0:f5de229c9a00 315 /* : INT32 inImage image info */
dkato 0:f5de229c9a00 316 /* : HVC_RESULT *outHVCResult result data */
dkato 0:f5de229c9a00 317 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 318 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 319 /* : 0...normal */
dkato 0:f5de229c9a00 320 /* : -1...parameter error */
dkato 0:f5de229c9a00 321 /* : other...signal error */
dkato 0:f5de229c9a00 322 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 323 INT32 HVC_Execute(INT32 inTimeOutTime, INT32 inExec, INT32 inImage, HVC_RESULT *outHVCResult, UINT8 *outStatus)
dkato 0:f5de229c9a00 324 {
dkato 0:f5de229c9a00 325 int i;
dkato 0:f5de229c9a00 326 INT32 ret = 0;
dkato 0:f5de229c9a00 327 INT32 size = 0;
dkato 0:f5de229c9a00 328 UINT8 sendData[32];
dkato 0:f5de229c9a00 329 UINT8 recvData[32];
dkato 0:f5de229c9a00 330
dkato 0:f5de229c9a00 331 if((NULL == outHVCResult) || (NULL == outStatus)){
dkato 0:f5de229c9a00 332 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 333 }
dkato 0:f5de229c9a00 334
dkato 0:f5de229c9a00 335 /* Send Execute command signal */
dkato 0:f5de229c9a00 336 sendData[0] = (UINT8)(inExec&0xff);
dkato 0:f5de229c9a00 337 sendData[1] = (UINT8)((inExec>>8)&0xff);
dkato 0:f5de229c9a00 338 sendData[2] = (UINT8)(inImage&0xff);
dkato 0:f5de229c9a00 339 ret = HVC_SendCommand(HVC_COM_EXECUTE, sizeof(UINT8)*3, sendData);
dkato 0:f5de229c9a00 340 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 341
dkato 0:f5de229c9a00 342 /* Receive header */
dkato 0:f5de229c9a00 343 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 344 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 345
dkato 0:f5de229c9a00 346 /* Receive result data */
dkato 0:f5de229c9a00 347 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 348 outHVCResult->executedFunc = inExec;
dkato 0:f5de229c9a00 349 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 350 outHVCResult->bdResult.num = recvData[0];
dkato 0:f5de229c9a00 351 outHVCResult->hdResult.num = recvData[1];
dkato 0:f5de229c9a00 352 outHVCResult->fdResult.num = recvData[2];
dkato 0:f5de229c9a00 353 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 354 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 355 }
dkato 0:f5de229c9a00 356
dkato 0:f5de229c9a00 357 /* Get Human Body Detection result */
dkato 0:f5de229c9a00 358 for(i = 0; i < outHVCResult->bdResult.num; i++){
dkato 0:f5de229c9a00 359 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 360 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 361 outHVCResult->bdResult.bdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 362 outHVCResult->bdResult.bdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 363 outHVCResult->bdResult.bdResult[i].size = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 364 outHVCResult->bdResult.bdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 365 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 366 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 367 }
dkato 0:f5de229c9a00 368 }
dkato 0:f5de229c9a00 369
dkato 0:f5de229c9a00 370 /* Get Hand Detection result */
dkato 0:f5de229c9a00 371 for(i = 0; i < outHVCResult->hdResult.num; i++){
dkato 0:f5de229c9a00 372 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 373 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 374 outHVCResult->hdResult.hdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 375 outHVCResult->hdResult.hdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 376 outHVCResult->hdResult.hdResult[i].size = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 377 outHVCResult->hdResult.hdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 378 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 379 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 380 }
dkato 0:f5de229c9a00 381 }
dkato 0:f5de229c9a00 382
dkato 0:f5de229c9a00 383 /* Face-related results */
dkato 0:f5de229c9a00 384 for(i = 0; i < outHVCResult->fdResult.num; i++){
dkato 0:f5de229c9a00 385 /* Face Detection result */
dkato 0:f5de229c9a00 386 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DETECTION)){
dkato 0:f5de229c9a00 387 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 388 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 389 outHVCResult->fdResult.fcResult[i].dtResult.posX = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 390 outHVCResult->fdResult.fcResult[i].dtResult.posY = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 391 outHVCResult->fdResult.fcResult[i].dtResult.size = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 392 outHVCResult->fdResult.fcResult[i].dtResult.confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 393 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 394 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 395 }
dkato 0:f5de229c9a00 396 }
dkato 0:f5de229c9a00 397
dkato 0:f5de229c9a00 398 /* Face direction */
dkato 0:f5de229c9a00 399 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DIRECTION)){
dkato 0:f5de229c9a00 400 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 401 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 402 outHVCResult->fdResult.fcResult[i].dirResult.yaw = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 403 outHVCResult->fdResult.fcResult[i].dirResult.pitch = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 404 outHVCResult->fdResult.fcResult[i].dirResult.roll = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 405 outHVCResult->fdResult.fcResult[i].dirResult.confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 406 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 407 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 408 }
dkato 0:f5de229c9a00 409 }
dkato 0:f5de229c9a00 410
dkato 0:f5de229c9a00 411 /* Age */
dkato 0:f5de229c9a00 412 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_AGE_ESTIMATION)){
dkato 0:f5de229c9a00 413 if ( size >= (INT32)sizeof(UINT8)*3 ) {
dkato 0:f5de229c9a00 414 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData);
dkato 4:55e0d1f4e55a 415 #if(1) // Mbed
dkato 4:55e0d1f4e55a 416 outHVCResult->fdResult.fcResult[i].ageResult.age = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 417 #else
dkato 0:f5de229c9a00 418 outHVCResult->fdResult.fcResult[i].ageResult.age = (char)(recvData[0]);
dkato 4:55e0d1f4e55a 419 #endif
dkato 0:f5de229c9a00 420 outHVCResult->fdResult.fcResult[i].ageResult.confidence = (short)(recvData[1] + (recvData[2]<<8));
dkato 0:f5de229c9a00 421 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 422 size -= sizeof(UINT8)*3;
dkato 0:f5de229c9a00 423 }
dkato 0:f5de229c9a00 424 }
dkato 0:f5de229c9a00 425
dkato 0:f5de229c9a00 426 /* Gender */
dkato 0:f5de229c9a00 427 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GENDER_ESTIMATION)){
dkato 0:f5de229c9a00 428 if ( size >= (INT32)sizeof(UINT8)*3 ) {
dkato 0:f5de229c9a00 429 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData);
dkato 4:55e0d1f4e55a 430 #if(1) // Mbed
dkato 4:55e0d1f4e55a 431 outHVCResult->fdResult.fcResult[i].genderResult.gender = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 432 #else
dkato 0:f5de229c9a00 433 outHVCResult->fdResult.fcResult[i].genderResult.gender = (char)(recvData[0]);
dkato 4:55e0d1f4e55a 434 #endif
dkato 0:f5de229c9a00 435 outHVCResult->fdResult.fcResult[i].genderResult.confidence = (short)(recvData[1] + (recvData[2]<<8));
dkato 0:f5de229c9a00 436 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 437 size -= sizeof(UINT8)*3;
dkato 0:f5de229c9a00 438 }
dkato 0:f5de229c9a00 439 }
dkato 0:f5de229c9a00 440
dkato 0:f5de229c9a00 441 /* Gaze */
dkato 0:f5de229c9a00 442 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GAZE_ESTIMATION)){
dkato 0:f5de229c9a00 443 if ( size >= (INT32)sizeof(UINT8)*2 ) {
dkato 0:f5de229c9a00 444 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*2, recvData);
dkato 4:55e0d1f4e55a 445 #if(1) // Mbed
dkato 4:55e0d1f4e55a 446 outHVCResult->fdResult.fcResult[i].gazeResult.gazeLR = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 447 outHVCResult->fdResult.fcResult[i].gazeResult.gazeUD = (signed char)(recvData[1]);
dkato 4:55e0d1f4e55a 448 #else
dkato 0:f5de229c9a00 449 outHVCResult->fdResult.fcResult[i].gazeResult.gazeLR = (char)(recvData[0]);
dkato 0:f5de229c9a00 450 outHVCResult->fdResult.fcResult[i].gazeResult.gazeUD = (char)(recvData[1]);
dkato 4:55e0d1f4e55a 451 #endif
dkato 0:f5de229c9a00 452 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 453 size -= sizeof(UINT8)*2;
dkato 0:f5de229c9a00 454 }
dkato 0:f5de229c9a00 455 }
dkato 0:f5de229c9a00 456
dkato 0:f5de229c9a00 457 /* Blink */
dkato 0:f5de229c9a00 458 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_BLINK_ESTIMATION)){
dkato 0:f5de229c9a00 459 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 460 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 461 outHVCResult->fdResult.fcResult[i].blinkResult.ratioL = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 462 outHVCResult->fdResult.fcResult[i].blinkResult.ratioR = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 463 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 464 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 465 }
dkato 0:f5de229c9a00 466 }
dkato 0:f5de229c9a00 467
dkato 0:f5de229c9a00 468 /* Expression */
dkato 0:f5de229c9a00 469 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_EXPRESSION_ESTIMATION)){
dkato 0:f5de229c9a00 470 if ( size >= (INT32)sizeof(UINT8)*3 ) {
dkato 0:f5de229c9a00 471 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData);
dkato 4:55e0d1f4e55a 472 #if(1) // Mbed
dkato 4:55e0d1f4e55a 473 outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 474 outHVCResult->fdResult.fcResult[i].expressionResult.topScore = (signed char)(recvData[1]);
dkato 4:55e0d1f4e55a 475 outHVCResult->fdResult.fcResult[i].expressionResult.degree = (signed char)(recvData[2]);
dkato 4:55e0d1f4e55a 476 #else
dkato 0:f5de229c9a00 477 outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = (char)(recvData[0]);
dkato 0:f5de229c9a00 478 outHVCResult->fdResult.fcResult[i].expressionResult.topScore = (char)(recvData[1]);
dkato 0:f5de229c9a00 479 outHVCResult->fdResult.fcResult[i].expressionResult.degree = (char)(recvData[2]);
dkato 4:55e0d1f4e55a 480 #endif
dkato 0:f5de229c9a00 481 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 482 size -= sizeof(UINT8)*3;
dkato 0:f5de229c9a00 483 }
dkato 0:f5de229c9a00 484 }
dkato 0:f5de229c9a00 485
dkato 0:f5de229c9a00 486 /* Face Recognition */
dkato 0:f5de229c9a00 487 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_RECOGNITION)){
dkato 0:f5de229c9a00 488 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 489 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 490 outHVCResult->fdResult.fcResult[i].recognitionResult.uid = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 491 outHVCResult->fdResult.fcResult[i].recognitionResult.confidence = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 492 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 493 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 494 }
dkato 0:f5de229c9a00 495 }
dkato 0:f5de229c9a00 496 }
dkato 0:f5de229c9a00 497
dkato 0:f5de229c9a00 498 if(HVC_EXECUTE_IMAGE_NONE != inImage){
dkato 0:f5de229c9a00 499 /* Image data */
dkato 0:f5de229c9a00 500 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 501 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 502 outHVCResult->image.width = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 503 outHVCResult->image.height = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 504 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 505 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 506 }
dkato 0:f5de229c9a00 507
dkato 0:f5de229c9a00 508 if ( size >= (INT32)sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height ) {
dkato 0:f5de229c9a00 509 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height, outHVCResult->image.image);
dkato 0:f5de229c9a00 510 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 511 size -= sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height;
dkato 0:f5de229c9a00 512 }
dkato 0:f5de229c9a00 513 }
dkato 0:f5de229c9a00 514 return 0;
dkato 0:f5de229c9a00 515 }
dkato 0:f5de229c9a00 516
dkato 0:f5de229c9a00 517 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 518 /* HVC_ExecuteEx */
dkato 0:f5de229c9a00 519 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 520 /* : INT32 inExec executable function */
dkato 0:f5de229c9a00 521 /* : INT32 inImage image info */
dkato 0:f5de229c9a00 522 /* : HVC_RESULT *outHVCResult result data */
dkato 0:f5de229c9a00 523 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 524 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 525 /* : 0...normal */
dkato 0:f5de229c9a00 526 /* : -1...parameter error */
dkato 0:f5de229c9a00 527 /* : other...signal error */
dkato 0:f5de229c9a00 528 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 529 INT32 HVC_ExecuteEx(INT32 inTimeOutTime, INT32 inExec, INT32 inImage, HVC_RESULT *outHVCResult, UINT8 *outStatus)
dkato 0:f5de229c9a00 530 {
dkato 0:f5de229c9a00 531 int i, j;
dkato 0:f5de229c9a00 532 INT32 ret = 0;
dkato 0:f5de229c9a00 533 INT32 size = 0;
dkato 0:f5de229c9a00 534 UINT8 sendData[32];
dkato 0:f5de229c9a00 535 UINT8 recvData[32];
dkato 0:f5de229c9a00 536
dkato 0:f5de229c9a00 537 if((NULL == outHVCResult) || (NULL == outStatus)){
dkato 0:f5de229c9a00 538 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 539 }
dkato 0:f5de229c9a00 540
dkato 0:f5de229c9a00 541 /* Send Execute command signal */
dkato 0:f5de229c9a00 542 sendData[0] = (UINT8)(inExec&0xff);
dkato 0:f5de229c9a00 543 sendData[1] = (UINT8)((inExec>>8)&0xff);
dkato 0:f5de229c9a00 544 sendData[2] = (UINT8)(inImage&0xff);
dkato 0:f5de229c9a00 545 ret = HVC_SendCommand(HVC_COM_EXECUTEEX, sizeof(UINT8)*3, sendData);
dkato 0:f5de229c9a00 546 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 547
dkato 0:f5de229c9a00 548 /* Receive header */
dkato 0:f5de229c9a00 549 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 550 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 551
dkato 0:f5de229c9a00 552 /* Receive result data */
dkato 0:f5de229c9a00 553 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 554 outHVCResult->executedFunc = inExec;
dkato 0:f5de229c9a00 555 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 556 outHVCResult->bdResult.num = recvData[0];
dkato 0:f5de229c9a00 557 outHVCResult->hdResult.num = recvData[1];
dkato 0:f5de229c9a00 558 outHVCResult->fdResult.num = recvData[2];
dkato 0:f5de229c9a00 559 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 560 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 561 }
dkato 0:f5de229c9a00 562
dkato 0:f5de229c9a00 563 /* Get Human Body Detection result */
dkato 0:f5de229c9a00 564 for(i = 0; i < outHVCResult->bdResult.num; i++){
dkato 0:f5de229c9a00 565 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 566 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 567 outHVCResult->bdResult.bdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 568 outHVCResult->bdResult.bdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 569 outHVCResult->bdResult.bdResult[i].size = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 570 outHVCResult->bdResult.bdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 571 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 572 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 573 }
dkato 0:f5de229c9a00 574 }
dkato 0:f5de229c9a00 575
dkato 0:f5de229c9a00 576 /* Get Hand Detection result */
dkato 0:f5de229c9a00 577 for(i = 0; i < outHVCResult->hdResult.num; i++){
dkato 0:f5de229c9a00 578 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 579 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 580 outHVCResult->hdResult.hdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 581 outHVCResult->hdResult.hdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 582 outHVCResult->hdResult.hdResult[i].size = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 583 outHVCResult->hdResult.hdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 584 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 585 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 586 }
dkato 0:f5de229c9a00 587 }
dkato 0:f5de229c9a00 588
dkato 0:f5de229c9a00 589 /* Face-related results */
dkato 0:f5de229c9a00 590 for(i = 0; i < outHVCResult->fdResult.num; i++){
dkato 0:f5de229c9a00 591 /* Face Detection result */
dkato 0:f5de229c9a00 592 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DETECTION)){
dkato 0:f5de229c9a00 593 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 594 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 595 outHVCResult->fdResult.fcResult[i].dtResult.posX = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 596 outHVCResult->fdResult.fcResult[i].dtResult.posY = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 597 outHVCResult->fdResult.fcResult[i].dtResult.size = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 598 outHVCResult->fdResult.fcResult[i].dtResult.confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 599 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 600 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 601 }
dkato 0:f5de229c9a00 602 }
dkato 0:f5de229c9a00 603
dkato 0:f5de229c9a00 604 /* Face direction */
dkato 0:f5de229c9a00 605 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DIRECTION)){
dkato 0:f5de229c9a00 606 if ( size >= (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 607 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData);
dkato 0:f5de229c9a00 608 outHVCResult->fdResult.fcResult[i].dirResult.yaw = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 609 outHVCResult->fdResult.fcResult[i].dirResult.pitch = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 610 outHVCResult->fdResult.fcResult[i].dirResult.roll = (short)(recvData[4] + (recvData[5]<<8));
dkato 0:f5de229c9a00 611 outHVCResult->fdResult.fcResult[i].dirResult.confidence = (short)(recvData[6] + (recvData[7]<<8));
dkato 0:f5de229c9a00 612 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 613 size -= sizeof(UINT8)*8;
dkato 0:f5de229c9a00 614 }
dkato 0:f5de229c9a00 615 }
dkato 0:f5de229c9a00 616
dkato 0:f5de229c9a00 617 /* Age */
dkato 0:f5de229c9a00 618 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_AGE_ESTIMATION)){
dkato 0:f5de229c9a00 619 if ( size >= (INT32)sizeof(UINT8)*3 ) {
dkato 0:f5de229c9a00 620 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData);
dkato 4:55e0d1f4e55a 621 #if(1) // Mbed
dkato 4:55e0d1f4e55a 622 outHVCResult->fdResult.fcResult[i].ageResult.age = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 623 #else
dkato 0:f5de229c9a00 624 outHVCResult->fdResult.fcResult[i].ageResult.age = (char)(recvData[0]);
dkato 4:55e0d1f4e55a 625 #endif
dkato 0:f5de229c9a00 626 outHVCResult->fdResult.fcResult[i].ageResult.confidence = (short)(recvData[1] + (recvData[2]<<8));
dkato 0:f5de229c9a00 627 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 628 size -= sizeof(UINT8)*3;
dkato 0:f5de229c9a00 629 }
dkato 0:f5de229c9a00 630 }
dkato 0:f5de229c9a00 631
dkato 0:f5de229c9a00 632 /* Gender */
dkato 0:f5de229c9a00 633 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GENDER_ESTIMATION)){
dkato 0:f5de229c9a00 634 if ( size >= (INT32)sizeof(UINT8)*3 ) {
dkato 0:f5de229c9a00 635 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData);
dkato 4:55e0d1f4e55a 636 #if(1) // Mbed
dkato 4:55e0d1f4e55a 637 outHVCResult->fdResult.fcResult[i].genderResult.gender = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 638 #else
dkato 0:f5de229c9a00 639 outHVCResult->fdResult.fcResult[i].genderResult.gender = (char)(recvData[0]);
dkato 4:55e0d1f4e55a 640 #endif
dkato 0:f5de229c9a00 641 outHVCResult->fdResult.fcResult[i].genderResult.confidence = (short)(recvData[1] + (recvData[2]<<8));
dkato 0:f5de229c9a00 642 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 643 size -= sizeof(UINT8)*3;
dkato 0:f5de229c9a00 644 }
dkato 0:f5de229c9a00 645 }
dkato 0:f5de229c9a00 646
dkato 0:f5de229c9a00 647 /* Gaze */
dkato 0:f5de229c9a00 648 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GAZE_ESTIMATION)){
dkato 0:f5de229c9a00 649 if ( size >= (INT32)sizeof(UINT8)*2 ) {
dkato 0:f5de229c9a00 650 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*2, recvData);
dkato 4:55e0d1f4e55a 651 #if(1) // Mbed
dkato 4:55e0d1f4e55a 652 outHVCResult->fdResult.fcResult[i].gazeResult.gazeLR = (signed char)(recvData[0]);
dkato 4:55e0d1f4e55a 653 outHVCResult->fdResult.fcResult[i].gazeResult.gazeUD = (signed char)(recvData[1]);
dkato 4:55e0d1f4e55a 654 #else
dkato 0:f5de229c9a00 655 outHVCResult->fdResult.fcResult[i].gazeResult.gazeLR = (char)(recvData[0]);
dkato 0:f5de229c9a00 656 outHVCResult->fdResult.fcResult[i].gazeResult.gazeUD = (char)(recvData[1]);
dkato 4:55e0d1f4e55a 657 #endif
dkato 0:f5de229c9a00 658 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 659 size -= sizeof(UINT8)*2;
dkato 0:f5de229c9a00 660 }
dkato 0:f5de229c9a00 661 }
dkato 0:f5de229c9a00 662
dkato 0:f5de229c9a00 663 /* Blink */
dkato 0:f5de229c9a00 664 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_BLINK_ESTIMATION)){
dkato 0:f5de229c9a00 665 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 666 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 667 outHVCResult->fdResult.fcResult[i].blinkResult.ratioL = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 668 outHVCResult->fdResult.fcResult[i].blinkResult.ratioR = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 669 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 670 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 671 }
dkato 0:f5de229c9a00 672 }
dkato 0:f5de229c9a00 673
dkato 0:f5de229c9a00 674 /* Expression */
dkato 0:f5de229c9a00 675 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_EXPRESSION_ESTIMATION)){
dkato 0:f5de229c9a00 676 if ( size >= (INT32)sizeof(UINT8)*6 ) {
dkato 0:f5de229c9a00 677 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*6, recvData);
dkato 0:f5de229c9a00 678 outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = -128;
dkato 0:f5de229c9a00 679 outHVCResult->fdResult.fcResult[i].expressionResult.topScore = -128;
dkato 0:f5de229c9a00 680 for(j = 0; j < 5; j++){
dkato 4:55e0d1f4e55a 681 #if(1) // Mbed
dkato 4:55e0d1f4e55a 682 outHVCResult->fdResult.fcResult[i].expressionResult.score[j] = (signed char)(recvData[j]);
dkato 4:55e0d1f4e55a 683 #else
dkato 0:f5de229c9a00 684 outHVCResult->fdResult.fcResult[i].expressionResult.score[j] = (char)(recvData[j]);
dkato 4:55e0d1f4e55a 685 #endif
dkato 0:f5de229c9a00 686 if(outHVCResult->fdResult.fcResult[i].expressionResult.topScore < outHVCResult->fdResult.fcResult[i].expressionResult.score[j]){
dkato 0:f5de229c9a00 687 outHVCResult->fdResult.fcResult[i].expressionResult.topScore = outHVCResult->fdResult.fcResult[i].expressionResult.score[j];
dkato 0:f5de229c9a00 688 outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = j + 1;
dkato 0:f5de229c9a00 689 }
dkato 0:f5de229c9a00 690 }
dkato 4:55e0d1f4e55a 691 #if(1) // Mbed
dkato 4:55e0d1f4e55a 692 outHVCResult->fdResult.fcResult[i].expressionResult.degree = (signed char)(recvData[5]);
dkato 4:55e0d1f4e55a 693 #else
dkato 0:f5de229c9a00 694 outHVCResult->fdResult.fcResult[i].expressionResult.degree = (char)(recvData[5]);
dkato 4:55e0d1f4e55a 695 #endif
dkato 0:f5de229c9a00 696 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 697 size -= sizeof(UINT8)*6;
dkato 0:f5de229c9a00 698 }
dkato 0:f5de229c9a00 699 }
dkato 0:f5de229c9a00 700
dkato 0:f5de229c9a00 701 /* Face Recognition */
dkato 0:f5de229c9a00 702 if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_RECOGNITION)){
dkato 0:f5de229c9a00 703 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 704 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 705 outHVCResult->fdResult.fcResult[i].recognitionResult.uid = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 706 outHVCResult->fdResult.fcResult[i].recognitionResult.confidence = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 707 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 708 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 709 }
dkato 0:f5de229c9a00 710 }
dkato 0:f5de229c9a00 711 }
dkato 0:f5de229c9a00 712
dkato 0:f5de229c9a00 713 if(HVC_EXECUTE_IMAGE_NONE != inImage){
dkato 0:f5de229c9a00 714 /* Image data */
dkato 0:f5de229c9a00 715 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 716 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 717 outHVCResult->image.width = (short)(recvData[0] + (recvData[1]<<8));
dkato 0:f5de229c9a00 718 outHVCResult->image.height = (short)(recvData[2] + (recvData[3]<<8));
dkato 0:f5de229c9a00 719 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 720 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 721 }
dkato 0:f5de229c9a00 722
dkato 0:f5de229c9a00 723 if ( size >= (INT32)sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height ) {
dkato 0:f5de229c9a00 724 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height, outHVCResult->image.image);
dkato 0:f5de229c9a00 725 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 726 size -= sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height;
dkato 0:f5de229c9a00 727 }
dkato 0:f5de229c9a00 728 }
dkato 0:f5de229c9a00 729 return 0;
dkato 0:f5de229c9a00 730 }
dkato 0:f5de229c9a00 731
dkato 0:f5de229c9a00 732 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 733 /* HVC_SetThreshold */
dkato 0:f5de229c9a00 734 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 735 /* : HVC_THRESHOLD *inThreshold threshold values */
dkato 0:f5de229c9a00 736 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 737 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 738 /* : 0...normal */
dkato 0:f5de229c9a00 739 /* : -1...parameter error */
dkato 0:f5de229c9a00 740 /* : other...signal error */
dkato 0:f5de229c9a00 741 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 742 INT32 HVC_SetThreshold(INT32 inTimeOutTime, HVC_THRESHOLD *inThreshold, UINT8 *outStatus)
dkato 0:f5de229c9a00 743 {
dkato 0:f5de229c9a00 744 INT32 ret = 0;
dkato 0:f5de229c9a00 745 INT32 size = 0;
dkato 0:f5de229c9a00 746 UINT8 sendData[32];
dkato 0:f5de229c9a00 747
dkato 0:f5de229c9a00 748 if((NULL == inThreshold) || (NULL == outStatus)){
dkato 0:f5de229c9a00 749 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 750 }
dkato 0:f5de229c9a00 751
dkato 0:f5de229c9a00 752 sendData[0] = (UINT8)(inThreshold->bdThreshold&0xff);
dkato 0:f5de229c9a00 753 sendData[1] = (UINT8)((inThreshold->bdThreshold>>8)&0xff);
dkato 0:f5de229c9a00 754 sendData[2] = (UINT8)(inThreshold->hdThreshold&0xff);
dkato 0:f5de229c9a00 755 sendData[3] = (UINT8)((inThreshold->hdThreshold>>8)&0xff);
dkato 0:f5de229c9a00 756 sendData[4] = (UINT8)(inThreshold->dtThreshold&0xff);
dkato 0:f5de229c9a00 757 sendData[5] = (UINT8)((inThreshold->dtThreshold>>8)&0xff);
dkato 0:f5de229c9a00 758 sendData[6] = (UINT8)(inThreshold->rsThreshold&0xff);
dkato 0:f5de229c9a00 759 sendData[7] = (UINT8)((inThreshold->rsThreshold>>8)&0xff);
dkato 0:f5de229c9a00 760 /* Send SetThreshold command signal */
dkato 0:f5de229c9a00 761 ret = HVC_SendCommand(HVC_COM_SET_THRESHOLD, sizeof(UINT8)*8, sendData);
dkato 0:f5de229c9a00 762 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 763
dkato 0:f5de229c9a00 764 /* Receive header */
dkato 0:f5de229c9a00 765 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 766 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 767 return 0;
dkato 0:f5de229c9a00 768 }
dkato 0:f5de229c9a00 769
dkato 0:f5de229c9a00 770 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 771 /* HVC_GetThreshold */
dkato 0:f5de229c9a00 772 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 773 /* : HVC_THRESHOLD *outThreshold threshold values */
dkato 0:f5de229c9a00 774 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 775 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 776 /* : 0...normal */
dkato 0:f5de229c9a00 777 /* : -1...parameter error */
dkato 0:f5de229c9a00 778 /* : other...signal error */
dkato 0:f5de229c9a00 779 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 780 INT32 HVC_GetThreshold(INT32 inTimeOutTime, HVC_THRESHOLD *outThreshold, UINT8 *outStatus)
dkato 0:f5de229c9a00 781 {
dkato 0:f5de229c9a00 782 INT32 ret = 0;
dkato 0:f5de229c9a00 783 INT32 size = 0;
dkato 0:f5de229c9a00 784 UINT8 recvData[32];
dkato 0:f5de229c9a00 785
dkato 0:f5de229c9a00 786 if((NULL == outThreshold) || (NULL == outStatus)){
dkato 0:f5de229c9a00 787 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 788 }
dkato 0:f5de229c9a00 789
dkato 0:f5de229c9a00 790 /* Send GetThreshold command signal */
dkato 0:f5de229c9a00 791 ret = HVC_SendCommand(HVC_COM_GET_THRESHOLD, 0, NULL);
dkato 0:f5de229c9a00 792 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 793
dkato 0:f5de229c9a00 794 /* Receive header */
dkato 0:f5de229c9a00 795 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 796 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 797
dkato 0:f5de229c9a00 798 if ( size > (INT32)sizeof(UINT8)*8 ) {
dkato 0:f5de229c9a00 799 size = sizeof(UINT8)*8;
dkato 0:f5de229c9a00 800 }
dkato 0:f5de229c9a00 801
dkato 0:f5de229c9a00 802 /* Receive data */
dkato 0:f5de229c9a00 803 ret = HVC_ReceiveData(inTimeOutTime, size, recvData);
dkato 0:f5de229c9a00 804 outThreshold->bdThreshold = recvData[0] + (recvData[1]<<8);
dkato 0:f5de229c9a00 805 outThreshold->hdThreshold = recvData[2] + (recvData[3]<<8);
dkato 0:f5de229c9a00 806 outThreshold->dtThreshold = recvData[4] + (recvData[5]<<8);
dkato 0:f5de229c9a00 807 outThreshold->rsThreshold = recvData[6] + (recvData[7]<<8);
dkato 0:f5de229c9a00 808 return ret;
dkato 0:f5de229c9a00 809 }
dkato 0:f5de229c9a00 810
dkato 0:f5de229c9a00 811 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 812 /* HVC_SetSizeRange */
dkato 0:f5de229c9a00 813 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 814 /* : HVC_SIZERANGE *inSizeRange detection sizes */
dkato 0:f5de229c9a00 815 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 816 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 817 /* : 0...normal */
dkato 0:f5de229c9a00 818 /* : -1...parameter error */
dkato 0:f5de229c9a00 819 /* : other...signal error */
dkato 0:f5de229c9a00 820 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 821 INT32 HVC_SetSizeRange(INT32 inTimeOutTime, HVC_SIZERANGE *inSizeRange, UINT8 *outStatus)
dkato 0:f5de229c9a00 822 {
dkato 0:f5de229c9a00 823 INT32 ret = 0;
dkato 0:f5de229c9a00 824 INT32 size = 0;
dkato 0:f5de229c9a00 825 UINT8 sendData[32];
dkato 0:f5de229c9a00 826
dkato 0:f5de229c9a00 827 if((NULL == inSizeRange) || (NULL == outStatus)){
dkato 0:f5de229c9a00 828 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 829 }
dkato 0:f5de229c9a00 830
dkato 0:f5de229c9a00 831 sendData[0] = (UINT8)(inSizeRange->bdMinSize&0xff);
dkato 0:f5de229c9a00 832 sendData[1] = (UINT8)((inSizeRange->bdMinSize>>8)&0xff);
dkato 0:f5de229c9a00 833 sendData[2] = (UINT8)(inSizeRange->bdMaxSize&0xff);
dkato 0:f5de229c9a00 834 sendData[3] = (UINT8)((inSizeRange->bdMaxSize>>8)&0xff);
dkato 0:f5de229c9a00 835 sendData[4] = (UINT8)(inSizeRange->hdMinSize&0xff);
dkato 0:f5de229c9a00 836 sendData[5] = (UINT8)((inSizeRange->hdMinSize>>8)&0xff);
dkato 0:f5de229c9a00 837 sendData[6] = (UINT8)(inSizeRange->hdMaxSize&0xff);
dkato 0:f5de229c9a00 838 sendData[7] = (UINT8)((inSizeRange->hdMaxSize>>8)&0xff);
dkato 0:f5de229c9a00 839 sendData[8] = (UINT8)(inSizeRange->dtMinSize&0xff);
dkato 0:f5de229c9a00 840 sendData[9] = (UINT8)((inSizeRange->dtMinSize>>8)&0xff);
dkato 0:f5de229c9a00 841 sendData[10] = (UINT8)(inSizeRange->dtMaxSize&0xff);
dkato 0:f5de229c9a00 842 sendData[11] = (UINT8)((inSizeRange->dtMaxSize>>8)&0xff);
dkato 0:f5de229c9a00 843 /* Send SetSizeRange command signal */
dkato 0:f5de229c9a00 844 ret = HVC_SendCommand(HVC_COM_SET_SIZE_RANGE, sizeof(UINT8)*12, sendData);
dkato 0:f5de229c9a00 845 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 846
dkato 0:f5de229c9a00 847 /* Receive header */
dkato 0:f5de229c9a00 848 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 849 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 850 return 0;
dkato 0:f5de229c9a00 851 }
dkato 0:f5de229c9a00 852
dkato 0:f5de229c9a00 853 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 854 /* HVC_GetSizeRange */
dkato 0:f5de229c9a00 855 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 856 /* : HVC_SIZERANGE *outSizeRange detection sizes */
dkato 0:f5de229c9a00 857 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 858 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 859 /* : 0...normal */
dkato 0:f5de229c9a00 860 /* : -1...parameter error */
dkato 0:f5de229c9a00 861 /* : other...signal error */
dkato 0:f5de229c9a00 862 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 863 INT32 HVC_GetSizeRange(INT32 inTimeOutTime, HVC_SIZERANGE *outSizeRange, UINT8 *outStatus)
dkato 0:f5de229c9a00 864 {
dkato 0:f5de229c9a00 865 INT32 ret = 0;
dkato 0:f5de229c9a00 866 INT32 size = 0;
dkato 0:f5de229c9a00 867 UINT8 recvData[32];
dkato 0:f5de229c9a00 868
dkato 0:f5de229c9a00 869 if((NULL == outSizeRange) || (NULL == outStatus)){
dkato 0:f5de229c9a00 870 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 871 }
dkato 0:f5de229c9a00 872
dkato 0:f5de229c9a00 873 /* Send GetSizeRange command signal */
dkato 0:f5de229c9a00 874 ret = HVC_SendCommand(HVC_COM_GET_SIZE_RANGE, 0, NULL);
dkato 0:f5de229c9a00 875 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 876
dkato 0:f5de229c9a00 877 /* Receive header */
dkato 0:f5de229c9a00 878 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 879 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 880
dkato 0:f5de229c9a00 881 if ( size > (INT32)sizeof(UINT8)*12 ) {
dkato 0:f5de229c9a00 882 size = sizeof(UINT8)*12;
dkato 0:f5de229c9a00 883 }
dkato 0:f5de229c9a00 884
dkato 0:f5de229c9a00 885 /* Receive data */
dkato 0:f5de229c9a00 886 ret = HVC_ReceiveData(inTimeOutTime, size, recvData);
dkato 0:f5de229c9a00 887 outSizeRange->bdMinSize = recvData[0] + (recvData[1]<<8);
dkato 0:f5de229c9a00 888 outSizeRange->bdMaxSize = recvData[2] + (recvData[3]<<8);
dkato 0:f5de229c9a00 889 outSizeRange->hdMinSize = recvData[4] + (recvData[5]<<8);
dkato 0:f5de229c9a00 890 outSizeRange->hdMaxSize = recvData[6] + (recvData[7]<<8);
dkato 0:f5de229c9a00 891 outSizeRange->dtMinSize = recvData[8] + (recvData[9]<<8);
dkato 0:f5de229c9a00 892 outSizeRange->dtMaxSize = recvData[10] + (recvData[11]<<8);
dkato 0:f5de229c9a00 893 return ret;
dkato 0:f5de229c9a00 894 }
dkato 0:f5de229c9a00 895
dkato 0:f5de229c9a00 896 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 897 /* HVC_SetFaceDetectionAngle */
dkato 0:f5de229c9a00 898 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 899 /* : INT32 inPose Yaw angle range */
dkato 0:f5de229c9a00 900 /* : INT32 inAngle Roll angle range */
dkato 0:f5de229c9a00 901 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 902 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 903 /* : 0...normal */
dkato 0:f5de229c9a00 904 /* : -1...parameter error */
dkato 0:f5de229c9a00 905 /* : other...signal error */
dkato 0:f5de229c9a00 906 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 907 INT32 HVC_SetFaceDetectionAngle(INT32 inTimeOutTime, INT32 inPose, INT32 inAngle, UINT8 *outStatus)
dkato 0:f5de229c9a00 908 {
dkato 0:f5de229c9a00 909 INT32 ret = 0;
dkato 0:f5de229c9a00 910 INT32 size = 0;
dkato 0:f5de229c9a00 911 UINT8 sendData[32];
dkato 0:f5de229c9a00 912
dkato 0:f5de229c9a00 913 if(NULL == outStatus){
dkato 0:f5de229c9a00 914 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 915 }
dkato 0:f5de229c9a00 916
dkato 0:f5de229c9a00 917 sendData[0] = (UINT8)(inPose&0xff);
dkato 0:f5de229c9a00 918 sendData[1] = (UINT8)(inAngle&0xff);
dkato 0:f5de229c9a00 919 /* Send SetFaceDetectionAngle command signal */
dkato 0:f5de229c9a00 920 ret = HVC_SendCommand(HVC_COM_SET_DETECTION_ANGLE, sizeof(UINT8)*2, sendData);
dkato 0:f5de229c9a00 921 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 922
dkato 0:f5de229c9a00 923 /* Receive header */
dkato 0:f5de229c9a00 924 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 925 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 926 return 0;
dkato 0:f5de229c9a00 927 }
dkato 0:f5de229c9a00 928
dkato 0:f5de229c9a00 929 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 930 /* HVC_GetFaceDetectionAngle */
dkato 0:f5de229c9a00 931 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 932 /* : INT32 *outPose Yaw angle range */
dkato 0:f5de229c9a00 933 /* : INT32 *outAngle Roll angle range */
dkato 0:f5de229c9a00 934 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 935 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 936 /* : 0...normal */
dkato 0:f5de229c9a00 937 /* : -1...parameter error */
dkato 0:f5de229c9a00 938 /* : other...signal error */
dkato 0:f5de229c9a00 939 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 940 INT32 HVC_GetFaceDetectionAngle(INT32 inTimeOutTime, INT32 *outPose, INT32 *outAngle, UINT8 *outStatus)
dkato 0:f5de229c9a00 941 {
dkato 0:f5de229c9a00 942 INT32 ret = 0;
dkato 0:f5de229c9a00 943 INT32 size = 0;
dkato 0:f5de229c9a00 944 UINT8 recvData[32];
dkato 0:f5de229c9a00 945
dkato 0:f5de229c9a00 946 if((NULL == outPose) || (NULL == outAngle) || (NULL == outStatus)){
dkato 0:f5de229c9a00 947 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 948 }
dkato 0:f5de229c9a00 949
dkato 0:f5de229c9a00 950 /* Send GetFaceDetectionAngle signal command */
dkato 0:f5de229c9a00 951 ret = HVC_SendCommand(HVC_COM_GET_DETECTION_ANGLE, 0, NULL);
dkato 0:f5de229c9a00 952 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 953
dkato 0:f5de229c9a00 954 /* Receive header */
dkato 0:f5de229c9a00 955 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 956 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 957
dkato 0:f5de229c9a00 958 if ( size > (INT32)sizeof(UINT8)*2 ) {
dkato 0:f5de229c9a00 959 size = sizeof(UINT8)*2;
dkato 0:f5de229c9a00 960 }
dkato 0:f5de229c9a00 961
dkato 0:f5de229c9a00 962 /* Receive data */
dkato 0:f5de229c9a00 963 ret = HVC_ReceiveData(inTimeOutTime, size, recvData);
dkato 0:f5de229c9a00 964 *outPose = recvData[0];
dkato 0:f5de229c9a00 965 *outAngle = recvData[1];
dkato 0:f5de229c9a00 966 return ret;
dkato 0:f5de229c9a00 967 }
dkato 0:f5de229c9a00 968
dkato 0:f5de229c9a00 969 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 970 /* HVC_SetBaudRate */
dkato 0:f5de229c9a00 971 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 972 /* : INT32 inRate Baudrate */
dkato 0:f5de229c9a00 973 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 974 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 975 /* : 0...normal */
dkato 0:f5de229c9a00 976 /* : -1...parameter error */
dkato 0:f5de229c9a00 977 /* : other...signal error */
dkato 0:f5de229c9a00 978 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 979 INT32 HVC_SetBaudRate(INT32 inTimeOutTime, INT32 inRate, UINT8 *outStatus)
dkato 0:f5de229c9a00 980 {
dkato 0:f5de229c9a00 981 INT32 ret = 0;
dkato 0:f5de229c9a00 982 INT32 size = 0;
dkato 0:f5de229c9a00 983 UINT8 sendData[32];
dkato 0:f5de229c9a00 984
dkato 0:f5de229c9a00 985 if(NULL == outStatus){
dkato 0:f5de229c9a00 986 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 987 }
dkato 0:f5de229c9a00 988
dkato 0:f5de229c9a00 989 sendData[0] = (UINT8)(inRate&0xff);
dkato 0:f5de229c9a00 990 /* Send SetBaudRate command signal */
dkato 0:f5de229c9a00 991 ret = HVC_SendCommand(HVC_COM_SET_BAUDRATE, sizeof(UINT8), sendData);
dkato 0:f5de229c9a00 992 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 993
dkato 0:f5de229c9a00 994 /* Receive header */
dkato 0:f5de229c9a00 995 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 996 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 997 return 0;
dkato 0:f5de229c9a00 998 }
dkato 0:f5de229c9a00 999
dkato 0:f5de229c9a00 1000 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1001 /* HVC_Registration */
dkato 0:f5de229c9a00 1002 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1003 /* : INT32 inUserID User ID (0-499) */
dkato 0:f5de229c9a00 1004 /* : INT32 inDataID Data ID (0-9) */
dkato 0:f5de229c9a00 1005 /* : HVC_IMAGE *outImage image info */
dkato 0:f5de229c9a00 1006 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1007 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1008 /* : 0...normal */
dkato 0:f5de229c9a00 1009 /* : -1...parameter error */
dkato 0:f5de229c9a00 1010 /* : other...signal error */
dkato 0:f5de229c9a00 1011 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1012 INT32 HVC_Registration(INT32 inTimeOutTime, INT32 inUserID, INT32 inDataID, HVC_IMAGE *outImage, UINT8 *outStatus)
dkato 0:f5de229c9a00 1013 {
dkato 0:f5de229c9a00 1014 INT32 ret = 0;
dkato 0:f5de229c9a00 1015 INT32 size = 0;
dkato 0:f5de229c9a00 1016 UINT8 sendData[32];
dkato 0:f5de229c9a00 1017 UINT8 recvData[32];
dkato 0:f5de229c9a00 1018
dkato 0:f5de229c9a00 1019 if((NULL == outImage) || (NULL == outStatus)){
dkato 0:f5de229c9a00 1020 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1021 }
dkato 0:f5de229c9a00 1022
dkato 0:f5de229c9a00 1023 /* Send Registration signal command */
dkato 0:f5de229c9a00 1024 sendData[0] = (UINT8)(inUserID&0xff);
dkato 0:f5de229c9a00 1025 sendData[1] = (UINT8)((inUserID>>8)&0xff);
dkato 0:f5de229c9a00 1026 sendData[2] = (UINT8)(inDataID&0xff);
dkato 0:f5de229c9a00 1027 ret = HVC_SendCommand(HVC_COM_REGISTRATION, sizeof(UINT8)*3, sendData);
dkato 0:f5de229c9a00 1028 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1029
dkato 0:f5de229c9a00 1030 /* Receive header */
dkato 0:f5de229c9a00 1031 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1032 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1033
dkato 0:f5de229c9a00 1034 /* Receive data */
dkato 0:f5de229c9a00 1035 if ( size >= (INT32)sizeof(UINT8)*4 ) {
dkato 0:f5de229c9a00 1036 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData);
dkato 0:f5de229c9a00 1037 outImage->width = recvData[0] + (recvData[1]<<8);
dkato 0:f5de229c9a00 1038 outImage->height = recvData[2] + (recvData[3]<<8);
dkato 0:f5de229c9a00 1039 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1040 size -= sizeof(UINT8)*4;
dkato 0:f5de229c9a00 1041 }
dkato 0:f5de229c9a00 1042
dkato 0:f5de229c9a00 1043 /* Image data */
dkato 0:f5de229c9a00 1044 if ( size >= (INT32)sizeof(UINT8)*64*64 ) {
dkato 0:f5de229c9a00 1045 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*64*64, outImage->image);
dkato 0:f5de229c9a00 1046 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1047 size -= sizeof(UINT8)*64*64;
dkato 0:f5de229c9a00 1048 }
dkato 0:f5de229c9a00 1049 return 0;
dkato 0:f5de229c9a00 1050 }
dkato 0:f5de229c9a00 1051
dkato 0:f5de229c9a00 1052 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1053 /* HVC_DeleteData */
dkato 0:f5de229c9a00 1054 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1055 /* : INT32 inUserID User ID (0-499) */
dkato 0:f5de229c9a00 1056 /* : INT32 inDataID Data ID (0-9) */
dkato 0:f5de229c9a00 1057 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1058 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1059 /* : 0...normal */
dkato 0:f5de229c9a00 1060 /* : -1...parameter error */
dkato 0:f5de229c9a00 1061 /* : other...signal error */
dkato 0:f5de229c9a00 1062 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1063 INT32 HVC_DeleteData(INT32 inTimeOutTime, INT32 inUserID, INT32 inDataID, UINT8 *outStatus)
dkato 0:f5de229c9a00 1064 {
dkato 0:f5de229c9a00 1065 INT32 ret = 0;
dkato 0:f5de229c9a00 1066 INT32 size = 0;
dkato 0:f5de229c9a00 1067 UINT8 sendData[32];
dkato 0:f5de229c9a00 1068
dkato 0:f5de229c9a00 1069 if(NULL == outStatus){
dkato 0:f5de229c9a00 1070 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1071 }
dkato 0:f5de229c9a00 1072
dkato 0:f5de229c9a00 1073 /* Send Delete Data signal command */
dkato 0:f5de229c9a00 1074 sendData[0] = (UINT8)(inUserID&0xff);
dkato 0:f5de229c9a00 1075 sendData[1] = (UINT8)((inUserID>>8)&0xff);
dkato 0:f5de229c9a00 1076 sendData[2] = (UINT8)(inDataID&0xff);
dkato 0:f5de229c9a00 1077 ret = HVC_SendCommand(HVC_COM_DELETE_DATA, sizeof(UINT8)*3, sendData);
dkato 0:f5de229c9a00 1078 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1079
dkato 0:f5de229c9a00 1080 /* Receive header */
dkato 0:f5de229c9a00 1081 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1082 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1083 return 0;
dkato 0:f5de229c9a00 1084 }
dkato 0:f5de229c9a00 1085
dkato 0:f5de229c9a00 1086 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1087 /* HVC_DeleteUser */
dkato 0:f5de229c9a00 1088 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1089 /* : INT32 inUserID User ID (0-499) */
dkato 0:f5de229c9a00 1090 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1091 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1092 /* : 0...normal */
dkato 0:f5de229c9a00 1093 /* : -1...parameter error */
dkato 0:f5de229c9a00 1094 /* : other...signal error */
dkato 0:f5de229c9a00 1095 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1096 INT32 HVC_DeleteUser(INT32 inTimeOutTime, INT32 inUserID, UINT8 *outStatus)
dkato 0:f5de229c9a00 1097 {
dkato 0:f5de229c9a00 1098 INT32 ret = 0;
dkato 0:f5de229c9a00 1099 INT32 size = 0;
dkato 0:f5de229c9a00 1100 UINT8 sendData[32];
dkato 0:f5de229c9a00 1101
dkato 0:f5de229c9a00 1102 if(NULL == outStatus){
dkato 0:f5de229c9a00 1103 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1104 }
dkato 0:f5de229c9a00 1105
dkato 0:f5de229c9a00 1106 /* Send Delete User signal command */
dkato 0:f5de229c9a00 1107 sendData[0] = (UINT8)(inUserID&0xff);
dkato 0:f5de229c9a00 1108 sendData[1] = (UINT8)((inUserID>>8)&0xff);
dkato 0:f5de229c9a00 1109 ret = HVC_SendCommand(HVC_COM_DELETE_USER, sizeof(UINT8)*2, sendData);
dkato 0:f5de229c9a00 1110 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1111
dkato 0:f5de229c9a00 1112 /* Receive header */
dkato 0:f5de229c9a00 1113 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1114 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1115 return 0;
dkato 0:f5de229c9a00 1116 }
dkato 0:f5de229c9a00 1117
dkato 0:f5de229c9a00 1118 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1119 /* HVC_DeleteAll */
dkato 0:f5de229c9a00 1120 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1121 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1122 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1123 /* : 0...normal */
dkato 0:f5de229c9a00 1124 /* : -1...parameter error */
dkato 0:f5de229c9a00 1125 /* : other...signal error */
dkato 0:f5de229c9a00 1126 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1127 INT32 HVC_DeleteAll(INT32 inTimeOutTime, UINT8 *outStatus)
dkato 0:f5de229c9a00 1128 {
dkato 0:f5de229c9a00 1129 INT32 ret = 0;
dkato 0:f5de229c9a00 1130 INT32 size = 0;
dkato 0:f5de229c9a00 1131
dkato 0:f5de229c9a00 1132 if(NULL == outStatus){
dkato 0:f5de229c9a00 1133 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1134 }
dkato 0:f5de229c9a00 1135
dkato 0:f5de229c9a00 1136 /* Send Delete All signal command */
dkato 0:f5de229c9a00 1137 ret = HVC_SendCommand(HVC_COM_DELETE_ALL, 0, NULL);
dkato 0:f5de229c9a00 1138 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1139
dkato 0:f5de229c9a00 1140 /* Receive header */
dkato 0:f5de229c9a00 1141 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1142 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1143 return 0;
dkato 0:f5de229c9a00 1144 }
dkato 0:f5de229c9a00 1145
dkato 0:f5de229c9a00 1146 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1147 /* HVC_GetUserData */
dkato 0:f5de229c9a00 1148 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1149 /* : INT32 inUserID User ID (0-499) */
dkato 0:f5de229c9a00 1150 /* : INT32 *outDataNo Registration Info */
dkato 0:f5de229c9a00 1151 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1152 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1153 /* : 0...normal */
dkato 0:f5de229c9a00 1154 /* : -1...parameter error */
dkato 0:f5de229c9a00 1155 /* : other...signal error */
dkato 0:f5de229c9a00 1156 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1157 INT32 HVC_GetUserData(INT32 inTimeOutTime, INT32 inUserID, INT32 *outDataNo, UINT8 *outStatus)
dkato 0:f5de229c9a00 1158 {
dkato 0:f5de229c9a00 1159 INT32 ret = 0;
dkato 0:f5de229c9a00 1160 INT32 size = 0;
dkato 0:f5de229c9a00 1161 UINT8 sendData[8];
dkato 0:f5de229c9a00 1162 UINT8 recvData[8];
dkato 0:f5de229c9a00 1163
dkato 0:f5de229c9a00 1164 if((NULL == outDataNo) || (NULL == outStatus)){
dkato 0:f5de229c9a00 1165 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1166 }
dkato 0:f5de229c9a00 1167
dkato 0:f5de229c9a00 1168 /* Send Get Registration Info signal command */
dkato 0:f5de229c9a00 1169 sendData[0] = (UINT8)(inUserID&0xff);
dkato 0:f5de229c9a00 1170 sendData[1] = (UINT8)((inUserID>>8)&0xff);
dkato 0:f5de229c9a00 1171 ret = HVC_SendCommand(HVC_COM_GET_PERSON_DATA, sizeof(UINT8)*2, sendData);
dkato 0:f5de229c9a00 1172 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1173
dkato 0:f5de229c9a00 1174 /* Receive header */
dkato 0:f5de229c9a00 1175 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1176 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1177
dkato 0:f5de229c9a00 1178 if ( size > (INT32)sizeof(UINT8)*2 ) {
dkato 0:f5de229c9a00 1179 size = sizeof(UINT8)*2;
dkato 0:f5de229c9a00 1180 }
dkato 0:f5de229c9a00 1181
dkato 0:f5de229c9a00 1182 /* Receive data */
dkato 0:f5de229c9a00 1183 ret = HVC_ReceiveData(inTimeOutTime, size, recvData);
dkato 0:f5de229c9a00 1184 *outDataNo = recvData[0] + (recvData[1]<<8);
dkato 0:f5de229c9a00 1185 return ret;
dkato 0:f5de229c9a00 1186 }
dkato 0:f5de229c9a00 1187
dkato 0:f5de229c9a00 1188 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1189 /* HVC_SaveAlbum */
dkato 0:f5de229c9a00 1190 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1191 /* : UINT8 *outAlbumData Album data */
dkato 0:f5de229c9a00 1192 /* : INT32 *outAlbumDataSize Album data size */
dkato 0:f5de229c9a00 1193 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1194 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1195 /* : 0...normal */
dkato 0:f5de229c9a00 1196 /* : -1...parameter error */
dkato 0:f5de229c9a00 1197 /* : other...signal error */
dkato 0:f5de229c9a00 1198 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1199 INT32 HVC_SaveAlbum(INT32 inTimeOutTime, UINT8 *outAlbumData, INT32 *outAlbumDataSize, UINT8 *outStatus)
dkato 0:f5de229c9a00 1200 {
dkato 0:f5de229c9a00 1201 INT32 ret = 0;
dkato 0:f5de229c9a00 1202 INT32 size = 0;
dkato 0:f5de229c9a00 1203
dkato 0:f5de229c9a00 1204 UINT8 *tmpAlbumData = NULL;;
dkato 0:f5de229c9a00 1205
dkato 0:f5de229c9a00 1206 if((NULL == outAlbumData) || (NULL == outAlbumDataSize) || (NULL == outStatus)){
dkato 0:f5de229c9a00 1207 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1208 }
dkato 0:f5de229c9a00 1209
dkato 0:f5de229c9a00 1210 /* Send Save Album signal command */
dkato 0:f5de229c9a00 1211 ret = HVC_SendCommand(HVC_COM_SAVE_ALBUM, 0, NULL);
dkato 0:f5de229c9a00 1212 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1213
dkato 0:f5de229c9a00 1214 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1215 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1216
dkato 0:f5de229c9a00 1217 if ( size >= (INT32)sizeof(UINT8)*8 + HVC_ALBUM_SIZE_MIN ) {
dkato 0:f5de229c9a00 1218 *outAlbumDataSize = size;
dkato 0:f5de229c9a00 1219 tmpAlbumData = outAlbumData;
dkato 0:f5de229c9a00 1220
dkato 0:f5de229c9a00 1221 do{
dkato 0:f5de229c9a00 1222 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, tmpAlbumData);
dkato 0:f5de229c9a00 1223 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1224 tmpAlbumData += sizeof(UINT8)*4;
dkato 0:f5de229c9a00 1225
dkato 0:f5de229c9a00 1226 ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, tmpAlbumData);
dkato 0:f5de229c9a00 1227 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1228 tmpAlbumData += sizeof(UINT8)*4;
dkato 0:f5de229c9a00 1229
dkato 0:f5de229c9a00 1230 ret = HVC_ReceiveData(inTimeOutTime, size - sizeof(UINT8)*8, tmpAlbumData);
dkato 0:f5de229c9a00 1231 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1232 }while(0);
dkato 0:f5de229c9a00 1233 }
dkato 0:f5de229c9a00 1234 return ret;
dkato 0:f5de229c9a00 1235 }
dkato 0:f5de229c9a00 1236
dkato 0:f5de229c9a00 1237
dkato 0:f5de229c9a00 1238 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1239 /* HVC_LoadAlbum */
dkato 0:f5de229c9a00 1240 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1241 /* : UINT8 *inAlbumData Album data */
dkato 0:f5de229c9a00 1242 /* : INT32 inAlbumDataSize Album data size */
dkato 0:f5de229c9a00 1243 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1244 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1245 /* : 0...normal */
dkato 0:f5de229c9a00 1246 /* : -1...parameter error */
dkato 0:f5de229c9a00 1247 /* : other...signal error */
dkato 0:f5de229c9a00 1248 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1249 INT32 HVC_LoadAlbum(INT32 inTimeOutTime, UINT8 *inAlbumData, INT32 inAlbumDataSize, UINT8 *outStatus)
dkato 0:f5de229c9a00 1250 {
dkato 0:f5de229c9a00 1251 INT32 ret = 0;
dkato 0:f5de229c9a00 1252 INT32 size = 0;
dkato 0:f5de229c9a00 1253
dkato 0:f5de229c9a00 1254 if((NULL == inAlbumData) || (NULL == outStatus)){
dkato 0:f5de229c9a00 1255 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1256 }
dkato 0:f5de229c9a00 1257
dkato 0:f5de229c9a00 1258 /* Send Save Album signal command */
dkato 0:f5de229c9a00 1259 ret = HVC_SendCommandOfLoadAlbum(HVC_COM_LOAD_ALBUM, inAlbumDataSize, inAlbumData);
dkato 0:f5de229c9a00 1260 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1261
dkato 0:f5de229c9a00 1262 /* Receive header */
dkato 0:f5de229c9a00 1263 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1264 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1265
dkato 0:f5de229c9a00 1266 return ret;
dkato 0:f5de229c9a00 1267 }
dkato 0:f5de229c9a00 1268
dkato 0:f5de229c9a00 1269 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1270 /* HVC_WriteAlbum */
dkato 0:f5de229c9a00 1271 /* param : INT32 inTimeOutTime timeout time (ms) */
dkato 0:f5de229c9a00 1272 /* : UINT8 *outStatus response code */
dkato 0:f5de229c9a00 1273 /* return : INT32 execution result error code */
dkato 0:f5de229c9a00 1274 /* : 0...normal */
dkato 0:f5de229c9a00 1275 /* : -1...parameter error */
dkato 0:f5de229c9a00 1276 /* : other...signal error */
dkato 0:f5de229c9a00 1277 /*----------------------------------------------------------------------------*/
dkato 0:f5de229c9a00 1278 INT32 HVC_WriteAlbum(INT32 inTimeOutTime, UINT8 *outStatus)
dkato 0:f5de229c9a00 1279 {
dkato 0:f5de229c9a00 1280 INT32 ret = 0;
dkato 0:f5de229c9a00 1281 INT32 size = 0;
dkato 0:f5de229c9a00 1282
dkato 0:f5de229c9a00 1283 if(NULL == outStatus){
dkato 0:f5de229c9a00 1284 return HVC_ERROR_PARAMETER;
dkato 0:f5de229c9a00 1285 }
dkato 0:f5de229c9a00 1286
dkato 0:f5de229c9a00 1287 /* Send Write Album signal command */
dkato 0:f5de229c9a00 1288 ret = HVC_SendCommand(HVC_COM_WRITE_ALBUM, 0, NULL);
dkato 0:f5de229c9a00 1289 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1290
dkato 0:f5de229c9a00 1291 /* Receive header */
dkato 0:f5de229c9a00 1292 ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus);
dkato 0:f5de229c9a00 1293 if ( ret != 0 ) return ret;
dkato 0:f5de229c9a00 1294
dkato 0:f5de229c9a00 1295 return ret;
dkato 0:f5de229c9a00 1296 }
dkato 0:f5de229c9a00 1297