Discussion:
SF.net SVN: harbour-project:[12006] trunk/harbour
vszakats-Rn4VEauK+AKRv+
2009-08-09 14:37:16 UTC
Permalink
Revision: 12006
http://harbour-project.svn.sourceforge.net/harbour-project/?rev=12006&view=rev
Author: vszakats
Date: 2009-08-09 14:37:15 +0000 (Sun, 09 Aug 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
trunk/harbour/ChangeLog
trunk/harbour/contrib/hbtpathy/Makefile
trunk/harbour/contrib/hbtpathy/hbtpathy.hbc
trunk/harbour/contrib/hbtpathy/telepath.prg
trunk/harbour/contrib/hbtpathy/tpcommon.c
trunk/harbour/contrib/hbtpathy/tpos2.c
trunk/harbour/contrib/hbtpathy/tpwin.c
trunk/harbour/contrib/hbwin/win_prt.c

Added Paths:
-----------
trunk/harbour/contrib/hbtpathy/tpunix.c

Removed Paths:
-------------
trunk/harbour/contrib/hbtpathy/tplinux.c


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
maurilio longo
2009-08-10 11:28:00 UTC
Permalink
Viktor,

I think that either tp_crc16() or tp_crc32() had to be reimplemented because the available RTL functions were not compatible with the original (DOS) telepathy ones; CRCs had not the same value.

Do you have the original library and can you test whether CRCs for the same string do match?

Best regards.

Maurilio.
Post by vszakats-Rn4VEauK+AKRv+
Revision: 12006
http://harbour-project.svn.sourceforge.net/harbour-project/?rev=12006&view=rev
Author: vszakats
Date: 2009-08-09 14:37:15 +0000 (Sun, 09 Aug 2009)
-----------
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.
--------------
trunk/harbour/ChangeLog
trunk/harbour/contrib/hbtpathy/Makefile
trunk/harbour/contrib/hbtpathy/hbtpathy.hbc
trunk/harbour/contrib/hbtpathy/telepath.prg
trunk/harbour/contrib/hbtpathy/tpcommon.c
trunk/harbour/contrib/hbtpathy/tpos2.c
trunk/harbour/contrib/hbtpathy/tpwin.c
trunk/harbour/contrib/hbwin/win_prt.c
-----------
trunk/harbour/contrib/hbtpathy/tpunix.c
-------------
trunk/harbour/contrib/hbtpathy/tplinux.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
Viktor Szakáts
2009-08-10 12:01:15 UTC
Permalink
Hi Maurilio,

Yes, the CRC16 is different indeed, but the CRC32 was the same, in
fact (reading the old comments) the CRC32 code was taken from a generic
unicode library, so it's nothing tpathy specific, before deletion
I've verified the code table and formula to be the same as in core.

I've now checked original Telepath(y) libs and it uses "std" CRC32
code with the same precalculated table. It's uses it for ZMODEM which
needs std CRC32.

Actually the correct name for CRC16 included in Telepath(y) lib should
be CRC16-CCITT (or CRC-CCITT, or CRC16 X.25), which is a variation of
CRC16 using different polynomial. It's used in XMODEM protocol.

There is an HB_CRC() function in core which is supposed to be
compatible with it, but I cannot get the same result.

---
? HB_CRC( "hello world" ) // -> 44550
? HB_CRCCT( "hello world" ) // -> 15332
? HB_CRC16( "hello world" ) // -> 8760
? TP_CRC16( "hello world" ) // -> 58427
? "Clipper original", 58427
---

Brgds,
Viktor
Post by maurilio longo
Viktor,
I think that either tp_crc16() or tp_crc32() had to be reimplemented
because the available RTL functions were not compatible with the
original (DOS) telepathy ones; CRCs had not the same value.
Do you have the original library and can you test whether CRCs for
the same string do match?
Best regards.
Maurilio.
Post by vszakats-Rn4VEauK+AKRv+
Revision: 12006
http://harbour-project.svn.sourceforge.net/harbour-project/?rev=12006&view=rev
Author: vszakats
Date: 2009-08-09 14:37:15 +0000 (Sun, 09 Aug 2009)
-----------
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.
--------------
trunk/harbour/ChangeLog
trunk/harbour/contrib/hbtpathy/Makefile
trunk/harbour/contrib/hbtpathy/hbtpathy.hbc
trunk/harbour/contrib/hbtpathy/telepath.prg
trunk/harbour/contrib/hbtpathy/tpcommon.c
trunk/harbour/contrib/hbtpathy/tpos2.c
trunk/harbour/contrib/hbtpathy/tpwin.c
trunk/harbour/contrib/hbwin/win_prt.c
-----------
trunk/harbour/contrib/hbtpathy/tpunix.c
-------------
trunk/harbour/contrib/hbtpathy/tplinux.c
This was sent by the SourceForge.net collaborative development
platform, the world's largest Open Source development site.
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
Przemyslaw Czerpak
2009-08-10 20:24:50 UTC
Permalink
On Mon, 10 Aug 2009, Szak�ts Viktor wrote:

Hi,
Post by Viktor Szakáts
Yes, the CRC16 is different indeed, but the CRC32 was the same, in
fact (reading the old comments) the CRC32 code was taken from a generic
unicode library, so it's nothing tpathy specific, before deletion
I've verified the code table and formula to be the same as in core.
Any CRC tables can be easy generated using generic hb_crc() and hb_crcct()
functions I added to hbrtl, i.e. this code generates CRC tables for
HB_CRC32(), HB_CRC16() and TP_CRC16():

proc main()
local i, n
set alternate to crctabs.c
set alternate on
? "static const ULONG crc32_tab[ 256 ] = {"
for i := 0 to 255
if i % 5 == 0
? " "
endif
n := hb_bitxor( hb_crc( chr( i ), 0xFFFFFFFF, 0x104C11DB7 ), ;
0xFFFFFFFF )
?? " 0x" + hb_numtohex( n, 8 ) + "L" + iif( i < 255, ",", "" )
next
? "};"
?
? "static const ULONG crc16_tab[] ="
for i := 0 to 255
if i % 8 == 0
? " "
endif
n := hb_bitxor( hb_crc( chr( i ), 0xFFFF, 0x18005 ), 0xFFFF )
?? " 0x" + hb_numtohex( n, 4 ) + iif( i < 255, ",", "" )
next
? "};"
?
? "static const ULONG crctp16_tab[] ="
for i := 0 to 255
if i % 8 == 0
? " "
endif
n := hb_crcct( chr( i ),, 0x11021 )
?? " 0x" + hb_numtohex( n, 4 ) + iif( i < 255, ",", "" )
next
? "};"
return
Post by Viktor Szakáts
I've now checked original Telepath(y) libs and it uses "std" CRC32
code with the same precalculated table. It's uses it for ZMODEM which
needs std CRC32.
Actually the correct name for CRC16 included in Telepath(y) lib should
be CRC16-CCITT (or CRC-CCITT, or CRC16 X.25), which is a variation of
CRC16 using different polynomial. It's used in XMODEM protocol.
It's not only different polynomial but also a little bit modified
algorithm used to calculate CRC so the results of HB_CRC() and HB_CRCCT()
are not equal even for the same polynomial.
Post by Viktor Szakáts
There is an HB_CRC() function in core which is supposed to be
compatible with it, but I cannot get the same result.
---
? HB_CRC( "hello world" ) // -> 44550
? HB_CRCCT( "hello world" ) // -> 15332
? HB_CRC16( "hello world" ) // -> 8760
? TP_CRC16( "hello world" ) // -> 58427
? "Clipper original", 58427
---
You should use hb_crcct() with default 0x11021 polynomial
( 0x11021 => P(X) = X^16 + X^15 + X^5 + X^0 ) and you should
swap bytes in calculated result, i.e.:

func tp_crc16( s )
local n := hb_crcct( s )
return int( n / 256 ) + int( n % 256 * 256 )

best regards,
Przemek

Loading...