Serial Port ActiveX: Sending Binary Data (VBScript)(Read 17308 times)
Serial Port ActiveX: Sending Binary Data (VBScript) on: April 11, 2008, 05:04:04 AM
The was a thread already, started for JavaScript problems. It did not provide any answers though.
Thus, it is still unclear how to send binary data using the control from VBScript too.

1. Use WriteStr()
  I can create a string which has \x00 character, let's say in the second position, i.e. str = "a" & Chr(0) & "b".
  Len(str) reports 3.
  SPortX.WriteStr(str) returns 1, as if it stops at the first 0 char. No good.

2. Use WriteVariant()
  Create an array like this:
  a = Array(CByte(&H01), CByte(&H00), CByte(&H03))
  SPortX.WriteVariant(a) returns 0. No good.

Could you please post an example on how is it possible to send a string with 0 char or an array of bytes with this ActiveX control using VBScript?

Your response would be greatly appreciated. Thank you.

Re: Serial Port ActiveX: Sending Binary Data (VBScript) Reply #1 on: April 11, 2008, 06:01:50 PM
Please be informed, that we released new build of Serial Port ActiveX Control. It was silent build which is available already.

To download the new build,please go to:

We will be eagerly waiting the test results from you.

Re: Serial Port ActiveX: Sending Binary Data (VBScript) Reply #2 on: April 12, 2008, 04:20:48 AM
Unfortunately, the new version does not show any improvements at all.
The behavior is exactly the same.
What type exactly do you expect in SPortX.WriteVariant()?
Why sending neither VBArray|VBVariant nor VBArray|VBByte are recognized?
The manual is very poor and not helpful.

Re: Serial Port ActiveX: Sending Binary Data (VBScript) Reply #3 on: April 14, 2008, 03:07:24 PM
We don't have enough information to be sure but the code below is correct:

                SPortX.Parity = 0
                SPortX.StopBits = 0
                SPortX.BaudRate = 9600

                Dim b
Dim Buff
'Buff = Array(CByte(&H01), CByte(&H02), CByte(&H03))
Buff = Array(CByte(1), CByte(0), CByte(0))
b = SportX.WriteVariant(Buff)
'b = SportX.Write(CByte(0),1)

                MsgBox b

Please, be informed that in SPortX.WriteVariant() we expect the data in VT_ARRAY | VT_VARIANT (VT_UI1) or VT_BYREF | VT_VARIANT (VT_ARRAY | VT_VARIANT (VT_UI1))


Sitemap 1 2 3 4 5