2007-11-11 18:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

+ contrib/telepath
   + contrib/telepath/ChangeLog
   + contrib/telepath/Makefile
   + contrib/telepath/make_b32.bat
   + contrib/telepath/make_vc.bat
   + contrib/telepath/common.mak
   + contrib/telepath/telepath.ch
   + contrib/telepath/tplinux.c
   + contrib/telepath/tpwin32.c
   + contrib/telepath/tpos2.c
   + contrib/telepath/telepath.prg
   + contrib/telepath/readme.txt
   + contrib/telepath/test
   + contrib/telepath/test/testtp.prg
     + Added Telep*th(y) compatible contrib lib.
       Borrowed from xhb.

   * source/debug/dbgtobj.prg
     ! Fixed crash. Borrowed from xhb.
This commit is contained in:
Viktor Szakats
2007-11-11 17:56:06 +00:00
parent 1998e7017d
commit 96d906cf55
14 changed files with 2426 additions and 1 deletions

View File

@@ -8,6 +8,27 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-11-11 18:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
+ contrib/telepath
+ contrib/telepath/ChangeLog
+ contrib/telepath/Makefile
+ contrib/telepath/make_b32.bat
+ contrib/telepath/make_vc.bat
+ contrib/telepath/common.mak
+ contrib/telepath/telepath.ch
+ contrib/telepath/tplinux.c
+ contrib/telepath/tpwin32.c
+ contrib/telepath/tpos2.c
+ contrib/telepath/telepath.prg
+ contrib/telepath/readme.txt
+ contrib/telepath/test
+ contrib/telepath/test/testtp.prg
+ Added Telep*th(y) compatible contrib lib.
Borrowed from xhb.
* source/debug/dbgtobj.prg
! Fixed crash. Borrowed from xhb.
2007-11-11 18:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/mtpl.mak
* contrib/mtpl_b32.mak

View File

@@ -0,0 +1,125 @@
/*
* $Id: ChangeLog,v 1.15 2005/10/24 14:39:26 mauriliolongo Exp $
*/
/* Use this format for the entry headers:
YYYY-MM-DD HH:MM UTC[-|+]hhmm Your Full Name <your_email@address>
For example:
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2005-10-24 16:30 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
! tp_/linux.c
! tp_/telepath.prg
! tp_/ChangeLog
! Latest commit broke EOL
* tp_/os2.c
+ stub tp_ctrlcts()
2005-10-13 13:00 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* NB: With latest commits tp_recv() and tp_recvto() wait up to
3 ms ( under linux ) before returning ( with or without any
character ).
OS/2 and win32 modules, instead, return immediatly if no
input is available and waiting in the com port receive buffer.
I think the correct way of doing read()s is the one implemented
in linux.c and I will change OS/2 and win32 behaviour as
soon as I can.
2005-10-13 12:50 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/Makefile
* added linux.c module to library
2005-10-13 10:05 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
+ tp_/linux.c
+ Added linux low level serial module, tested with a
a serial printer and a connection to a cash register.
* tp_/telepath.prg
* changes to a few functions to make them work nicely with linux.c
2004-08-31 16:50 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/os2.c
* tp_/telepath.prg
! corrected an error on tp_crc16()
+ added a bunch of functions, right now only to OS/2 build
2004-08-31 16:45 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/TELEPATH.CH
- removed UPPERCASE file
+ added telepath.ch
2004-08-26 09:30 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/os2.c
+ added OS/2 low level C code
2004-08-25 23:50 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/telepath.prg
+ tp_crc32()
2004-08-25 15:50 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/telepath.prg
* tp_/win32.c
+ tp_baud(), tp_sendsub()
! tp_send() and tp_receive() seem to work as expected.
2004-08-25 10:35 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/telepath.prg
+ tp_crc16() thanks to Pete Disdale.
* modified a few functions to start using low level win32.c
+ tp_/win32.c
+ Low level C code for win32 serial port access
+ tp_/Makefile
+ OS/2 Makefile
+ tp_/makefile.bc
+ bcc32 makefile
+ tp_/make_b32.bat
+ win32 makefile
+ tp_/TELEPATH.CH
+ .prg level defines for telepathy compatibility
/* At this time, on win32, I can ask to my modem its name :) */
2004-08-16 16:32 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/telepath.prg
* tp_/testtp.prg
+ Added xharbour Copyright header with full credit to the original
author of this library
/* I think I will change a lot this library since I want to have it
multiplatform, so, for example, all C code will go to separated files
(one per platform) to have a common (high level) .prg code which
calls common (low level) C code functions from different (one per
platform) .c files.
As it is now should compile and work under linux, I can't test it right
now and, probably, something will break in the process of making it
multiplatform.
*/
2004-08-16 16:32 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/telepath.prg
+ removed the original developed with Flagship and inserted
the one ported to xharbour by Luiz Rafael Culik Guimaraes (culikr@brturbo.com)
2004-08-16 16:22 UTC+0200 Maurilio Longo <maurilio.longo@libero.it>
* tp_/ChangeLog
* tp_/Makefile
* tp_/README
* tp_/telepath.prg
* tp_/testtp.prg
+ Added CVS ID to every file
I sent the original version to the flagship website in may 2000.
I just now (July 2001) made the first change to the code.
7/19/2001
The bug I found is REALLY esoteric... it's in tp_open. It comes into play
when something previously set the parity to Even or Odd and then your telepathy program does a tp_open on that port and sets parity to None. I previously
assumed that if you were setting parity to N, the port was already at N and I
didn't explicitly call stty -parenb and -parodd.
I included telepathy.bak in case you care to look at the prior version.

