Difference between revisions of "3rd:RS232"

From wiki.visual-prolog.com

(changed link)
 
Line 18: Line 18:
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.  
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://hooijeb.home.xs4all.nl/RS232.html.
If you want to give the program a try before downloading a library and so on, you can download the compiled program here: https://bensprikbord.nl/RS232/RS232.html.


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

Latest revision as of 15:07, 15 December 2019

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.

The last version of the code compiles under the commercial as well as under the personal edition of Vip75

The first program has been developed under Windows XP sp2 but XP is no longer supported. However, the kernel32.lib I use is still the same and works under Windows 7,8 and 8.1. Very recently I tested the compiled program on a laptop with Windows 8.1 and a USB to serial converter. Furthermore on desktops with Windows 7 or Windows 8. 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: https://bensprikbord.nl/RS232/RS232.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