I was talking to a friend today, and he mentioned a mate who he said used BASIC to program serial connections, etc. I was really interested and I want to know more about programming at such a low level. Is it possible in C++? Could I write code on a computer to control the electricity flow in something like a train track? I've heard of it bieng done at my local university (I'm not old enough to attend yet), but how?
Could someone please show me a few places to start? Or even a quick explanation as to how?
Yes, you can do serial communications programming with C++. It is also possible to control the electricity flow in a train track, that is a matter of controlling the switches which control the electricity flow.
Here's some info and an example of serial communications programming using Borland C++ and some links to further info.
Here info on RS232:
More general info on serial communication:
Note that there are also free libraries available to do communication.
I used to be interested in that as well. Are you looking to turn on a certain pin in a serial cable, or something similar to that? I'm sure it's possible in C++, but I would suspect that it would be very difficult. Modern programming languages tend to make it difficult for people to access ports directly. More often than not, drivers are used for interfacing. But don't give up hope, someone out there knows how to do it.
Another link I almost forgot:
>Modern programming languages tend to make it difficult for
>people to access ports directly.
Not necessarily, modern programming languages have the facilities to access ports, but it is usually the OS which does not allow applications to access ports directly. Some Windows systems for example don't allow direct hardware accessing.
>More often than not, drivers are used for interfacing. But don't
>give up hope, someone out there knows how to do it.
Drivers make it easier to work with the hardware. Usually drivers have implemented the basic operations with the hardware, this makes it easier for an application programmer to work with the hardware.
You guys are absolute legends! You've really made my day!
Thanks very much!
Sorry to bother you again, but I'm only on the net here for a minute and don't have chance to read anything, so i've thrown it all on a disk to read when I get home.
Let me see if I have a basic understanding here: If I wanted to do the train thing, I'd set up switches to control the electricity, which have serial connection on them so my computer can talk to them? Is that it? Do I need to put special software into the switches to make it work or would the serial cable communicate straight into the switch by itself?
I'm probably way off track.
PS: Thanks for all your help!
The parallel port is easier to interface, unless you have an existing serial device you want to interface with. In either case, if you're using a windows OS other than Win95 or Win98, you'll still have to get-around the "user mode" access restrictions.