GXDN: Gurux Developer Network
GuruxTerminal component
The Gurux software products are based on the Microsoft COM technology, and designed to be Automation (formerly OLE Automation) compatible. This means that the Gurux components can be used with all automation compatible languages, including scripting languages supported by Microsoft Scripting Technologies.

To support the scripting languages, VARIANT data type often has to be used as parameter type. For C++ programmers the use of VARIANT data type does not hide the intended format of the data, but for Visual Basic and C# programmers the format of the data may not be as obvious. In the C# environment, the VARIANT data type is shown as Object.

Since the VARIANT data type can represent almost any kind of data, you often have to explicitly set the data type as a parameter. This is particularly important, when using data sending methods, for example the SendSync method. The first parameter of the SendSync method is the data to be sent.

In Visual Basic, the SendSync method can be used as follows:
Dim dataToSend
dataToSend = 123
GXMedia1.SendSync(dataToSend, ... )

There is no way of knowing, what type of data the programmer is actually
intending to use. The number 123 can be a byte, a word, an integer or
some other data type describing integer numbers.

At the lowest level, the communication is sending and receiving byte arrays.
If the exact size of the parameter is not known, the wrong size of the
byte buffer may be allocated, resulting a data packet that is not understood
by the receiving device.

To ensure using right data types, Visual Basic programmers
should use type conversion functions:
If the intended data type, in the previous example, is a byte, the correct format would then be:
Dim dataToSend
dataToSend = 123
GXMedia1.SendSync(CByte(dataToSend), ... )

Note: If type conversion functions are not used, the Gurux products handle the variable as a string. In the following example data is send as "123", not as a number 123.
Dim dataToSend
dataToSend = 123
GXMedia1.SendSync(dataToSend, ... )
'SendSync-method sends data as Hex 0x31 0x32 0x33

In C# language, the object data type is the base class of every class, including standard data types. If a parameter is specified in the right format, it will automatically be in the right format for methods that are defined to use the object type.

Note: As a programmer, you should also be aware of the size differences of some data types, between C# and C++. If basic VARIANT type is used in C++, the data type has to be explicitly set, since the VARIANT type is only a struct, with union of data type flag, and different data type members.

There are also a number of VARIANT wrapper classes, such as CComVariant. The wrapper classes are designed to help the use of VARIANT data type. If you use such a class, ensure that the data is set to the correct format. VARIANT wrapper classes usually contain methods to change the data type.
Send | SendSync