AnsweredAssumed Answered

vrf Modbus (again...)

Question asked by VRFuser on Apr 23, 2006
Hi all,

Update on Modbus:

I was checking some other software to use the modbus driver, and I found
this program I could use it with VBScript,
but was not able to access the registers, more or less the same problem
with VEE. The author of DM2003 send me the following reply: (in summary,
most probably mbserver will not be usable in VEE without modifying and

When you obtain data using following statement

MBServer.ReadOutputRegisters 1,0,3,Regs

Regs variable become an array of integers, while VBScript
supports only array of variants. Take a look at this code
(ModbusServerModbusSrv.cpp from

STDMETHODIMP CModbusSrv::ReadInputRegisters(short Addr, long DataStart,
short Quantity, VARIANT * vRegValues, VARIANT vVarType, VARIANT
vRealType, long * plRetVal)
COleVariantEx vDataType(vVarType);
if (vDataType.IsMissing()){
else {
   if ((vDataType.ToInt()>=VT_I2) && (vDataType.ToInt()<=VT_R8)){
   else {
switch (vtDest) {
case VT_I2:

As one can conclude, even vVarType=vbVariant has no result because
appropriate case is filtered (VT_I2=2, VT_R8=5, vt_variant=12).

However, things are not so bad in this case. DM2003 can successfully
process such arrays because when you invoke DM2003 methods, variant
array is converted in the Delphi code. So that, if you record data
to the DM2003 worksheet, you can immediately read the last item to
obtain current readout as shown below:

sub ReadMBServer
dim Regs, Cont
MBServer.ReadOutputRegisters 1,0,3,Regs
set Cont=Server.ActiveDocument.Container
Cont.AddItem Regs
' ^ now Regs is correct VBScript array!
if Running then SetTimeOut "ReadMBServer", 1000
end sub

Another workaround is just to create separate Visual Basic application
(exe or ocx) instead of HTML scriptlet. DM2003 may be launched and its
objects may be accessed from "true" VB as well; moreover, this is one of
most commonly used scenarios.

One could also consider parsing "raw" MODBUS data packages by script in
the same way as I usually do with SCPI commands used by laboratory
measurement instruments. DM2003 includes TCP client socket, and I plan
some experiments in this direction.

And my last suggestion at the moment: since we have source code of
MBServer, I could try to modify and recompile it so it will be
compatible with VBScript environment.


You are currently subscribed to vrf as:
To subscribe please send an email to: "" with the word subscribe in the message body.
To unsubscribe send a blank email to "".
To send messages to this mailing list,  email "". 
If you need help with the mailing list send a message to
Search the "unofficial vrf archive" at "".