Permalink
Browse files

readme

  • Loading branch information...
gagagu committed Apr 20, 2015
1 parent 2f4abea commit 6160ea0ca9609aa3cf350f97324053094d02fef8
Showing with 65 additions and 0 deletions.
  1. +65 −0 README.md
View
@@ -0,0 +1,65 @@
# XPLMDataAccess
X-Plane offers the possibility to create own plugins, unfortunately, only in ANSI c, a computer language I’m not really good in (pointers makes me crazy). As an alternative I would like to use c#. However, I have to find out this is not possible so simply. My plan was to connect other Devices to X-Plane over UDP Network. But it was not possible for my purposes. There are two reasons:
1) The datarefs of the x737 from eadt team are not published over the interface (may be my error, I don't know)
2) You can only connect one device to the UDP Interface of X-Plane
The reason, why I need this I don't want to say yet. I will make a post on right time.
Well. In search of more information about X-Plane and programming in c# I found the following side:
https://github.com/delacruz/XplaneRestApi/wiki
Jason de la Cruz wrote a plugin to access the XPLMDataAccess API from X-Plane over a REST Webserver. The plugin is written in ANSI c and the Rest Webserver is written in c#. First the solution seems resolve all my problems. After closer consideration I still found some little things I have to change. So I’ve done a complete rewrite of the code and split the API from webserver.
At this point I would like to thank Jason de la Cruz for the excellent work and publication. With pleasure I would like to step with him in contact to discuss my changes, however, I couldn't find out any contact dates. Because the code was published on github hopefully my release is ok for him.
Now, I’ve created a .Net Library (DLL) in combination with an .xpl plugin for X-Plane. The library offers the possibility to access all methods of the XPLMDataAccess API from a .Net application. The communication between both takes place about shared memory.
##Installation
1) Extract XPLMDataAccess_{version}.zip
2) Copy the folder "DotNetDataRefConnector" into the x-plane folder {X-PLANE}/Resources/plugins/ Please copy the folder not only the content.
3) Put the DotNetDataRefConnector.dll into your reference of your visual studio project.
4) Do not forget the using or imports statement:
c#:
using DotNetDataRefConnector;
VB.net:
Imports DotNetDataRefConnector
##Using the library
(c#)
// define connection
DotNetDataRefConnector.XPLMDataAccess da = new DotNetDataRefConnector.XPLMDataAccess();
// open connection
da.Open();
// get reference of DataRef
UInt32 res = da.XPLMFindDataRef(tbDataRef.Text);
// show result
this.textBox1.Text = res.ToString();
// close connection
da.Close();
Use for your own own risk!
For more information check the demo app.
## Licensing
MIT

7 comments on commit 6160ea0

@roarkr

This comment has been minimized.

Show comment
Hide comment
@roarkr

roarkr Dec 5, 2016

Hi,

I am about to make a X-Plane plugin and found your fine XPLMDataAccess source code. I have played a little with it and found out that it works fine for reading and writing datarefs.

My question to you is what do I need to modify it so it also can find and execute commands (both default and custom commands).

The lines below shows some info about the extra XPLMcommands I need to implement in your code to be able to

// First, get a reference to the command. This is an expensive operation that you
// only want to do once, probably when your plugin is initialized.
command_ref = XPLMFindCommand("sim/your/command/name");

// Check to make sure the commandref exists (and we have a valid reference to it)
if(NULL == command_ref) {
//This command ref doesn't exist, we have a problem
}

//Now you can execute the command like this:
XPLMCommandOnce(command_ref);

    //See also XPLMCommandBegin() and  XPLMCommandEnd()

rgs,

Roar Kristensen

roarkr replied Dec 5, 2016

Hi,

I am about to make a X-Plane plugin and found your fine XPLMDataAccess source code. I have played a little with it and found out that it works fine for reading and writing datarefs.

My question to you is what do I need to modify it so it also can find and execute commands (both default and custom commands).

The lines below shows some info about the extra XPLMcommands I need to implement in your code to be able to

// First, get a reference to the command. This is an expensive operation that you
// only want to do once, probably when your plugin is initialized.
command_ref = XPLMFindCommand("sim/your/command/name");

// Check to make sure the commandref exists (and we have a valid reference to it)
if(NULL == command_ref) {
//This command ref doesn't exist, we have a problem
}

//Now you can execute the command like this:
XPLMCommandOnce(command_ref);

    //See also XPLMCommandBegin() and  XPLMCommandEnd()

rgs,

Roar Kristensen

@roarkr

This comment has been minimized.

Show comment
Hide comment
@roarkr

roarkr Dec 6, 2016

Hi,

To simplify my question:

How do I implement :

XPLMFindCommand
XPLMCommandOnce
XPLMCommandBegin
XPLMCommandEnd

to you source code
?

roarkr replied Dec 6, 2016

Hi,

To simplify my question:

How do I implement :

XPLMFindCommand
XPLMCommandOnce
XPLMCommandBegin
XPLMCommandEnd

to you source code
?

@gagagu

This comment has been minimized.

Show comment
Hide comment
@gagagu

gagagu Dec 6, 2016

Owner

Hi, i have not used the code for a long time so i don't know atm how to do ist. I am too long out of this project. Please give me some time to look into the code, but i sm very busy at work atm. It will need some time.

Owner

gagagu replied Dec 6, 2016

Hi, i have not used the code for a long time so i don't know atm how to do ist. I am too long out of this project. Please give me some time to look into the code, but i sm very busy at work atm. It will need some time.

@roarkr

This comment has been minimized.

Show comment
Hide comment
@roarkr

roarkr Dec 8, 2016

Hi, I have now been able to modify your code so can send all XPLMCommands to X-Plane. I still have some testing to do, to check that X-Plane really accept these commands and give expected results.

roarkr replied Dec 8, 2016

Hi, I have now been able to modify your code so can send all XPLMCommands to X-Plane. I still have some testing to do, to check that X-Plane really accept these commands and give expected results.

@roarkr

This comment has been minimized.

Show comment
Hide comment
@roarkr

roarkr Dec 11, 2016

Hi,

Here is a download link to a modified XPLMDataAccess.

https://1drv.ms/u/s!AjRjRKdTF9fGibd6u26-r3P6ymJXZg

The mod was done in Visual Studio 2015 and the SDK references are changed to my setup. I have made modification so the following commands are implemented:
XPLMFindCommand
XPLMCommandOnce
XPLMCommandBegin
XPLMCommandEnd

During testing XPLMFindCommand work OK, but XPLMCommnadOnce gives a crash and fault message by X-Plane. Debugging looks OK to me, it just when the XPLMCommnadOnce is sent that the crash occurs.

I have implemeted XPLMCommandOnce and using the same commnadRef in another plugin and it works OK, but not in the modified XPLMDataAccess. So I know that I am using a correct commandRef.

I do not know if I have to make any changes to some .net stuff.

Do you have any ideas of why it is not work.

roarkr replied Dec 11, 2016

Hi,

Here is a download link to a modified XPLMDataAccess.

https://1drv.ms/u/s!AjRjRKdTF9fGibd6u26-r3P6ymJXZg

The mod was done in Visual Studio 2015 and the SDK references are changed to my setup. I have made modification so the following commands are implemented:
XPLMFindCommand
XPLMCommandOnce
XPLMCommandBegin
XPLMCommandEnd

During testing XPLMFindCommand work OK, but XPLMCommnadOnce gives a crash and fault message by X-Plane. Debugging looks OK to me, it just when the XPLMCommnadOnce is sent that the crash occurs.

I have implemeted XPLMCommandOnce and using the same commnadRef in another plugin and it works OK, but not in the modified XPLMDataAccess. So I know that I am using a correct commandRef.

I do not know if I have to make any changes to some .net stuff.

Do you have any ideas of why it is not work.

@roarkr

This comment has been minimized.

Show comment
Hide comment
@roarkr

roarkr Dec 13, 2016

Do you remember if you ever tested this program in a X-Plane 64 bit version?

roarkr replied Dec 13, 2016

Do you remember if you ever tested this program in a X-Plane 64 bit version?

@roarkr

This comment has been minimized.

Show comment
Hide comment
@roarkr

roarkr Dec 19, 2016

Hi,

No need for help anymore. I have changed most of your code lines to fit in my projects.

roarkr replied Dec 19, 2016

Hi,

No need for help anymore. I have changed most of your code lines to fit in my projects.

Please sign in to comment.