Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 3.4

FEATURE

Advanced Serial Programming

Tips and tricks to get the most out of your connections

Issue: 3.4 (March/April 2005)
Author Bio: Contrary to popular beliefs, Aaron gets let out of the Cave of Networking once in a while so he can work on Serial programming projects. While out of his cave, he likes to find new ways he can re-program his pickup truck using REALbasic's Serial control.
Article Description: No description available.
Article Length (in bytes): 9,831
Starting Page Number: 14
Article Number: 3409
Related Link(s): None

Excerpt of article text...

When we left off last time, you had just started writing your own serial applications using the Serial control in REALbasic. You learned about all the basics of serial programming and the general structure of a serial application. In this article, you're going to learn some of the more advanced topics about serial programming.

For the most part, your applications will be communicating from a computer (a DTE) to a device of some sort (a DCE). But what happens when you want to communicate from one computer to another? Well, if you've ever tried this on your own, you'll notice that you can't just use a regular serial cable to do the communications. This is because of the way a serial cable is wired. If you think about it logically, the line that the computer uses to send the data (the TXD line) is the same line that the serial device uses to retrieve data (the RXD line). But, if you're hooking a computer to another computer, then the TXD line on one side is still the TXD line on the other side -- how is the other computer supposed to receive the data when you're sending it? Simple! You need to use a device called a null modem, also known as a cross-over cable. In this case, the wire pairs are swapped so that the TXD line from one machine switches into the RXD line. This way, the line pairs all match up the way they're supposed to. Without using a null modem, you cannot get one computer to talk to another via a serial cable.

Speaking of lines, last time you learned the names of the various important pins that the RS-232 adapter uses. You may recall that these pins perform things like hardware flow control and other such "automatic" functions, but heard that they can also be used for non-standard serial programming. How exactly does one deal with these "non-standard" serial devices? Well, in REALbasic, you're able to test the state of the lines as well as set the state of some of the lines. When you want to see whether a certain line is asserted or not, you can use the pin's full name to determine its state. For example, if we wanted to see the state of the CTS line, you could do something like this:

If mSerial.ClearToSend then

MsgBox "CTS is asserted"

...End of Excerpt. Please purchase the magazine to read the full article.