Serial Port ActiveX Control Buffer

Discussion forum about all things Team Developer 7.x
lfonda
Italy
Posts: 54
Joined: 13 Apr 2017, 14:40
Location: Italy

Serial Port ActiveX Control Buffer

Post by lfonda » 03 Sep 2019, 16:14

We have to read a buffer from a RS232 port using ActiveX Serial Port programming library from Eltima Software.
Here is how Read ActiveX function is defined:

Code: Select all

Function: Read
	Description:
	Returns
		Boolean:
	Parameters
		Receive Number: Buf
			!
		Receive Number: Count
			!
		Receive Number: returnValue
			!
	Static Variables
	Local variables
		Boolean: tmpret
	Actions
		Call __ObjectPushNumberByRef(Buf, VT_UI1)
		Call __ObjectPushNumberByRef(Count, VT_I4)
		Set tmpret = __ObjectInvoke("Read", INVOKE_FUNCTION)
		Call __ObjectPopNumber(-1, returnValue)
		Call PopNumber(0, Buf)
		Call PopNumber(1, Count)
		Call __ObjectFlushArgs()
		Return tmpret
How can I fill a binary in Gupta knowing only its address ?

Thank you
lfonda

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2837
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Serial Port ActiveX Control Buffer

Post by Dave Rabelink » 04 Sep 2019, 06:02

It would be something like this

Code: Select all

! Create a memory buffer with the needed size
Call SalSetBufferLength( sBuffer, nBufferSize )
!
! Copy the data from the memory pointer (address) to the created buffer
Call CStructCopyFromFarMem( nPointer, sBuffer, nBufferSize )
!
! Use CStructGet* functions to read the values from the buffer
Set nByte = CStructGetByte( sBuffer, 0 )		! Get (first) byte from buffer (at position 0)
Set nByte = CStructGetByte( sBuffer, 1 )		! Get (second) byte from buffer  (at position 1)
Set nInteger = CStructGetInt( sBuffer, 2 )		! Get integer from buffer  (at position 2)
etc etc
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

lfonda
Italy
Posts: 54
Joined: 13 Apr 2017, 14:40
Location: Italy

Re: Serial Port ActiveX Control Buffer

Post by lfonda » 04 Sep 2019, 13:29

Thank you very much. We will try with this code.

lfonda

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 1 guest