I'm developing an application using Visual Studio (C#).
My interface has to send a structure to the server (written using ansi C but not by me and I can't modify it) running on Unix-like OS (vxWorks).
The structure contains integers, enums, long, double, char and structures data.
How can I send this structure from C# to C?
Searching on Google I found something called "serialization" but I didn't understand how to use it correctly on visual c # and, least of all, on ansi c (Unix-like).
Thanks.
C Structure declared in Unix-like OS (vxWorks):
enum TYPE_OP
{
START_INITIALIZE = 0,
STOP_INITIALIZE = 1,
IDENTIFY = 2,
GET_VALUE = 3,
SET_VALUE = 4,
SET_RSE_MODE = 5,
GET_VALUE_DOUBLE = 6,
SET_VALUE_DOUBLE = 7,
SET_STRING = 8,
GET_VALUE_FLOAT = 9,
SET_VALUE_FLOAT = 10,
SET_TARGET = 11,
GET_TARGET = 12,
GET_TASK_STATUS = 13
};
typedef struct
{
long addr; //address of an element in GPIB chain (ex. 1, 13, etc.)
long value; //number (ex. enumerative position)
double dvalue; //a double number
} DESCR_DATA;
struct VAR_DATA
{
int len ;
enum TYPE_OP type;
char name[100]; //Name of the element in GPIB chain
DESCR_DATA data;
};
C# structure declared in Windows:
public enum TYPE_OP
{
START_INITIALIZE = 0,
STOP_INITIALIZE = 1,
IDENTIFY = 2,
GET_VALUE = 3,
SET_VALUE = 4,
SET_RSE_MODE = 5,
GET_VALUE_DOUBLE = 6,
SET_VALUE_DOUBLE = 7,
SET_STRING = 8,
GET_VALUE_FLOAT = 9,
SET_VALUE_FLOAT = 10,
SET_TARGET = 11,
GET_TARGET = 12,
GET_TASK_STATUS = 13
}
public struct DESCR_DATA
{
public long addr;
public long value;
public double dvalue;
}
public struct VAR_DATA
{
public int len;
public TYPE_OP type;
public string name;
public DESCR_DATA data;
}
VAR_DATA vardata = new VAR_DATA();