BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

External control available?

2 posters

Go down

External control available? Empty External control available?

Post by ghenghis Thu Jan 20, 2022 9:21 am

Hey All,

Some time ago I managed to make a diy loco controller for OpenRails, as there is a web server providing train data, so it was possible to output data to an arduino controller. Is it possible to get the live train/sim data from a running openbve instance, through a similar web/api/etc means?

ghenghis

Posts : 5
Join date : 2018-09-25

Back to top Go down

External control available? Empty Re: External control available?

Post by leezer3 Thu Jan 27, 2022 3:49 pm

Most of what you want in an API should be there already- Look into creating an ITrainInputDevice plugin, although this will require you to know a little C#

https://github.com/leezer3/OpenBVE/blob/master/source/OpenBveApi/Interface/Input/InputDevice.cs#L105

For an existing example, look at the included DenshaDeGo! Input or SSanYingInput plugins in the main sim source.
Not tried specifically with an Arduino, but should be easy enough.

leezer3

Posts : 1957
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

External control available? Empty Re: External control available?

Post by ghenghis Fri Jan 28, 2022 9:10 pm

Thanks, this looks like an entry point to the puzzle. However, how about -output-, e.g - display train speed?

ghenghis

Posts : 5
Join date : 2018-09-25

Back to top Go down

External control available? Empty Re: External control available?

Post by leezer3 Sat Jan 29, 2022 8:59 am

You're running what's essentially arbitrary code within the plugin.

Just import whatever library you need to communicate with your Arduino.
Something like this for example: https://create.arduino.cc/projecthub/haoming-weng/c-arduino-gui-to-control-the-led-0877f8

leezer3

Posts : 1957
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

External control available? Empty Re: External control available?

Post by ghenghis Sat Jan 29, 2022 11:43 am

Well that cleared things up. Besides C# part, as I'm a python guy.External control available? 1f605 But that means that this is doable, I just need to become a C# expert over the weekend.

ghenghis

Posts : 5
Join date : 2018-09-25

Back to top Go down

External control available? Empty Re: External control available?

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum