2015-12-29 17:03 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
+ src/3rd/hbdossrl/Makefile
+ src/3rd/hbdossrl/serial.c
+ src/3rd/hbdossrl/serial.h
+ src/3rd/hbdossrl/README
+ added DOS Serial Library - it's much cleaner and simpler then COMLib
we used so far in DOS builds. It also supports hardware and software
flow control. Many thanks for Karl Stenerud for his wonderful job.
* src/rtl/hbcom.c
+ added support for DOS Serial Library used as low level backend in
Harbour DOS builds.
* config/dos/djgpp.mk
* config/dos/watcom.mk
* config/dyn.mk
* config/lib.mk
* src/3rd/Makefile
* src/Makefile
* utils/hbmk2/hbmk2.hbp
* utils/hbmk2/hbmk2.prg
* use DOS Serial Library (hbdossrl) instead of COMLib (hbpmcom)
This commit is contained in:
@@ -10,6 +10,29 @@
|
|||||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
2015-12-29 17:03 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||||
|
+ src/3rd/hbdossrl/Makefile
|
||||||
|
+ src/3rd/hbdossrl/serial.c
|
||||||
|
+ src/3rd/hbdossrl/serial.h
|
||||||
|
+ src/3rd/hbdossrl/README
|
||||||
|
+ added DOS Serial Library - it's much cleaner and simpler then COMLib
|
||||||
|
we used so far in DOS builds. It also supports hardware and software
|
||||||
|
flow control. Many thanks for Karl Stenerud for his wonderful job.
|
||||||
|
|
||||||
|
* src/rtl/hbcom.c
|
||||||
|
+ added support for DOS Serial Library used as low level backend in
|
||||||
|
Harbour DOS builds.
|
||||||
|
|
||||||
|
* config/dos/djgpp.mk
|
||||||
|
* config/dos/watcom.mk
|
||||||
|
* config/dyn.mk
|
||||||
|
* config/lib.mk
|
||||||
|
* src/3rd/Makefile
|
||||||
|
* src/Makefile
|
||||||
|
* utils/hbmk2/hbmk2.hbp
|
||||||
|
* utils/hbmk2/hbmk2.prg
|
||||||
|
* use DOS Serial Library (hbdossrl) instead of COMLib (hbpmcom)
|
||||||
|
|
||||||
2015-12-24 14:53 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
2015-12-24 14:53 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||||
* src/vm/hvm.c
|
* src/vm/hvm.c
|
||||||
! casting for C++ compilation
|
! casting for C++ compilation
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ ifneq ($(HB_LINKING_RTL),)
|
|||||||
SYSLIBPATHS += $(HB_LIB_WATT)
|
SYSLIBPATHS += $(HB_LIB_WATT)
|
||||||
SYSLIBS += watt
|
SYSLIBS += watt
|
||||||
endif
|
endif
|
||||||
SYSLIBS += hbpmcom
|
SYSLIBS += hbdossrl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SYSLIBS += m
|
SYSLIBS += m
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ ifneq ($(HB_LINKING_RTL),)
|
|||||||
ifneq ($(HB_HAS_WATT),)
|
ifneq ($(HB_HAS_WATT),)
|
||||||
LDLIBS += $(HB_LIB_WATT)/wattcpwf
|
LDLIBS += $(HB_LIB_WATT)/wattcpwf
|
||||||
endif
|
endif
|
||||||
LDLIBS += $(LIB_DIR)/hbpmcom
|
LDLIBS += $(LIB_DIR)/hbdossrl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# workaround for not included automatically CLIB in pure C mode builds
|
# workaround for not included automatically CLIB in pure C mode builds
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ ifneq ($(HB_HAS_ZLIB_LOCAL),)
|
|||||||
HB_DYN_LIBS += hbzlib
|
HB_DYN_LIBS += hbzlib
|
||||||
endif
|
endif
|
||||||
ifeq ($(HB_PLATFORM),dos)
|
ifeq ($(HB_PLATFORM),dos)
|
||||||
HB_DYN_LIBS += hbpmcom
|
HB_DYN_LIBS += hbdossrl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# hbcplr \
|
# hbcplr \
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ ifneq ($(HB_HAS_ZLIB_LOCAL),)
|
|||||||
HB_DYN_LIBS += hbzlib
|
HB_DYN_LIBS += hbzlib
|
||||||
endif
|
endif
|
||||||
ifeq ($(HB_PLATFORM),dos)
|
ifeq ($(HB_PLATFORM),dos)
|
||||||
HB_DYN_LIBS += hbpmcom
|
HB_DYN_LIBS += hbdossrl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Added only for hbpp
|
# Added only for hbpp
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
ROOT := ../../
|
ROOT := ../../
|
||||||
|
|
||||||
DIRS := \
|
DIRS := \
|
||||||
hbpmcom \
|
hbdossrl \
|
||||||
png \
|
png \
|
||||||
jpeg \
|
jpeg \
|
||||||
pcre \
|
pcre \
|
||||||
|
|||||||
29
src/3rd/hbdossrl/Makefile
Normal file
29
src/3rd/hbdossrl/Makefile
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
ROOT := ../../../
|
||||||
|
|
||||||
|
include $(TOP)$(ROOT)config/global.mk
|
||||||
|
|
||||||
|
LIBNAME := hbdosser
|
||||||
|
|
||||||
|
#HB_BUILD_WARN := no
|
||||||
|
HB_BUILD_MODE := c
|
||||||
|
|
||||||
|
C_SOURCES := \
|
||||||
|
serial.c \
|
||||||
|
|
||||||
|
HB_BUILD_DOSSER := no
|
||||||
|
|
||||||
|
ifeq ($(HB_PLATFORM),dos)
|
||||||
|
ifeq ($(HB_COMPILER),djgpp)
|
||||||
|
HB_BUILD_DOSSER := yes
|
||||||
|
endif
|
||||||
|
ifeq ($(HB_COMPILER),watcom)
|
||||||
|
HB_BUILD_DOSSER := yes
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HB_BUILD_DOSSER),yes)
|
||||||
|
include $(TOP)$(ROOT)config/lib.mk
|
||||||
|
else
|
||||||
|
HB_SKIP_REASON := platform or compiler not supported
|
||||||
|
include $(TOP)$(ROOT)config/none.mk
|
||||||
|
endif
|
||||||
48
src/3rd/hbdossrl/README
Normal file
48
src/3rd/hbdossrl/README
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
DOS Serial Library
|
||||||
|
==================
|
||||||
|
|
||||||
|
A serial port (UART) library for DOS written back in the days when 16-bit
|
||||||
|
systems were still a going concern and far pointers were a thing.
|
||||||
|
|
||||||
|
I'm putting it on Github because I still think it's way cool, and who knows...
|
||||||
|
Perhaps someone, somewhere, is in dire need of a serial library for DOS (I've
|
||||||
|
needed it from time to time to deal with some DOS based embedded piece of crap).
|
||||||
|
|
||||||
|
Supports simultaneous communication over up to 4 serial ports.
|
||||||
|
|
||||||
|
Have a look at term.c for an example of how to use it.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
How do I build it?
|
||||||
|
==================
|
||||||
|
|
||||||
|
Good question! It was built to compile under Borland C++ 3 and whatever
|
||||||
|
Microsoft compiler happened to be current at the time. It conforms to ANSI C
|
||||||
|
(1989) and it doesn't do anything too crazy, so it shouldn't be too bad in a
|
||||||
|
more modern compiler. Have a go and let me know how it works!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright 1998 Karl Stenerud
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
1677
src/3rd/hbdossrl/serial.c
Normal file
1677
src/3rd/hbdossrl/serial.c
Normal file
File diff suppressed because it is too large
Load Diff
196
src/3rd/hbdossrl/serial.h
Normal file
196
src/3rd/hbdossrl/serial.h
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
/* Serial Library 1.4 (22-Jun-2000) (c) 1998 Karl Stenerud
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SERIAL__HEADER
|
||||||
|
#define SERIAL__HEADER
|
||||||
|
|
||||||
|
/* COM Ports */
|
||||||
|
#define COM_1 0
|
||||||
|
#define COM_2 1
|
||||||
|
#define COM_3 2
|
||||||
|
#define COM_4 3
|
||||||
|
|
||||||
|
/* Handshaking Modes */
|
||||||
|
#define SER_HANDSHAKING_NONE 0
|
||||||
|
#define SER_HANDSHAKING_XONXOFF 1
|
||||||
|
#define SER_HANDSHAKING_RTSCTS 2
|
||||||
|
#define SER_HANDSHAKING_DTRDSR 3
|
||||||
|
|
||||||
|
/* Error Codes */
|
||||||
|
#define SER_SUCCESS 0 /* Function completed successfully */
|
||||||
|
#define SER_ERR_UNKNOWN -1 /* An unknown error occured */
|
||||||
|
#define SER_ERR_NOT_OPEN -2 /* The specified COM port is not opened */
|
||||||
|
#define SER_ERR_ALREADY_OPEN -3 /* The specified COM port is already opened */
|
||||||
|
#define SER_ERR_NO_UART -4 /* Could not find a UART for this COM port */
|
||||||
|
#define SER_ERR_INVALID_COMPORT -5 /* User specified an invalid COM port */
|
||||||
|
#define SER_ERR_INVALID_BASE -6 /* User specified an invalid base address */
|
||||||
|
#define SER_ERR_INVALID_IRQ -7 /* User specified an invalid IRQ number */
|
||||||
|
#define SER_ERR_INVALID_BPS -8 /* User specified an invalid BPS rate */
|
||||||
|
#define SER_ERR_INVALID_DATA_BITS -9 /* User specified an invalid number of data bits */
|
||||||
|
#define SER_ERR_INVALID_PARITY -10 /* User specified an invalid parity type */
|
||||||
|
#define SER_ERR_INVALID_STOP_BITS -11 /* User specified an invalid number of stop bits */
|
||||||
|
#define SER_ERR_INVALID_HANDSHAKING -12 /* User specified an invalid handshaking type */
|
||||||
|
#define SER_ERR_INVALID_FIFO_THRESHOLD -13 /* User specified an invalid fifo threshold value */
|
||||||
|
#define SER_ERR_NULL_PTR -14 /* User specified a buffer address that was NULL */
|
||||||
|
#define SER_ERR_IRQ_NOT_FOUND -15 /* Could not find an IRQ for the specified COM port */
|
||||||
|
#define SER_ERR_LOCK_MEM -16 /* Could not lock memory in DPMI mode */
|
||||||
|
#define SER_ERR_UNLOCK_MEM -17 /* Could not unlock memory in DPMI mode */
|
||||||
|
|
||||||
|
|
||||||
|
/* Name: serial_open()
|
||||||
|
*
|
||||||
|
* Desc: Finds and initializes the specified COM port.
|
||||||
|
*
|
||||||
|
* Params: int com: Communications port (COM_1, COM_2, COM_3, COM_4)
|
||||||
|
* long bps: Bits per second.
|
||||||
|
* (50, 75, 110, 150, 300, 600, 1200, 2400, 4800,
|
||||||
|
* 9600, 19200, 38400, 57600, 115200)
|
||||||
|
* int data_bits: Number of data word bits (5-8)
|
||||||
|
* char parity: Parity mode ('e', 'o', 'n', 'm', 's')
|
||||||
|
* int stop_bits: Stop bits (1-2). If data_bits=5 and stop_bits=2,
|
||||||
|
* actual stop bits is 1.5.
|
||||||
|
* int handshaking: Handshaking mode
|
||||||
|
* (SER_HANDSHAKING_NONE, SER_HANDSHAKING_XONXOFF,
|
||||||
|
* SER_HANDSHAKING_RTSCTS, SER_HANDSHAKING_DTRDSR)
|
||||||
|
*
|
||||||
|
* Return: SER_SUCCESS or an error code
|
||||||
|
*/
|
||||||
|
int serial_open(int com, long bps, int data_bits, char parity, int stop_bits, int handshaking);
|
||||||
|
|
||||||
|
|
||||||
|
/* Name: serial_close()
|
||||||
|
*
|
||||||
|
* Desc: Clean up and close the specified serial port.
|
||||||
|
*
|
||||||
|
* Params: int com: Communications port (COM_1, COM_2, COM_3, COM_4)
|
||||||
|
*
|
||||||
|
* Return: SER_SUCCESS or an error code
|
||||||
|
*/
|
||||||
|
int serial_close(int com);
|
||||||
|
|
||||||
|
|
||||||
|
/* Name: serial_read()
|
||||||
|
*
|
||||||
|
* Desc: Read data from the specified serial port buffer.
|
||||||
|
*
|
||||||
|
* Params: int com: Communications port (COM_1, COM_2, COM_3, COM_4)
|
||||||
|
* char* data: Pointer to data buffer
|
||||||
|
* int len: Number of bytes to read
|
||||||
|
*
|
||||||
|
* Return: number of bytes read or an error code
|
||||||
|
*/
|
||||||
|
int serial_read(int com, char* data, int len);
|
||||||
|
|
||||||
|
|
||||||
|
/* Name: serial_write() and serial_write_buffered()
|
||||||
|
*
|
||||||
|
* Desc: Write data to the serial port.
|
||||||
|
* serial_write() will write the data directly to serial port and will
|
||||||
|
* block until it has completely sent the data or handshaking has
|
||||||
|
* stopped output transmission while serial_write_buffered() will copy
|
||||||
|
* as much as possible data bytes to the transmit buffer and will return
|
||||||
|
* immediately enabling asynchronous output.
|
||||||
|
*
|
||||||
|
* Params: int com: Communications port (COM_1, COM_2, COM_3, COM_4)
|
||||||
|
* char* data: Pointer to data buffer
|
||||||
|
* int len: Number of bytes to write
|
||||||
|
*
|
||||||
|
* Return: number of bytes written or an error code
|
||||||
|
*/
|
||||||
|
int serial_write (int com, const char* data, int len);
|
||||||
|
int serial_write_buffered(int com, const char* data, int len);
|
||||||
|
|
||||||
|
|
||||||
|
/* Name: serial_set()
|
||||||
|
*
|
||||||
|
* Desc: Change the specified serial port's settings.
|
||||||
|
*
|
||||||
|
* Params: int com: Communications port (COM_1, COM_2, COM_3, COM_4)
|
||||||
|
* long bps: Bits per second.
|
||||||
|
* (50, 75, 110, 150, 300, 600, 1200, 2400, 4800,
|
||||||
|
* 9600, 19200, 38400, 57600, 115200)
|
||||||
|
* int data_bits: Data bits (5, 6, 7, or 8)
|
||||||
|
* char parity: Parity ('n' = none, 'e' = even, 'o' = odd, 'm' = mark, 's' = space)
|
||||||
|
* int stop_bits: Stop bits (1-2). If data_bits=5 and stop_bits=2,
|
||||||
|
* actual stop bits is 1.5.
|
||||||
|
* int handshaking: Handshaking type (see handshaking modes at top of file)
|
||||||
|
*
|
||||||
|
* Return: SER_SUCCESS or an error code
|
||||||
|
*/
|
||||||
|
int serial_set(int com, long bps, int data_bits, char parity, int stop_bits, int handshaking);
|
||||||
|
|
||||||
|
|
||||||
|
/* serial_set_xxx() functions. These take the same arguments
|
||||||
|
* as the corresponding ones in serial_set() and return either
|
||||||
|
* SER_SUCCESS or an error code.
|
||||||
|
*/
|
||||||
|
int serial_set_bps (int com, long bps);
|
||||||
|
int serial_set_parity (int com, char parity);
|
||||||
|
int serial_set_data (int com, int data);
|
||||||
|
int serial_set_stop (int com, int stop);
|
||||||
|
int serial_set_handshaking (int com, int handshaking);
|
||||||
|
|
||||||
|
/* Advanced settings. Use these only if you know what you are doing. */
|
||||||
|
|
||||||
|
/* UART's FIFO threshold -- 14, 8, 4, 1, or 0 (off) */
|
||||||
|
int serial_set_fifo_threshold(int com, int threshold);
|
||||||
|
/* UART's base address */
|
||||||
|
int serial_set_base (int com, int base);
|
||||||
|
/* UART's IRQ */
|
||||||
|
int serial_set_irq (int com, int base);
|
||||||
|
|
||||||
|
int serial_set_rts(int comport, int rts);
|
||||||
|
int serial_set_dtr(int comport, int dtr);
|
||||||
|
|
||||||
|
int serial_set_mcr(int comport, int mcr);
|
||||||
|
|
||||||
|
|
||||||
|
/* serial_get_xxx() functions. These return the same types as are supplied
|
||||||
|
* to serial_set(). The returned type may be negative, in which case it
|
||||||
|
* is an error code.
|
||||||
|
*/
|
||||||
|
int serial_get_base (int com);
|
||||||
|
int serial_get_irq (int com);
|
||||||
|
long serial_get_bps (int com);
|
||||||
|
char serial_get_parity (int com);
|
||||||
|
int serial_get_data (int com);
|
||||||
|
int serial_get_stop (int com);
|
||||||
|
int serial_get_handshaking (int com);
|
||||||
|
|
||||||
|
|
||||||
|
int serial_get_rts(int comport);
|
||||||
|
int serial_get_dtr(int comport);
|
||||||
|
int serial_get_cts(int comport);
|
||||||
|
int serial_get_dsr(int comport);
|
||||||
|
|
||||||
|
int serial_get_mcr(int comport);
|
||||||
|
int serial_get_msr(int comport);
|
||||||
|
int serial_get_lsr(int comport);
|
||||||
|
|
||||||
|
|
||||||
|
/* get number of bytes or discard data in TX/RX buffers
|
||||||
|
*/
|
||||||
|
int serial_get_tx_buffered(int comport);
|
||||||
|
int serial_get_rx_buffered(int comport);
|
||||||
|
int serial_clear_tx_buffer(int comport);
|
||||||
|
int serial_clear_rx_buffer(int comport);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -38,7 +38,7 @@ else
|
|||||||
ifeq ($(HB_PLATFORM),dos)
|
ifeq ($(HB_PLATFORM),dos)
|
||||||
DYNDIRLIST_BASE += src/rtl/gtdos
|
DYNDIRLIST_BASE += src/rtl/gtdos
|
||||||
ifneq ($(filter $(HB_COMPILER),watcom djgpp),)
|
ifneq ($(filter $(HB_COMPILER),watcom djgpp),)
|
||||||
DYNDIRLIST_BASE += src/3rd/hbpmcom
|
DYNDIRLIST_BASE += src/3rd/hbdossrl
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(HB_PLATFORM),os2)
|
ifeq ($(HB_PLATFORM),os2)
|
||||||
|
|||||||
572
src/rtl/hbcom.c
572
src/rtl/hbcom.c
@@ -68,8 +68,9 @@
|
|||||||
# define BSD_COMP
|
# define BSD_COMP
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#elif defined( HB_OS_DOS )
|
#elif defined( HB_OS_DOS ) && \
|
||||||
# define HB_HAS_PMCOM
|
! defined( HB_HAS_PMCOM ) && ! defined( HB_HAS_DOSSRL )
|
||||||
|
# define HB_HAS_DOSSRL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -88,6 +89,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#elif defined( HB_HAS_SIOLIB )
|
#elif defined( HB_HAS_SIOLIB )
|
||||||
# include <sioLib.h>
|
# include <sioLib.h>
|
||||||
|
#elif defined( HB_HAS_DOSSRL )
|
||||||
|
# include "../../src/3rd/hbdossrl/serial.h"
|
||||||
#elif defined( HB_HAS_PMCOM )
|
#elif defined( HB_HAS_PMCOM )
|
||||||
# include "../../src/3rd/hbpmcom/com.h"
|
# include "../../src/3rd/hbpmcom/com.h"
|
||||||
#elif defined( HB_OS_WIN )
|
#elif defined( HB_OS_WIN )
|
||||||
@@ -3084,6 +3087,571 @@ int hb_comOpen( int iPort )
|
|||||||
|
|
||||||
/* end of HB_OS_OS2 */
|
/* end of HB_OS_OS2 */
|
||||||
|
|
||||||
|
#elif defined( HB_HAS_DOSSRL )
|
||||||
|
|
||||||
|
static void hb_comSetOsError( PHB_COM pCom, int iError )
|
||||||
|
{
|
||||||
|
pCom->oserr = iError;
|
||||||
|
|
||||||
|
switch( iError )
|
||||||
|
{
|
||||||
|
case SER_SUCCESS: /* Function completed successfully */
|
||||||
|
pCom->error = 0;
|
||||||
|
break;
|
||||||
|
case SER_ERR_NOT_OPEN: /* The specified COM port is not opened */
|
||||||
|
pCom->error = HB_COM_ERR_CLOSED;
|
||||||
|
break;
|
||||||
|
case SER_ERR_ALREADY_OPEN: /* The specified COM port is already opened */
|
||||||
|
pCom->error = HB_COM_ERR_ALREADYOPEN;
|
||||||
|
break;
|
||||||
|
case SER_ERR_NO_UART: /* Could not find a UART for this COM port */
|
||||||
|
pCom->error = HB_COM_ERR_NOCOM;
|
||||||
|
break;
|
||||||
|
case SER_ERR_INVALID_COMPORT: /* User specified an invalid COM port */
|
||||||
|
pCom->error = HB_COM_ERR_WRONGPORT;
|
||||||
|
break;
|
||||||
|
case SER_ERR_INVALID_BPS: /* User specified an invalid BPS rate */
|
||||||
|
case SER_ERR_INVALID_DATA_BITS: /* User specified an invalid number of data bits */
|
||||||
|
case SER_ERR_INVALID_PARITY: /* User specified an invalid parity type */
|
||||||
|
case SER_ERR_INVALID_STOP_BITS: /* User specified an invalid number of stop bits */
|
||||||
|
case SER_ERR_INVALID_HANDSHAKING: /* User specified an invalid handshaking type */
|
||||||
|
case SER_ERR_INVALID_FIFO_THRESHOLD:/* User specified an invalid fifo threshold value */
|
||||||
|
case SER_ERR_NULL_PTR: /* User specified a buffer address that was NULL */
|
||||||
|
pCom->error = HB_COM_ERR_PARAMVALUE;
|
||||||
|
break;
|
||||||
|
case SER_ERR_INVALID_BASE: /* User specified an invalid base address */
|
||||||
|
case SER_ERR_INVALID_IRQ: /* User specified an invalid IRQ number */
|
||||||
|
pCom->error = HB_COM_ERR_PARAMVALUE;
|
||||||
|
break;
|
||||||
|
case SER_ERR_IRQ_NOT_FOUND: /* Could not find an IRQ for the specified COM port */
|
||||||
|
case SER_ERR_LOCK_MEM: /* Could not lock memory in DPMI mode */
|
||||||
|
case SER_ERR_UNKNOWN: /* An unknown error occured */
|
||||||
|
default:
|
||||||
|
pCom->error = iError < 0 ? HB_COM_ERR_OTHER : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comInputCount( int iPort )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iCount = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iCount = serial_get_rx_buffered( iPort - 1 );
|
||||||
|
hb_comSetOsError( pCom, iCount );
|
||||||
|
if( iCount < 0 )
|
||||||
|
iCount = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comOutputCount( int iPort )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iCount = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iCount = serial_get_tx_buffered( iPort - 1 );
|
||||||
|
hb_comSetOsError( pCom, iCount );
|
||||||
|
if( iCount < 0 )
|
||||||
|
iCount = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comFlush( int iPort, int iType )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
switch( iType )
|
||||||
|
{
|
||||||
|
case HB_COM_IFLUSH:
|
||||||
|
case HB_COM_IOFLUSH:
|
||||||
|
iResult = serial_clear_rx_buffer( iPort - 1 );
|
||||||
|
if( iType == HB_COM_IFLUSH || iResult != SER_SUCCESS )
|
||||||
|
break;
|
||||||
|
break;
|
||||||
|
case HB_COM_OFLUSH:
|
||||||
|
iResult = serial_clear_tx_buffer( iPort - 1 );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_PARAMVALUE );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
if( iResult < 0 )
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comMCR( int iPort, int * piValue, int iClr, int iSet )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
int iValue = 0;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iResult = serial_get_mcr( iPort - 1 );
|
||||||
|
if( iResult >= 0 )
|
||||||
|
{
|
||||||
|
int iNewVal = ( iResult & ~iClr ) | iSet;
|
||||||
|
iValue = iResult;
|
||||||
|
iResult = iValue == iNewVal ? 0 : serial_set_mcr( iPort - 1, iNewVal );
|
||||||
|
}
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
if( iResult < 0 )
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( piValue )
|
||||||
|
*piValue = iValue;
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comMSR( int iPort, int * piValue )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
int iValue = 0;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iValue = serial_get_msr( iPort - 1 );
|
||||||
|
hb_comSetOsError( pCom, iValue );
|
||||||
|
if( iValue < 0 )
|
||||||
|
{
|
||||||
|
iResult = -1;
|
||||||
|
iValue = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( piValue )
|
||||||
|
*piValue = iValue;
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comLSR( int iPort, int * piValue )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1, iValue = 0;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iValue = serial_get_lsr( iPort - 1 );
|
||||||
|
hb_comSetOsError( pCom, iValue );
|
||||||
|
if( iValue < 0 )
|
||||||
|
{
|
||||||
|
iResult = -1;
|
||||||
|
iValue = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( piValue )
|
||||||
|
*piValue = iValue;
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comSendBreak( int iPort, int iDurationInMilliSecs )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
|
||||||
|
HB_SYMBOL_UNUSED( iDurationInMilliSecs );
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_NOSUPPORT );
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comFlowControl( int iPort, int *piFlow, int iFlow )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1, iValue = 0;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iResult = serial_get_handshaking( iPort - 1 );
|
||||||
|
|
||||||
|
if( iResult >= 0 )
|
||||||
|
{
|
||||||
|
switch( iResult )
|
||||||
|
{
|
||||||
|
case SER_HANDSHAKING_XONXOFF:
|
||||||
|
iValue |= HB_COM_FLOW_XOFF | HB_COM_FLOW_XOFF;
|
||||||
|
break;
|
||||||
|
case SER_HANDSHAKING_RTSCTS:
|
||||||
|
iValue |= HB_COM_FLOW_IRTSCTS | HB_COM_FLOW_ORTSCTS;
|
||||||
|
break;
|
||||||
|
case SER_HANDSHAKING_DTRDSR:
|
||||||
|
iValue |= HB_COM_FLOW_IDTRDSR | HB_COM_FLOW_ODTRDSR;
|
||||||
|
break;
|
||||||
|
case SER_HANDSHAKING_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( iFlow >= 0 )
|
||||||
|
{
|
||||||
|
int iFlowVal = 0;
|
||||||
|
|
||||||
|
if( iFlow & ( HB_COM_FLOW_IRTSCTS | HB_COM_FLOW_ORTSCTS ) )
|
||||||
|
iFlowVal = SER_HANDSHAKING_RTSCTS;
|
||||||
|
else if( iFlow & ( HB_COM_FLOW_IDTRDSR | HB_COM_FLOW_ODTRDSR ) )
|
||||||
|
iFlowVal = SER_HANDSHAKING_DTRDSR;
|
||||||
|
else if( iFlow & ( HB_COM_FLOW_XON | HB_COM_FLOW_XOFF ) )
|
||||||
|
iFlowVal = SER_HANDSHAKING_XONXOFF;
|
||||||
|
|
||||||
|
if( iFlowVal != iResult )
|
||||||
|
iResult = serial_set_handshaking( iPort - 1, iFlowVal );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
if( iResult < 0 )
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( piFlow )
|
||||||
|
*piFlow = iValue;
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comFlowSet( int iPort, int iFlow )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
|
||||||
|
HB_SYMBOL_UNUSED( iFlow );
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_NOSUPPORT );
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comFlowChars( int iPort, int iXONchar, int iXOFFchar )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
HB_SYMBOL_UNUSED( iXONchar );
|
||||||
|
HB_SYMBOL_UNUSED( iXOFFchar );
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_NOSUPPORT );
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comDiscardChar( int iPort, int iChar )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
|
||||||
|
HB_SYMBOL_UNUSED( iChar );
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_NOSUPPORT );
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comErrorChar( int iPort, int iChar )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
|
||||||
|
HB_SYMBOL_UNUSED( iChar );
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_NOSUPPORT );
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comOutputState( int iPort )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iResult = serial_get_tx_buffered( iPort - 1 );
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
if( iResult < 0 )
|
||||||
|
iResult = -1;
|
||||||
|
else if( iResult == 0 )
|
||||||
|
iResult = HB_COM_TX_EMPTY;
|
||||||
|
else
|
||||||
|
iResult = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comInputState( int iPort )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_NOSUPPORT );
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
long hb_comSend( int iPort, const void * data, long len, HB_MAXINT timeout )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
long lSent = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
const char * buffer = ( const char * ) data;
|
||||||
|
HB_MAXUINT timer = timeout <= 0 ? 0 : ( hb_dateMilliSeconds() + timeout );
|
||||||
|
|
||||||
|
hb_comSetOsError( pCom, SER_SUCCESS );
|
||||||
|
lSent = 0;
|
||||||
|
|
||||||
|
hb_vmUnlock();
|
||||||
|
|
||||||
|
while( len > 0 )
|
||||||
|
{
|
||||||
|
int iSent;
|
||||||
|
|
||||||
|
iSent = serial_write_buffered( iPort - 1, buffer, len );
|
||||||
|
if( iSent < 0 )
|
||||||
|
{
|
||||||
|
hb_comSetOsError( pCom, iSent );
|
||||||
|
if( lSent == 0 )
|
||||||
|
lSent = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lSent += iSent;
|
||||||
|
buffer += iSent;
|
||||||
|
len -= iSent;
|
||||||
|
|
||||||
|
if( len > 0 )
|
||||||
|
{
|
||||||
|
if( timer == 0 || timer < hb_dateMilliSeconds() )
|
||||||
|
{
|
||||||
|
if( lSent == 0 )
|
||||||
|
{
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_TIMEOUT );
|
||||||
|
lSent = -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hb_releaseCPU();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_vmLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
long hb_comRecv( int iPort, void * data, long len, HB_MAXINT timeout )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
long lReceived = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
char * buffer = ( char * ) data;
|
||||||
|
HB_MAXUINT timer = timeout <= 0 ? 0 : ( hb_dateMilliSeconds() + timeout );
|
||||||
|
|
||||||
|
hb_comSetOsError( pCom, SER_SUCCESS );
|
||||||
|
lReceived = 0;
|
||||||
|
|
||||||
|
hb_vmUnlock();
|
||||||
|
|
||||||
|
while( len > 0 )
|
||||||
|
{
|
||||||
|
int iRecv = serial_read( iPort - 1, buffer, len );
|
||||||
|
|
||||||
|
if( iRecv < 0 )
|
||||||
|
{
|
||||||
|
hb_comSetOsError( pCom, iRecv );
|
||||||
|
if( lReceived == 0 )
|
||||||
|
lReceived = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lReceived += iRecv;
|
||||||
|
buffer += iRecv;
|
||||||
|
len -= iRecv;
|
||||||
|
|
||||||
|
if( lReceived > 0 || timer == 0 || timer < hb_dateMilliSeconds() )
|
||||||
|
{
|
||||||
|
if( lReceived == 0 )
|
||||||
|
{
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_TIMEOUT );
|
||||||
|
lReceived = -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hb_releaseCPU();
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_vmLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_comChkPortParam( int *piBaud, int *piParity,
|
||||||
|
int *piSize, int *piStop )
|
||||||
|
{
|
||||||
|
int iResult = 0;
|
||||||
|
|
||||||
|
if( *piBaud == 0 )
|
||||||
|
*piBaud = 9600;
|
||||||
|
|
||||||
|
*piParity = HB_TOLOWER( *piParity );
|
||||||
|
switch( *piParity )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
*piParity = 'n';
|
||||||
|
case 'n':
|
||||||
|
case 'e':
|
||||||
|
case 'o':
|
||||||
|
case 's':
|
||||||
|
case 'm':
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( *piSize )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
*piSize = 8;
|
||||||
|
case 8:
|
||||||
|
case 7:
|
||||||
|
case 6:
|
||||||
|
case 5:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( *piStop )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
*piStop = 1;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comInit( int iPort, int iBaud, int iParity, int iSize, int iStop )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
iResult = s_comChkPortParam( &iBaud, &iParity, &iSize, &iStop );
|
||||||
|
if( iResult == 0 )
|
||||||
|
{
|
||||||
|
iResult = serial_set_bps( iPort - 1, iBaud );
|
||||||
|
if( iResult == SER_SUCCESS )
|
||||||
|
iResult = serial_set_data( iPort - 1, iSize );
|
||||||
|
if( iResult == SER_SUCCESS )
|
||||||
|
iResult = serial_set_parity( iPort - 1, iParity );
|
||||||
|
if( iResult == SER_SUCCESS )
|
||||||
|
iResult = serial_set_stop( iPort - 1, iStop );
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
if( iResult < 0 )
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_PARAMVALUE );
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comClose( int iPort )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_OPEN );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
hb_vmUnlock();
|
||||||
|
iResult = serial_close( iPort - 1 );
|
||||||
|
pCom->status &= ~HB_COM_OPEN;
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
if( iResult < 0 )
|
||||||
|
iResult = -1;
|
||||||
|
hb_vmLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hb_comOpen( int iPort )
|
||||||
|
{
|
||||||
|
PHB_COM pCom = hb_comGetPort( iPort, HB_COM_ENABLED );
|
||||||
|
int iResult = -1;
|
||||||
|
|
||||||
|
if( pCom )
|
||||||
|
{
|
||||||
|
if( pCom->status & HB_COM_OPEN )
|
||||||
|
{
|
||||||
|
hb_comSetComError( pCom, HB_COM_ERR_ALREADYOPEN );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int iBaud, iParity, iSize, iStop, iFlowControl;
|
||||||
|
|
||||||
|
hb_vmUnlock();
|
||||||
|
|
||||||
|
iBaud = iParity = iSize = iStop = 0;
|
||||||
|
iFlowControl = SER_HANDSHAKING_NONE;
|
||||||
|
s_comChkPortParam( &iBaud, &iParity, &iSize, &iStop );
|
||||||
|
iResult = serial_open( iPort - 1, iBaud, iSize, iParity, iStop,
|
||||||
|
iFlowControl );
|
||||||
|
if( iResult == 0 )
|
||||||
|
{
|
||||||
|
pCom->status |= HB_COM_OPEN;
|
||||||
|
hb_comSetOsError( pCom, 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serial_close( iPort - 1 );
|
||||||
|
hb_comSetOsError( pCom, iResult );
|
||||||
|
iResult = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_vmLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return iResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end of HB_HAS_DOSSRL */
|
||||||
|
|
||||||
#elif defined( HB_HAS_PMCOM )
|
#elif defined( HB_HAS_PMCOM )
|
||||||
|
|
||||||
static void hb_comSetOsError( PHB_COM pCom, int iError )
|
static void hb_comSetOsError( PHB_COM pCom, int iError )
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ hbmk2.prg
|
|||||||
|
|
||||||
-DHBMK_WITH_ALL_EMBEDDED_HEADERS
|
-DHBMK_WITH_ALL_EMBEDDED_HEADERS
|
||||||
|
|
||||||
-lhbpmcom{dos}
|
-lhbdossrl{dos}
|
||||||
|
|
||||||
# not using these together with .rc input, because some compilers (mingw)
|
# not using these together with .rc input, because some compilers (mingw)
|
||||||
# do not support multiple .rc inputs
|
# do not support multiple .rc inputs
|
||||||
|
|||||||
@@ -3640,7 +3640,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
|
|||||||
OTHERWISE ; tmp := NIL
|
OTHERWISE ; tmp := NIL
|
||||||
ENDSWITCH
|
ENDSWITCH
|
||||||
|
|
||||||
AAdd( hbmk[ _HBMK_aLIBUSERSYS ], "hbpmcom" )
|
AAdd( hbmk[ _HBMK_aLIBUSERSYS ], "hbdossrl" )
|
||||||
IF ! Empty( tmp )
|
IF ! Empty( tmp )
|
||||||
#if defined( HB_HAS_WATT )
|
#if defined( HB_HAS_WATT )
|
||||||
AAdd( hbmk[ _HBMK_aLIBUSERSYSPRE ], tmp )
|
AAdd( hbmk[ _HBMK_aLIBUSERSYSPRE ], tmp )
|
||||||
|
|||||||
Reference in New Issue
Block a user