View File

@@ -0,0 +1,27 @@
#
# $Id: Makefile,v 1.4 2005/10/13 10:45:46 mauriliolongo Exp $
#
ROOT = ../../
ifneq ($(HB_ARCHITECTURE),dos)
ifeq ($(HB_ARCHITECTURE),linux)
C_SOURCES=\
tplinux.c
else ($(HB_ARCHITECTURE),win32)
C_SOURCES=\
tpwin32.c
else
C_SOURCES=\
tpos2.c
endif
PRG_SOURCES=\
telepath.prg
LIBNAME=telepath
include $(TOP)$(ROOT)config/lib.cf
endif

View File

@@ -0,0 +1,18 @@
#
# $Id: common.mak 7935 2007-11-10 11:31:17Z vszakats $
#
LIBNAME = telepath
LIB_PATH = $(LIB_DIR)\$(LIBNAME)$(LIBEXT)
#
# LIB rules
#
LIB_OBJS = \
$(OBJ_DIR)\telepath$(OBJEXT) \
$(OBJ_DIR)\tpwin32$(OBJEXT)
all: \
$(LIB_PATH) \

View File

@@ -0,0 +1,60 @@
@echo off
rem
rem $Id: make_b32.bat 7949 2007-11-11 17:08:43Z vszakats $
rem
rem ---------------------------------------------------------------
rem This is a generic template file, if it doesn't fit your own needs
rem please DON'T MODIFY IT.
rem
rem Instead, make a local copy and modify that one, or make a call to
rem this batch file from your customized one. [vszakats]
rem
rem Set any of the below settings to customize your build process:
rem set HB_MAKE_PROGRAM=
rem set HB_MAKE_FLAGS=
rem ---------------------------------------------------------------
if "%HB_CC_NAME%" == "" set HB_CC_NAME=b32
if "%HB_MAKE_PROGRAM%" == "" set HB_MAKE_PROGRAM=make.exe
set HB_MAKEFILE=..\mtpl_%HB_CC_NAME%.mak
rem ---------------------------------------------------------------
rem Save the user value, force silent file overwrite with COPY
rem (not all Windows versions support the COPY /Y flag)
set HB_ORGENV_COPYCMD=%COPYCMD%
set COPYCMD=/Y
rem ---------------------------------------------------------------
if "%1" == "clean" goto CLEAN
if "%1" == "CLEAN" goto CLEAN
if "%1" == "install" goto INSTALL
if "%1" == "INSTALL" goto INSTALL
:BUILD
%HB_MAKE_PROGRAM% %HB_MAKE_FLAGS% -f %HB_MAKEFILE% %1 %2 %3 > make_%HB_CC_NAME%.log
if errorlevel 1 notepad make_%HB_CC_NAME%.log
goto EXIT
:CLEAN
%HB_MAKE_PROGRAM% %HB_MAKE_FLAGS% -f %HB_MAKEFILE% CLEAN > make_%HB_CC_NAME%.log
if exist make_%HB_CC_NAME%.log del make_%HB_CC_NAME%.log > nul
if exist inst_%HB_CC_NAME%.log del inst_%HB_CC_NAME%.log > nul
goto EXIT
:INSTALL
%HB_MAKE_PROGRAM% %HB_MAKE_FLAGS% -f %HB_MAKEFILE% INSTALL > nul
goto EXIT
:EXIT
rem ---------------------------------------------------------------
rem Restore user value
set COPYCMD=%HB_ORGENV_COPYCMD%

