Hi all,
I am just starting to experiment with the c# sdk and as a result have written a little console app to experiment with the sdk.
I am able to initialise, open and close the fusipc instance. But a read on airspeed always returns 0.
The fsuipc (f in the code) is the supplied class with the SDK. I should point out this is dotNet 2.
Code Below,
Many Thanks in advance
Simon
--- Code ---
using System;
using System.Collections.Generic;
using System.Text;
using FsuipcSdk;
namespace FSUIPC_testing {
class Program {
static Fsuipc f = new Fsuipc();
static bool result = false;
static bool stop = false;
static int fsVersion = 0;
static int fsuResult = -1;
static int offAirspeed = 0x02BC;
static int size4 = 4;
static int token = -1;
static string TranslateResultCode(int code) {
string message = string.Empty;
switch (code) {
case Fsuipc.FSUIPC_ERR_OK:
message = "FSUIPC_ERR_OK";
break;
case Fsuipc.FSUIPC_ERR_OPEN:
message = "Already Open";
break;
case Fsuipc.FSUIPC_ERR_NOFS:
message = "FSUIPC_ERR_NOFS";
break;
case Fsuipc.FSUIPC_ERR_REGMSG:
message = "FSUIPC_ERR_REGMSG";
break;
case Fsuipc.FSUIPC_ERR_ATOM:
message = "FSUIPC_ERR_ATOM";
break;
case Fsuipc.FSUIPC_ERR_MAP:
message = "FSUIPC_ERR_MAP";
break;
case Fsuipc.FSUIPC_ERR_VIEW:
message = "FSUIPC_ERR_VIEW";
break;
case Fsuipc.FSUIPC_ERR_VERSION:
message = "FSUIPC_ERR_VERSION";
break;
case Fsuipc.FSUIPC_ERR_WRONGFS:
message = "FSUIPC_ERR_WRONGFS";
break;
case Fsuipc.FSUIPC_ERR_NOTOPEN:
message = "FSUIPC_ERR_NOTOPEN";
break;
case Fsuipc.FSUIPC_ERR_NODATA:
message = "FSUIPC_ERR_NODATA";
break;
case Fsuipc.FSUIPC_ERR_TIMEOUT:
message = "FSUIPC_ERR_TIMEOUT";
break;
case Fsuipc.FSUIPC_ERR_SENDMSG:
message = "FSUIPC_ERR_SENDMSG";
break;
case Fsuipc.FSUIPC_ERR_DATA:
message = "FSUIPC_ERR_DATA";
break;
case Fsuipc.FSUIPC_ERR_RUNNING:
message = "FSUIPC_ERR_RUNNING";
break;
case Fsuipc.FSUIPC_ERR_SIZE:
message = "FSUIPC_ERR_SIZE";
break;
case Fsuipc.FSUIPC_ERR_BUFOVERFLOW:
message = "FSUIPC_ERR_BUFOVERFLOW";
break;
default:
message = code.ToString();
break;
}
return message;
}
static void Main(string[] args) {
bool exit = false;
string command = string.Empty;
while (!exit) {
command = Console.ReadLine();
switch (command) {
case "init":
Console.WriteLine(Init());
break;
case "open":
Console.WriteLine(Open());
break;
case "close":
Console.WriteLine(Close());
break;
case "airspeed":
Console.WriteLine(GetAirspeed());
break;
case "exit":
exit = true;
break;
default:
Console.WriteLine("-- Bad Command : " + command);
break;
}
}
}
static private string Init() {
f.FSUIPC_Initialization();
return "-- Initialised";
}
static private string Open() {
result = f.FSUIPC_Open(fsVersion, ref fsuResult);
if (result) {
return "-- Open";
} else {
string msg = "-- Not Open: " + TranslateResultCode(fsuResult);
return msg;
}
}
static private string Close() {
f.FSUIPC_Close();
return "-- Closed";
}
static private string GetAirspeed() {
string msg = string.Empty;
result = f.FSUIPC_Read(offAirspeed, size4, ref token, ref fsuResult);
if (result) {
msg = "a/s read; ";
} else {
msg += "-- Error: " + TranslateResultCode(fsuResult);
return msg;
}
result = f.FSUIPC_Process(ref fsuResult);
if (result) {
msg += "a/s processed; ";
} else {
msg += "Error: " + TranslateResultCode(fsuResult);
return msg;
}
result = f.FSUIPC_Get(ref token, ref fsuResult);
if (result) {
msg += "a/s got; ";
} else {
msg += "Error: " + TranslateResultCode(fsuResult);
return msg;
}
return msg += "a/s = " + fsuResult * 128;
}
}
}