Jump to content
The simFlight Network Forums

FSUIPC Data to VB then out to Serial port


Recommended Posts

Hello All,

Can someone help me out with this???

What I am trying to do is Get data from FSUIPC (Say Airspeed for example), and read it from a VB program and send that data out to the serial port using a simple VB program. Conversely, I would like to send data in to the serial port (I.E. Rudder position) and have it read by the VB program and have it write to FSUIPC. I can do the hardware interface, but looking fpr some help in coding this using VB. I can program in VB but quiet not sure how to write an I/O sequence to do this. If someone can post a sample listing I would greatly appreciate it.

Thanks

Sean W.

Link to comment
Share on other sites

I have no experience whatso ever with reading and writeing to COM ports but.......

Here is some code I found on PLanet source code that may help...

It has three OCX that need regsvr32 ing but appart from that just open it up and read the code and start communicating with your serial ports.

http://www.planetsourcecode.com/vb/scrigWId=1#zip

If this dosnt work go to planetsourcecode.com and do a search for VB & serial port

Link to comment
Share on other sites

Regarding the serial inteface portion of your question, working with the serial ports can be a painful thing, and you will need a good set of library code to help you. In the past when I've done this, I've always purchased a commercial package, as the are usually more stable, full featured, good docs and good example programs. There is quite a good selection out there, and most are not that expensive.

If you choose a library that is not stable and tested, you will spend time trying to understand if the problem you are having is your code, the library code, the serial port, the O/S, etc.

Link to comment
Share on other sites

Hi,

Using serial ports with Windows can be a pain in the comm port for sure.

I've been working on a Java SDK for FSUIPC which will be released soon(ish). COM port access under java is actually quite simple.

I've been using Java via FSUIPC to talk via a serial port to some hardware (PIC chip) that I've made. It all works very smoothly.

Just a thought.

Cheers

Mark

Link to comment
Share on other sites

Fisrt let me explain that I know as much about java as about chickens. Just want to ask something with that kind of interface it will be possible to make applets that allow to control and display FS status in a browser?

Can you elaborate a litle bit more about the new possibilities.

Thanks

José

Link to comment
Share on other sites

I think chickens are probably more complex than Java.

I prefer Java to VB for several reasons. The main being it's power and included libraries - you want for nothing. And of course it free. All you need is the Java SDK and a text editor - no fancy IDE required.

There are 2 ways to run a Java app. One is as an applet and use a browser as the user interface host.

The apps I've written at the moment (working on an auto pilot) are stand alone apps with a very simple UI. In fact a lot of the tests I've been performing don't have a UI at all and just print stuff to the command prompt - I don't know if you can even do this in VB.

As I mentioned before I've also been using the serial port to talk to some custom hardware I built. The Java comm library is very simple to use and takes care of all platform differences (Win98,Nt, Xp, etc).

Another nice feature of Java is the language supports multiple threads (a bit advanced if you are used to this) which is perfect for listening and talking to my hardware while at the same time talking and listening to FS.

The Java FSUIPC SDK will be available some time after FS2004 is released.

Cheers

Mark

Link to comment
Share on other sites

Thanks everyone for their help.

Mark, I have not programmed with Java before. Only VB and some assembly. Is it possible that you could post a small routine in java that shows how to extract data from FSUIPC and send it out to a com port and tpo read data from a com port and send it out to FSUIPC to be passed on to FS.

Thanks again for all your help.

PETE, Great job and keep-up the good work. I for one be willing to pay for the next version of FSUIPC.

Sean W

Link to comment
Share on other sites

Hi,

Using the Java SDK I developed for FSUIPC reading can be done at various levels.

i) direct with fsuipc offset:

byte[] data = new byte[8];

fsuipc_wrapper.ReadData(0x0560,8,data);

ii) at a higer level:

getLong(0x0560);

iii) or even higher level:

FSAircraft air = new FSAircraft();

double latitude = air.Latitude();

It's my plan to wrap all the FSUIPC offsets into logical classes, so to provide a friendlier API.

In the simplest form sending data via a com port in Java is just a mater of calling:

OutputStream = SerialPort.getOutputStream();

OutputStream.write(data);

Reading is similar. My code is a bit more complex because I use threads. This makes the programme flow a bit simpler.

Cheers

Mark

Link to comment
Share on other sites

  • 4 weeks later...

Hi all,

If I understand the question correctly then the solution to your problem is real easyVB comes with a control specifically designed for this stuff. It is called MSComm32.ocx and uses a number of very basic properties and methods to read and write data to the COM ports. I've used it many times for all kinds of applications and it's really easy to use !

Look in the Components list and you'll find it there.

Kind regards,

Björn

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.