View File

@@ -0,0 +1,60 @@
@echo off
rem
rem $Id: make_vc.bat 7949 2007-11-11 17:08:43Z vszakats $
rem
rem ---------------------------------------------------------------
rem This is a generic template file, if it doesn't fit your own needs
rem please DON'T MODIFY IT.
rem
rem Instead, make a local copy and modify that one, or make a call to
rem this batch file from your customized one. [vszakats]
rem
rem Set any of the below settings to customize your build process:
rem set HB_MAKE_PROGRAM=
rem set HB_MAKE_FLAGS=
rem ---------------------------------------------------------------
if "%HB_CC_NAME%" == "" set HB_CC_NAME=vc
if "%HB_MAKE_PROGRAM%" == "" set HB_MAKE_PROGRAM=nmake.exe
set HB_MAKEFILE=..\mtpl_%HB_CC_NAME%.mak
rem ---------------------------------------------------------------
rem Save the user value, force silent file overwrite with COPY
rem (not all Windows versions support the COPY /Y flag)
set HB_ORGENV_COPYCMD=%COPYCMD%
set COPYCMD=/Y
rem ---------------------------------------------------------------
if "%1" == "clean" goto CLEAN
if "%1" == "CLEAN" goto CLEAN
if "%1" == "install" goto INSTALL
if "%1" == "INSTALL" goto INSTALL
:BUILD
%HB_MAKE_PROGRAM% %HB_MAKE_FLAGS% -f %HB_MAKEFILE% %1 %2 %3 > make_%HB_CC_NAME%.log
if errorlevel 1 notepad make_%HB_CC_NAME%.log
goto EXIT
:CLEAN
%HB_MAKE_PROGRAM% %HB_MAKE_FLAGS% -f %HB_MAKEFILE% CLEAN > make_%HB_CC_NAME%.log
if exist make_%HB_CC_NAME%.log del make_%HB_CC_NAME%.log > nul
if exist inst_%HB_CC_NAME%.log del inst_%HB_CC_NAME%.log > nul
goto EXIT
:INSTALL
%HB_MAKE_PROGRAM% %HB_MAKE_FLAGS% -f %HB_MAKEFILE% INSTALL > nul
goto EXIT
:EXIT
rem ---------------------------------------------------------------
rem Restore user value
set COPYCMD=%HB_ORGENV_COPYCMD%

View File

@@ -0,0 +1,55 @@
/*
* $Id: README,v 1.2 2004/08/16 14:30:18 mauriliolongo Exp $
*/
Telepathy is the best serial communication library for Nantucket/CA Clipper.
I ported a significant amount of the functionality contained in Telepathy in
this Flagship port.
The .prg (in the MyTelepathy.tar package) is meant to be compiled with
Flagship and provide some of the functionality of the Telepathy serial
library from Extrasensory Inc. I've talked to Ira Emus, the proprietor of
Extrasensory and he's ok with what I've done here. But Extrasensory has no
involvement or responsibility with this project.
I wrote this originally on RedHat Linux 5.1 and I've tested it on RedHat
6.2. And now Neolinux 2.0.1 and 2.1. I've tested it on kernels 2.0.x - 2.4.x.
Your mileage may vary.
I only ported the parts of Telepathy that I needed. If you need other parts
of the telepathy libarary, Use the Source... (and send me your new functions)
I tried to keep parameter counts and orders as consistent as possible between
this Telepathy and the real Telepathy. The only difference I can think of is
the parameter list for tp_open (and tp_reopen). That's just because unix has
filename comports like /dev/ttyS0 and dos has com port numbers like 1. I kept
the com port number thing so that all the telepathy functions (and all your
code) that uses com port number won't need to be changed. But you do need to
change the calls to tp_open.
Feel free to use, modify, distribute, hack, kludge, append, extend or whatever
you like to this source code. You can (at your own risk) compile it into any
program you wish and sell or freely distribute the resulting application. I
would prefer you make your application Free and distribute the source. But who
am I to say - the suite of applications that my company sells that I originally
wrote this for is closed source.
Though I use this code in a production environment for a suite of programs that
my company actually sells, I make no promises (expressed or implied) about its
stability, functionality, effectiveness or anything else. I warn you now
that if you use my code, you're doing so at your own risk and it will probably
blow up your computer. But that's a risk you'll just have to take.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE (thanks RMS).
This software is totally as is, you may use it at your own risk.
This is freeware. But if you actually use this in your program, please send
me email at dan@boba-fett.net. I'd just be curious to see if anyone ever
uses it.
If you find a bug or write some new code for this project, pretty please send
me email with it.
- Dan Levitt <dan@boba-fett.net>

View File

@@ -0,0 +1,131 @@
/*
* $Id: telepath.ch,v 1.1 2004/08/31 14:48:39 mauriliolongo Exp $
*/
/*
* Harbour Project source code:
* Telepathy emulation library
*
* Copyright 2000, 2001 Dan Levitt <dan@boba-fett.net>
* www - http://www.harbour-project.org
*
* 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)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#define TP_MAXPORTS 8
#define TPFP_NAME 1 // Structure of ports array
#define TPFP_HANDLE 2
#define TPFP_BAUD 3
#define TPFP_DBITS 4
#define TPFP_PARITY 5
#define TPFP_SBITS 6
#define TPFP_OC 7 // Open/Close Flag
#define TPFP_INBUF 8
#define TPFP_INBUF_SIZE 9 // Size of input buffer
// Error code definitions
#define TE_PARAM -1 // Bad parameter
#define TE_NOPORT -2 // No such port
#define TE_CLOSED -3 // Port not open
#define TE_CONFL -4 // IRQ conflict
#define TE_TMOUT -5 // Timeout
#define TE_NDCD -6 // Lost DCD
#define TE_ESCAPE -7 // User escape
#define TE_LENGTH -8 // Length limit
#define TE_CANCEL -9 // Input canceled
#define TE_NOHDL -10 // Out of handles
#define TE_UCANCEL -50 // Canceled by user
#define TE_RCANCEL -51 // Canceled by remote
#define TE_STARTTM -52 // Timeout waiting to start
#define TE_BLOCKTM -53 // Timeout waiting for block
#define TE_ACKTM -54 // Timeout waiting for acknowledge
#define TE_SENDTM -55 // Timeout waiting to send
#define TE_CLEARTM -56 // Timeout waiting for sender to stop
#define TE_NAK -57 // Negative acknowledge
#define TE_BADACK -58 // Bad acknowledge character
#define TE_BADBLK -59 // Bad block format
#define TE_LONGBLK -60 // Long block received
#define TE_ERRMAX -61 // Too many errors
#define TE_DUPBLK -62 // Duplicate block
#define TE_PROTO -63 // Protocol failure
#define TE_CKSUM -64 // Checksum error
#define TE_HDRTM -65 // Timeout waiting for Zmodem header
#define TE_DISKFULL -100 // Disk full
#define TE_NOFILE -102 // File not found
#define TE_NOPATH -103 // Path not found
#define TE_MFILE -104 // Too many open files
#define TE_ACCESS -105 // Access denied
// File transfer status
#define TXS_START 1 // Start of transfer
#define TXS_SFILE 2 // Start of file
#define TXS_NEWNAME 3 // File renamed
#define TXS_SDATA 4 // Start of file data
#define TXS_BLOCK 5 // End of block
#define TXS_ERROR 6 // Error
#define TXS_ABFILE 7 // Aborting file
#define TXS_ABORT 8 // Aborting transfer
#define TXS_WEND 9 // Waiting for end of file
#define TXS_EFILE 10 // End of file
#define TXS_END 11 // End of transfer
#define TP_32MAGIC 558161692
// Handshaking flags for tp_hshk()
#define THS_RDSR 1 // Require DSR
#define THS_RCTS 2 // Require CTS
#define THS_RXOFF 4 // Respect XON/XOFF
#define THS_RDCD 8 // Require DCD
#define THS_ADTR 16 // Assert DTR
#define THS_CDTR 32 // Flow control with DTR
#define THS_ARTS 64 // Assert RTS
#define THS_CRTS 128 // Flow control with RTS
#define THS_SXOFF 256 // Send XON/XOFF

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,78 @@
/*
* $Id: testtp.prg,v 1.4 2004/08/25 08:49:06 mauriliolongo Exp $
*/
/*
* Harbour Project source code:
* Telepathy emulation library
*
* Copyright 2000, 2001 Dan Levitt <dan@boba-fett.net>
* www - http://www.harbour-project.org
*
* 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)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*
This is based upon a library originally made by Dan Levitt <dan@boba-fett.net>
(see README and ChangeLog). The original files have been committed as v1.0,
so you can always retrieve them (see CVS docs on how to)
First xHarbour Port by Luiz Rafael Culik Guimaraes (culikr@brturbo.com)
*/
/*
instructions - hook up a loopback device to "com1" of your computer
run this program. It should echo Hi there bob.
If it gives you a file i/o error, try running as root.
also make sure that other programs (minicom?) can successfully talk to your
com port.
*/
function main
?
?
? tp_open( 1,, 9600, 8, "N", 1 )
//tp_send( 1, "Hi there bob" )
tp_inkey( .5 )
//? tp_recv( 1 )
?
tp_Close( 1 )
return nil

View File

