And are you sending a true array or a string of bytes?
Mark
-----Original Message-----
From: Shawn Fessenden [mailto:shawn@vrfarchive.com]
Sent: Wednesday, June 18, 2008 9:38 AM
To: VRF
Subject: RE: [vrf] WriteByteBuffer arguments
> * The data buffer should be a normal array of bytes as opposed to a
> BSTR
Are you sending UInt8?
-SHAWN-
---
You are currently subscribed to vrf as: Mark.Goldberg@atk.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com"
with the word subscribe in the message body.
To unsubscribe send a blank email to
"leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at
"http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
---
You are currently subscribed to vrf as: ming_meng@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
Mark
-----Original Message-----
From: Shawn Fessenden [mailto:shawn@vrfarchive.com]
Sent: Wednesday, June 18, 2008 9:38 AM
To: VRF
Subject: RE: [vrf] WriteByteBuffer arguments
> * The data buffer should be a normal array of bytes as opposed to a
> BSTR
Are you sending UInt8?
-SHAWN-
---
You are currently subscribed to vrf as: Mark.Goldberg@atk.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com"
with the word subscribe in the message body.
To unsubscribe send a blank email to
"leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at
"http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
---
You are currently subscribed to vrf as: ming_meng@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".
I've got an instrument that has a complicated interface format requirement (MicroStrain accelerometer). Experiments indicate that perhaps the best way to talk to it is by sending a byte buffer pre-loaded with the proper commands. Fortunately, my RS232 port control ActiveX (CommX) has this capability but, unfortunately, I can't seem to make it work. I'm quite sure the problem is in the arguments, probably the first one which is supposed to be a pointer to an array of bytes (error msg = "Type mismatch at argument index 1"). The following is the ActiveX function description and some sample code from the documentation
- can anyone give me some suggestions on how to make this work in Vee?
Thanks,
Barrie
whoi
WriteByteBuffer Description
Writes a buffer to the Tx buffer for the port
Syntax
object.WriteByteBuffer( const unsigned char * buffer, long count long *retval )
Part Description
object Evaluates to a PortCtl object
buffer Pointer to data buffer for writing to the serial port count Number of bytes to write retval Number of bytes actually written
Remarks
· The data buffer should be a normal array of bytes as opposed to a BSTR (as expected by WriteByte(), WriteString(), etc. This is the data type usually used by C++ programs to hold textual data.
· The method will write the number of bytes specified in count
Returns
· Number of bytes transferred to Tx buffer (0 or more)
Errors
· If the port is not open an E_HANDLE exception will be thrown
~~~~~~~~~~~~~~
C++
WriteByteBuffer - C++
long retval;
retval = object.WriteByteBuffer( const unsigned char *buffer, long count ); ~~~~~~~~~~~~~~~ Delphi WriteByteBuffer - Delphi
var
buffer : Array[ count + 1 ] Of Byte;
retval : Integer;
begin
retval := object.WriteByteBuffer( const buffer, count : Integer ) ~~~~~~~~~~~~ Visual Basic The ReadByteBuffer() , ReadByteBufferTimed() , WriteByteBuffer() , and
WriteByteBufferTimed() methods, when used in Visual Basic, require the first argument to be of type byte. These methods are not recommended for use in Visual Basic for lack of a data type to represent char *.
However, if a buffer is declared and space allocated for an array of byte data, they will work . The first argument is of type byte, but the data is passed by reference, thus allowing these methods to be used.
Following is some example code:
Private Sub ReadBuffer_Click()
Dim byte_buffer( 81 ) As Byte
Dim retval As Integer
Dim s1 As String
Dim v1 As Integer
Retval = PortCtl.ReadByteBuffer( byte_buffer(0), 80 )
If retval > 0 Then
For nCount = 0 To retval – 1 Step 1
V1 = byte_buffer( nCount )
If v1 = 0 Then
s1 = s1 + “nul”
Else
s1 = s1 + Chr( v1 )
End If
s1 = s1 + “ “
Next nCount
Else
TextBox.Text = CStr( retval )
End If
End Sub
---
You are currently subscribed to vrf as: ming_meng@agilent.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".