3rd:RS232

From wiki.visual-prolog.com

Revision as of 22:39, 5 February 2008 by Thomas Linder Puls (talk | contribs) (Signed)

In this program you find packages for communicating via the RS232-interface of a computer. There is a native-class for the external predicates and an api-class for the glue code. These two classes are the heart of the program.

Every port is seen as an object. So there is a serialport_class for interfacing. In that way it should be possible to use more ports at the same time.

To make RS232-communication possible between Visual Prolog and a microcontroller was the reason for building the program. The hardware demands are very small: pin two, three and ground is all that is needed. This means also that not all external predicates are present.

I had to use Kernel32.Lib which can be found in the Platform SDK from Microsoft. Distributing this library is not possible here. You have to get to the Microsoft-site for downloading the SDK, in case you do not have it already.

Furthermore, you have to use the commercial edition of VIP because the program uses multi-threading. That was unavoidable.

The program has been developed under Windows XP sp2 and I used the latest edition of VIP: version 7103. The library I use was downloaded two years ago. Very recently I tested the compiled program on a laptop under Vista with an USB to serial converter. I had no problems there so far.

Using the packages, I wrote this test program for inspecting the RS232-communication at a very basic level. It reads out the buffer of a port at your command and you can send a byte sequence over the line. You should read the help file to discover how to do these things.

There is no protocol; just a byte sequence. If you should decide to use the packages then you might have to develop a protocol yourself.

Programming the RS232 port is not easy. I am afraid; you have to spit through the code to see how the predicates are used. At essential points, I made a short comment, especially in the user interface part, to make your live a little easier. I think you should start there. Then there are two examples, where you can see how events are handled.

If you want to give the program a try before downloading a library and so on, you can download the compiled program here: http://www.xs4all.nl/~hooijeb/index.html.

If you use two computers and a null modem cable, you are in business.

And if you have a robot, talking VIP to him is fun!

Contributed by Ben Hooijenga

Download the software