Page 1 of 1
Serial Communications
Posted: Mon Nov 03, 2008 5:01 pm
by PeterHarmes
Hi,
In our 16bit app we used to use a function that returned a numeric handle
when we initiated a serial port - we now use init_port (xHarbour function) that returns a pointer value of the handle rather than a numeric value. We need a numeric handle for the port to use the fivewin function EnableCommNotification().
Is there any way to get the numeric handle from the pointer value?
I know this is probably a xHarbour question, I have posted this in the xHarbour forum, but havent recieved a response yet and wondered if anyone else has had a similar problem.
Thanks in advance
Pete
Posted: Mon Nov 03, 2008 8:45 pm
by Antonio Linares
Pete,
Please try this function, where x is your "pointer" value:
Code: Select all | Expand
MsgInfo( PointerValue( x ) )
...
#pragma BEGINDUMP
#include <hbapi.h>
HB_FUNC( POINTERVALUE )
{
hb_retnl( ( long ) hb_parptr( 1 ) );
}
#pragma ENDDUMP
Posted: Tue Nov 04, 2008 9:19 am
by PeterHarmes
Thanks Antonio,
I have tested this on my machine and it now returns a numeric handle - i havent got a device attached to my pc at the moment and wont be able to test this fully untill i get to my clients site - i did notice that the value returned is a high number when i was expecting a 0 as no device was present - is this correct?
Pete
Posted: Tue Nov 04, 2008 9:32 am
by Antonio Linares
Peter,
> i did notice that the value returned is a high number when i was expecting a 0 as no device was present - is this correct?
I can't tell you for sure as we have never used init_port().
FWH comm functions work fine, so we use and recommend them

Posted: Thu Nov 06, 2008 12:55 pm
by PeterHarmes
Thanks for the response Antonio,
I'm at my clients site next week, so i might be able to do some tests then. Is there any examples of sending and reading of strings sent to/from a serial device using FWH functions available? I'm also currently using FWH v7.12 so are there any enhancements/fixes to any of the serial routines since then i should be aware of?
Pete
Posted: Thu Nov 06, 2008 1:27 pm
by Antonio Linares
Pete,
yes, please review FWH\samples\TestComm.prg, TestCom1.prg, TestCom2.prg and phone.prg
Comm functions have not been modified since your FWH build
Posted: Tue Nov 11, 2008 1:44 pm
by PeterHarmes
Antonio,
I'm currently at a customers site and doing some tests using fivewin functions, however whenever i try to use the function escapecomm to set rts i get an unresolved external when i compile - i'm currently using FWH 7.12 and can't upgrade at the moment untill i get back in the office - is there a way of linking this function in or an alternative way of setting rts?
Thanks
Pete
Posted: Tue Nov 11, 2008 2:34 pm
by PeterHarmes
Ignore previous post -i found that it should be escapecommfunctions