diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6e5c414892..d61d7f7cf4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,21 @@ The license applies to all entries newer than 2009-04-28. */ +2010-09-28 17:46 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbcom.ch + + added new error constant value: HB_COM_ERR_IO + * harbour/src/rtl/hbcom.c + + added translation for some important OS error code + in *nix builds + + added translation ERROR_TIMEOUT -> HB_COM_ERR_TIMEOUT + in Windows build. + TODO: check real error codes for it and also for other + operations like opening the same port more then + once and add valid translations + ; TODO: add some basic trnaslation for OS2 error codes. + HB_COM_ERR_TIMEOUT seems to be most important for portable + programs. + 2010-09-28 09:56 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/hbcom.c ! fixed typo in MS-Windows builds diff --git a/harbour/include/hbcom.ch b/harbour/include/hbcom.ch index b56e95517f..d52c23e2e2 100644 --- a/harbour/include/hbcom.ch +++ b/harbour/include/hbcom.ch @@ -125,5 +125,6 @@ #define HB_COM_ERR_BUSY 6 #define HB_COM_ERR_OTHER 7 #define HB_COM_ERR_ALREADYOPEN 8 +#define HB_COM_ERR_IO 9 #endif /* HB_COM_CH_ */ diff --git a/harbour/src/rtl/hbcom.c b/harbour/src/rtl/hbcom.c index e5a670777c..521f37a188 100644 --- a/harbour/src/rtl/hbcom.c +++ b/harbour/src/rtl/hbcom.c @@ -296,7 +296,24 @@ int hb_comLastNum( void ) static void hb_comSetOsError( PHB_COM pCom, HB_BOOL fError ) { pCom->oserr = fError ? HB_COM_GETERROR() : 0; - pCom->error = pCom->oserr ? HB_COM_ERR_OTHER : 0; + switch( pCom->oserr ) + { + case 0: + pCom->error = 0; + break; + case EIO: + pCom->error = HB_COM_ERR_IO; + break; + case EBUSY: + pCom->error = HB_COM_ERR_BUSY; + break; + case EAGAIN: + pCom->error = HB_COM_ERR_TIMEOUT; + break; + default: + pCom->error = HB_COM_ERR_OTHER; + break; + } } #if defined( HB_OS_UNIX ) @@ -1260,7 +1277,19 @@ int hb_comOpen( int iPort ) static void hb_comSetOsError( PHB_COM pCom, BOOL fError ) { pCom->oserr = fError ? GetLastError() : 0; - pCom->error = pCom->oserr ? HB_COM_ERR_OTHER : 0; + + switch( pCom->oserr ) + { + case 0: + pCom->error = 0; + break; + case ERROR_TIMEOUT: + pCom->error = HB_COM_ERR_TIMEOUT; + break; + default: + pCom->error = HB_COM_ERR_OTHER; + break; + } } int hb_comInputCount( int iPort ) @@ -1945,7 +1974,15 @@ int hb_comOpen( int iPort ) static void hb_comSetOsError( PHB_COM pCom, APIRET rc ) { pCom->oserr = rc; - pCom->error = rc != NO_ERROR ? HB_COM_ERR_OTHER : 0; + switch( pCom->oserr ) + { + case NO_ERROR: + pCom->error = 0; + break; + default: + pCom->error = HB_COM_ERR_OTHER; + break; + } } int hb_comInputCount( int iPort )