2009-08-09 16:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtpathy/Makefile
- contrib/hbtpathy/tplinux.c
+ contrib/hbtpathy/tpunix.c
* contrib/hbtpathy/tpcommon.c
* contrib/hbtpathy/tpwin.c
* contrib/hbtpathy/tpos2.c
* contrib/hbtpathy/telepath.prg
* contrib/hbtpathy/hbtpathy.hbc
+ Enabled for all *nix systems (was only linux and darwin).
I don't know if it works on all *nix systems, but it should
be our goal. We will see. Please test.
% Using HB_CRC32() in core instead of reimplementing it locally.
! P_CTRLCTS() dummy now returns proper type.
+ P_OUTFREE() implemented for Windows platforms.
+ P_ISDCD(), P_ISRI(), P_ISDSR(), P_ISCTS()
implemented for Windows platforms. (ideas taken from hbwin)
Neither of these were tested, but it's a start.
+ P_INFREE() added for Windows and OS/2.
Only clean compilation was tested.
+ TP_INFREE() added.
* Some formatting.
* contrib/hbwin/win_prt.c
+ Some extra safety.
This commit is contained in:
@@ -17,6 +17,32 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-08-09 16:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbtpathy/Makefile
|
||||
- contrib/hbtpathy/tplinux.c
|
||||
+ contrib/hbtpathy/tpunix.c
|
||||
* contrib/hbtpathy/tpcommon.c
|
||||
* contrib/hbtpathy/tpwin.c
|
||||
* contrib/hbtpathy/tpos2.c
|
||||
* contrib/hbtpathy/telepath.prg
|
||||
* contrib/hbtpathy/hbtpathy.hbc
|
||||
+ Enabled for all *nix systems (was only linux and darwin).
|
||||
I don't know if it works on all *nix systems, but it should
|
||||
be our goal. We will see. Please test.
|
||||
% Using HB_CRC32() in core instead of reimplementing it locally.
|
||||
! P_CTRLCTS() dummy now returns proper type.
|
||||
+ P_OUTFREE() implemented for Windows platforms.
|
||||
+ P_ISDCD(), P_ISRI(), P_ISDSR(), P_ISCTS()
|
||||
implemented for Windows platforms. (ideas taken from hbwin)
|
||||
Neither of these were tested, but it's a start.
|
||||
+ P_INFREE() added for Windows and OS/2.
|
||||
Only clean compilation was tested.
|
||||
+ TP_INFREE() added.
|
||||
* Some formatting.
|
||||
|
||||
* contrib/hbwin/win_prt.c
|
||||
+ Some extra safety.
|
||||
|
||||
2009-08-09 13:38 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbtpathy/telepath.prg
|
||||
! Fixed tp_open() to not add numeric port to passed portname.
|
||||
|
||||
@@ -8,25 +8,13 @@ LIBNAME=hbtpathy
|
||||
|
||||
C_SOURCES=
|
||||
|
||||
ifeq ($(HB_ARCHITECTURE),linux)
|
||||
ifneq ($(findstring $(HB_ARCHITECTURE),linux darwin hpux bsd sunos),)
|
||||
C_SOURCES=\
|
||||
tplinux.c \
|
||||
tpunix.c \
|
||||
tpcommon.c \
|
||||
|
||||
endif
|
||||
ifeq ($(HB_ARCHITECTURE),darwin)
|
||||
C_SOURCES=\
|
||||
tplinux.c \
|
||||
tpcommon.c \
|
||||
|
||||
endif
|
||||
ifeq ($(HB_ARCHITECTURE),win)
|
||||
C_SOURCES=\
|
||||
tpwin.c \
|
||||
tpcommon.c \
|
||||
|
||||
endif
|
||||
ifeq ($(HB_ARCHITECTURE),wce)
|
||||
ifneq ($(findstring $(HB_ARCHITECTURE),win wce),)
|
||||
C_SOURCES=\
|
||||
tpwin.c \
|
||||
tpcommon.c \
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# $Id$
|
||||
#
|
||||
|
||||
{!(linux|darwin|win|os2)}skip=yes
|
||||
{!(unix|win|os2)}skip=yes
|
||||
|
||||
incpaths=.
|
||||
|
||||
|
||||
@@ -87,8 +87,6 @@ FUNCTION tp_baud( nPort, nNewBaud )
|
||||
t_aPorts[ nPort, TPFP_SBITS ] ) == 0
|
||||
|
||||
t_aPorts[ nPort, TPFP_BAUD ] := nNewBaud
|
||||
|
||||
|
||||
ELSE
|
||||
// set error code
|
||||
ENDIF
|
||||
@@ -170,7 +168,7 @@ FUNCTION tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortn
|
||||
|
||||
LOCAL nRes, lPortExist
|
||||
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#if defined( __PLATFORM__UNIX )
|
||||
LOCAL nFileCase
|
||||
LOCAL nDirCase
|
||||
#endif
|
||||
@@ -183,20 +181,20 @@ FUNCTION tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortn
|
||||
DEFAULT nStop TO 1
|
||||
|
||||
/* Serial ports name are made up of cPortName + nPort if nPort is not NIL */
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#if defined( __PLATFORM__UNIX )
|
||||
DEFAULT cPortName TO "/dev/ttyS" + iif( ISNUMBER( nPort ), hb_NToS( nPort - 1 ), "" )
|
||||
#else
|
||||
DEFAULT cPortName TO "COM" + iif( ISNUMBER( nPort ), hb_NToS( nPort ), "" )
|
||||
#endif
|
||||
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#if defined( __PLATFORM__UNIX )
|
||||
nFileCase := Set( _SET_FILECASE, 0 )
|
||||
nDirCase := Set( _SET_DIRCASE, 0 )
|
||||
#endif
|
||||
|
||||
lPortExist := File( cPortname )
|
||||
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#if defined( __PLATFORM__UNIX )
|
||||
Set( _SET_FILECASE, nFileCase )
|
||||
Set( _SET_DIRCASE, nDirCase )
|
||||
#endif
|
||||
@@ -218,7 +216,7 @@ FUNCTION tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortn
|
||||
t_aPorts[ nPort, TPFP_INBUF ] := ""
|
||||
t_aPorts[ nPort, TPFP_INBUF_SIZE ] := nInSize
|
||||
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#if defined( __PLATFORM__UNIX )
|
||||
// Maybe we should have a p_Open() on every platform
|
||||
t_aPorts[ nPort, TPFP_HANDLE ] := p_Open( cPortname )
|
||||
#else
|
||||
@@ -448,13 +446,21 @@ FUNCTION tp_inchrs( nPort )
|
||||
|
||||
RETURN Len( t_aPorts[ nPort, TPFP_INBUF ] )
|
||||
|
||||
FUNCTION tp_infree( nPort )
|
||||
|
||||
IF ! isopenport( nPort )
|
||||
RETURN 0
|
||||
ENDIF
|
||||
|
||||
RETURN p_infree( t_aPorts[ nPort, TPFP_HANDLE ] )
|
||||
|
||||
FUNCTION tp_outfree( nPort )
|
||||
|
||||
IF ! isopenport( nPort )
|
||||
RETURN 0
|
||||
ENDIF
|
||||
|
||||
RETURN p_OutFree( t_aPorts[ nPort, TPFP_HANDLE ] )
|
||||
RETURN p_outfree( t_aPorts[ nPort, TPFP_HANDLE ] )
|
||||
|
||||
PROCEDURE tp_clearin( nPort )
|
||||
|
||||
@@ -477,7 +483,7 @@ FUNCTION tp_crc16( cString )
|
||||
|
||||
FUNCTION tp_crc32( cString )
|
||||
|
||||
RETURN p_CRC32( cString )
|
||||
RETURN hb_crc32( cString )
|
||||
|
||||
|
||||
/* nPort, nTimeout, acList|cString..., lIgnorecase */
|
||||
@@ -585,7 +591,7 @@ FUNCTION tp_ctrldtr( nPort, nParamNewval )
|
||||
ENDIF
|
||||
nph := t_aPorts[ nPort, TPFP_HANDLE ]
|
||||
|
||||
_P_CTRLDTR( nph, @nnewval, @noldval )
|
||||
P_CTRLDTR( nph, @nnewval, @noldval )
|
||||
|
||||
RETURN noldval
|
||||
*/
|
||||
@@ -622,7 +628,7 @@ FUNCTION tp_iscts( nPort )
|
||||
|
||||
RETURN p_iscts( t_aPorts[ nPort, TPFP_HANDLE ] )
|
||||
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#if defined( __PLATFORM__UNIX )
|
||||
// NB: On linux i don't know how to make a drain with a timeout, so here
|
||||
// I'll wait as long as it takes to drain the port.
|
||||
FUNCTION tp_flush( nPort, nTimeout )
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* Telepathy emulation library
|
||||
*
|
||||
* Copyright 2000, 2001 Dan Levitt <dan@boba-fett.net>
|
||||
*
|
||||
* Copyright 2004, 2005 - Maurilio Longo <maurilio.longo@libero.it>
|
||||
* www - http://www.xharbour.org
|
||||
*
|
||||
@@ -93,84 +92,19 @@ static unsigned short crctab[ 256 ] = {
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
|
||||
|
||||
/* updcrc() macro by Pete Disdale */
|
||||
#define updcrc( cp, crc ) ( ( crc << 8 ) ^ ( crctab[ ( ( crc >> 8 ) ^ cp ) & 0xFF ] ) )
|
||||
|
||||
HB_FUNC( P_CRC16 )
|
||||
{
|
||||
const char *ptr = hb_parc( 1 );
|
||||
const char * ptr = hb_parc( 1 );
|
||||
int count = hb_parclen( 1 );
|
||||
|
||||
register unsigned short crc = 0;
|
||||
unsigned short crc = 0;
|
||||
|
||||
while ( count-- > 0 )
|
||||
while( count-- > 0 )
|
||||
crc = updcrc( *ptr++, crc );
|
||||
|
||||
/* swap Hi and Lo byte */
|
||||
hb_retnl( ( crc >> 8 ) | ( ( crc << 8 ) & 0xFF00 ) );
|
||||
}
|
||||
|
||||
/* Taken from: contrib/unicode/hbcrc32.c
|
||||
|
||||
* Harbour Unicode Support
|
||||
*
|
||||
* Source codes for functions:
|
||||
* HB_CRC32()
|
||||
* HB_NCRC32()
|
||||
*
|
||||
* Copyright 2004 Dmitry V. Korzhov <dk@april26.spb.ru>
|
||||
* www - http://www.harbour-project.org
|
||||
*/
|
||||
|
||||
#define CRC32INIT ( 0xFFFFFFFFL )
|
||||
|
||||
static ULONG crc32tbl[ 256 ] = {
|
||||
0x00000000l,0x77073096l,0xEE0E612Cl,0x990951BAl,0x076DC419l,0x706AF48Fl,0xE963A535l,0x9E6495A3l,
|
||||
0x0EDB8832l,0x79DCB8A4l,0xE0D5E91El,0x97D2D988l,0x09B64C2Bl,0x7EB17CBDl,0xE7B82D07l,0x90BF1D91l,
|
||||
0x1DB71064l,0x6AB020F2l,0xF3B97148l,0x84BE41DEl,0x1ADAD47Dl,0x6DDDE4EBl,0xF4D4B551l,0x83D385C7l,
|
||||
0x136C9856l,0x646BA8C0l,0xFD62F97Al,0x8A65C9ECl,0x14015C4Fl,0x63066CD9l,0xFA0F3D63l,0x8D080DF5l,
|
||||
0x3B6E20C8l,0x4C69105El,0xD56041E4l,0xA2677172l,0x3C03E4D1l,0x4B04D447l,0xD20D85FDl,0xA50AB56Bl,
|
||||
0x35B5A8FAl,0x42B2986Cl,0xDBBBC9D6l,0xACBCF940l,0x32D86CE3l,0x45DF5C75l,0xDCD60DCFl,0xABD13D59l,
|
||||
0x26D930ACl,0x51DE003Al,0xC8D75180l,0xBFD06116l,0x21B4F4B5l,0x56B3C423l,0xCFBA9599l,0xB8BDA50Fl,
|
||||
0x2802B89El,0x5F058808l,0xC60CD9B2l,0xB10BE924l,0x2F6F7C87l,0x58684C11l,0xC1611DABl,0xB6662D3Dl,
|
||||
0x76DC4190l,0x01DB7106l,0x98D220BCl,0xEFD5102Al,0x71B18589l,0x06B6B51Fl,0x9FBFE4A5l,0xE8B8D433l,
|
||||
0x7807C9A2l,0x0F00F934l,0x9609A88El,0xE10E9818l,0x7F6A0DBBl,0x086D3D2Dl,0x91646C97l,0xE6635C01l,
|
||||
0x6B6B51F4l,0x1C6C6162l,0x856530D8l,0xF262004El,0x6C0695EDl,0x1B01A57Bl,0x8208F4C1l,0xF50FC457l,
|
||||
0x65B0D9C6l,0x12B7E950l,0x8BBEB8EAl,0xFCB9887Cl,0x62DD1DDFl,0x15DA2D49l,0x8CD37CF3l,0xFBD44C65l,
|
||||
0x4DB26158l,0x3AB551CEl,0xA3BC0074l,0xD4BB30E2l,0x4ADFA541l,0x3DD895D7l,0xA4D1C46Dl,0xD3D6F4FBl,
|
||||
0x4369E96Al,0x346ED9FCl,0xAD678846l,0xDA60B8D0l,0x44042D73l,0x33031DE5l,0xAA0A4C5Fl,0xDD0D7CC9l,
|
||||
0x5005713Cl,0x270241AAl,0xBE0B1010l,0xC90C2086l,0x5768B525l,0x206F85B3l,0xB966D409l,0xCE61E49Fl,
|
||||
0x5EDEF90El,0x29D9C998l,0xB0D09822l,0xC7D7A8B4l,0x59B33D17l,0x2EB40D81l,0xB7BD5C3Bl,0xC0BA6CADl,
|
||||
0xEDB88320l,0x9ABFB3B6l,0x03B6E20Cl,0x74B1D29Al,0xEAD54739l,0x9DD277AFl,0x04DB2615l,0x73DC1683l,
|
||||
0xE3630B12l,0x94643B84l,0x0D6D6A3El,0x7A6A5AA8l,0xE40ECF0Bl,0x9309FF9Dl,0x0A00AE27l,0x7D079EB1l,
|
||||
0xF00F9344l,0x8708A3D2l,0x1E01F268l,0x6906C2FEl,0xF762575Dl,0x806567CBl,0x196C3671l,0x6E6B06E7l,
|
||||
0xFED41B76l,0x89D32BE0l,0x10DA7A5Al,0x67DD4ACCl,0xF9B9DF6Fl,0x8EBEEFF9l,0x17B7BE43l,0x60B08ED5l,
|
||||
0xD6D6A3E8l,0xA1D1937El,0x38D8C2C4l,0x4FDFF252l,0xD1BB67F1l,0xA6BC5767l,0x3FB506DDl,0x48B2364Bl,
|
||||
0xD80D2BDAl,0xAF0A1B4Cl,0x36034AF6l,0x41047A60l,0xDF60EFC3l,0xA867DF55l,0x316E8EEFl,0x4669BE79l,
|
||||
0xCB61B38Cl,0xBC66831Al,0x256FD2A0l,0x5268E236l,0xCC0C7795l,0xBB0B4703l,0x220216B9l,0x5505262Fl,
|
||||
0xC5BA3BBEl,0xB2BD0B28l,0x2BB45A92l,0x5CB36A04l,0xC2D7FFA7l,0xB5D0CF31l,0x2CD99E8Bl,0x5BDEAE1Dl,
|
||||
0x9B64C2B0l,0xEC63F226l,0x756AA39Cl,0x026D930Al,0x9C0906A9l,0xEB0E363Fl,0x72076785l,0x05005713l,
|
||||
0x95BF4A82l,0xE2B87A14l,0x7BB12BAEl,0x0CB61B38l,0x92D28E9Bl,0xE5D5BE0Dl,0x7CDCEFB7l,0x0BDBDF21l,
|
||||
0x86D3D2D4l,0xF1D4E242l,0x68DDB3F8l,0x1FDA836El,0x81BE16CDl,0xF6B9265Bl,0x6FB077E1l,0x18B74777l,
|
||||
0x88085AE6l,0xFF0F6A70l,0x66063BCAl,0x11010B5Cl,0x8F659EFFl,0xF862AE69l,0x616BFFD3l,0x166CCF45l,
|
||||
0xA00AE278l,0xD70DD2EEl,0x4E048354l,0x3903B3C2l,0xA7672661l,0xD06016F7l,0x4969474Dl,0x3E6E77DBl,
|
||||
0xAED16A4Al,0xD9D65ADCl,0x40DF0B66l,0x37D83BF0l,0xA9BCAE53l,0xDEBB9EC5l,0x47B2CF7Fl,0x30B5FFE9l,
|
||||
0xBDBDF21Cl,0xCABAC28Al,0x53B39330l,0x24B4A3A6l,0xBAD03605l,0xCDD70693l,0x54DE5729l,0x23D967BFl,
|
||||
0xB3667A2El,0xC4614AB8l,0x5D681B02l,0x2A6F2B94l,0xB40BBE37l,0xC30C8EA1l,0x5A05DF1Bl,0x2D02EF8Dl };
|
||||
|
||||
|
||||
#define updcrc32( cp, crc ) ( crc32tbl[ ( crc ^ cp ) & 0xff ] ^ ( crc >> 8 ) )
|
||||
|
||||
HB_FUNC( P_CRC32 )
|
||||
{
|
||||
const char * ptr = hb_parc( 1 );
|
||||
int count = hb_parclen( 1 );
|
||||
|
||||
register ULONG crc = CRC32INIT;
|
||||
|
||||
while( count-- > 0 )
|
||||
crc = updcrc32( *ptr++, crc );
|
||||
|
||||
hb_retnl( crc ^ CRC32INIT );
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapifs.h"
|
||||
|
||||
#ifdef HB_OS_OS2
|
||||
#if defined( HB_OS_OS2 )
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
@@ -156,6 +156,20 @@ HB_FUNC( P_WRITEPORT )
|
||||
hb_retnl( rc == NO_ERROR ? ( long ) nWritten : -1 ); /* Put GetLastError() on error, or better a second byref param? */
|
||||
}
|
||||
|
||||
HB_FUNC( P_INFREE )
|
||||
{
|
||||
APIRET rc;
|
||||
RXQUEUE rxqueue;
|
||||
|
||||
memset( &rxqueue, 0, sizeof( rxqueue ) );
|
||||
|
||||
if( ( rc = DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETINQUECOUNT,
|
||||
NULL, 0L, NULL, &rxqueue, sizeof( RXQUEUE ), NULL ) ) == NO_ERROR )
|
||||
hb_retnl( rxqueue.cb - rxqueue.cch );
|
||||
else
|
||||
hb_retnl( -1 ); /* Put GetLastError() here, or better a second byref param? */
|
||||
}
|
||||
|
||||
HB_FUNC( P_OUTFREE )
|
||||
{
|
||||
APIRET rc;
|
||||
@@ -164,7 +178,7 @@ HB_FUNC( P_OUTFREE )
|
||||
memset( &rxqueue, 0, sizeof( rxqueue ) );
|
||||
|
||||
if( ( rc = DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
|
||||
NULL, 0L, NULL, &rxqueue, sizeof(RXQUEUE), NULL ) ) == NO_ERROR )
|
||||
NULL, 0L, NULL, &rxqueue, sizeof( RXQUEUE ), NULL ) ) == NO_ERROR )
|
||||
hb_retnl( rxqueue.cb - rxqueue.cch );
|
||||
else
|
||||
hb_retnl( -1 ); /* Put GetLastError() here, or better a second byref param? */
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Telepathy emulation library
|
||||
* C low level module for linux serial communication
|
||||
* C low level module for *nix serial communication
|
||||
*
|
||||
* Copyright 2005 - Maurilio Longo <maurilio.longo@libero.it>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* Lots of code from http://www.easysw.com/~mike/serial/serial.html
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
@@ -58,7 +57,7 @@
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapifs.h"
|
||||
|
||||
#ifdef HB_OS_UNIX
|
||||
#if defined( HB_OS_UNIX )
|
||||
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
@@ -197,6 +196,11 @@ HB_FUNC( P_DRAIN )
|
||||
hb_retnl( tcdrain( hb_parnl( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( P_INFREE )
|
||||
{
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
|
||||
HB_FUNC( P_OUTFREE )
|
||||
{
|
||||
#if 0
|
||||
@@ -7,7 +7,8 @@
|
||||
* Telepathy emulation library
|
||||
* C low level module for Windows serial communication
|
||||
*
|
||||
* Copyright 2004 - Maurilio Longo <maurilio.longo@libero.it>
|
||||
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* Copyright 2004 Maurilio Longo <maurilio.longo@libero.it>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -99,33 +100,96 @@ HB_FUNC( P_INITPORTSPEED )
|
||||
|
||||
HB_FUNC( P_READPORT )
|
||||
{
|
||||
char Buffer[ 512 ];
|
||||
char buffer[ 512 ];
|
||||
DWORD nRead = 0;
|
||||
OVERLAPPED Overlapped;
|
||||
BOOL bRet;
|
||||
|
||||
memset( &Overlapped, 0, sizeof( OVERLAPPED ) );
|
||||
bRet = ReadFile( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), Buffer, sizeof( Buffer ), &nRead, &Overlapped );
|
||||
hb_retclen( bRet ? Buffer : NULL, nRead );
|
||||
if( ReadFile( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), buffer, sizeof( buffer ), &nRead, &Overlapped ) )
|
||||
hb_retclen( buffer, nRead );
|
||||
else
|
||||
hb_retc_null();
|
||||
}
|
||||
|
||||
HB_FUNC( P_WRITEPORT )
|
||||
{
|
||||
DWORD nWritten = 0;
|
||||
OVERLAPPED Overlapped;
|
||||
BOOL bRet;
|
||||
|
||||
memset( &Overlapped, 0, sizeof( OVERLAPPED ) );
|
||||
bRet = WriteFile( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten, &Overlapped );
|
||||
hb_retnl( bRet ? ( long ) nWritten : -1 ); /* Put GetLastError() on error, or better a second byref param? */
|
||||
if( WriteFile( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten, &Overlapped ) )
|
||||
hb_retnl( ( long ) nWritten ); /* Put GetLastError() on error, or better a second byref param? */
|
||||
else
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
|
||||
/* TODO: Implement these dummy functions. */
|
||||
HB_FUNC( P_OUTFREE ) {}
|
||||
HB_FUNC( P_CTRLCTS ) {}
|
||||
HB_FUNC( P_ISDCD ) {}
|
||||
HB_FUNC( P_ISRI ) {}
|
||||
HB_FUNC( P_ISDSR ) {}
|
||||
HB_FUNC( P_ISCTS ) {}
|
||||
HB_FUNC( P_INFREE )
|
||||
{
|
||||
HANDLE hPort = ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 );
|
||||
COMMPROP CommProp;
|
||||
if( GetCommProperties( hPort, &CommProp ) )
|
||||
{
|
||||
COMSTAT ComStat;
|
||||
if( ClearCommError( hPort, NULL, &ComStat ) && CommProp.dwCurrentRxQueue != 0 )
|
||||
hb_retnl( CommProp.dwCurrentRxQueue - ComStat.cbInQue );
|
||||
else
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
else
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
|
||||
HB_FUNC( P_OUTFREE )
|
||||
{
|
||||
HANDLE hPort = ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 );
|
||||
COMMPROP CommProp;
|
||||
if( GetCommProperties( hPort, &CommProp ) )
|
||||
{
|
||||
COMSTAT ComStat;
|
||||
if( ClearCommError( hPort, NULL, &ComStat ) && CommProp.dwCurrentTxQueue != 0 )
|
||||
hb_retnl( CommProp.dwCurrentTxQueue - ComStat.cbOutQue );
|
||||
else
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
else
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
|
||||
HB_FUNC( P_CTRLCTS )
|
||||
{
|
||||
hb_retni( 0 ); /* dummy */
|
||||
}
|
||||
|
||||
HB_FUNC( P_ISDCD )
|
||||
{
|
||||
DWORD dwModemStat = 0;
|
||||
BOOL bRet = GetCommModemStatus( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), &dwModemStat );
|
||||
|
||||
hb_retl( bRet ? ( dwModemStat & MS_RLSD_ON ) != 0 : FALSE ); /* The RLSD (receive-line-signal-detect) signal is on. Also is DCD. */
|
||||
}
|
||||
|
||||
HB_FUNC( P_ISRI )
|
||||
{
|
||||
DWORD dwModemStat = 0;
|
||||
BOOL bRet = GetCommModemStatus( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), &dwModemStat );
|
||||
|
||||
hb_retl( bRet ? ( dwModemStat & MS_RING_ON ) != 0 : FALSE );
|
||||
}
|
||||
|
||||
HB_FUNC( P_ISDSR )
|
||||
{
|
||||
DWORD dwModemStat = 0;
|
||||
BOOL bRet = GetCommModemStatus( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), &dwModemStat );
|
||||
|
||||
hb_retl( bRet ? ( dwModemStat & MS_DSR_ON ) != 0 : FALSE );
|
||||
}
|
||||
|
||||
HB_FUNC( P_ISCTS )
|
||||
{
|
||||
DWORD dwModemStat = 0;
|
||||
BOOL bRet = GetCommModemStatus( ( HANDLE ) ( HB_PTRUINT ) hb_parnint( 1 ), &dwModemStat );
|
||||
|
||||
hb_retl( bRet ? ( dwModemStat & MS_CTS_ON ) != 0 : FALSE );
|
||||
}
|
||||
|
||||
#endif /* HB_OS_WIN */
|
||||
|
||||
@@ -400,7 +400,7 @@ HB_FUNC( WIN_PORTSTATUS )
|
||||
if( iPort >= 0 && iPort < ( int ) HB_SIZEOFARRAY( s_PortData ) )
|
||||
{
|
||||
HANDLE hCommPort = s_PortData[ iPort ].hPort;
|
||||
DWORD dwModemStat;
|
||||
DWORD dwModemStat = 0;
|
||||
|
||||
s_PortData[ iPort ].iFunction = FCNGETCOMMMODEMSTATUS;
|
||||
s_PortData[ iPort ].dwError = 0;
|
||||
@@ -460,7 +460,7 @@ HB_FUNC( WIN_PORTQUEUESTATUS )
|
||||
if( iPort >= 0 && iPort < ( int ) HB_SIZEOFARRAY( s_PortData ) )
|
||||
{
|
||||
HANDLE hCommPort = s_PortData[ iPort ].hPort;
|
||||
DWORD dwErrors;
|
||||
DWORD dwErrors = 0;
|
||||
COMSTAT ComStat;
|
||||
|
||||
s_PortData[ iPort ].iFunction = FCNCLEARCOMMERROR;
|
||||
|
||||
Reference in New Issue
Block a user