From 260fdbf23bca0c3a91f096c281965cabd43798c4 Mon Sep 17 00:00:00 2001 From: leslie Date: Sun, 29 Mar 2009 12:06:33 +0800 Subject: [PATCH] smartcards: ignore setserial failure if custombaud not used --- smartcard.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/smartcard.c b/smartcard.c index b592404..6182ba4 100644 --- a/smartcard.c +++ b/smartcard.c @@ -651,6 +651,7 @@ bool cSmartCardSlots::ParseLinePlain(const char *line) class cSmartCardSlotSerial : public cSmartCardSlot { private: int statInv, invRST; + bool custombaud; // speed_t FindBaud(int baud); protected: @@ -675,7 +676,7 @@ static cSmartCardSlotLinkReg __scs_serial("serial"); cSmartCardSlotSerial::cSmartCardSlotSerial(void) { - fd=-1; statInv=0; invRST=false; + fd=-1; statInv=0; invRST=false; custombaud=false; } bool cSmartCardSlotSerial::DeviceOpen(const char *cfg) @@ -777,8 +778,12 @@ bool cSmartCardSlotSerial::DeviceSetMode(int mode, int baud) struct serial_struct s; if(ioctl(fd,TIOCGSERIAL,&s)<0) { - PRINTF(L_GEN_ERROR,"%s: get serial failed: %s",devName,strerror(errno)); - return false; + if(custom || custombaud) { + PRINTF(L_GEN_ERROR,"%s: get serial failed: %s",devName,strerror(errno)); + return false; + } + PRINTF(L_CORE_SERIAL,"%s: get serial failed: %s",devName,strerror(errno)); + PRINTF(L_CORE_SERIAL,"%s: custombaud not used, try to continue...",devName); } if(!custom && ((s.flags&ASYNC_SPD_MASK)==ASYNC_SPD_CUST || s.custom_divisor!=0)) { s.custom_divisor=0; @@ -787,6 +792,7 @@ bool cSmartCardSlotSerial::DeviceSetMode(int mode, int baud) PRINTF(L_GEN_ERROR,"%s: set serial failed: %s",devName,strerror(errno)); return false; } + custombaud=false; } if(!tcsetattr(fd,TCSANOW,&tio)) { if(custom) { @@ -797,6 +803,7 @@ bool cSmartCardSlotSerial::DeviceSetMode(int mode, int baud) PRINTF(L_GEN_ERROR,"%s: set serial failed: %s",devName,strerror(errno)); return false; } + custombaud=true; } currMode=mode; Flush(); return true; -- 2.39.5