From 8d2c665f98af3581fb1ef75ac8da6c981f6a3d35 Mon Sep 17 00:00:00 2001 From: Mindaugas Kavaliauskas Date: Mon, 28 Jun 2010 14:23:11 +0000 Subject: [PATCH] 2010-06-28 17:22 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/include/hbcom.ch * harbour/rtl/hbcom.c * implemented new error code HB_COM_ALREADYOPEN in hb_comOpen() * harbour/contrib/hbct/ctcom1.c * changed COM_OPEN() behaviour to be compatible with HBCOM API and original CT behaviour --- harbour/ChangeLog | 8 ++++++++ harbour/contrib/hbct/ctcom1.c | 5 +++-- harbour/include/hbcom.ch | 1 + harbour/src/rtl/hbcom.c | 21 ++++++++++++--------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2d2624eaa8..89d88b4877 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2010-06-28 17:22 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * harbour/include/hbcom.ch + * harbour/rtl/hbcom.c + * implemented new error code HB_COM_ALREADYOPEN in hb_comOpen() + * harbour/contrib/hbct/ctcom1.c + * changed COM_OPEN() behaviour to be compatible with HBCOM API + and original CT behaviour + 2010-06-28 10:58 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * config/win/msvc.mk ! Fixed HB_BUILD_SHARED=yes mode for msvc. diff --git a/harbour/contrib/hbct/ctcom1.c b/harbour/contrib/hbct/ctcom1.c index d2d4014d7a..037c49a6bd 100644 --- a/harbour/contrib/hbct/ctcom1.c +++ b/harbour/contrib/hbct/ctcom1.c @@ -387,11 +387,12 @@ HB_FUNC( COM_INIT ) */ HB_FUNC( COM_OPEN ) { + int iPort = hb_parni( 1 ); /* TODO: add support for */ /* TODO: add support for */ /* TODO: add support for */ - - hb_retl( hb_comOpen( hb_parni( 1 ) ) != -1 ); + hb_comClose( iPort ); + hb_retl( hb_comOpen( iPort ) != -1 ); } /* COM_CLOSE( ) -> diff --git a/harbour/include/hbcom.ch b/harbour/include/hbcom.ch index 918ab8346f..ccdd000140 100644 --- a/harbour/include/hbcom.ch +++ b/harbour/include/hbcom.ch @@ -124,5 +124,6 @@ #define HB_COM_ERR_PARAMVALUE 5 #define HB_COM_ERR_BUSY 6 #define HB_COM_ERR_OTHER 7 +#define HB_COM_ERR_ALREADYOPEN 8 #endif /* HB_COM_CH_ */ diff --git a/harbour/src/rtl/hbcom.c b/harbour/src/rtl/hbcom.c index 0899ddd226..feeb2efa81 100644 --- a/harbour/src/rtl/hbcom.c +++ b/harbour/src/rtl/hbcom.c @@ -1187,9 +1187,10 @@ int hb_comOpen( int iPort ) if( pCom ) { if( pCom->status & HB_COM_OPEN ) - hb_comClose( iPort ); - - if( ( pCom->status & HB_COM_OPEN ) == 0 ) + { + hb_comSetError( pCom, HB_COM_ERR_ALREADYOPEN ); + } + else { char buffer[ HB_COM_DEV_NAME_MAX ]; const char * name = hb_comGetName( pCom, buffer, sizeof( buffer ) ); @@ -1874,9 +1875,10 @@ int hb_comOpen( int iPort ) if( pCom ) { if( pCom->status & HB_COM_OPEN ) - hb_comClose( iPort ); - - if( ( pCom->status & HB_COM_OPEN ) == 0 ) + { + hb_comSetError( pCom, HB_COM_ERR_ALREADYOPEN ); + } + else { char buffer[ HB_COM_DEV_NAME_MAX ]; const char * szName = hb_comGetName( pCom, buffer, sizeof( buffer ) ); @@ -2659,9 +2661,10 @@ int hb_comOpen( int iPort ) if( pCom ) { if( pCom->status & HB_COM_OPEN ) - hb_comClose( iPort ); - - if( ( pCom->status & HB_COM_OPEN ) == 0 ) + { + hb_comSetError( pCom, HB_COM_ERR_ALREADYOPEN ); + } + else { char buffer[ HB_COM_DEV_NAME_MAX ]; const char * pszName = hb_comGetName( pCom, buffer, sizeof( buffer ) );