- Timestamp:
- 01/18/10 17:53:21 (14 years ago)
- Location:
- branches/smartreader/csctapi
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/smartreader/csctapi/config.h
r1186 r1280 91 91 /* #undef ICC_TYPE_SYNC */ 92 92 93 /* Smartcard with direct convention */94 /* #undef IFD_TOWITOKO_CONVENTION_DIRECT */95 96 /* Smartcard with inverse convention */97 /* #undef IFD_TOWITOKO_CONVENTION_INVERSE */98 99 93 /* ATR for asynchronous cards is cheked */ 100 94 #define IFD_TOWITOKO_STRICT_ATR_CHECK 1 -
branches/smartreader/csctapi/ct_slot.c
r1271 r1280 121 121 unsigned buffer_len = 0; 122 122 123 /* Initiaice ICC */ 124 slot->icc = ICC_Async_New (); 125 126 if (slot->icc == NULL) 127 return ERR_MEMORY; 128 129 if (ICC_Async_Init (slot->icc) != ICC_ASYNC_OK) 130 { 131 ICC_Async_Delete (slot->icc); 132 133 slot->icc = NULL; 134 slot->icc_type = CT_SLOT_NULL; 123 if (ICC_Async_Init () != ICC_ASYNC_OK) 124 { 135 125 return ERR_TRANS; 136 126 … … 148 138 if (slot->icc_type == CT_SLOT_ICC_ASYNC) 149 139 { 150 pps = PPS_New( (ICC_Async *) slot->icc);140 pps = PPS_New(); 151 141 152 142 if (pps == NULL) 153 143 { 154 ICC_Async_Close ((ICC_Async *) slot->icc); 155 ICC_Async_Delete ((ICC_Async *) slot->icc); 144 ICC_Async_Close (); 156 145 157 146 slot->icc = NULL; … … 169 158 PPS_Delete (pps); 170 159 171 ICC_Async_Close ((ICC_Async *) slot->icc); 172 ICC_Async_Delete ((ICC_Async *) slot->icc); 160 ICC_Async_Close (); 173 161 174 162 slot->icc = NULL; … … 222 210 if (slot->icc_type == CT_SLOT_ICC_ASYNC) 223 211 { 224 if (ICC_Async_Close ((ICC_Async *) slot->icc) != ICC_ASYNC_OK) 225 ret = ERR_TRANS; 226 227 ICC_Async_Delete ((ICC_Async *) slot->icc); 212 if (ICC_Async_Close () != ICC_ASYNC_OK) 213 ret = ERR_TRANS; 228 214 } 229 215 … … 241 227 if (slot->protocol_type == CT_SLOT_PROTOCOL_T0) /* T=0 protocol ICC */ 242 228 { 243 if (Protocol_T0_Command ( (Protocol_T0 *) slot->protocol,cmd, rsp) != PROTOCOL_T0_OK)229 if (Protocol_T0_Command ( cmd, rsp) != PROTOCOL_T0_OK) 244 230 ret = ERR_TRANS; 245 231 else … … 255 241 else if (slot->protocol_type == CT_SLOT_PROTOCOL_T14) /* T=14 protocol ICC */ 256 242 { 257 if (Protocol_T14_Command ( (Protocol_T14 *) slot->protocol,cmd, rsp) != PROTOCOL_T14_OK)243 if (Protocol_T14_Command (cmd, rsp) != PROTOCOL_T14_OK) 258 244 ret = ERR_TRANS; 259 245 else … … 290 276 { 291 277 if (slot->icc_type == CT_SLOT_ICC_ASYNC) 292 return ((void *) ICC_Async_GetAtr((ICC_Async *) slot->icc)); 278 return ((void *) atr ); 279 //return ((void *) ICC_Async_GetAtr((ICC_Async *) slot->icc)); 293 280 294 281 return NULL; … … 338 325 if (slot->icc_type == CT_SLOT_ICC_ASYNC) 339 326 { 340 if (ICC_Async_Close ((ICC_Async *) slot->icc) != ICC_ASYNC_OK) 341 ret = ERR_TRANS; 342 343 ICC_Async_Delete ((ICC_Async *) slot->icc); 327 if (ICC_Async_Close () != ICC_ASYNC_OK) 328 ret = ERR_TRANS; 344 329 } 345 330 -
branches/smartreader/csctapi/icc_async.c
r1271 r1280 43 43 44 44 static void ICC_Async_InvertBuffer (unsigned size, BYTE * buffer); 45 static void ICC_Async_Clear ( ICC_Async * icc);45 static void ICC_Async_Clear (); 46 46 47 47 int fdmc=(-1); … … 50 50 * Exported functions definition 51 51 */ 52 53 ICC_Async *ICC_Async_New (void)54 {55 ICC_Async *icc;56 57 /* Allocate memory */58 icc = (ICC_Async *) malloc (sizeof (ICC_Async));59 60 if (icc != NULL)61 ICC_Async_Clear (icc);62 63 return icc;64 }65 52 66 53 int ICC_Async_Device_Init () … … 196 183 } 197 184 198 int ICC_Async_Init ( ICC_Async * icc)185 int ICC_Async_Init () 199 186 { 200 187 #ifndef ICC_TYPE_SYNC … … 211 198 /* Reset ICC */ 212 199 if (reader[ridx].typ == R_INTERNAL) { 213 if (!Sci_Reset(&( icc->atr)))214 { 215 icc->atr = NULL;200 if (!Sci_Reset(&(atr))) 201 { 202 atr = NULL; 216 203 return ICC_ASYNC_IFD_ERROR; 217 204 } … … 221 208 #ifdef COOL 222 209 if (reader[ridx].typ == R_INTERNAL) { 223 if (!Cool_Reset(&( icc->atr)))224 { 225 icc->atr = NULL;226 return ICC_ASYNC_IFD_ERROR; 227 } 228 } 229 else 230 #endif 231 if (!Phoenix_Reset(&( icc->atr)))232 { 233 icc->atr = NULL;210 if (!Cool_Reset(&(atr))) 211 { 212 atr = NULL; 213 return ICC_ASYNC_IFD_ERROR; 214 } 215 } 216 else 217 #endif 218 if (!Phoenix_Reset(&(atr))) 219 { 220 atr = NULL; 234 221 return ICC_ASYNC_IFD_ERROR; 235 222 } 236 223 /* Get ICC convention */ 237 if (ATR_GetConvention ( icc->atr, &(icc->convention)) != ATR_OK)238 { 239 ATR_Delete ( icc->atr);240 icc->atr = NULL;241 icc->convention = 0;224 if (ATR_GetConvention (atr, &(convention)) != ATR_OK) 225 { 226 ATR_Delete (atr); 227 atr = NULL; 228 convention = 0; 242 229 243 230 return ICC_ASYNC_ATR_ERROR; 244 231 } 245 232 246 icc->protocol_type = ATR_PROTOCOL_TYPE_T0;247 248 ATR_GetNumberOfProtocols ( icc->atr, &np);233 protocol_type = ATR_PROTOCOL_TYPE_T0; 234 235 ATR_GetNumberOfProtocols (atr, &np); 249 236 250 237 /* … … 253 240 */ 254 241 /* if (np>1) 255 ATR_GetProtocolType ( icc->atr, 1, &(icc->protocol_type));242 ATR_GetProtocolType (atr, 1, &(protocol_type)); 256 243 257 244 #ifdef DEBUG_ICC 258 printf("ICC: Detected %s convention processor card T=%d\n",( icc->convention == ATR_CONVENTION_DIRECT ? "direct" : "inverse"), icc->protocol_type);245 printf("ICC: Detected %s convention processor card T=%d\n",(convention == ATR_CONVENTION_DIRECT ? "direct" : "inverse"), protocol_type); 259 246 #endif 260 247 *///really should let PPS handle this 261 248 262 249 /* Initialize member variables */ 263 icc->baudrate = ICC_ASYNC_BAUDRATE; 264 265 if (icc->convention == ATR_CONVENTION_INVERSE) 250 if (convention == ATR_CONVENTION_INVERSE) 266 251 { 267 252 if (!IO_Serial_SetParity (PARITY_ODD)) 268 253 return ICC_ASYNC_IFD_ERROR; 269 254 } 270 else if( icc->protocol_type == ATR_PROTOCOL_TYPE_T14)255 else if(protocol_type == ATR_PROTOCOL_TYPE_T14) 271 256 { 272 257 if (!IO_Serial_SetParity (PARITY_NONE)) … … 288 273 } 289 274 290 int ICC_Async_SetTimings (ICC_Async * icc, ICC_Async_Timings * timings) 291 { 292 icc->timings.block_delay = timings->block_delay; 293 icc->timings.char_delay = timings->char_delay; 294 icc->timings.block_timeout = timings->block_timeout; 295 icc->timings.char_timeout = timings->char_timeout; 296 /* if (icc->protocol_type == ATR_PROTOCOL_TYPE_T1) 275 int ICC_Async_SetTimings () 276 { 277 /* if (protocol_type == ATR_PROTOCOL_TYPE_T1) 297 278 cs_debug("SetTimings: T1: chardelay %d, chartimeout CWT %d, blockdelay BGT??? %d, blocktimeout BWT %d",timings->char_delay,timings->char_timeout, timings->block_delay, timings->block_timeout); 298 279 else … … 307 288 if (ioctl(reader[ridx].handle, IOCTL_GET_PARAMETERS, ¶ms) < 0 ) 308 289 return ICC_ASYNC_IFD_ERROR; 309 switch ( icc->protocol_type) {290 switch (protocol_type) { 310 291 case ATR_PROTOCOL_TYPE_T1: 311 params.BWT = icc ->timings.block_timeout;312 params.CWT = icc ->timings.char_timeout;313 //params.BGT = icc ->timings.block_delay; load into params.EGT??292 params.BWT = icc_timings.block_timeout; 293 params.CWT = icc_timings.char_timeout; 294 //params.BGT = icc_timings.block_delay; load into params.EGT?? 314 295 break; 315 296 case ATR_PROTOCOL_TYPE_T0: 316 297 case ATR_PROTOCOL_TYPE_T14: 317 298 default: 318 params.WWT = icc ->timings.char_timeout;299 params.WWT = icc_timings.char_timeout; 319 300 break; 320 301 } … … 328 309 } 329 310 330 int ICC_Async_GetTimings (ICC_Async * icc, ICC_Async_Timings * timings) 331 { 332 timings->block_delay = icc->timings.block_delay; 333 timings->char_delay = icc->timings.char_delay; 334 timings->block_timeout = icc->timings.block_timeout; 335 timings->char_timeout = icc->timings.char_timeout; 336 337 return ICC_ASYNC_OK; 338 } 339 340 int ICC_Async_SetBaudrate (ICC_Async * icc, unsigned long baudrate) 341 { 342 icc->baudrate = baudrate; 311 int ICC_Async_SetBaudrate (unsigned long baudrate) 312 { 343 313 if (!Phoenix_SetBaudrate (baudrate)) 344 314 return ICC_ASYNC_IFD_ERROR; … … 347 317 } 348 318 349 int ICC_Async_GetBaudrate ( ICC_Async * icc,unsigned long * baudrate)350 { 351 (*baudrate) = icc->baudrate;319 int ICC_Async_GetBaudrate (unsigned long * baudrate) 320 { 321 (*baudrate) = reader[ridx].baudrate; 352 322 return ICC_ASYNC_OK; 353 323 } 354 324 355 int ICC_Async_Transmit ( ICC_Async * icc,unsigned size, BYTE * data)325 int ICC_Async_Transmit (unsigned size, BYTE * data) 356 326 { 357 327 BYTE *buffer = NULL, *sent; 358 328 IFD_Timings timings; 359 329 360 if ( icc->convention == ATR_CONVENTION_INVERSE && reader[ridx].typ != R_INTERNAL)330 if (convention == ATR_CONVENTION_INVERSE && reader[ridx].typ != R_INTERNAL) 361 331 { 362 332 buffer = (BYTE *) calloc(sizeof (BYTE), size); … … 370 340 } 371 341 372 timings.block_delay = icc ->timings.block_delay;373 timings.char_delay = icc ->timings.char_delay;342 timings.block_delay = icc_timings.block_delay; 343 timings.char_delay = icc_timings.char_delay; 374 344 375 345 #ifdef COOL … … 383 353 return ICC_ASYNC_IFD_ERROR; 384 354 385 if ( icc->convention == ATR_CONVENTION_INVERSE)355 if (convention == ATR_CONVENTION_INVERSE) 386 356 free (buffer); 387 357 … … 389 359 } 390 360 391 int ICC_Async_Receive ( ICC_Async * icc,unsigned size, BYTE * data)361 int ICC_Async_Receive (unsigned size, BYTE * data) 392 362 { 393 363 IFD_Timings timings; 394 364 395 timings.block_timeout = icc ->timings.block_timeout;396 timings.char_timeout = icc ->timings.char_timeout;365 timings.block_timeout = icc_timings.block_timeout; 366 timings.char_timeout = icc_timings.char_timeout; 397 367 398 368 #ifdef COOL … … 407 377 #endif 408 378 409 if ( icc->convention == ATR_CONVENTION_INVERSE && reader[ridx].typ != R_INTERNAL)379 if (convention == ATR_CONVENTION_INVERSE && reader[ridx].typ != R_INTERNAL) 410 380 ICC_Async_InvertBuffer (size, data); 411 381 … … 413 383 } 414 384 415 ATR * ICC_Async_GetAtr (ICC_Async * icc) 416 { 417 return icc->atr; 418 } 419 420 int ICC_Async_Close (ICC_Async * icc) 385 int ICC_Async_Close () 421 386 { 422 387 #ifdef SCI_DEV … … 427 392 428 393 /* Delete atr */ 429 ATR_Delete ( icc->atr);430 431 ICC_Async_Clear ( icc);394 ATR_Delete (atr); 395 396 ICC_Async_Clear (); 432 397 433 398 return ICC_ASYNC_OK; … … 447 412 } 448 413 449 void ICC_Async_Delete (ICC_Async * icc)450 {451 free (icc);452 }453 454 414 /* 455 415 * Not exported functions definition … … 464 424 } 465 425 466 static void ICC_Async_Clear (ICC_Async * icc) 467 { 468 icc->atr = NULL; 469 icc->baudrate = 0L; 470 icc->convention = 0; 471 icc->protocol_type = -1; 472 icc->timings.block_delay = 0; 473 icc->timings.char_delay = 0; 474 icc->timings.block_timeout = 0; 475 icc->timings.char_timeout = 0; 476 } 426 static void ICC_Async_Clear () 427 { 428 atr = NULL; 429 convention = 0; 430 protocol_type = -1; 431 icc_timings.block_delay = 0; 432 icc_timings.char_delay = 0; 433 icc_timings.block_timeout = 0; 434 icc_timings.char_timeout = 0; 435 } -
branches/smartreader/csctapi/icc_async.h
r1271 r1280 58 58 } 59 59 ICC_Async_Timings; 60 60 /* 61 61 typedef struct 62 62 { 63 ATR *atr; /* Answer to reset of this ICC */64 int convention; /* Convention of this ICC */65 unsigned long baudrate; /* Current baudrate (bps) for transmiting to this ICC */66 ICC_Async_Timings timings; /* Current timings for transmiting to this ICC */67 BYTE protocol_type; /* Type of protocol */68 63 } 69 64 ICC_Async; 65 */ 66 ATR *atr; /* Answer to reset of this ICC */ 67 int convention; /* Convention of this ICC */ 68 BYTE protocol_type; /* Type of protocol */ 69 ICC_Async_Timings icc_timings; /* Current timings for transmiting to this ICC */ 70 70 71 71 /* … … 73 73 */ 74 74 75 /* Creation and Deletion */76 extern ICC_Async * ICC_Async_New (void);77 extern void ICC_Async_Delete (ICC_Async * icc);78 79 75 /* Initialization and Deactivation */ 80 extern int ICC_Async_Init ( ICC_Async * icc);81 extern int ICC_Async_Close ( ICC_Async * icc);76 extern int ICC_Async_Init (); 77 extern int ICC_Async_Close (); 82 78 83 79 /* Attributes */ 84 extern int ICC_Async_SetTimings (ICC_Async * icc, ICC_Async_Timings * timings); 85 extern int ICC_Async_GetTimings (ICC_Async * icc, ICC_Async_Timings * timings); 86 extern int ICC_Async_SetBaudrate (ICC_Async * icc, unsigned long baudrate); 87 extern int ICC_Async_GetBaudrate (ICC_Async * icc, unsigned long * baudrate); 88 extern ATR *ICC_Async_GetAtr (ICC_Async * icc); 80 extern int ICC_Async_SetTimings (); 81 extern int ICC_Async_SetBaudrate (unsigned long baudrate); 82 extern int ICC_Async_GetBaudrate (unsigned long * baudrate); 89 83 extern unsigned long ICC_Async_GetClockRate (); 90 84 91 85 /* Operations */ 92 extern int ICC_Async_Transmit ( ICC_Async * icc,unsigned size, BYTE * buffer);93 extern int ICC_Async_Receive ( ICC_Async * icc,unsigned size, BYTE * buffer);86 extern int ICC_Async_Transmit (unsigned size, BYTE * buffer); 87 extern int ICC_Async_Receive (unsigned size, BYTE * buffer); 94 88 95 89 #endif /* _ICC_ASYNC_ */ -
branches/smartreader/csctapi/ifd_phoenix.c
r1271 r1280 283 283 int Phoenix_SetBaudrate (unsigned long baudrate) 284 284 { 285 if(reader[ridx].typ == R_INTERNAL)286 return OK;287 288 285 #ifdef DEBUG_IFD 289 286 printf ("IFD: Setting baudrate to %lu\n", baudrate); 290 287 #endif 291 if (reader[ridx].baudrate == baudrate) 292 return OK; 293 294 /* Get current settings */ 295 struct termios tio; 296 if (tcgetattr (reader[ridx].handle, &tio) != 0) 297 return ERROR; 298 299 //write baudrate here! 300 if (!IO_Serial_SetBitrate (baudrate, &tio)) 301 return ERROR; 302 303 if (!IO_Serial_SetProperties(tio)) 304 return ERROR; 305 288 if ((reader[ridx].typ != R_INTERNAL) && (reader[ridx].baudrate != baudrate)) 289 { 290 /* Get current settings */ 291 struct termios tio; 292 if (tcgetattr (reader[ridx].handle, &tio) != 0) 293 return ERROR; 294 295 //write baudrate here! 296 if (!IO_Serial_SetBitrate (baudrate, &tio)) 297 return ERROR; 298 299 if (!IO_Serial_SetProperties(tio)) 300 return ERROR; 301 } 306 302 reader[ridx].baudrate = baudrate; 307 308 303 return OK; 309 304 } -
branches/smartreader/csctapi/pps.c
r1239 r1280 51 51 */ 52 52 53 static int PPS_Exchange ( PPS * pps,BYTE * params, unsigned *length);53 static int PPS_Exchange (BYTE * params, unsigned *length); 54 54 55 55 static bool PPS_Match (BYTE * request, unsigned len_request, BYTE * reply, unsigned len_reply); … … 67 67 */ 68 68 69 PPS * PPS_New ( ICC_Async * icc)69 PPS * PPS_New () 70 70 { 71 71 PPS *pps; … … 75 75 if (pps != NULL) 76 76 { 77 pps->icc = icc;78 77 pps->protocol = NULL; 79 78 pps->parameters.t = PPS_DEFAULT_PROTOCOL; … … 100 99 //also from FI -> F is easy, other way around not 101 100 102 ATR *atr;103 101 int ret; 104 102 bool PPS_success; … … 107 105 if ((*length) > 0) 108 106 { 109 ret = PPS_Exchange (p ps, params, length);107 ret = PPS_Exchange (params, length); 110 108 111 109 /* Get parameters from PPS handsake */ … … 136 134 PPS_success = PPS_OK; 137 135 int protocol_selected = 0; //stores which TAi,TBi etc. bytes must be used 0 means not set 138 atr = ICC_Async_GetAtr (pps->icc);139 136 if ((*length) <= 0 || !PPS_success) // If not by command, or PPS Exchange by command failed: Try PPS Exchange by ATR or Get parameters from ATR 140 137 { … … 225 222 //req[3]=PPS_GetPCK(req,sizeof(req)-1); will be set by PPS_Exchange 226 223 unsigned int len = sizeof(req); 227 ret = PPS_Exchange ( pps,req, &len);224 ret = PPS_Exchange (req, &len); 228 225 if (ret == PPS_OK) { 229 226 pps->parameters.FI = req[2] >> 4; … … 275 272 } 276 273 277 p ps->icc->protocol_type = pps->parameters.t;274 protocol_type = pps->parameters.t; 278 275 279 276 #ifdef DEBUG_PROTOCOL … … 319 316 */ 320 317 321 static int PPS_Exchange ( PPS * pps,BYTE * params, unsigned *length)318 static int PPS_Exchange (BYTE * params, unsigned *length) 322 319 { 323 320 BYTE confirm[PPS_MAX_LENGTH]; … … 363 360 return PPS_HANDSAKE_ERROR; 364 361 #else 365 if (ICC_Async_Transmit ( pps->icc,len_request, params) != ICC_ASYNC_OK)362 if (ICC_Async_Transmit (len_request, params) != ICC_ASYNC_OK) 366 363 return PPS_ICC_ERROR; 367 364 368 365 /* Get PPS confirm */ 369 if (ICC_Async_Receive ( pps->icc,2, confirm) != ICC_ASYNC_OK)366 if (ICC_Async_Receive (2, confirm) != ICC_ASYNC_OK) 370 367 return PPS_ICC_ERROR; 371 368 372 369 len_confirm = PPS_GetLength (confirm); 373 370 374 if (ICC_Async_Receive ( pps->icc,len_confirm - 2, confirm + 2) != ICC_ASYNC_OK)371 if (ICC_Async_Receive (len_confirm - 2, confirm + 2) != ICC_ASYNC_OK) 375 372 return PPS_ICC_ERROR; 376 373 … … 439 436 if (ioctl(reader[ridx].handle, IOCTL_GET_PARAMETERS, ¶ms) < 0 ) 440 437 return PPS_ICC_ERROR; 441 442 ATR *atr = ICC_Async_GetAtr (pps->icc);443 438 444 439 params.T = pps->parameters.t; … … 489 484 490 485 491 if (ICC_Async_SetBaudrate ( pps->icc,baudrate) != ICC_ASYNC_OK)486 if (ICC_Async_SetBaudrate (baudrate) != ICC_ASYNC_OK) 492 487 return PPS_ICC_ERROR; 493 488 … … 506 501 if ((pps->protocol) != NULL) 507 502 { 508 ret = Protocol_T0_Init ((Protocol_T0 *) pps->protocol, (ICC_Async *) pps->icc,&(pps->parameters), selected_protocol);503 ret = Protocol_T0_Init ((Protocol_T0 *) pps->protocol, &(pps->parameters), selected_protocol); 509 504 510 505 if (ret != PROTOCOL_T0_OK) … … 524 519 if (pps->protocol != NULL) 525 520 { 526 ret = Protocol_T1_Init ((Protocol_T1 *) pps->protocol, (ICC_Async *) pps->icc,selected_protocol);521 ret = Protocol_T1_Init ((Protocol_T1 *) pps->protocol, selected_protocol); 527 522 528 523 if (ret != PROTOCOL_T1_OK) … … 542 537 if ((pps->protocol) != NULL) 543 538 { 544 ret = Protocol_T14_Init ((Protocol_T14 *) pps->protocol, (ICC_Async *) pps->icc,&(pps->parameters), selected_protocol);539 ret = Protocol_T14_Init ((Protocol_T14 *) pps->protocol, &(pps->parameters), selected_protocol); 545 540 546 541 if (ret != PROTOCOL_T14_OK) -
branches/smartreader/csctapi/pps.h
r842 r1280 53 53 typedef struct 54 54 { 55 ICC_Async *icc;56 55 void *protocol; 57 56 PPS_ProtocolParameters parameters; … … 64 63 65 64 /* Create PPS context */ 66 extern PPS *PPS_New ( ICC_Async * icc);65 extern PPS *PPS_New (); 67 66 68 67 /* Perform protcol type selection and return confirm */ -
branches/smartreader/csctapi/protocol_t0.c
r1239 r1280 55 55 static void Protocol_T14_Clear (Protocol_T14 * t14); 56 56 57 static int Protocol_T0_Case1 ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);58 59 static int Protocol_T0_Case2S ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);60 static int Protocol_T14_Case2S ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp);61 62 static int Protocol_T0_Case3S ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);63 static int Protocol_T14_Case3S ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp);64 65 static int Protocol_T0_Case4S ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);66 67 static int Protocol_T0_Case2E ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);68 69 static int Protocol_T0_Case3E ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);70 71 static int Protocol_T0_Case4E ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);72 73 static int Protocol_T0_ExchangeTPDU ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);74 static int Protocol_T14_ExchangeTPDU ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp);57 static int Protocol_T0_Case1 (APDU_Cmd * cmd, APDU_Rsp ** rsp); 58 59 static int Protocol_T0_Case2S (APDU_Cmd * cmd, APDU_Rsp ** rsp); 60 static int Protocol_T14_Case2S (APDU_Cmd * cmd, APDU_Rsp ** rsp); 61 62 static int Protocol_T0_Case3S (APDU_Cmd * cmd, APDU_Rsp ** rsp); 63 static int Protocol_T14_Case3S (APDU_Cmd * cmd, APDU_Rsp ** rsp); 64 65 static int Protocol_T0_Case4S (APDU_Cmd * cmd, APDU_Rsp ** rsp); 66 67 static int Protocol_T0_Case2E (APDU_Cmd * cmd, APDU_Rsp ** rsp); 68 69 static int Protocol_T0_Case3E (APDU_Cmd * cmd, APDU_Rsp ** rsp); 70 71 static int Protocol_T0_Case4E (APDU_Cmd * cmd, APDU_Rsp ** rsp); 72 73 static int Protocol_T0_ExchangeTPDU (APDU_Cmd * cmd, APDU_Rsp ** rsp); 74 static int Protocol_T14_ExchangeTPDU (APDU_Cmd * cmd, APDU_Rsp ** rsp); 75 75 76 76 /* … … 102 102 } 103 103 104 int Protocol_T0_Init (Protocol_T0 * t0, ICC_Async * icc, PPS_ProtocolParameters * params, int selected_protocol) 105 { 106 ICC_Async_Timings timings; 104 int Protocol_T0_Init (Protocol_T0 * t0, PPS_ProtocolParameters * params, int selected_protocol) 105 { 107 106 BYTE wi; 108 #ifndef PROTOCOL_T0_USE_DEFAULT_TIMINGS109 ATR *atr = ICC_Async_GetAtr (icc);110 #endif111 112 /* Set ICC */113 t0->icc = icc;114 107 115 108 /* Integer value WI = TC2, by default 10 */ … … 124 117 125 118 /* Set timings */ 126 ICC_Async_GetTimings (t0->icc, &timings); 127 128 timings.block_timeout = t0->wwt; 129 timings.char_timeout = t0->wwt; 130 131 ICC_Async_SetTimings (t0->icc, &timings); 119 icc_timings.block_timeout = t0->wwt; 120 icc_timings.char_timeout = t0->wwt; 121 ICC_Async_SetTimings (); 132 122 133 123 #ifdef DEBUG_PROTOCOL … … 138 128 } 139 129 140 int Protocol_T14_Init (Protocol_T14 * t14, ICC_Async * icc, PPS_ProtocolParameters * params, int selected_protocol) 141 { 142 ICC_Async_Timings timings; 130 int Protocol_T14_Init (Protocol_T14 * t14, PPS_ProtocolParameters * params, int selected_protocol) 131 { 143 132 BYTE wi; 144 #ifndef PROTOCOL_T14_USE_DEFAULT_TIMINGS145 ATR *atr = ICC_Async_GetAtr (icc);146 #endif147 148 /* Set ICC */149 t14->icc = icc;150 133 151 134 /* Integer value WI = TC2, by default 10 */ … … 161 144 162 145 /* Set timings */ 163 ICC_Async_GetTimings (t14->icc, &timings); 164 165 timings.block_timeout = t14->wwt; 166 timings.char_timeout = t14->wwt; 167 168 ICC_Async_SetTimings (t14->icc, &timings); 169 146 icc_timings.block_timeout = t14->wwt; 147 icc_timings.char_timeout = t14->wwt; 148 ICC_Async_SetTimings (); 149 170 150 #ifdef DEBUG_PROTOCOL 171 151 printf ("Protocol: T=14: WWT=%d\n", (int)(t14->wwt)); … … 175 155 } 176 156 177 int Protocol_T0_Command ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)157 int Protocol_T0_Command (APDU_Cmd * cmd, APDU_Rsp ** rsp) 178 158 { 179 159 int cmd_case, ret; … … 187 167 188 168 if (cmd_case == APDU_CASE_1) 189 ret = Protocol_T0_Case1 ( t0,cmd, rsp);169 ret = Protocol_T0_Case1 (cmd, rsp); 190 170 else if (cmd_case == APDU_CASE_2S) 191 ret = Protocol_T0_Case2S ( t0,cmd, rsp);171 ret = Protocol_T0_Case2S (cmd, rsp); 192 172 else if (cmd_case == APDU_CASE_3S) 193 ret = Protocol_T0_Case3S ( t0,cmd, rsp);173 ret = Protocol_T0_Case3S (cmd, rsp); 194 174 else if (cmd_case == APDU_CASE_4S) 195 ret = Protocol_T0_Case4S ( t0,cmd, rsp);175 ret = Protocol_T0_Case4S (cmd, rsp); 196 176 else if (cmd_case == APDU_CASE_2E) 197 ret = Protocol_T0_Case2E ( t0,cmd, rsp);177 ret = Protocol_T0_Case2E (cmd, rsp); 198 178 else if (cmd_case == APDU_CASE_3E) 199 ret = Protocol_T0_Case3E ( t0,cmd, rsp);179 ret = Protocol_T0_Case3E (cmd, rsp); 200 180 else if (cmd_case == APDU_CASE_4E) 201 ret = Protocol_T0_Case4E ( t0,cmd, rsp);181 ret = Protocol_T0_Case4E (cmd, rsp); 202 182 else 203 183 { … … 211 191 } 212 192 213 int Protocol_T14_Command ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp)193 int Protocol_T14_Command (APDU_Cmd * cmd, APDU_Rsp ** rsp) 214 194 { 215 195 int cmd_case, ret; … … 224 204 if (cmd_case == APDU_CASE_2S) 225 205 { 226 ret = Protocol_T14_Case2S ( t14,cmd, rsp);206 ret = Protocol_T14_Case2S (cmd, rsp); 227 207 } 228 208 else if (cmd_case == APDU_CASE_3S) 229 209 { 230 ret = Protocol_T14_Case3S ( t14,cmd, rsp);210 ret = Protocol_T14_Case3S (cmd, rsp); 231 211 } 232 212 else … … 269 249 */ 270 250 271 static int Protocol_T0_Case1 ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)251 static int Protocol_T0_Case1 (APDU_Cmd * cmd, APDU_Rsp ** rsp) 272 252 { 273 253 int ret; … … 282 262 283 263 /* Send command TPDU */ 284 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, rsp);264 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, rsp); 285 265 286 266 /* Delete command TPDU */ … … 291 271 292 272 293 static int Protocol_T0_Case2S ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)273 static int Protocol_T0_Case2S (APDU_Cmd * cmd, APDU_Rsp ** rsp) 294 274 { 295 275 int ret; 296 276 297 277 /* Send command TPDU */ 298 ret = Protocol_T0_ExchangeTPDU (t0,cmd, rsp);278 ret = Protocol_T0_ExchangeTPDU(cmd, rsp); 299 279 300 280 return ret; 301 281 } 302 282 303 static int Protocol_T14_Case2S ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp)283 static int Protocol_T14_Case2S (APDU_Cmd * cmd, APDU_Rsp ** rsp) 304 284 { 305 285 int ret; 306 286 307 287 /* Send command TPDU */ 308 ret = Protocol_T14_ExchangeTPDU (t14,cmd, rsp);288 ret = Protocol_T14_ExchangeTPDU(cmd, rsp); 309 289 310 290 return ret; 311 291 } 312 292 313 static int Protocol_T0_Case3S ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)293 static int Protocol_T0_Case3S (APDU_Cmd * cmd, APDU_Rsp ** rsp) 314 294 { 315 295 int ret; … … 321 301 322 302 /* Send command TPDU */ 323 ret = Protocol_T0_ExchangeTPDU (t0,cmd, (&tpdu_rsp));303 ret = Protocol_T0_ExchangeTPDU(cmd, (&tpdu_rsp)); 324 304 325 305 if (ret == PROTOCOL_T0_OK) … … 344 324 345 325 /* Re-issue command TPDU */ 346 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, rsp);326 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, rsp); 347 327 348 328 /* Delete command TPDU */ … … 375 355 tpdu_cmd = APDU_Cmd_New (buffer, 5); 376 356 377 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, (&tpdu_rsp));357 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, (&tpdu_rsp)); 378 358 379 359 /* Delete command TPDU */ … … 414 394 } 415 395 416 static int Protocol_T14_Case3S ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp)396 static int Protocol_T14_Case3S (APDU_Cmd * cmd, APDU_Rsp ** rsp) 417 397 { 418 398 int ret; 419 399 420 400 /* Send command TPDU */ 421 ret = Protocol_T14_ExchangeTPDU (t14,cmd, rsp);401 ret = Protocol_T14_ExchangeTPDU(cmd, rsp); 422 402 423 403 return ret; 424 404 } 425 405 426 static int Protocol_T0_Case4S ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)406 static int Protocol_T0_Case4S (APDU_Cmd * cmd, APDU_Rsp ** rsp) 427 407 { 428 408 int ret; … … 437 417 438 418 /* Send command TPDU */ 439 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, (&tpdu_rsp));419 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, (&tpdu_rsp)); 440 420 441 421 /* Delete command TPDU */ … … 465 445 466 446 /* Issue Get Reponse command */ 467 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, rsp);447 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, rsp); 468 448 469 449 /* Delete command TPDU */ … … 504 484 505 485 506 static int Protocol_T0_Case2E ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)486 static int Protocol_T0_Case2E (APDU_Cmd * cmd, APDU_Rsp ** rsp) 507 487 { 508 488 int ret = PROTOCOL_T0_OK; … … 526 506 527 507 /* Send command TPDU */ 528 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, rsp);508 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, rsp); 529 509 530 510 /* Delete command TPDU */ … … 548 528 549 529 /* Send envelope command TPDU */ 550 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, (&tpdu_rsp));530 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, (&tpdu_rsp)); 551 531 552 532 /* Delete command TPDU */ … … 588 568 589 569 590 static int Protocol_T0_Case3E ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)570 static int Protocol_T0_Case3E (APDU_Cmd * cmd, APDU_Rsp ** rsp) 591 571 { 592 572 int ret; … … 608 588 609 589 /* Send command TPDU */ 610 ret = Protocol_T0_Case3S (t 0, tpdu_cmd, rsp);590 ret = Protocol_T0_Case3S (tpdu_cmd, rsp); 611 591 612 592 /* Delete command TPDU */ … … 625 605 626 606 /* Send command TPDU */ 627 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, (&tpdu_rsp));607 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, (&tpdu_rsp)); 628 608 629 609 /* Delete command TPDU */ … … 650 630 651 631 /* Re-issue command TPDU */ 652 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, rsp);632 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, rsp); 653 633 654 634 /* Delete command TPDU */ … … 676 656 677 657 /* Issue Get Response command TPDU */ 678 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, (&tpdu_rsp));658 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, (&tpdu_rsp)); 679 659 680 660 /* Delete command TPDU */ … … 714 694 715 695 716 static int Protocol_T0_Case4E ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)696 static int Protocol_T0_Case4E (APDU_Cmd * cmd, APDU_Rsp ** rsp) 717 697 { 718 698 int ret; … … 736 716 737 717 /* Send command TPDU */ 738 ret = Protocol_T0_ExchangeTPDU (t0,tpdu_cmd, (&tpdu_rsp));718 ret = Protocol_T0_ExchangeTPDU(tpdu_cmd, (&tpdu_rsp)); 739 719 740 720 /* Delete command TPDU */ … … 743 723 else /* 4E2 */ 744 724 { 745 ret = Protocol_T0_Case2E ( t0,cmd, (&tpdu_rsp));725 ret = Protocol_T0_Case2E (cmd, (&tpdu_rsp)); 746 726 } 747 727 … … 773 753 774 754 /* Issue Case 3E get response command */ 775 ret = Protocol_T0_Case3E ( t0,gr_cmd, rsp);755 ret = Protocol_T0_Case3E (gr_cmd, rsp); 776 756 777 757 /* Delete Get Response command APDU */ … … 800 780 801 781 /* Issue Case 3E get response command */ 802 ret = Protocol_T0_Case3E ( t0,gr_cmd, rsp);782 ret = Protocol_T0_Case3E (gr_cmd, rsp); 803 783 804 784 /* Delete Get Response command APDU */ … … 810 790 811 791 812 static int Protocol_T0_ExchangeTPDU ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp)792 static int Protocol_T0_ExchangeTPDU (APDU_Cmd * cmd, APDU_Rsp ** rsp) 813 793 { 814 794 BYTE buffer[PROTOCOL_T0_MAX_SHORT_RESPONSE]; … … 828 808 829 809 /* Send header bytes */ 830 if (ICC_Async_Transmit ( t0->icc,5, APDU_Cmd_Header (cmd)) != ICC_ASYNC_OK)810 if (ICC_Async_Transmit (5, APDU_Cmd_Header (cmd)) != ICC_ASYNC_OK) 831 811 { 832 812 (*rsp) = NULL; … … 848 828 { 849 829 /* Read one procedure byte */ 850 if (ICC_Async_Receive ( t0->icc,1, buffer + recv) != ICC_ASYNC_OK)830 if (ICC_Async_Receive (1, buffer + recv) != ICC_ASYNC_OK) 851 831 { 852 832 ret = PROTOCOL_T0_ICC_ERROR; … … 876 856 877 857 /* Read SW2 byte */ 878 if (ICC_Async_Receive ( t0->icc,1, buffer + recv) != ICC_ASYNC_OK)858 if (ICC_Async_Receive (1, buffer + recv) != ICC_ASYNC_OK) 879 859 { 880 860 ret = PROTOCOL_T0_ICC_ERROR; … … 898 878 return PROTOCOL_T0_ERROR; 899 879 900 if (ICC_Async_Transmit( t0->icc,MAX (Lc - sent, 0), data + sent) != ICC_ASYNC_OK) /* Send remaining data bytes */880 if (ICC_Async_Transmit(MAX (Lc - sent, 0), data + sent) != ICC_ASYNC_OK) /* Send remaining data bytes */ 901 881 { 902 882 ret = PROTOCOL_T0_ICC_ERROR; … … 917 897 918 898 /* Read remaining data bytes */ 919 if (ICC_Async_Receive( t0->icc,MAX (Le - recv, 0), buffer + recv) != ICC_ASYNC_OK)899 if (ICC_Async_Receive(MAX (Le - recv, 0), buffer + recv) != ICC_ASYNC_OK) 920 900 {//printf("error %d\n", (int)Le); 921 901 ret = PROTOCOL_T0_ICC_ERROR; … … 939 919 940 920 /* Send next data byte */ 941 if (ICC_Async_Transmit ( t0->icc,1, data + sent) !=ICC_ASYNC_OK)921 if (ICC_Async_Transmit (1, data + sent) !=ICC_ASYNC_OK) 942 922 { 943 923 ret = PROTOCOL_T0_ICC_ERROR; … … 954 934 955 935 /* Read next data byte */ 956 if (ICC_Async_Receive ( t0->icc,1, buffer + recv) != ICC_ASYNC_OK)936 if (ICC_Async_Receive (1, buffer + recv) != ICC_ASYNC_OK) 957 937 { 958 938 ret = PROTOCOL_T0_ICC_ERROR; … … 979 959 } 980 960 981 static int Protocol_T14_ExchangeTPDU ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp)961 static int Protocol_T14_ExchangeTPDU (APDU_Cmd * cmd, APDU_Rsp ** rsp) 982 962 { 983 963 BYTE buffer[PROTOCOL_T14_MAX_SHORT_RESPONSE]; … … 1004 984 { 1005 985 /* Send 0x01 byte */ 1006 if (ICC_Async_Transmit ( t14->icc,1, &b1) != ICC_ASYNC_OK)986 if (ICC_Async_Transmit (1, &b1) != ICC_ASYNC_OK) 1007 987 { 1008 988 (*rsp) = NULL; … … 1011 991 1012 992 /* Send apdu */ 1013 if (ICC_Async_Transmit ( t14->icc,cmd_len, cmd_raw) != ICC_ASYNC_OK)993 if (ICC_Async_Transmit (cmd_len, cmd_raw) != ICC_ASYNC_OK) 1014 994 { 1015 995 (*rsp) = NULL; … … 1018 998 1019 999 /* Send xor byte */ 1020 if (ICC_Async_Transmit ( t14->icc,1, &ixor) != ICC_ASYNC_OK)1000 if (ICC_Async_Transmit (1, &ixor) != ICC_ASYNC_OK) 1021 1001 { 1022 1002 (*rsp) = NULL; … … 1031 1011 1032 1012 /* Send apdu */ 1033 if (ICC_Async_Transmit ( t14->icc,cmd_len+2, buffer) != ICC_ASYNC_OK)1013 if (ICC_Async_Transmit (cmd_len+2, buffer) != ICC_ASYNC_OK) 1034 1014 { 1035 1015 (*rsp) = NULL; … … 1068 1048 } 1069 1049 /* Read one procedure byte */ 1070 if (ICC_Async_Receive ( t14->icc,8, buffer) != ICC_ASYNC_OK)1050 if (ICC_Async_Receive (8, buffer) != ICC_ASYNC_OK) 1071 1051 { 1072 1052 ret = PROTOCOL_T14_ICC_ERROR; … … 1079 1059 if(recv) 1080 1060 { 1081 if (ICC_Async_Receive ( t14->icc,recv, buffer + 8) != ICC_ASYNC_OK)1061 if (ICC_Async_Receive (recv, buffer + 8) != ICC_ASYNC_OK) 1082 1062 { 1083 1063 ret = PROTOCOL_T14_ICC_ERROR; … … 1086 1066 } 1087 1067 1088 if (ICC_Async_Receive ( t14->icc,1, &ixor) != ICC_ASYNC_OK)1068 if (ICC_Async_Receive (1, &ixor) != ICC_ASYNC_OK) 1089 1069 { 1090 1070 ret = PROTOCOL_T14_ICC_ERROR; … … 1124 1104 static void Protocol_T0_Clear (Protocol_T0 * t0) 1125 1105 { 1126 t0->icc = NULL;1127 1106 t0->wwt = 0; 1128 1107 } … … 1130 1109 static void Protocol_T14_Clear (Protocol_T14 * t14) 1131 1110 { 1132 t14->icc = NULL;1133 1111 t14->wwt = 0; 1134 1112 } -
branches/smartreader/csctapi/protocol_t0.h
r842 r1280 56 56 typedef struct 57 57 { 58 ICC_Async *icc; /* Asynchrosous integrated cirtuit card */59 58 unsigned long wwt; /* Work waiting time (ms) */ 60 59 } … … 64 63 typedef struct 65 64 { 66 ICC_Async *icc; /* Asynchrosous integrated cirtuit card */67 65 unsigned long wwt; /* Work waiting time (ms) */ 68 66 } … … 82 80 83 81 /* Initialise a protocol handler */ 84 extern int Protocol_T0_Init (Protocol_T0 * t0, ICC_Async * icc,PPS_ProtocolParameters * params, int selected_protocol);85 extern int Protocol_T14_Init (Protocol_T14 * t14, ICC_Async * icc,PPS_ProtocolParameters * params, int selected_protocol);82 extern int Protocol_T0_Init (Protocol_T0 * t0, PPS_ProtocolParameters * params, int selected_protocol); 83 extern int Protocol_T14_Init (Protocol_T14 * t14, PPS_ProtocolParameters * params, int selected_protocol); 86 84 87 85 /* Send a command and return a response */ 88 extern int Protocol_T0_Command ( Protocol_T0 * t0,APDU_Cmd * cmd, APDU_Rsp ** rsp);89 extern int Protocol_T14_Command ( Protocol_T14 * t14,APDU_Cmd * cmd, APDU_Rsp ** rsp);86 extern int Protocol_T0_Command (APDU_Cmd * cmd, APDU_Rsp ** rsp); 87 extern int Protocol_T14_Command (APDU_Cmd * cmd, APDU_Rsp ** rsp); 90 88 91 89 /* Close a protocol handler */ -
branches/smartreader/csctapi/protocol_t1.c
r1225 r1280 49 49 50 50 static int 51 Protocol_T1_SendBlock ( Protocol_T1 * t1,T1_Block * block);51 Protocol_T1_SendBlock (T1_Block * block); 52 52 53 53 static int … … 55 55 56 56 static int 57 Protocol_T1_UpdateBWT ( Protocol_T1 * t1,unsigned short bwt);57 Protocol_T1_UpdateBWT (unsigned short bwt); 58 58 59 59 /* … … 75 75 76 76 int 77 Protocol_T1_Init (Protocol_T1 * t1, ICC_Async * icc, int selected_protocol) 78 { 79 ICC_Async_Timings timings; 77 Protocol_T1_Init (Protocol_T1 * t1, int selected_protocol) 78 { 80 79 BYTE ta, tb, tc, cwi, bwi; 81 80 unsigned long baudrate; 82 81 double work_etu; 83 ATR *atr;84 82 int i; 85 86 /* Set ICC */87 t1->icc = icc;88 89 /* Get ATR of the card */90 atr = ICC_Async_GetAtr (t1->icc);91 83 92 84 /* Set IFSC */ … … 121 113 122 114 /* Work etu = (1000 / baudrate) milliseconds */ 123 ICC_Async_GetBaudrate ( t1->icc,&baudrate);115 ICC_Async_GetBaudrate (&baudrate); 124 116 work_etu = 1000 / (double)baudrate; 125 117 … … 152 144 153 145 /* Set timings */ 154 ICC_Async_GetTimings (t1->icc, &timings); 155 156 timings.block_timeout = t1->bwt; 157 timings.char_timeout = t1->cwt; 158 timings.block_delay = t1->bgt; 159 160 ICC_Async_SetTimings (t1->icc, &timings); 146 icc_timings.block_timeout = t1->bwt; 147 icc_timings.char_timeout = t1->cwt; 148 icc_timings.block_delay = t1->bgt; 149 ICC_Async_SetTimings (); 161 150 162 151 #ifdef DEBUG_PROTOCOL … … 188 177 #endif 189 178 /* Send IFSD request */ 190 ret = Protocol_T1_SendBlock ( t1,block);179 ret = Protocol_T1_SendBlock (block); 191 180 192 181 /* Delete block */ … … 233 222 234 223 /* Send a block */ 235 ret = Protocol_T1_SendBlock ( t1,block);224 ret = Protocol_T1_SendBlock (block); 236 225 237 226 /* Delete I-block */ … … 274 263 #endif 275 264 /* Send a block */ 276 ret = Protocol_T1_SendBlock ( t1,block);265 ret = Protocol_T1_SendBlock (block); 277 266 278 267 /* Delete I-block */ … … 304 293 { 305 294 if (wtx > 1) 306 Protocol_T1_UpdateBWT ( t1,wtx * (t1->bwt));295 Protocol_T1_UpdateBWT (wtx * (t1->bwt)); 307 296 308 297 /* Receive a block */ … … 311 300 if (wtx > 1) 312 301 { 313 Protocol_T1_UpdateBWT (t1 , t1->bwt);302 Protocol_T1_UpdateBWT (t1->bwt); 314 303 wtx = 0; 315 304 } … … 348 337 #endif 349 338 /* Send R-Block */ 350 ret = Protocol_T1_SendBlock ( t1,block);339 ret = Protocol_T1_SendBlock (block); 351 340 352 341 /* Delete I-block */ … … 372 361 #endif 373 362 /* Send WTX response */ 374 ret = Protocol_T1_SendBlock ( t1,block);363 ret = Protocol_T1_SendBlock (block); 375 364 376 365 /* Delete block */ … … 413 402 414 403 static int 415 Protocol_T1_SendBlock ( Protocol_T1 * t1,T1_Block * block)404 Protocol_T1_SendBlock (T1_Block * block) 416 405 { 417 406 BYTE *buffer; … … 423 412 length = T1_Block_RawLen (block); 424 413 425 if (ICC_Async_Transmit ( t1->icc,length, buffer) != ICC_ASYNC_OK)414 if (ICC_Async_Transmit (length, buffer) != ICC_ASYNC_OK) 426 415 { 427 416 ret = PROTOCOL_T1_ICC_ERROR; … … 442 431 443 432 /* Receive four mandatory bytes */ 444 if (ICC_Async_Receive ( t1->icc,4, buffer) != ICC_ASYNC_OK)433 if (ICC_Async_Receive (4, buffer) != ICC_ASYNC_OK) 445 434 { 446 435 ret = PROTOCOL_T1_ICC_ERROR; … … 453 442 { 454 443 /* Set timings to read the remaining block */ 455 Protocol_T1_UpdateBWT (t1 , t1->cwt);444 Protocol_T1_UpdateBWT (t1->cwt); 456 445 457 446 /* Receive remaining bytes */ 458 if (ICC_Async_Receive ( t1->icc,buffer[2], buffer + 4) !=447 if (ICC_Async_Receive (buffer[2], buffer + 4) != 459 448 ICC_ASYNC_OK) 460 449 { … … 470 459 471 460 /* Restore timings */ 472 Protocol_T1_UpdateBWT (t1 , t1->bwt);461 Protocol_T1_UpdateBWT (t1->bwt); 473 462 } 474 463 else … … 485 474 Protocol_T1_Clear (Protocol_T1 * t1) 486 475 { 487 t1->icc = NULL;488 476 t1->ifsc = 0; 489 477 t1->ifsd = 0; … … 496 484 497 485 static int 498 Protocol_T1_UpdateBWT (Protocol_T1 * t1, unsigned short bwt) 499 { 500 ICC_Async_Timings timings; 501 502 ICC_Async_GetTimings (t1->icc, &timings); 503 504 timings.block_timeout = bwt; 505 506 ICC_Async_SetTimings (t1->icc, &timings); 486 Protocol_T1_UpdateBWT (unsigned short bwt) 487 { 488 icc_timings.block_timeout = bwt; 489 ICC_Async_SetTimings (); 507 490 508 491 return PROTOCOL_T1_OK; -
branches/smartreader/csctapi/protocol_t1.h
r1127 r1280 48 48 typedef struct 49 49 { 50 ICC_Async *icc; /* Asynchronous integrated cirtuit card */51 50 unsigned short ifsc; /* Information field size for the ICC */ 52 51 unsigned short ifsd; /* Information field size for the IFD */ … … 73 72 /* Initialise a protocol handler */ 74 73 extern int 75 Protocol_T1_Init (Protocol_T1 * t1, ICC_Async * icc,int selected_protocol);74 Protocol_T1_Init (Protocol_T1 * t1, int selected_protocol); 76 75 77 76 /* Send a command and return a response */
Note:
See TracChangeset
for help on using the changeset viewer.