Changeset 1236
- Timestamp:
- 01/15/10 16:53:19 (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/cardterminal.c
r1220 r1236 714 714 { 715 715 length = 2; 716 I FD_Towitoko_SetParity(ct->slots[0]->ifd, IFD_TOWITOKO_PARITY_ODD);716 IO_Serial_SetParity (PARITY_ODD); 717 717 buffer[0] = CTBCS_SW1_OK; 718 718 buffer[1] = CTBCS_SW2_OK; … … 722 722 { 723 723 length = 2; 724 I FD_Towitoko_SetParity(ct->slots[0]->ifd, IFD_TOWITOKO_PARITY_EVEN);724 IO_Serial_SetParity (PARITY_EVEN); 725 725 buffer[0] = CTBCS_SW1_OK; 726 726 buffer[1] = CTBCS_SW2_OK; … … 730 730 { 731 731 length = 2; 732 I FD_Towitoko_SetParity(ct->slots[0]->ifd, IFD_TOWITOKO_PARITY_NONE);732 IO_Serial_SetParity (PARITY_NONE); 733 733 buffer[0] = CTBCS_SW1_OK; 734 734 buffer[1] = CTBCS_SW2_OK; -
trunk/csctapi/icc_async.c
r1234 r1236 275 275 if (icc->convention == ATR_CONVENTION_INVERSE) 276 276 { 277 if ( IFD_Towitoko_SetParity (icc->ifd, IFD_TOWITOKO_PARITY_ODD) != IFD_TOWITOKO_OK)277 if (!IO_Serial_SetParity (PARITY_ODD)) 278 278 return ICC_ASYNC_IFD_ERROR; 279 279 } 280 280 else if(icc->protocol_type == ATR_PROTOCOL_TYPE_T14) 281 281 { 282 if ( IFD_Towitoko_SetParity (icc->ifd, IFD_TOWITOKO_PARITY_NONE) != IFD_TOWITOKO_OK)282 if (!IO_Serial_SetParity (PARITY_NONE)) 283 283 return ICC_ASYNC_IFD_ERROR; 284 284 } 285 285 else 286 286 { 287 if ( IFD_Towitoko_SetParity (icc->ifd, IFD_TOWITOKO_PARITY_EVEN) != IFD_TOWITOKO_OK)287 if (!IO_Serial_SetParity (PARITY_EVEN)) 288 288 return ICC_ASYNC_IFD_ERROR; 289 289 } -
trunk/csctapi/ifd_towitoko.c
r1235 r1236 185 185 io->bits = 8; 186 186 io->stopbits = 2; 187 io->parity = IO_SERIAL_PARITY_EVEN;187 io->parity = PARITY_EVEN; 188 188 io->dtr = IO_SERIAL_HIGH; 189 189 // io->dtr = IO_SERIAL_LOW; … … 192 192 193 193 194 if (!IO_Serial_SetProperties (io))194 if (!IO_Serial_SetPropertiesOld (io)) 195 195 return IFD_TOWITOKO_IO_ERROR; 196 196 … … 209 209 } 210 210 211 ret = IFD_Towitoko_SetParity (ifd, IFD_TOWITOKO_PARITY_EVEN); 211 if (!IO_Serial_SetParity (PARITY_EVEN)) 212 return IFD_TOWITOKO_IO_ERROR; 212 213 213 214 if (ret != IFD_TOWITOKO_OK) … … 264 265 #endif 265 266 /* Get current settings */ 266 if (!IO_Serial_GetProperties (ifd->io))267 if (!IO_Serial_GetPropertiesOld (ifd->io)) 267 268 return IFD_TOWITOKO_IO_ERROR; 268 269 … … 275 276 ifd->io->input_bitrate = baudrate; 276 277 277 if (!IO_Serial_SetProperties (ifd->io))278 if (!IO_Serial_SetPropertiesOld (ifd->io)) 278 279 return IFD_TOWITOKO_IO_ERROR; 279 280 … … 289 290 290 291 /* Get current settings */ 291 if (!IO_Serial_GetProperties (ifd->io))292 if (!IO_Serial_GetPropertiesOld (ifd->io)) 292 293 return IFD_TOWITOKO_IO_ERROR; 293 294 294 295 (*baudrate) = ifd->io->output_bitrate; 295 296 return IFD_TOWITOKO_OK;297 }298 299 extern int IFD_Towitoko_SetParity (IFD * ifd, BYTE parity)300 {301 if(reader[ridx].typ == R_INTERNAL)302 {303 return IFD_TOWITOKO_OK;304 }305 306 #ifdef DEBUG_IFD307 printf ("IFD: Parity = %s\n",308 parity == IFD_TOWITOKO_PARITY_ODD ? "Odd" :309 parity == IFD_TOWITOKO_PARITY_EVEN ? "Even" : "Invalid");310 #endif311 312 if ((parity != IFD_TOWITOKO_PARITY_EVEN) && (parity != IFD_TOWITOKO_PARITY_ODD) && (parity != IFD_TOWITOKO_PARITY_NONE))313 return IFD_TOWITOKO_PARAM_ERROR;314 315 /* Get current settings */316 if (!IO_Serial_GetProperties (ifd->io))317 return IFD_TOWITOKO_IO_ERROR;318 319 if (ifd->io->parity !=parity)320 {321 ifd->io->parity = parity;322 323 if (!IO_Serial_SetProperties (ifd->io))324 return IFD_TOWITOKO_IO_ERROR;325 }326 296 327 297 return IFD_TOWITOKO_OK; … … 408 378 int parity; 409 379 int i; 410 int par[3] = { IFD_TOWITOKO_PARITY_EVEN, IFD_TOWITOKO_PARITY_ODD, IFD_TOWITOKO_PARITY_NONE};380 int par[3] = {PARITY_EVEN, PARITY_ODD, PARITY_NONE}; 411 381 #ifdef HAVE_NANOSLEEP 412 382 struct timespec req_ts; … … 421 391 IO_Serial_Flush(); 422 392 423 ret = IFD_Towitoko_SetParity (ifd, parity); 424 if (ret != IFD_TOWITOKO_OK) 425 return ret; 393 if (!IO_Serial_SetParity (parity)) 394 return IFD_TOWITOKO_IO_ERROR; 426 395 427 396 ret = IFD_TOWITOKO_IO_ERROR; -
trunk/csctapi/ifd_towitoko.h
r1234 r1236 67 67 #define IFD_TOWITOKO_CHANGE(status) (((status) & 0x80) == 0x80) 68 68 69 /* Led Color */70 #define IFD_TOWITOKO_LED_OFF 0x0071 #define IFD_TOWITOKO_LED_RED 0x0172 #define IFD_TOWITOKO_LED_GREEN 0x0273 #define IFD_TOWITOKO_LED_YELLOW 0x0374 75 /* IFD parity */76 //#define IFD_TOWITOKO_PARITY_ODD 0x8077 //#define IFD_TOWITOKO_PARITY_EVEN 0x4078 #define IFD_TOWITOKO_PARITY_ODD 179 #define IFD_TOWITOKO_PARITY_EVEN 280 #define IFD_TOWITOKO_PARITY_NONE 381 82 69 /* ICC types */ 83 70 #define IFD_TOWITOKO_I2C_SHORT 0 … … 130 117 extern int IFD_Towitoko_SetBaudrate (IFD * ifd, unsigned long baudrate); 131 118 extern int IFD_Towitoko_GetBaudrate (IFD * ifd, unsigned long *baudrate); 132 extern int IFD_Towitoko_SetParity (IFD * ifd, BYTE parity);133 119 134 120 /* General handling of ICC inserted in this IFD */ -
trunk/csctapi/io_serial.c
r1235 r1236 180 180 } 181 181 182 bool IO_Serial_GetProperties (IO_Serial * io)182 bool IO_Serial_GetPropertiesOld (IO_Serial * io) 183 183 { 184 184 struct termios currtio; … … 424 424 { 425 425 if (((currtio.c_cflag) & PARODD) == PARODD) 426 io->parity = IO_SERIAL_PARITY_ODD;426 io->parity = PARITY_ODD; 427 427 else 428 io->parity = IO_SERIAL_PARITY_EVEN;428 io->parity = PARITY_EVEN; 429 429 } 430 430 else 431 431 { 432 io->parity = IO_SERIAL_PARITY_NONE;432 io->parity = PARITY_NONE; 433 433 } 434 434 … … 445 445 446 446 #ifdef DEBUG_IO 447 printf("IO: Getting properties: %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts);447 printf("IO: Getting properties: %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->input_bitrate, io->bits, io->parity == PARITY_EVEN ? "Even" : io->parity == PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts); 448 448 #endif 449 449 … … 451 451 } 452 452 453 bool IO_Serial_SetProperties (IO_Serial * io)453 bool IO_Serial_SetPropertiesOld (IO_Serial * io) 454 454 { 455 455 struct termios newtio; … … 460 460 #endif 461 461 462 // printf("IO: Setting properties: reader_type%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", reader[ridx].typ, io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts);462 // printf("IO: Setting properties: reader_type%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", reader[ridx].typ, io->input_bitrate, io->bits, io->parity == PARITY_EVEN ? "Even" : io->parity == PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts); 463 463 memset (&newtio, 0, sizeof (newtio)); 464 464 … … 513 513 switch (io->parity) 514 514 { 515 case IO_SERIAL_PARITY_ODD:515 case PARITY_ODD: 516 516 newtio.c_cflag |= PARENB; 517 517 newtio.c_cflag |= PARODD; 518 518 break; 519 519 520 case IO_SERIAL_PARITY_EVEN:520 case PARITY_EVEN: 521 521 newtio.c_cflag |= PARENB; 522 522 newtio.c_cflag &= ~PARODD; 523 523 break; 524 524 525 case IO_SERIAL_PARITY_NONE:525 case PARITY_NONE: 526 526 newtio.c_cflag &= ~PARENB; 527 527 break; … … 566 566 567 567 #ifdef DEBUG_IO 568 printf("IO: Setting properties: reader_type%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", reader[ridx].typ, io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts); 569 #endif 568 printf("IO: Setting properties: reader_type%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", reader[ridx].typ, io->input_bitrate, io->bits, io->parity == PARITY_EVEN ? "Even" : io->parity == PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts); 569 #endif 570 return TRUE; 571 } 572 573 bool IO_Serial_SetProperties (struct termios newtio) 574 { 575 if(reader[ridx].typ == R_INTERNAL) 576 return FALSE; 577 578 if (tcsetattr (reader[ridx].handle, TCSANOW, &newtio) < 0) 579 return FALSE; 580 // tcflush(reader[ridx].handle, TCIOFLUSH); 581 // if (tcsetattr (reader[ridx].handle, TCSAFLUSH, &newtio) < 0) 582 // return FALSE; 583 584 unsigned int mctl; 585 if (ioctl (reader[ridx].handle, TIOCMGET, &mctl) < 0) 586 return FALSE; 587 588 int dtr = ((mctl & TIOCM_DTR) ? IO_SERIAL_HIGH : IO_SERIAL_LOW); 589 int rts = ((mctl & TIOCM_RTS) ? IO_SERIAL_HIGH : IO_SERIAL_LOW); 590 591 IO_Serial_Ioctl_Lock(1); 592 IO_Serial_DTR_RTS(0, rts == IO_SERIAL_HIGH); 593 IO_Serial_DTR_RTS(1, dtr == IO_SERIAL_HIGH); 594 IO_Serial_Ioctl_Lock(0); 595 596 #ifdef DEBUG_IO 597 printf("IO: Setting properties\n"); 598 #endif 599 600 return TRUE; 601 } 602 603 int IO_Serial_SetParity (BYTE parity) 604 { 605 if(reader[ridx].typ == R_INTERNAL) 606 return TRUE; 607 608 if ((parity != PARITY_EVEN) && (parity != PARITY_ODD) && (parity != PARITY_NONE)) 609 return FALSE; 610 611 struct termios tio; 612 int current_parity; 613 // Get current parity 614 if (tcgetattr (reader[ridx].handle, &tio) != 0) 615 return FALSE; 616 617 if (((tio.c_cflag) & PARENB) == PARENB) 618 { 619 if (((tio.c_cflag) & PARODD) == PARODD) 620 current_parity = PARITY_ODD; 621 else 622 current_parity = PARITY_EVEN; 623 } 624 else 625 { 626 current_parity = PARITY_NONE; 627 } 628 629 #ifdef DEBUG_IFD 630 printf ("IFD: Setting parity from %s to %s\n", 631 current_parity == PARITY_ODD ? "Odd" : 632 current_parity == PARITY_NONE ? "None" : 633 current_parity == PARITY_EVEN ? "Even" : "Invalid", 634 parity == PARITY_ODD ? "Odd" : 635 parity == PARITY_NONE ? "None" : 636 parity == PARITY_EVEN ? "Even" : "Invalid"); 637 #endif 638 639 if (current_parity != parity) 640 { 641 642 // Set the parity 643 switch (parity) 644 { 645 case PARITY_ODD: 646 tio.c_cflag |= PARENB; 647 tio.c_cflag |= PARODD; 648 break; 649 650 case PARITY_EVEN: 651 tio.c_cflag |= PARENB; 652 tio.c_cflag &= ~PARODD; 653 break; 654 655 case PARITY_NONE: 656 tio.c_cflag &= ~PARENB; 657 break; 658 } 659 if (!IO_Serial_SetProperties (tio)) 660 return FALSE; 661 } 662 570 663 return TRUE; 571 664 } … … 959 1052 io->input_bitrate = 1200; 960 1053 io->output_bitrate = 1200; 961 io->parity = IO_SERIAL_PARITY_NONE;1054 io->parity = PARITY_NONE; 962 1055 io->bits = 7; 963 1056 io->stopbits = 1; 964 1057 io->dtr = IO_SERIAL_HIGH; 965 // io->rts = IO_SERIAL_HIGH;966 1058 io->rts = IO_SERIAL_LOW; 967 1059 968 if (!IO_Serial_SetProperties (io))1060 if (!IO_Serial_SetPropertiesOld (io)) 969 1061 return FALSE; 970 1062 -
trunk/csctapi/io_serial.h
r1235 r1236 37 37 38 38 /* Type of parity of the serial device */ 39 #define IO_SERIAL_PARITY_ODD 140 #define IO_SERIAL_PARITY_EVEN 241 #define IO_SERIAL_PARITY_NONE 339 #define PARITY_ODD 1 40 #define PARITY_EVEN 2 41 #define PARITY_NONE 3 42 42 43 43 /* Values for the modem lines */ … … 86 86 87 87 /* Transmission properties */ 88 extern bool IO_Serial_SetProperties (IO_Serial * io);89 extern bool IO_Serial_GetProperties (IO_Serial * io);88 extern bool IO_Serial_SetPropertiesOld (IO_Serial * io); 89 extern bool IO_Serial_GetPropertiesOld (IO_Serial * io); 90 90 extern bool IO_Serial_DTR_RTS(int, int); 91 91 #if defined(TUXBOX) && defined(PPC) -
trunk/globals.h
r1220 r1236 411 411 int card_status; //highlevel status 412 412 unsigned short status; //lowlevel status: states whether card inserted and/or change of status FIXME look at integration with pcsc_has_card/detect/card_status 413 unsigned long baudrate; //we are storing baudrate to prevent unnecessary conversions from/to termios structure 413 414 struct s_module ph; 414 415 uchar ncd_key[16];
Note:
See TracChangeset
for help on using the changeset viewer.