@@ -0,0 +1,412 @@
/*
* $Id: linux.c,v 1.2 2005/10/24 14:39:26 mauriliolongo Exp $
*/
/*
* Harbour Project source code:
* Telepathy emulation library
* C low level module for linux 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)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#define _CLIPDEFS_H
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <sys/ioctl.h>
#include "hbapifs.h"
#include "extend.api"
#include "item.api"
HB_FUNC( P_OPEN ) {
int fd; /* File descriptor for the port */
fd = open( hb_parcx( 1 ), O_RDWR | O_NOCTTY | O_NDELAY );
if (fd != -1) {
fcntl( fd, F_SETFL, 0 );
}
hb_retnl( fd );
}
/*
p_InitPortSpeed( aPorts[ nPort, TPFP_HANDLE ] ,;
aPorts[ nPort, TPFP_BAUD ] ,;
aPorts[ nPort, TPFP_DBITS ] ,;
aPorts[ nPort, TPFP_PARITY ] ,;
aPorts[ nPort, TPFP_SBITS ] )
*/
HB_FUNC( P_INITPORTSPEED ) {
struct termios options;
int port = hb_parnl( 1 );
int baud = B300;
char *ptr = hb_parcx( 4 );
int rc;
tcgetattr( port, &options );
// let's set baud rate
switch ( hb_parnl( 2 ) ) {
case 0:
baud = B0; // Drop line
break;
case 50:
baud = B50;
break;
case 75:
baud = B75;
break;
case 110:
baud = B110;
break;
case 150:
baud = B150;
break;
case 200:
baud = B200;
break;
case 300:
baud = B300;
break;
case 600:
baud = B600;
break;
case 1200:
baud = B1200;
break;
case 1800:
baud = B1800;
break;
case 2400:
baud = B2400;
break;
case 4800:
baud = B4800;
break;
case 9600:
baud = B9600;
break;
case 19200:
baud = B19200;
break;
case 38400:
baud = B38400;
break;
case 57600:
baud = B57600;
break;
case 115200:
baud = B115200;
break;
case 230400:
baud = B230400;
break;
}
cfsetispeed( &options, baud );
cfsetospeed( &options, baud );
// Enable the receiver and set local mode...
options.c_cflag |= ( CLOCAL | CREAD );
// Raw input from device
cfmakeraw( &options );
// Reset data bits ( cfmakeraw() puts it to CS8 )
options.c_cflag &= ~CSIZE;
// Data bits
if ( hb_parni( 3 ) == 8 ) {
options.c_cflag |= CS8;
} else {
options.c_cflag |= CS7;
}
// Stop bits
if ( hb_parni( 5 ) == 1 ) {
options.c_cflag &= ~CSTOPB;
}
// Parity, only No, Even, Odd supported
switch ( *ptr ) {
case 'N':
case 'n':
options.c_cflag &= ~PARENB;
options.c_iflag &= ~(INPCK); /* disable input parity checking */
break;
case 'O':
case 'o':
options.c_cflag |= PARENB;
options.c_cflag |= PARODD;
options.c_iflag |= INPCK;
break;
case 'E':
case 'e':
options.c_cflag |= PARENB;
options.c_cflag &= ~PARODD;
options.c_iflag |= INPCK;
break;
}
// Every read() call returns as soon as a char is available OR after 3 tenths of a second
options.c_cc[ VMIN ] = 0;
options.c_cc[ VTIME ] = 3;
// Set the new options for the port...
rc = tcsetattr( port, TCSAFLUSH, &options );
hb_retnl( rc );
}
HB_FUNC( P_READPORT ) {
char Buffer[512];
int nRead;
nRead = read( hb_parnl( 1 ), Buffer, 512 );
if ( nRead < 0 ) {
hb_retclen( "", 0 );
} else {
hb_retclen( Buffer, nRead );
}
}
HB_FUNC( P_WRITEPORT ) {
long n;
n = write( hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ) );
if ( n < 0 ) {
hb_retnl( -1 );
} else {
hb_retnl( n );
}
}
HB_FUNC( P_DRAIN ) {
hb_retnl( tcdrain( hb_parnl( 1 ) ) );
}
HB_FUNC( P_OUTFREE ) {
/*
APIRET rc;
RXQUEUE rxqueue = { 0 };
if ( ( rc = DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
NULL, 0L, NULL, &rxqueue, sizeof(RXQUEUE), NULL ) ) == NO_ERROR ) {
hb_retnl( rxqueue.cb - rxqueue.cch );
} else {
// Put GetLastError() here, or better a second byref param?
hb_retnl( -1 );
}
*/
}
HB_FUNC( P_ISDCD ) {
int status;
int rc;
rc = ioctl( hb_parnl( 1 ), TIOCMGET, &status );
if ( rc == 0 ) {
hb_retl( ( status & TIOCM_CD ) == TIOCM_CD );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_ISRI ) {
int status;
int rc;
rc = ioctl( hb_parnl( 1 ), TIOCMGET, &status );
if ( rc == 0 ) {
hb_retl( ( status & TIOCM_RI ) == TIOCM_RI );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_ISDSR ) {
int status;
int rc;
rc = ioctl( hb_parnl( 1 ), TIOCMGET, &status );
if ( rc == 0 ) {
hb_retl( ( status & TIOCM_DSR ) == TIOCM_DSR );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_ISCTS ) {
int status;
int rc;
rc = ioctl( hb_parnl( 1 ), TIOCMGET, &status );
if ( rc == 0 ) {
hb_retl( ( status & TIOCM_CTS ) == TIOCM_CTS );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_CTRLCTS ) {
struct termios options;
int port = hb_parnl( 1 );
int newvalue = hb_pcount() == 2 ? hb_parnl( 2 ) : -1;
int curvalue;
int rc;
tcgetattr( port, &options );
curvalue = ( options.c_cflag & CRTSCTS ) == CRTSCTS;
if ( newvalue == 0 ) {
options.c_cflag &= ~CRTSCTS;
} else {
if ( newvalue == 1 ) {
options.c_cflag |= CRTSCTS;
}
}
if ( newvalue >= 0 ) {
rc = tcsetattr( port, TCSAFLUSH, &options );
}
hb_retni( curvalue ? 1 : 0 );
}

View File

@@ -0,0 +1,278 @@
/*
* $Id: os2.c,v 1.5 2005/10/24 14:39:26 mauriliolongo Exp $
*/
/*
* Harbour Project source code:
* Telepathy emulation library
* C low level module for OS/2 serial communication
*
* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#define _CLIPDEFS_H
#define INCL_BASE
#define INCL_DOS
#define INCL_DOSERROR
#define INCL_DOSDEVIOCTL
#include <os2.h>
#include <stdio.h>
#include "hbapifs.h"
#include "extend.api"
#include "item.api"
HB_FUNC( P_INITPORTSPEED ) {
APIRET rc;
LINECONTROL lctl;
DCBINFO dcb;
USHORT Baud;
char *ptr = hb_parcx(4);
memset( &dcb, 0, sizeof(dcb) );
memset( &lctl, 0, sizeof(lctl) );
Baud = (USHORT) hb_parnl(2);
/* OS/2 has Mark and Space parity options */
switch ( *ptr ) {
case 'N':
case 'n':
lctl.bParity = 0;
break;
case 'O':
case 'o':
lctl.bParity = 1;
break;
case 'E':
case 'e':
lctl.bParity = 2;
break;
case 'M':
case 'm':
lctl.bParity = 3;
break;
case 'S':
case 's':
lctl.bParity = 4;
}
lctl.bDataBits = hb_parnl( 3 );
lctl.bStopBits = hb_parnl( 5 ) == 1 ? 0 : hb_parnl( 5 ); // 1 == 1.5 stop bits only valid with 5 data bits
lctl.fTransBreak = 0;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETBAUDRATE, &Baud,
sizeof(USHORT), NULL, NULL, 0L, NULL) != NO_ERROR ) {
hb_retnl( -1 );
} else {
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETLINECTRL,
&lctl, sizeof(LINECONTROL), NULL, NULL, 0L, NULL) != NO_ERROR ) {
hb_retnl( -2 );
} else {
/* tp_ help says: on port open
DTR ON (value 1)
CTS OFF
DCD IGNORE
DSR OFF
RTS ON (value 1)
XON/XOFF OFF
*/
dcb.fbCtlHndShake = MODE_DTR_HANDSHAKE | MODE_RTS_HANDSHAKE;
/* 0x20 == full duplex */
dcb.fbFlowReplace = MODE_RTS_HANDSHAKE | 0x20;
dcb.fbTimeout = MODE_NO_WRITE_TIMEOUT | MODE_NOWAIT_READ_TIMEOUT;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb,
sizeof(DCBINFO), 0L, NULL, 0L, NULL) == NO_ERROR ) {
hb_retnl( 0 );
} else {
hb_retnl( -3 );
}
}
}
}
HB_FUNC( P_READPORT ) {
char Buffer[512];
ULONG nRead = 0;
APIRET rc;
rc = DosRead( (HFILE) hb_parnl( 1 ), Buffer, 512, &nRead );
if ( rc == NO_ERROR ) {
hb_retclen( Buffer, nRead );
} else {
hb_retclen( "", 0 );
}
}
HB_FUNC( P_WRITEPORT ) {
ULONG nWritten = 0;
APIRET rc;
rc = DosWrite( (HFILE) hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten );
if ( rc == NO_ERROR ) {
hb_retnl( nWritten );
} else {
// Put GetLastError() here, or better a second byref param?
hb_retnl( -1 );
}
}
HB_FUNC( P_OUTFREE ) {
APIRET rc;
RXQUEUE rxqueue = { 0 };
if ( ( rc = DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
NULL, 0L, NULL, &rxqueue, sizeof(RXQUEUE), NULL ) ) == NO_ERROR ) {
hb_retnl( rxqueue.cb - rxqueue.cch );
} else {
// Put GetLastError() here, or better a second byref param?
hb_retnl( -1 );
}
}
HB_FUNC( P_ISDCD ) {
BYTE instat;
/* if DosDevIOCtl() returns an error, return no DCD */
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
hb_retl( ( instat & DCD_ON ) == DCD_ON );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_ISRI ) {
BYTE instat;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
hb_retl( ( instat & RI_ON ) == RI_ON );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_ISDSR ) {
BYTE instat;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
hb_retl( ( instat & DSR_ON ) == DSR_ON );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_ISCTS ) {
BYTE instat;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
hb_retl( ( instat & CTS_ON ) == CTS_ON );
} else {
hb_retl( FALSE );
}
}
HB_FUNC( P_CTRLCTS ) {
hb_retni( 0 );
}

View File

@@ -0,0 +1,135 @@
/*
* $Id: win32.c,v 1.2 2004/08/25 13:43:53 mauriliolongo Exp $
*/
/*
* Harbour Project source code:
* Telepathy emulation library
* C low level module for Win32 serial communication
*
* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#define _CLIPDEFS_H
#include <windows.h>
#include <stdio.h>
#include "hbapifs.h"
#include "extend.api"
#include "item.api"
HB_FUNC( P_INITPORTSPEED ) {
DCB dcb;
char values[20];
FillMemory(&dcb, sizeof(dcb), 0);
dcb.DCBlength = sizeof(dcb);
sprintf(values, "%u,%1s,%1u,%1u", hb_parnl(2), hb_parcx(4), hb_parnl(3), hb_parnl(5));
if ( ! BuildCommDCB(values, &dcb)) {
hb_retnl(-1);
} else {
if ( ! SetCommState( (HANDLE) hb_parnl(1), &dcb) ) {
hb_retnl(-1);
} else {
COMMTIMEOUTS timeouts;
// read/write operations return immediatly
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
if ( SetCommTimeouts( (HANDLE) hb_parnl(1), &timeouts ) ) {
hb_retnl(0);
} else {
hb_retnl(-1);
}
}
}
}
HB_FUNC( P_READPORT ) {
char Buffer[512];
DWORD nRead = 0;
BOOL bRet;
OVERLAPPED Overlapped = {0};
bRet = ReadFile( (HANDLE) hb_parnl( 1 ), Buffer, 512, &nRead, &Overlapped );
if ( bRet ) {
hb_retclen( Buffer, nRead );
} else {
hb_retclen( "", 0 );
}
}
HB_FUNC( P_WRITEPORT ) {
DWORD nWritten = 0;
BOOL bRet;
OVERLAPPED Overlapped = {0};
bRet = WriteFile( (HANDLE) hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten, &Overlapped );
if ( bRet ) {
hb_retnl( nWritten );
} else {
// Put GetLastError() here, or better a second byref param?
hb_retnl( -1 );
}
}

View File

@@ -71,7 +71,7 @@ CREATE CLASS HBDbObject
METHOD New( oObject, cVarName, lEditable )
METHOD addWindows( aArray, nRow )
METHOD doGet( oBrowse, pItem, nSet )
METHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, aArray )
METHOD SetsKeyPressed( nKey, oBrwSets, nSets, oWnd, cName, aArray )
ENDCLASS